Biweekly · AAI Eurecat
June 4, 2024
Giulia Zarpellon
This repository accompanies the tutorial on Pyomo presented at our Biweekly on June 4, 2024.
The slideshow was derived from the notebook pyomo-tutorial.ipynb
, which you can run yourself by following the instructions below.
A vanilla conda environment is specified in environment.yml
. Simply run
conda env create -f environment.yml
conda activate pyomo-env
If you have your own favourite base environment that already contains Jupyter, just add to it Pyomo and HiGHS, which is the solver used here. Using HiGHS in Pyomo is possible via some contributed APPSI (Auto-Persistent Pyomo Solver Interfaces), so install Pyomo with its conditional dependencies followed by the HiGHS solver:
pip install 'pyomo[optional]'
pip install highspy
To run the same environment in a Jupyter kernel:
python -m ipykernel install --user --name=ipy-pyomo-env
You should be all set! To test the installation, open a Python console and try
import highspy
import pyomo.environ as pyo
from pyomo.contrib import appsi
To visualize the notebook as a slide deck and serve it in a local https server,
we use nbconvert
with the --post serve
option specified:
jupyter nbconvert pyomo-tutorial.ipynb --to slides --post serve
See here for more details.
Note: this works because the notebook cells have a "Slide Type" associated with them. If you wish to build a similar presentation in the future, use the "Property inspector" icon (the two little gears) at the top right of a Jupyter notebook to define extra properties for cells. Under "Common tools" you should be able to edit the "Slide Type" field to build your own presentation.