Skip to content

Commit

Permalink
Textual changes (#70)
Browse files Browse the repository at this point in the history
  • Loading branch information
leonlan committed Nov 1, 2023
1 parent 5a2e66a commit 2b3a7fa
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
4 changes: 4 additions & 0 deletions notebooks/01/production-planning-basic.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -285,13 +285,17 @@
"\n",
"The first method is to use `pyo.Objective()` where the expression to be optimized is assigned with the `expr` keyword and the type of objective is assigned with the `sense` keyword.\n",
"\n",
"```python\n",
" model.profit = pyo.Objective(expr = model.revenue - model.cost, sense = pyo.maximize)\n",
"```\n",
" \n",
"Recent releases of Pyomo provide a second method that uses Python [decorators](https://peps.python.org/pep-0318/) to specify an objective. With a decorator, the same objective is written as\n",
"\n",
"```python\n",
" @model.Objective(sense = pyo.maximize)\n",
" def profit(m):\n",
" return m.revenue - m.cost\n",
"```\n",
"\n",
"Python decorators modify the behavior of the function defined in the next line. In this case, the decorator `@model.Objective()` modifies the behavior of `profit()` so that it returns an expression for the profit to Pyomo. The keyword `sense` sets the type of objective, which can either be to maximize or minimize the value returned by the objective function. The function `profit()`, after being decorated, takes the Pyomo model as its first argument and adds its name to the model attributes.\n",
"\n",
Expand Down
12 changes: 6 additions & 6 deletions notebooks/01/production-planning.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@
"source": [
"## Problem statement\n",
"\n",
"A company produces two versions of a product. Each version is made from the same raw material that costs 10$ per gram, and each version requires two different types of specialized labor to finish. $U$ is the higher priced version of the product. $U$ sells for 270$ per unit and requires 10 grams of raw material, one hour of labor type $A$, two hours of labor type $B$. Due to the higher price, the market demand for $U$ is limited to 40 units per week. $V$ is the lower priced version of the product with unlimited demand that sells for 210$ per unit and requires 9 grams of raw material, 1 hour of labor type $A$ and 1 hour of labor type $B$. This data is summarized in the following table:\n",
"A company produces two versions of a product. Each version is made from the same raw material that costs 10 per gram, and each version requires two different types of specialized labor to finish. $U$ is the higher priced version of the product. $U$ sells for 270 per unit and requires 10 grams of raw material, one hour of labor type $A$, two hours of labor type $B$. Due to the higher price, the market demand for $U$ is limited to 40 units per week. $V$ is the lower priced version of the product with unlimited demand that sells for 210 per unit and requires 9 grams of raw material, 1 hour of labor type $A$ and 1 hour of labor type $B$. This data is summarized in the following table:\n",
"\n",
"<div align=\"center\">\n",
"\n",
"| Version | Raw Material <br> required | Labor A <br> required | Labor B <br> required | Market <br> Demand | Price |\n",
"| :-: | :-: | :-: | :-: | :-: | :-: | \n",
"| U | 10 g | 1 hr | 2 hr | $\\leq$ 40 units | 270$ |\n",
"| V | 9 g | 1 hr | 1 hr | unlimited | 210$ |\n",
"| U | 10 g | 1 hr | 2 hr | $\\leq$ 40 units | 270 |\n",
"| V | 9 g | 1 hr | 1 hr | unlimited | 210 |\n",
"\n",
"</div>\n",
"\n",
Expand All @@ -48,9 +48,9 @@
"\n",
"| Resource | Amount <br> Available | Cost | \n",
"| :-: | :-: | :-: |\n",
"| Raw Material | unlimited | 10$ / g |\n",
"| Labor A | 80 hours/week | 50$ / hour |\n",
"| Labor B | 100 hours/week | 40$ / hour | \n",
"| Raw Material | unlimited | 10 / g |\n",
"| Labor A | 80 hours/week | 50 / hour |\n",
"| Labor B | 100 hours/week | 40 / hour | \n",
"\n",
"</div>\n",
"\n",
Expand Down

0 comments on commit 2b3a7fa

Please sign in to comment.