Skip to content

The notebooks of the course

Every chapter with models 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: the instances of the course are small and all fit with plenty of room. For larger instances activate the free academic licence at portal.gurobi.com.

Chapter Class Notebook
3.5 The protocol, and how to run it implementation Open in Colab
4. Constructive heuristics algorithms Open in Colab
5. Logic and binary variables BIP Open in Colab
6. Links between variables modelling techniques Open in Colab
3.4 Three classic models implementation Open in Colab
3.4 Three classic models implementation Open in Colab
3.4 Three classic models implementation Open in Colab
EX 1 — The eight-seat van BIP Open in Colab
EX 2 — Bus lines BIP Open in Colab
EX 3 — Relay BIP Open in Colab
EX 4 — Hub-and-spoke BIP Open in Colab
EX 5 — Funds bought in lots ILP Open in Colab
EX 6 — Vehicles with a minimum quantity MILP Open in Colab
EX 7 — Custom aircraft with a fixed cost MILP Open in Colab
EX 8 — Seminars BIP Open in Colab
EX 9 — Queens on the chessboard BIP Open in Colab
EX 10 — Tools of a CNC machine BIP Open in Colab
EX 11 — Shoes with a minimum production threshold MILP Open in Colab
EX 12 — Balancing between two workers MILP Open in Colab
EX 13 — The emergency room shifts ILP Open in Colab
EX 14 — Shoes: production, inventory and hiring MILP Open in Colab
EX 15 — The music school timetable BIP Open in Colab
Minimum-cost assignment with availability BIP Open in Colab
Machines with a fixed usage cost BIP Open in Colab
Job selection with revenues and fixed-cost machines BIP Open in Colab
Parallel jobs: the processing time as a maximum MILP Open in Colab
One machine, job classes with setup BIP Open in Colab
Classes with completion bonus and "if and only if" reduction BIP Open in Colab
Total tardiness on one machine: sequencing with big-M MILP Open in Colab
Capacitated facility location MILP Open in Colab
p-median: at most \(k\) locations BIP Open in Colab
Signal coverage with interference BIP Open in Colab
Hub location with maximum cost MILP Open in Colab
Lot sizing with a fixed setup cost MILP Open in Colab
Production and workforce: two equivalent formulations MILP Open in Colab
Vehicles: minimum lot and a bonus for variety MILP Open in Colab
Prizes obtainable in two ways BIP Open in Colab
Combinatorial auction BIP Open in Colab
Diet with a count of the foods and a minimum lot MILP Open in Colab
Christmas trees and boxes of lights MILP Open in Colab
Shipments in boxes MILP Open in Colab
Children across summer camps ILP Open in Colab
Branches across two companies BIP Open in Colab
Songs across CDs MILP Open in Colab
Books across shelves MILP 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 fam07_1_assignment.py