Skip to content

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 Open in Colab
Supply chain with congestion and sustainability LP / convex NLP Open in Colab
The Markowitz portfolio convex QP Open in Colab
Pricing and revenue management concave / non-convex NLP Open in Colab
Advertising budget allocation convex NLP Open in Colab
Continuous location of a service convex NLP Open in Colab
Smart charging of electric vehicles LP / convex QP Open in Colab
Service capacity and waiting times convex NLP (M/M/1 queue) Open in Colab
The Newsvendor and its variants 1D convex / scenario-based stochastic LP Open in Colab
VaR and CVaR: measuring and optimizing risk scenario-based LP Open in Colab
Arbitrage and arbitrage-free pricing LP Open in Colab
Support Vector Machine: optimization for machine learning convex QP Open in Colab
Robust and quantile regression LP (compared with a QP) Open in Colab

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