Skip to content

Commit

Permalink
deploy: df1de51
Browse files Browse the repository at this point in the history
  • Loading branch information
alessandrozocca committed Nov 19, 2023
1 parent b396b9c commit eef1aee
Show file tree
Hide file tree
Showing 8 changed files with 146 additions and 292 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
40 changes: 16 additions & 24 deletions _sources/notebooks/01/production-planning-advanced.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,7 @@
"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 checks if the notebook is run on Google Colab. If so, it does a quiet installation of Pyomo and the HiGHS solver. The solver is then selected, a test performed to verify that the solver is available, and the solver interface is stored in a global object `SOLVER` for later use."
]
},
{
Expand All @@ -59,19 +54,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 Expand Up @@ -332,8 +325,6 @@
"metadata": {},
"outputs": [],
"source": [
"import pyomo.environ as pyo\n",
"\n",
"model = pyo.ConcreteModel()"
]
},
Expand Down Expand Up @@ -552,6 +543,8 @@
" labor B : -Inf : 2*y[U] + y[V] - x[labor B] : 0.0 : True\n",
"\n",
"12 Declarations: PRODUCTS RESOURCES demand available cp cr a_index a x y profit materials_used\n",
"Running HiGHS 1.5.3 [date: 2023-05-16, git hash: 594fa5a9d]\n",
"Copyright (c) 2023 HiGHS under MIT licence terms\n",
"Profit = 2600.0\n",
"\n",
"Production Report\n",
Expand Down Expand Up @@ -601,6 +594,8 @@
"name": "stdout",
"output_type": "stream",
"text": [
"Running HiGHS 1.5.3 [date: 2023-05-16, git hash: 594fa5a9d]\n",
"Copyright (c) 2023 HiGHS under MIT licence terms\n",
"Profit = 2600.0\n",
"\n",
"Production Report\n",
Expand All @@ -615,9 +610,6 @@
}
],
"source": [
"import pyomo.environ as pyo\n",
"\n",
"\n",
"class ProductionModel(pyo.ConcreteModel):\n",
" \"\"\"\n",
" A class representing a production model using Pyomo.\n",
Expand Down Expand Up @@ -736,7 +728,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.2"
"version": "3.10.10"
},
"latex_envs": {
"LaTeX_envs_menu_present": true,
Expand Down
Loading

0 comments on commit eef1aee

Please sign in to comment.