Skip to content

Commit

Permalink
Fix broken hyperlinks and formula not displayed correctly on Colab
Browse files Browse the repository at this point in the history
  • Loading branch information
alessandrozocca committed Feb 5, 2024
1 parent c510644 commit b3d1185
Show file tree
Hide file tree
Showing 9 changed files with 34 additions and 20 deletions.
2 changes: 1 addition & 1 deletion notebooks/01/01-production-planning.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@
"\n",
"For a practitioner, mathematical optimization often boils down to formulating the problem as a model above, then passing it over to one of the open-source or commercial software packages that can solve such a model regardless of what was the original *story* behind the model. To do so, we need an interface of communication between the models and the algorithms. In this website, we adopt a Python-based interface which is the ```Pyomo``` modeling package.\n",
"\n",
"The next step is to create the corresponding Pyomo model, which we will carry out in the next [notebook](production-planning-basic.ipynb)."
"The next step is to create the corresponding Pyomo model, which we will carry out in the next [notebook](02-production-planning-basic.ipynb)."
]
}
],
Expand Down
6 changes: 3 additions & 3 deletions notebooks/01/02-production-planning-basic.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"\n",
"Pyomo is an algebraic modeling language for mathematical optimization that is integrated within the Python programming environment. It enables users to create optimization models consisting of decision variables, expressions, objective functions, and constraints. Pyomo provides tools to transform models, and then solve them using a variety of open-source and commercial solvers. As an open-source project, Pyomo is not tied to any specific vendor, solver, or class of mathematical optimization problems, and is constantly evolving through contributions from third-party developers.\n",
"\n",
"This notebook introduces basic elements of Pyomo common to most applications for the small production planning problem introduced earlier in [this notebook](production-planning.ipynb) introduced in a companion notebook:\n",
"This notebook introduces basic elements of Pyomo common to most applications for the small production planning problem introduced earlier in [this notebook](01-production-planning.ipynb) introduced in a companion notebook:\n",
"\n",
"* [Variables](https://pyomo.readthedocs.io/en/latest/pyomo_modeling_components/Variables.html)\n",
"* [Expressions](https://pyomo.readthedocs.io/en/latest/pyomo_modeling_components/Expressions.html)\n",
Expand Down Expand Up @@ -440,7 +440,7 @@
"source": [
"## Step 8. Reporting the solution\n",
"\n",
"The final step in most applications is to report the solution in a suitable format. For this example, we demonstrate simple tabular and graphic reports using the Pandas library. For an overview of other ways to report and visualize the solutions, see also the appendix of [this notebook](../04/gasoline-distribution.ipynb) from Chapter 4."
"The final step in most applications is to report the solution in a suitable format. For this example, we demonstrate simple tabular and graphic reports using the Pandas library. For an overview of other ways to report and visualize the solutions, see also the appendix of [this notebook](../04/03-gasoline-distribution.ipynb) from Chapter 4."
]
},
{
Expand Down Expand Up @@ -710,7 +710,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"To discover more advanced Pyomo features, see the [next notebook](production-planning-advanced.ipynb)."
"To discover more advanced Pyomo features, see the [next notebook](03-production-planning-advanced.ipynb)."
]
}
],
Expand Down
2 changes: 1 addition & 1 deletion notebooks/01/03-production-planning-advanced.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
"source": [
"## Data representations\n",
"\n",
"We begin by revisiting the data sets and mathematical model developed for the basic production planning problem presented in the [previous notebook](production-planning-basic.ipynb). The original data sets were given as:\n",
"We begin by revisiting the data sets and mathematical model developed for the basic production planning problem presented in the [previous notebook](02-production-planning-basic.ipynb). The original data sets were given as:\n",
"\n",
"<div align=\"center\">\n",
"\n",
Expand Down
20 changes: 16 additions & 4 deletions notebooks/03/09-strip-packing.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -712,6 +712,7 @@
"Rotating the boxes is an option for packing the boxes more tightly on the shelf. The boxes can be placed either in their original orientation or in a rotated orientation. This introduces a second exclusive OR disjunction to the model that determines the orientation of the bounding box. A binary indicator variable $r_i$ tracks which boxes were rotated which is used in the `show_boxes` function to show which boxes have been rotated.\n",
"\n",
"$$\n",
"\n",
"\\begin{align*}\n",
"\\min \\quad & W \\\\\n",
"\\text{s.t} \\quad\n",
Expand All @@ -720,17 +721,28 @@
"& y_{i, 1} = 0 & \\forall \\, i \\\\\n",
"& [x_{i, 2} \\leq x_{j,1}] \\veebar [ x_{j, 2} \\leq x_{i, 1}] & \\forall \\, i < j \\\\\n",
"\n",
"& \\begin{bmatrix}\n",
"& \n",
"\\left[ \n",
"\\begin{array}{l}\n",
"\\begin{array}{l}\n",
"r_i = 0 \\\\\n",
"x_{i,2} = x_{i,1} + w_i\\\\\n",
"y_{i,2} = y_{i,1} + d_i\\\\\n",
"\\end{bmatrix} \\veebar \n",
"\\begin{bmatrix}\n",
"\\end{array}\n",
"\\end{array}\n",
"\\right]\n",
"\\veebar\n",
"\\left[ \n",
"\\begin{array}{l}\n",
"\\begin{array}{l}\n",
"r_i = 1 \\\\\n",
"x_{i,2} = x_{i,1} + d_i\\\\\n",
"y_{i,2} = y_{i,1} + w_i\\\\\n",
"\\end{bmatrix} & \\forall \\, i < j\n",
"\\end{array}\n",
"\\end{array}\n",
"\\right] & \\forall \\, i < j\n",
"\\end{align*}\n",
"\n",
"$$\n",
"\n",
"In this version of the model, the boxes will be lined up against the edge of the shelf with $y_{i,1} = 0$. Decision variables are now included in the model for rotation $r$ to the $y$ dimension of the bounding boxes."
Expand Down
2 changes: 1 addition & 1 deletion notebooks/06/03-markowitz-portfolio-revisited.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
"source": [
"## Problem description and model formulation\n",
"\n",
"Consider again the [Markowitz portfolio optimization](../05/markowitz_portfolio.ipynb) we presented earlier in Chapter 5. Recall that the matrix $\\Sigma$ describes the covariance among the uncertain return rates $r_i$, $i=1,\\dots, n$. Since $\\Sigma$ is positive semidefinite by definition, it allows for a Cholesky factorization, namely $\\Sigma = B B^\\top$. We can then rewrite the quadratic constraint as $\\|B^\\top x \\|_2 \\leq \\gamma$ and thus as $(\\gamma, B^\\top x) \\in \\mathcal{L}^{n+1}$ using the Lorentz cone. In this way, we realize that the original portfolio problem we formulated [earlier](../05/markowitz_portfolio.ipynb) is in fact a conic quadratic optimization problem, which can thus be solved faster and more reliably. The optimal solution of that problem was the one with the maximum expected return while allowing for a specific level $\\gamma$ of risk. \n",
"Consider again the [Markowitz portfolio optimization](../05/03-markowitz_portfolio.ipynb) we presented earlier in Chapter 5. Recall that the matrix $\\Sigma$ describes the covariance among the uncertain return rates $r_i$, $i=1,\\dots, n$. Since $\\Sigma$ is positive semidefinite by definition, it allows for a Cholesky factorization, namely $\\Sigma = B B^\\top$. We can then rewrite the quadratic constraint as $\\|B^\\top x \\|_2 \\leq \\gamma$ and thus as $(\\gamma, B^\\top x) \\in \\mathcal{L}^{n+1}$ using the Lorentz cone. In this way, we realize that the original portfolio problem we formulated [earlier](../05/03-markowitz_portfolio.ipynb) is in fact a conic quadratic optimization problem, which can thus be solved faster and more reliably. The optimal solution of that problem was the one with the maximum expected return while allowing for a specific level $\\gamma$ of risk. \n",
"\n",
"However, an investor could aim for a different trade-off between return and risk and formulate a slightly different optimization problem, namely\n",
"\n",
Expand Down
2 changes: 1 addition & 1 deletion notebooks/07/02-bim-robustness-analysis.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
"source": [
"## Problem description\n",
"\n",
"This example is a continuation of the BIM chip production problem illustrated [here](../02/bim.ipynb). Recall hat BIM produces logic and memory chips using copper, silicon, germanium, and plastic and that each chip requires the following quantities of raw materials:\n",
"This example is a continuation of the BIM chip production problem illustrated [here](../02/01-bim.ipynb). Recall hat BIM produces logic and memory chips using copper, silicon, germanium, and plastic and that each chip requires the following quantities of raw materials:\n",
"\n",
"| chip | copper | silicon | germanium | plastic |\n",
"|:-------|-------:|--------:|----------:|--------:|\n",
Expand Down
2 changes: 1 addition & 1 deletion notebooks/08/01-bim-robust-optimization.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
"source": [
"## Original BIM production planning model\n",
"\n",
"The full description of the BIM production problem, can be found [here](../02/bim.ipynb). The resulting linear optimization problem was formulated as follows:\n",
"The full description of the BIM production problem, can be found [here](../02/01-bim.ipynb). The resulting linear optimization problem was formulated as follows:\n",
"\n",
"$$\n",
"\\begin{array}{rrcrcl}\n",
Expand Down
14 changes: 8 additions & 6 deletions notebooks/10/03-opf-linear-decision-rule.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@
"\n",
"where $c_i(.)$ and $\\hat{c}_i(.)$ are the cost functions related to the pre-committed $\\bar{p}_i$ and changed $r_i$ amounts of energy, remembering that among $\\bar{p}_i$'s, only those with $i \\in \\mathcal{G}^{\\text{coal}} \\cup \\mathcal{G}^{\\text{gas}}$ are actual decision variables while $\\bar{p}_i$, $i \\in \\mathcal{G}^{\\text{solar}} \\cup \\mathcal{G}^{\\text{wind}}$ are known parameters (think of them as wind and solar power forecasts).\n",
"\n",
"In the [OPF problem with wind curtailment](../10/opf-wind-curtailment.ipynb) we solved a similar problem using the SAA method. More specifically, we generated a number of scenarios for the unknown parameters and combined the second-stage problems related to each of these scenarios with the single first-stage problem obtaining one large MILO problem.\n",
"In the [OPF problem with wind curtailment](../10/05-opf-wind-curtailment.ipynb) we solved a similar problem using the SAA method. More specifically, we generated a number of scenarios for the unknown parameters and combined the second-stage problems related to each of these scenarios with the single first-stage problem obtaining one large MILO problem.\n",
"In this notebook, we are going to use a slightly different approach, namely implementing a specific type of linear decision rules. For each conventional generator, we set a recourse action, that is real-time adjustment of its power production, based on the realization of the renewable energy. More specifically, each conventional generator $i \\in \\mathcal{G}^{\\text{coal}} \\cup \\mathcal{G}^{\\text{gas}}$ has a _participation factor_ $\\alpha_i \\geq 0$ which determines to which extent that generator responds to the total imbalance $\\sum_j \\Delta_j$. Specifically, the power production _after the recourse action_ at the conventional generator $i$ is denoted by $p_i$ and is given by\n",
"\n",
"$$\n",
Expand Down Expand Up @@ -208,7 +208,7 @@
"source": [
"### Data imports\n",
"\n",
"Importantly for our problem, the variable costs of producing a unit of energy per generator are stored in their corresponding 'c_var' attributes. For the rest, we are using the same data elements as in the [OPF problem with wind curtailment](../10/opf-wind-curtailment.ipynb)."
"Importantly for our problem, the variable costs of producing a unit of energy per generator are stored in their corresponding 'c_var' attributes. For the rest, we are using the same data elements as in the [OPF problem with wind curtailment](../10/05-opf-wind-curtailment.ipynb)."
]
},
{
Expand Down Expand Up @@ -442,9 +442,11 @@
"# wind or solar power is between 0.5 and 1.5 times the forecasted value\n",
"imbalances = [\n",
" {\n",
" i: rng.uniform(-nodes_df[\"p_min\"][i] / 2, nodes_df[\"p_min\"][i] / 2)\n",
" if i in SW\n",
" else 0\n",
" i: (\n",
" rng.uniform(-nodes_df[\"p_min\"][i] / 2, nodes_df[\"p_min\"][i] / 2)\n",
" if i in SW\n",
" else 0\n",
" )\n",
" for i in nodes_df.index\n",
" }\n",
" for t in range(T)\n",
Expand Down Expand Up @@ -510,7 +512,7 @@
"source": [
"It is key to understand how this solution would perform if there were perturbations in renewable energy production.\n",
"\n",
"First of all, it is not guaranteed that it is possible to find a feasible solution in such a case. Following an approach similar to that of the [OPF problem with wind curtailment](../10/opf-wind-curtailment.ipynb), one can solve for the remaining variables when keeping the initial solution $\\bar{p}$ fixed and check that with uniform participation factors, it is not possible to find a feasible flow in any of the scenarios we consider. If instead we allow for non-uniform participation factors, then this is not possible in 13 out of 100 scenarios.\n",
"First of all, it is not guaranteed that it is possible to find a feasible solution in such a case. Following an approach similar to that of the [OPF problem with wind curtailment](../10/05-opf-wind-curtailment.ipynb), one can solve for the remaining variables when keeping the initial solution $\\bar{p}$ fixed and check that with uniform participation factors, it is not possible to find a feasible flow in any of the scenarios we consider. If instead we allow for non-uniform participation factors, then this is not possible in 13 out of 100 scenarios.\n",
"\n",
"Putting the feasibility issues aside for a moment, let us check how much extra cost would there be with uniform participation factors would there be on average across our scenarios. We can calculate this by taking the total imbalance and computing the cost of the recourse action to cover it, assuming that every coal and gas generator adjusts its production proportionally to the optimal participation factor previously obtained."
]
Expand Down
4 changes: 2 additions & 2 deletions notebooks/10/05-opf-wind-curtailment.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
"\n",
"<img src=\"https://www.mdpi.com/energies/energies-13-05595/article_deploy/html/images/energies-13-05595-g018.png\" width=\"600\"/>\n",
"\n",
"The goal of this notebook is to ensure that power demand meets supply while taking into account wind fluctuations. We will introduce two optimization problems and solve them as stochastic optimization problems. **Read first the [energy dispatch problem](../04/power-network.ipynb) from the Chapter 4 for the preliminaries on power networks and the Optimal Power Flow (OPF) problem**. An important difference from the setting there, is that here we *will not assume that the wind generation is a decision variable*. Instead, wind generation is a random variable, as will be explained later on. We do assume that solar and hydropower are decision variables, since the former is accurately predicated whereas the latter is controllable."
"The goal of this notebook is to ensure that power demand meets supply while taking into account wind fluctuations. We will introduce two optimization problems and solve them as stochastic optimization problems. **Read first the [energy dispatch problem](../04/06-power-network.ipynb) from the Chapter 4 for the preliminaries on power networks and the Optimal Power Flow (OPF) problem**. An important difference from the setting there, is that here we *will not assume that the wind generation is a decision variable*. Instead, wind generation is a random variable, as will be explained later on. We do assume that solar and hydropower are decision variables, since the former is accurately predicated whereas the latter is controllable."
]
},
{
Expand Down Expand Up @@ -200,7 +200,7 @@
"source": [
"### Network data\n",
"\n",
"This notebook uses the same network as in [energy dispatch problem](../04/power-network.ipynb) and hence the same data structure. In particular, the nodes and edges of the network are stored in the `nodes` and `edges` dataframes, respectively. The `edges` dataframe contains the following columns: \n",
"This notebook uses the same network as in [energy dispatch problem](../04/06-power-network.ipynb) and hence the same data structure. In particular, the nodes and edges of the network are stored in the `nodes` and `edges` dataframes, respectively. The `edges` dataframe contains the following columns: \n",
"* `edge id`: the unique identifier of the edge, describing the node pair `(i,j)` of the edge;\n",
"* `f_max`: describing the maximum power flow capacity of the edge; and\n",
"* `b`: the susceptance of the edge."
Expand Down

0 comments on commit b3d1185

Please sign in to comment.