Skip to content

Commit

Permalink
deploy: ab937d7
Browse files Browse the repository at this point in the history
  • Loading branch information
alessandrozocca committed Jan 15, 2024
1 parent a94a058 commit 537ee5c
Show file tree
Hide file tree
Showing 9 changed files with 63 additions and 55 deletions.
11 changes: 6 additions & 5 deletions _sources/notebooks/03/02-shift-scheduling.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,15 @@
"outputs": [],
"source": [
"import sys\n",
" \n",
"if 'google.colab' in sys.modules:\n",
"\n",
"if \"google.colab\" in sys.modules:\n",
" %pip install pyomo >/dev/null 2>/dev/null\n",
" %pip install highspy >/dev/null 2>/dev/null\n",
" \n",
"solver = 'appsi_highs'\n",
"\n",
"solver = \"appsi_highs\"\n",
"\n",
"import pyomo.environ as pyo\n",
"\n",
"SOLVER = pyo.SolverFactory(solver)\n",
"\n",
"assert SOLVER.available(), f\"Solver {solver} is not available.\""
Expand Down Expand Up @@ -97,7 +98,7 @@
"source": [
"### Model sets\n",
"\n",
"Assuming that we have $N$ available workers, the problem requires the assignment of these available workers to a predetermined set of shifts with specific staffing requirements. Let $\\textup{R}_{d, s}$ describe the minimum number of workers required for the day-shift pair $(d, s)$.\n",
"Assuming that we have $N$ available workers, the problem requires the assignment of these available workers to a predetermined set of shifts with specific staffing requirements. Let $\\text{R}_{d, s}$ describe the minimum number of workers required for the day-shift pair $(d, s)$.\n",
"\n",
"There are three shifts per day, seven days per week. These observations suggest the need for three ordered sets:\n",
"\n",
Expand Down
15 changes: 8 additions & 7 deletions _sources/notebooks/03/05-machine-scheduling.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,15 @@
"outputs": [],
"source": [
"import sys\n",
" \n",
"if 'google.colab' in sys.modules:\n",
"\n",
"if \"google.colab\" in sys.modules:\n",
" %pip install pyomo >/dev/null 2>/dev/null\n",
" %pip install highspy >/dev/null 2>/dev/null\n",
" \n",
"solver = 'appsi_highs'\n",
" \n",
"\n",
"solver = \"appsi_highs\"\n",
"\n",
"import pyomo.environ as pyo\n",
"\n",
"SOLVER = pyo.SolverFactory(solver)\n",
"\n",
"assert SOLVER.available(), f\"Solver {solver} is not available.\""
Expand Down Expand Up @@ -813,8 +814,8 @@
"\n",
"$$\n",
"\\begin{align*}\n",
"\\textup{finish}_i & \\leq \\textup{start}_j + M z_{ij} \\\\\n",
"\\textup{finish}_j & \\leq \\textup{start}_i + M (1 - z_{ij}).\n",
"\\text{finish}_i & \\leq \\text{start}_j + M z_{ij} \\\\\n",
"\\text{finish}_j & \\leq \\text{start}_i + M (1 - z_{ij}).\n",
"\\end{align*}\n",
"$$\n",
"\n",
Expand Down
13 changes: 7 additions & 6 deletions _sources/notebooks/03/07-bim-production-revisited.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,15 @@
"outputs": [],
"source": [
"import sys\n",
" \n",
"if 'google.colab' in sys.modules:\n",
"\n",
"if \"google.colab\" in sys.modules:\n",
" %pip install pyomo >/dev/null 2>/dev/null\n",
" %pip install highspy >/dev/null 2>/dev/null\n",
" \n",
"solver = 'appsi_highs'\n",
" \n",
"\n",
"solver = \"appsi_highs\"\n",
"\n",
"import pyomo.environ as pyo\n",
"\n",
"SOLVER = pyo.SolverFactory(solver)\n",
"\n",
"assert SOLVER.available(), f\"Solver {solver} is not available.\""
Expand Down Expand Up @@ -520,7 +521,7 @@
"\\begin{align*}\n",
" \\min \\quad & \\sum_{t \\in T} \\Big( \\Big( \\sum_{s \\in S} \\pi_{s} b_{ts} + \\alpha_{s} y_{ts} \\Big) - \\beta p_t \\Big) +&\n",
" \\sum_{t \\in T} \\Big ( \\gamma_{\\text{copper}} r_t + \\sum_{p \\in P \\setminus \\{ \\text{copper}\\}} \\gamma_{p} s_{pt} \\Big) \\\\\n",
" \\textup{s.t.} \\quad \n",
" \\text{s.t.} \\quad \n",
" & \\sum_{p \\in P \\setminus \\{ \\text{copper}\\}} x_{pts} \\leq 100 \\cdot b_{ts} & \\forall \\, t \\in T, \\, \\forall \\, s \\in S\\\\\n",
" & s_{\\text{copper}, t} \\leq 10 \\cdot r_t & \\forall \\, t \\in T\\\\\n",
" & s_{\\text{copper}, t} \\leq 10000 & \\forall \\, t \\in T\\\\\n",
Expand Down
19 changes: 10 additions & 9 deletions _sources/notebooks/10/02-two-stage-production-planning.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,15 @@
"outputs": [],
"source": [
"import sys\n",
" \n",
"if 'google.colab' in sys.modules:\n",
"\n",
"if \"google.colab\" in sys.modules:\n",
" %pip install pyomo >/dev/null 2>/dev/null\n",
" %pip install highspy >/dev/null 2>/dev/null\n",
"\n",
"solver = 'appsi_highs'\n",
" \n",
"solver = \"appsi_highs\"\n",
"\n",
"import pyomo.environ as pyo\n",
"\n",
"SOLVER = pyo.SolverFactory(solver)\n",
"\n",
"assert SOLVER.available(), f\"Solver {solver} is not available.\""
Expand Down Expand Up @@ -204,9 +205,9 @@
"\\begin{align*}\n",
"x = \\begin{pmatrix} x \\end{pmatrix},\n",
"\\\n",
"\\bm{y} = \\begin{pmatrix} y_1 \\\\ y_2 \\\\ y_3 \\end{pmatrix},\n",
"y = \\begin{pmatrix} y_1 \\\\ y_2 \\\\ y_3 \\end{pmatrix},\n",
"\\\n",
"\\bm{z} = \\begin{pmatrix} z_A \\\\ z_B \\\\ z_D \\end{pmatrix}\n",
"z = \\begin{pmatrix} z_A \\\\ z_B \\\\ z_D \\end{pmatrix}\n",
"\\end{align*}\n",
"$$\n",
"\n",
Expand All @@ -221,11 +222,11 @@
"\n",
"$$\n",
"\\begin{align*}\n",
"R(\\bm{z}) = \\begin{pmatrix} 0 \\\\ 0 \\\\ 0 \\\\ 0 \\\\ -1 \\end{pmatrix}, \n",
"R(z) = \\begin{pmatrix} 0 \\\\ 0 \\\\ 0 \\\\ 0 \\\\ -1 \\end{pmatrix}, \n",
"\\\n",
"S(\\bm{z}) = \\begin{pmatrix} - (140 - 50z_A - 80z_B) & - (120 - 50z_A - 40z_B) & 1 \\\\ 1 & 0 & 0 \\\\ 1+z_A & 1 + z_A & 0 \\\\ 2(1+z_B) & 1 + z_B & 0 \\\\ 10 & 9 & 0 \\end{pmatrix},\n",
"S(z) = \\begin{pmatrix} - (140 - 50z_A - 80z_B) & - (120 - 50z_A - 40z_B) & 1 \\\\ 1 & 0 & 0 \\\\ 1+z_A & 1 + z_A & 0 \\\\ 2(1+z_B) & 1 + z_B & 0 \\\\ 10 & 9 & 0 \\end{pmatrix},\n",
"\\\n",
"t(\\bm{z}) = \\begin{pmatrix} 0 \\\\ -20(1+z_D) \\\\ 80 \\\\ 100 \\\\ 0 \\end{pmatrix} \\\\\n",
"t(z) = \\begin{pmatrix} 0 \\\\ -20(1+z_D) \\\\ 80 \\\\ 100 \\\\ 0 \\end{pmatrix} \\\\\n",
"\\end{align*}\n",
"$$"
]
Expand Down
11 changes: 6 additions & 5 deletions notebooks/03/02-shift-scheduling.html
Original file line number Diff line number Diff line change
Expand Up @@ -552,14 +552,15 @@ <h2>Preamble: Install Pyomo and a solver<a class="headerlink" href="#preamble-in
<div class="cell docutils container">
<div class="cell_input docutils container">
<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">sys</span>
<span class="k">if</span> <span class="s1">&#39;google.colab&#39;</span> <span class="ow">in</span> <span class="n">sys</span><span class="o">.</span><span class="n">modules</span><span class="p">:</span>

<span class="k">if</span> <span class="s2">&quot;google.colab&quot;</span> <span class="ow">in</span> <span class="n">sys</span><span class="o">.</span><span class="n">modules</span><span class="p">:</span>
<span class="o">%</span><span class="k">pip</span> install pyomo &gt;/dev/null 2&gt;/dev/null
<span class="o">%</span><span class="k">pip</span> install highspy &gt;/dev/null 2&gt;/dev/null
<span class="n">solver</span> <span class="o">=</span> <span class="s1">&#39;appsi_highs&#39;</span>

<span class="n">solver</span> <span class="o">=</span> <span class="s2">&quot;appsi_highs&quot;</span>

<span class="kn">import</span> <span class="nn">pyomo.environ</span> <span class="k">as</span> <span class="nn">pyo</span>

<span class="n">SOLVER</span> <span class="o">=</span> <span class="n">pyo</span><span class="o">.</span><span class="n">SolverFactory</span><span class="p">(</span><span class="n">solver</span><span class="p">)</span>

<span class="k">assert</span> <span class="n">SOLVER</span><span class="o">.</span><span class="n">available</span><span class="p">(),</span> <span class="sa">f</span><span class="s2">&quot;Solver </span><span class="si">{</span><span class="n">solver</span><span class="si">}</span><span class="s2"> is not available.&quot;</span>
Expand All @@ -584,7 +585,7 @@ <h2>Problem Statement<a class="headerlink" href="#problem-statement" title="Perm
<h2>Model formulation<a class="headerlink" href="#model-formulation" title="Permalink to this heading">#</a></h2>
<section id="model-sets">
<h3>Model sets<a class="headerlink" href="#model-sets" title="Permalink to this heading">#</a></h3>
<p>Assuming that we have <span class="math notranslate nohighlight">\(N\)</span> available workers, the problem requires the assignment of these available workers to a predetermined set of shifts with specific staffing requirements. Let <span class="math notranslate nohighlight">\(\textup{R}_{d, s}\)</span> describe the minimum number of workers required for the day-shift pair <span class="math notranslate nohighlight">\((d, s)\)</span>.</p>
<p>Assuming that we have <span class="math notranslate nohighlight">\(N\)</span> available workers, the problem requires the assignment of these available workers to a predetermined set of shifts with specific staffing requirements. Let <span class="math notranslate nohighlight">\(\text{R}_{d, s}\)</span> describe the minimum number of workers required for the day-shift pair <span class="math notranslate nohighlight">\((d, s)\)</span>.</p>
<p>There are three shifts per day, seven days per week. These observations suggest the need for three ordered sets:</p>
<ul class="simple">
<li><p><code class="docutils literal notranslate"><span class="pre">W</span></code> is a set with <span class="math notranslate nohighlight">\(N\)</span> elements representing workers.</p></li>
Expand Down
15 changes: 8 additions & 7 deletions notebooks/03/05-machine-scheduling.html
Original file line number Diff line number Diff line change
Expand Up @@ -548,14 +548,15 @@ <h2>Preamble: Install Pyomo and a solver<a class="headerlink" href="#preamble-in
<div class="cell docutils container">
<div class="cell_input docutils container">
<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">sys</span>
<span class="k">if</span> <span class="s1">&#39;google.colab&#39;</span> <span class="ow">in</span> <span class="n">sys</span><span class="o">.</span><span class="n">modules</span><span class="p">:</span>

<span class="k">if</span> <span class="s2">&quot;google.colab&quot;</span> <span class="ow">in</span> <span class="n">sys</span><span class="o">.</span><span class="n">modules</span><span class="p">:</span>
<span class="o">%</span><span class="k">pip</span> install pyomo &gt;/dev/null 2&gt;/dev/null
<span class="o">%</span><span class="k">pip</span> install highspy &gt;/dev/null 2&gt;/dev/null
<span class="n">solver</span> <span class="o">=</span> <span class="s1">&#39;appsi_highs&#39;</span>

<span class="n">solver</span> <span class="o">=</span> <span class="s2">&quot;appsi_highs&quot;</span>

<span class="kn">import</span> <span class="nn">pyomo.environ</span> <span class="k">as</span> <span class="nn">pyo</span>

<span class="n">SOLVER</span> <span class="o">=</span> <span class="n">pyo</span><span class="o">.</span><span class="n">SolverFactory</span><span class="p">(</span><span class="n">solver</span><span class="p">)</span>

<span class="k">assert</span> <span class="n">SOLVER</span><span class="o">.</span><span class="n">available</span><span class="p">(),</span> <span class="sa">f</span><span class="s2">&quot;Solver </span><span class="si">{</span><span class="n">solver</span><span class="si">}</span><span class="s2"> is not available.&quot;</span>
Expand Down Expand Up @@ -1135,8 +1136,8 @@ <h2>Optimal scheduling using disjunctive programming<a class="headerlink" href="
<div class="math notranslate nohighlight">
\[\begin{split}
\begin{align*}
\textup{finish}_i &amp; \leq \textup{start}_j + M z_{ij} \\
\textup{finish}_j &amp; \leq \textup{start}_i + M (1 - z_{ij}).
\text{finish}_i &amp; \leq \text{start}_j + M z_{ij} \\
\text{finish}_j &amp; \leq \text{start}_i + M (1 - z_{ij}).
\end{align*}
\end{split}\]</div>
<p>This creates an equivalent MILO model which leads to the same solution, but it features many more variables and is usually slower to solve.</p>
Expand Down
13 changes: 7 additions & 6 deletions notebooks/03/07-bim-production-revisited.html
Original file line number Diff line number Diff line change
Expand Up @@ -541,14 +541,15 @@ <h2>Preamble: Install Pyomo and a solver<a class="headerlink" href="#preamble-in
<div class="cell docutils container">
<div class="cell_input docutils container">
<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">sys</span>
<span class="k">if</span> <span class="s1">&#39;google.colab&#39;</span> <span class="ow">in</span> <span class="n">sys</span><span class="o">.</span><span class="n">modules</span><span class="p">:</span>

<span class="k">if</span> <span class="s2">&quot;google.colab&quot;</span> <span class="ow">in</span> <span class="n">sys</span><span class="o">.</span><span class="n">modules</span><span class="p">:</span>
<span class="o">%</span><span class="k">pip</span> install pyomo &gt;/dev/null 2&gt;/dev/null
<span class="o">%</span><span class="k">pip</span> install highspy &gt;/dev/null 2&gt;/dev/null
<span class="n">solver</span> <span class="o">=</span> <span class="s1">&#39;appsi_highs&#39;</span>

<span class="n">solver</span> <span class="o">=</span> <span class="s2">&quot;appsi_highs&quot;</span>

<span class="kn">import</span> <span class="nn">pyomo.environ</span> <span class="k">as</span> <span class="nn">pyo</span>

<span class="n">SOLVER</span> <span class="o">=</span> <span class="n">pyo</span><span class="o">.</span><span class="n">SolverFactory</span><span class="p">(</span><span class="n">solver</span><span class="p">)</span>

<span class="k">assert</span> <span class="n">SOLVER</span><span class="o">.</span><span class="n">available</span><span class="p">(),</span> <span class="sa">f</span><span class="s2">&quot;Solver </span><span class="si">{</span><span class="n">solver</span><span class="si">}</span><span class="s2"> is not available.&quot;</span>
Expand Down Expand Up @@ -979,7 +980,7 @@ <h2>Optimization model<a class="headerlink" href="#optimization-model" title="Pe
\begin{align*}
\min \quad &amp; \sum_{t \in T} \Big( \Big( \sum_{s \in S} \pi_{s} b_{ts} + \alpha_{s} y_{ts} \Big) - \beta p_t \Big) +&amp;
\sum_{t \in T} \Big ( \gamma_{\text{copper}} r_t + \sum_{p \in P \setminus \{ \text{copper}\}} \gamma_{p} s_{pt} \Big) \\
\textup{s.t.} \quad
\text{s.t.} \quad
&amp; \sum_{p \in P \setminus \{ \text{copper}\}} x_{pts} \leq 100 \cdot b_{ts} &amp; \forall \, t \in T, \, \forall \, s \in S\\
&amp; s_{\text{copper}, t} \leq 10 \cdot r_t &amp; \forall \, t \in T\\
&amp; s_{\text{copper}, t} \leq 10000 &amp; \forall \, t \in T\\
Expand Down
19 changes: 10 additions & 9 deletions notebooks/10/02-two-stage-production-planning.html
Original file line number Diff line number Diff line change
Expand Up @@ -547,14 +547,15 @@ <h2>Preamble: Install Pyomo and a solver<a class="headerlink" href="#preamble-in
<div class="cell docutils container">
<div class="cell_input docutils container">
<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">sys</span>
<span class="k">if</span> <span class="s1">&#39;google.colab&#39;</span> <span class="ow">in</span> <span class="n">sys</span><span class="o">.</span><span class="n">modules</span><span class="p">:</span>

<span class="k">if</span> <span class="s2">&quot;google.colab&quot;</span> <span class="ow">in</span> <span class="n">sys</span><span class="o">.</span><span class="n">modules</span><span class="p">:</span>
<span class="o">%</span><span class="k">pip</span> install pyomo &gt;/dev/null 2&gt;/dev/null
<span class="o">%</span><span class="k">pip</span> install highspy &gt;/dev/null 2&gt;/dev/null

<span class="n">solver</span> <span class="o">=</span> <span class="s1">&#39;appsi_highs&#39;</span>
<span class="n">solver</span> <span class="o">=</span> <span class="s2">&quot;appsi_highs&quot;</span>

<span class="kn">import</span> <span class="nn">pyomo.environ</span> <span class="k">as</span> <span class="nn">pyo</span>

<span class="n">SOLVER</span> <span class="o">=</span> <span class="n">pyo</span><span class="o">.</span><span class="n">SolverFactory</span><span class="p">(</span><span class="n">solver</span><span class="p">)</span>

<span class="k">assert</span> <span class="n">SOLVER</span><span class="o">.</span><span class="n">available</span><span class="p">(),</span> <span class="sa">f</span><span class="s2">&quot;Solver </span><span class="si">{</span><span class="n">solver</span><span class="si">}</span><span class="s2"> is not available.&quot;</span>
Expand Down Expand Up @@ -664,9 +665,9 @@ <h2>Two-stage problem formulation<a class="headerlink" href="#two-stage-problem-
\begin{align*}
x = \begin{pmatrix} x \end{pmatrix},
\
\bm{y} = \begin{pmatrix} y_1 \\ y_2 \\ y_3 \end{pmatrix},
y = \begin{pmatrix} y_1 \\ y_2 \\ y_3 \end{pmatrix},
\
\bm{z} = \begin{pmatrix} z_A \\ z_B \\ z_D \end{pmatrix}
z = \begin{pmatrix} z_A \\ z_B \\ z_D \end{pmatrix}
\end{align*}
\end{split}\]</div>
<p>Lastly, we define the data matrices as functions of uncertainties:</p>
Expand All @@ -680,11 +681,11 @@ <h2>Two-stage problem formulation<a class="headerlink" href="#two-stage-problem-
<div class="math notranslate nohighlight">
\[\begin{split}
\begin{align*}
R(\bm{z}) = \begin{pmatrix} 0 \\ 0 \\ 0 \\ 0 \\ -1 \end{pmatrix},
R(z) = \begin{pmatrix} 0 \\ 0 \\ 0 \\ 0 \\ -1 \end{pmatrix},
\
S(\bm{z}) = \begin{pmatrix} - (140 - 50z_A - 80z_B) &amp; - (120 - 50z_A - 40z_B) &amp; 1 \\ 1 &amp; 0 &amp; 0 \\ 1+z_A &amp; 1 + z_A &amp; 0 \\ 2(1+z_B) &amp; 1 + z_B &amp; 0 \\ 10 &amp; 9 &amp; 0 \end{pmatrix},
S(z) = \begin{pmatrix} - (140 - 50z_A - 80z_B) &amp; - (120 - 50z_A - 40z_B) &amp; 1 \\ 1 &amp; 0 &amp; 0 \\ 1+z_A &amp; 1 + z_A &amp; 0 \\ 2(1+z_B) &amp; 1 + z_B &amp; 0 \\ 10 &amp; 9 &amp; 0 \end{pmatrix},
\
t(\bm{z}) = \begin{pmatrix} 0 \\ -20(1+z_D) \\ 80 \\ 100 \\ 0 \end{pmatrix} \\
t(z) = \begin{pmatrix} 0 \\ -20(1+z_D) \\ 80 \\ 100 \\ 0 \end{pmatrix} \\
\end{align*}
\end{split}\]</div>
</section>
Expand Down
2 changes: 1 addition & 1 deletion searchindex.js

Large diffs are not rendered by default.

0 comments on commit 537ee5c

Please sign in to comment.