From 2b3a7fa46d9d9d2faee2bf88a20cf7ff7c3b071b Mon Sep 17 00:00:00 2001 From: Leon Lan <30997278+leonlan@users.noreply.github.com> Date: Wed, 1 Nov 2023 10:58:56 +0100 Subject: [PATCH] Textual changes (#70) --- notebooks/01/production-planning-basic.ipynb | 4 ++++ notebooks/01/production-planning.ipynb | 12 ++++++------ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/notebooks/01/production-planning-basic.ipynb b/notebooks/01/production-planning-basic.ipynb index 51181c2a..33373119 100644 --- a/notebooks/01/production-planning-basic.ipynb +++ b/notebooks/01/production-planning-basic.ipynb @@ -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", diff --git a/notebooks/01/production-planning.ipynb b/notebooks/01/production-planning.ipynb index f210caf0..86ba2416 100644 --- a/notebooks/01/production-planning.ipynb +++ b/notebooks/01/production-planning.ipynb @@ -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", "
\n", "\n", "| Version | Raw Material
required | Labor A
required | Labor B
required | Market
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", "
\n", "\n", @@ -48,9 +48,9 @@ "\n", "| Resource | Amount
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", "\n", "\n",