The notebooks of the lab
Every chapter with a model has its own notebook: one click on the badge opens
it in Google Colab, it installs the solver by itself and runs in the browser —
nothing to install on your machine. It is the very same code as the scripts in
python/, cell by cell, with the figures appearing below the cells instead of
being written to a file.
The pip licence is enough
The licence bundled with gurobipy is limited to 2000 variables and 2000
constraints, and every model of the lab fits: the largest one — the scenario
newsvendor — uses 1803 and 1801. Raising the number of scenarios can exceed it:
in that case activate the free academic licence at
portal.gurobi.com.
| Chapter | Class | Notebook |
|---|---|---|
| Multi-period production and inventory | LP / convex QP | |
| Supply chain with congestion and sustainability | LP / convex NLP | |
| The Markowitz portfolio | convex QP | |
| Pricing and revenue management | concave / non-convex NLP | |
| Advertising budget allocation | convex NLP | |
| Continuous location of a service | convex NLP | |
| Smart charging of electric vehicles | LP / convex QP | |
| Service capacity and waiting times | convex NLP (M/M/1 queue) | |
| The Newsvendor and its variants | 1D convex / scenario-based stochastic LP | |
| VaR and CVaR: measuring and optimizing risk | scenario-based LP | |
| Arbitrage and arbitrage-free pricing | LP | |
| Support Vector Machine: optimization for machine learning | convex QP | |
| Robust and quantile regression | LP (compared with a QP) |
How they are made
The notebooks are not written by hand: they are generated from the scripts with
python3 python/make_notebooks.py
The chapter script remains the single source of the code — the notebook takes its
docstring, sections and comments from it — and whoever prefers the command line
keeps running, from the python/ folder:
python3 lab06_markowitz.py