Skip to content

Commit

Permalink
Fix rendering error on Colab (caused by \bm macro)
Browse files Browse the repository at this point in the history
  • Loading branch information
alessandrozocca committed Jan 15, 2024
1 parent ab937d7 commit 4dad201
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions notebooks/10/02-two-stage-production-planning.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@
"outputs": [],
"source": [
"import numpy as np\n",
"import pyomo.environ as pyo\n",
"import pandas as pd\n",
"import matplotlib.pyplot as plt"
]
Expand Down Expand Up @@ -171,24 +170,24 @@
"\n",
"$$\n",
"\\begin{align*}\n",
"\\max \\quad & - 10x + \\inf\\limits_{\\bm{z} \\in Z} Q(x, \\bm{z}) \\\\\n",
"\\max \\quad & - 10x + \\inf\\limits_{z \\in Z} Q(x, z) \\\\\n",
"\\text{s.t.} \\quad & x \\geq 0, \n",
"\\end{align*}\n",
"$$\n",
"\n",
"where $x$ is the amount of raw material to order, and where the uncertainty $\\bm{z} = (z_A, z_B, z_D)$ is given by\n",
"where $x$ is the amount of raw material to order, and where the uncertainty $z = (z_A, z_B, z_D)$ is given by\n",
"\n",
"$$\n",
"\\begin{align*}\n",
"Z = \\left\\{ \\bm{z}=(z_A, z_B, z_D): \\ |z_A| \\leq 0.15, \\ |z_B| \\leq 0.25, \\ |z_D| \\leq 0.25, \\ \\frac{|z_A|}{0.15} + \\frac{|z_A|}{0.25} + \\frac{|z_D|}{0.25} \\leq 2 \\right\\}.\n",
"Z = \\left\\{ z=(z_A, z_B, z_D): \\ |z_A| \\leq 0.15, \\ |z_B| \\leq 0.25, \\ |z_D| \\leq 0.25, \\ \\frac{|z_A|}{0.15} + \\frac{|z_A|}{0.25} + \\frac{|z_D|}{0.25} \\leq 2 \\right\\}.\n",
"\\end{align*}\n",
"$$\n",
"\n",
"$Q(x, \\bm{z})$ is the second-stage profit defined by\n",
"$Q(x, z)$ is the second-stage profit defined by\n",
"\n",
"$$\n",
"\\begin{align*}\n",
"Q(x, \\bm{z}) = \\min \\quad & y_3 \\\\\n",
"Q(x, z) = \\min \\quad & y_3 \\\\\n",
"\\text{s.t.}\\quad & (140 - 50z_A - 80z_B) y_1 + (120 - 50z_A - 40z_B) y_2 \\geq y_3 && \\text{(worst-case profit)} \\\\\n",
"& y_1 \\geq 20 (1 + z_D) && \\text{(pre-production orders)} \\\\\n",
"& y_2 \\leq 40 && \\text{(maximum demand for $U$)}\\\\\n",
Expand Down Expand Up @@ -239,7 +238,7 @@
"source": [
"## Solving the robust problem using sampled scenarios\n",
"\n",
"How can we actually solve such a two-stage problem if it is indeed the worst-case profit that we are interested in? Note that the matrix $S(\\bm{z})$ depends on $\\bm{z}$ and, therefore, we cannot easily formulate the second-stage decisions as linear functions of $\\bm{z}$ (linear decision rules). However, we can generate a finite list of $N$ scenarios and solve a problem that will maximize the worst-case profit across such a set of scenarios:\n",
"How can we actually solve such a two-stage problem if it is indeed the worst-case profit that we are interested in? Note that the matrix $S(z)$ depends on $z$ and, therefore, we cannot easily formulate the second-stage decisions as linear functions of $z$ (linear decision rules). However, we can generate a finite list of $N$ scenarios and solve a problem that will maximize the worst-case profit across such a set of scenarios:\n",
"\n",
"$$\n",
"\\begin{align*}\n",
Expand All @@ -250,7 +249,7 @@
"\\end{align*}\n",
"$$\n",
"\n",
"We first define an auxiliary function that evaluates the system matrix coefficients for a particular scenario $\\bm{z} \\in Z$ and returns them as nested dictionaries."
"We first define an auxiliary function that evaluates the system matrix coefficients for a particular scenario $z \\in Z$ and returns them as nested dictionaries."
]
},
{
Expand Down Expand Up @@ -329,9 +328,9 @@
"id": "D8ztVJoAfuEu"
},
"source": [
"We define Pyomo model to maximize the worst-case profit for a set of scenarios, where the block structure is used to repeat the parts of the model which are structurally identical for each outcome of $\\bm{z}$.\n",
"We define Pyomo model to maximize the worst-case profit for a set of scenarios, where the block structure is used to repeat the parts of the model which are structurally identical for each outcome of $z$.\n",
"\n",
"We then generate $N=1000$ scenarios sampling uniformly at random from the given uncertainty set. We then solve both the nominal problem (inputting a single scenario with the nominal values for the parameters) and the robust problem using $N=1000$ samples. "
"We generate $N=1000$ scenarios sampling uniformly at random from the given uncertainty set. We then solve both the nominal problem (inputting a single scenario with the nominal values for the parameters) and the robust problem using $N=1000$ samples. "
]
},
{
Expand Down

0 comments on commit 4dad201

Please sign in to comment.