Skip to content

Commit

Permalink
Fix preambles
Browse files Browse the repository at this point in the history
Replaced !pip with %pip
  • Loading branch information
alessandrozocca committed Nov 20, 2023
1 parent 094ff6e commit a9be9c6
Show file tree
Hide file tree
Showing 38 changed files with 362 additions and 923 deletions.
30 changes: 12 additions & 18 deletions notebooks/03/bim-perturbed.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,8 @@
"source": [
"## Preamble: Install Pyomo and a solver\n",
"\n",
"This cell selects and verifies a global SOLVER for the notebook.\n",
"\n",
"If run on Google Colab, the cell installs Pyomo and HiGHS, then sets SOLVER to \n",
"use the Highs solver via the appsi module. If run elsewhere, it assumes Pyomo and CBC\n",
"have been previously installed and sets SOLVER to use the CBC solver via the Pyomo \n",
"SolverFactory. It then verifies that SOLVER is available."
"The following cell sets and verifies a global SOLVER for the notebook. If run on Google Colab, the cell installs Pyomo and the HiGHS solver, while, if run elsewhere, it \n",
"assumes Pyomo and HiGHS have been previously installed. It then sets to use HiGHS as solver via the appsi module and a test is performed to verify that it is available. The solver interface is stored in a global object `SOLVER` for later use."
]
},
{
Expand All @@ -42,19 +38,17 @@
"outputs": [],
"source": [
"import sys\n",
"\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",
" from pyomo.environ import SolverFactory\n",
" SOLVER = SolverFactory('appsi_highs')\n",
" \n",
"else:\n",
" from pyomo.environ import SolverFactory\n",
" SOLVER = SolverFactory('cbc')\n",
"\n",
"assert SOLVER.available(), f\"Solver {SOLVER} is not available.\""
" %pip install pyomo >/dev/null 2>/dev/null\n",
" %pip install highspy >/dev/null 2>/dev/null\n",
" \n",
"solver = 'appsi_highs'\n",
" \n",
"import pyomo.environ as pyo\n",
"SOLVER = pyo.SolverFactory(solver)\n",
" \n",
"assert SOLVER.available(), f\"Solver {solver} is not available.\""
]
},
{
Expand Down
12 changes: 4 additions & 8 deletions notebooks/03/bim-production-revisited.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,8 @@
"source": [
"## Preamble: Install Pyomo and a solver\n",
"\n",
"This cell selects and verifies a global SOLVER for the notebook.\n",
"\n",
"If run on Google Colab, the cell installs Pyomo and HiGHS, then sets SOLVER to \n",
"use the Highs solver via the appsi module. If run elsewhere, it assumes Pyomo and CBC\n",
"have been previously installed and sets SOLVER to use the CBC solver via the Pyomo \n",
"SolverFactory. It then verifies that SOLVER is available."
"The following cell sets and verifies a global SOLVER for the notebook. If run on Google Colab, the cell installs Pyomo and the HiGHS solver, while, if run elsewhere, it \n",
"assumes Pyomo and HiGHS have been previously installed. It then sets to use HiGHS as solver via the appsi module and a test is performed to verify that it is available. The solver interface is stored in a global object `SOLVER` for later use."
]
},
{
Expand All @@ -49,8 +45,8 @@
"import sys\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",
" %pip install pyomo >/dev/null 2>/dev/null\n",
" %pip install highspy >/dev/null 2>/dev/null\n",
" \n",
"solver = 'appsi_highs'\n",
" \n",
Expand Down
30 changes: 12 additions & 18 deletions notebooks/03/cryptarithms.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,8 @@
"source": [
"## Preamble: Install Pyomo and a solver\n",
"\n",
"This cell selects and verifies a global SOLVER for the notebook.\n",
"\n",
"If run on Google Colab, the cell installs Pyomo and HiGHS, then sets SOLVER to \n",
"use the Highs solver via the appsi module. If run elsewhere, it assumes Pyomo and CBC\n",
"have been previously installed and sets SOLVER to use the CBC solver via the Pyomo \n",
"SolverFactory. It then verifies that SOLVER is available."
"The following cell sets and verifies a global SOLVER for the notebook. If run on Google Colab, the cell installs Pyomo and the HiGHS solver, while, if run elsewhere, it \n",
"assumes Pyomo and HiGHS have been previously installed. It then sets to use HiGHS as solver via the appsi module and a test is performed to verify that it is available. The solver interface is stored in a global object `SOLVER` for later use."
]
},
{
Expand All @@ -47,19 +43,17 @@
"outputs": [],
"source": [
"import sys\n",
"\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",
" from pyomo.environ import SolverFactory\n",
" SOLVER = SolverFactory('appsi_highs')\n",
" \n",
"else:\n",
" from pyomo.environ import SolverFactory\n",
" SOLVER = SolverFactory('cbc')\n",
"\n",
"assert SOLVER.available(), f\"Solver {SOLVER} is not available.\""
" %pip install pyomo >/dev/null 2>/dev/null\n",
" %pip install highspy >/dev/null 2>/dev/null\n",
" \n",
"solver = 'appsi_highs'\n",
" \n",
"import pyomo.environ as pyo\n",
"SOLVER = pyo.SolverFactory(solver)\n",
" \n",
"assert SOLVER.available(), f\"Solver {solver} is not available.\""
]
},
{
Expand Down
636 changes: 78 additions & 558 deletions notebooks/03/facility-location.ipynb

Large diffs are not rendered by default.

103 changes: 48 additions & 55 deletions notebooks/03/job-shop-scheduling.ipynb

Large diffs are not rendered by default.

22 changes: 10 additions & 12 deletions notebooks/03/machine-scheduling.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -46,19 +46,17 @@
"outputs": [],
"source": [
"import sys\n",
"\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",
" from pyomo.environ import SolverFactory\n",
" SOLVER = SolverFactory('appsi_highs')\n",
" \n",
"else:\n",
" from pyomo.environ import SolverFactory\n",
" SOLVER = SolverFactory('cbc')\n",
"\n",
"assert SOLVER.available(), f\"Solver {SOLVER} is not available.\""
" %pip install pyomo >/dev/null 2>/dev/null\n",
" %pip install highspy >/dev/null 2>/dev/null\n",
" \n",
"solver = 'appsi_highs'\n",
" \n",
"import pyomo.environ as pyo\n",
"SOLVER = pyo.SolverFactory(solver)\n",
" \n",
"assert SOLVER.available(), f\"Solver {solver} is not available.\""
]
},
{
Expand Down
21 changes: 9 additions & 12 deletions notebooks/03/maintenance-planning.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -58,19 +58,17 @@
"outputs": [],
"source": [
"import sys\n",
"\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",
" from pyomo.environ import SolverFactory\n",
" SOLVER = SolverFactory('appsi_highs')\n",
" \n",
"else:\n",
" from pyomo.environ import SolverFactory\n",
" SOLVER = SolverFactory('cbc')\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",
"assert SOLVER.available(), f\"Solver {SOLVER} is not available.\""
"import pyomo.environ as pyo\n",
"SOLVER = pyo.SolverFactory(solver)\n",
" \n",
"assert SOLVER.available(), f\"Solver {solver} is not available.\""
]
},
{
Expand All @@ -82,7 +80,6 @@
"import matplotlib.pyplot as plt\n",
"import numpy as np\n",
"import pandas as pd\n",
"import pyomo.environ as pyo\n",
"import pyomo.gdp as gdp"
]
},
Expand Down
20 changes: 9 additions & 11 deletions notebooks/03/recharging-electric-vehicle.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -49,19 +49,17 @@
"outputs": [],
"source": [
"import sys\n",
"\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",
" from pyomo.environ import SolverFactory\n",
" SOLVER = SolverFactory('appsi_highs')\n",
" \n",
"else:\n",
" from pyomo.environ import SolverFactory\n",
" SOLVER = SolverFactory('cbc')\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",
"assert SOLVER.available(), f\"Solver {SOLVER} is not available.\""
"import pyomo.environ as pyo\n",
"SOLVER = pyo.SolverFactory(solver)\n",
" \n",
"assert SOLVER.available(), f\"Solver {solver} is not available.\""
]
},
{
Expand Down
6 changes: 3 additions & 3 deletions notebooks/03/shift-scheduling.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,11 @@
"import sys\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",
" %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",
"import pyomo.environ as pyo\n",
"SOLVER = pyo.SolverFactory(solver)\n",
" \n",
Expand Down
6 changes: 3 additions & 3 deletions notebooks/03/simple-production-model-gdp.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@
"import sys\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",
" %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",
"import pyomo.environ as pyo\n",
"SOLVER = pyo.SolverFactory(solver)\n",
" \n",
Expand Down
20 changes: 9 additions & 11 deletions notebooks/03/strip-packing.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -60,19 +60,17 @@
"outputs": [],
"source": [
"import sys\n",
"\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",
" from pyomo.environ import SolverFactory\n",
" SOLVER = SolverFactory('appsi_highs')\n",
" \n",
"else:\n",
" from pyomo.environ import SolverFactory\n",
" SOLVER = SolverFactory('cbc')\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",
"assert SOLVER.available(), f\"Solver {SOLVER} is not available.\""
"import pyomo.environ as pyo\n",
"SOLVER = pyo.SolverFactory(solver)\n",
" \n",
"assert SOLVER.available(), f\"Solver {solver} is not available.\""
]
},
{
Expand Down
8 changes: 4 additions & 4 deletions notebooks/04/cryptocurrency-arbitrage.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@
"import sys\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",
" %pip install pyomo >/dev/null 2>/dev/null\n",
" %pip install highspy >/dev/null 2>/dev/null\n",
" \n",
"solver = 'appsi_highs'\n",
" \n",
Expand Down Expand Up @@ -96,7 +96,7 @@
"\n",
"[CCXT](https://github.com/ccxt/ccxt) is an open-source library for connecting to cryptocurrency exchanges. The CCXT library is not installed by default in Google Colab, so it must be installed with the following command.\n",
"\n",
" !pip install ccxt\n"
" %pip install ccxt\n"
]
},
{
Expand All @@ -105,7 +105,7 @@
"metadata": {},
"outputs": [],
"source": [
"!pip install ccxt"
"%pip install ccxt"
]
},
{
Expand Down
4 changes: 2 additions & 2 deletions notebooks/04/dinner-seat-allocation.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@
"import sys\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",
" %pip install pyomo >/dev/null 2>/dev/null\n",
" %pip install highspy >/dev/null 2>/dev/null\n",
" \n",
"solver = 'appsi_highs'\n",
" \n",
Expand Down
4 changes: 2 additions & 2 deletions notebooks/04/forex-arbitrage.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@
"import sys\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",
" %pip install pyomo >/dev/null 2>/dev/null\n",
" %pip install highspy >/dev/null 2>/dev/null\n",
" \n",
"solver = 'appsi_highs'\n",
" \n",
Expand Down
4 changes: 2 additions & 2 deletions notebooks/04/gasoline-distribution.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@
"import sys\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",
" %pip install pyomo >/dev/null 2>/dev/null\n",
" %pip install highspy >/dev/null 2>/dev/null\n",
" \n",
"solver = 'appsi_highs'\n",
" \n",
Expand Down
4 changes: 2 additions & 2 deletions notebooks/04/graph-coloring.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@
"import sys\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",
" %pip install pyomo >/dev/null 2>/dev/null\n",
" %pip install highspy >/dev/null 2>/dev/null\n",
" \n",
"solver = 'appsi_highs'\n",
" \n",
Expand Down
4 changes: 2 additions & 2 deletions notebooks/04/mincost-flow.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@
"import sys\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",
" %pip install pyomo >/dev/null 2>/dev/null\n",
" %pip install highspy >/dev/null 2>/dev/null\n",
" \n",
"solver = 'appsi_highs'\n",
" \n",
Expand Down
4 changes: 2 additions & 2 deletions notebooks/04/power-network.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@
"import sys\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",
" %pip install pyomo >/dev/null 2>/dev/null\n",
" %pip install highspy >/dev/null 2>/dev/null\n",
" \n",
"solver = 'appsi_highs'\n",
"\n",
Expand Down
Loading

0 comments on commit a9be9c6

Please sign in to comment.