Skip to content

Operations Research Lab

Teaching material designed and developed by Fabio Furini, associate professor at DIAG, Sapienza University of Rome.

Continuous optimization models for Management Engineering — the course lecture notes in online form, with Python/Gurobi code, data and reproducible case studies.

Every chapter starts from a concrete managerial problem — how much to produce, where to locate a service, which price to set, how much risk to accept — turns it into an optimization model, solves it with Gurobi called from Python and, above all, interrogates it: how much is one extra hour of capacity worth? Does the solution hold if the data change by 5%?

Every model can be run right away in the browser: each chapter has its own notebook that opens in Colab, with nothing to install.

The right question

At the end of every lab session the question is not only “what is the optimum?”, but “which decision do we recommend and how robust is it?”. All the models use only continuous variables: duality, shadow prices and KKT conditions apply.

The four parts of the lab

  • Tools


    How a model is built, how it is run, how to read the solution, the shadow prices and the reduced costs: the theory and the solver.

    The four chapters

  • Deterministic models


    Production, supply chain, portfolio, pricing, budget, location, electric vehicle charging, queues: every datum is known.

    The eight problems

  • Decisions under uncertainty


    You decide before you know: the quantile rule, tail risk and the duality that prices financial instruments.

    The three problems

  • Optimization and machine learning


    The SVM as a convex QP and robust regression as an LP: margin, dual, support vectors and support points — without ML libraries.

    The two problems

Complete index

Tools

  1. Theory: linear programming and nonlinear optimization — duality, shadow prices, KKT, sensitivity protocol
  2. Solver, linear models and nonlinear — building the model, running it, retrieving the solution, interpreting the output

Deterministic models

  1. Multi-period production and inventory — LP/QP
  2. Supply chain with congestion and CO₂ — LP/NLP
  3. The Markowitz portfolio — QP
  4. Pricing and revenue management — NLP
  5. Advertising budget — convex NLP
  6. Continuous location — convex NLP
  7. Electric vehicle charging — LP/QP
  8. Queues and service capacity — convex NLP

Decisions under uncertainty

  1. The Newsvendor and its variants — stochastic LP
  2. VaR and CVaR — scenario-based LP
  3. Arbitrage and pricing — LP and duality that prices

Optimization and machine learning

  1. Support Vector Machine — QP
  2. Robust and quantile regression — LP

The course

  1. Organization of the lab — lab sessions, submissions, assessment, mistakes to avoid

Notation and classes of models

  • LP (Linear Programming): linear objective and constraints;
  • QP (Quadratic Programming): quadratic objective, linear constraints;
  • NLP (Nonlinear Programming): general nonlinear objective or constraints.

A problem is convex when every local minimum is also global: for LPs this is always true; for QPs and NLPs it depends on the functions.

Notation used throughout the course. Scalars and indices in lowercase (\(x_{it}\), \(\lambda\)); the objects of the models (products, channels, assets, scenarios…) are numbered and the indices run over explicitly enumerated sets, \(i \in \{1, 2, \dots, n\}\); integer counts (\(n \in \mathbb{Z}_{\ge 1}\)), rational data (\(\mathbb{Q}\)); vectors in lowercase bold (\(\boldsymbol{x}\)), matrices in uppercase bold (\(\boldsymbol{Q}\)). Dual variables \(\pi_i\), reduced costs \(\bar c_j\), slacks \(\bar s_i\): the bar denotes the values of a feasible solution, the tilde those of an optimal one (\(\tilde x_j\), \(\tilde z\)). In the models the wording is always "subject to", the variables are introduced before the formulation and the constraints defining them close the model.

Download as PDF

  • 📘 Full lecture notes — 115 pages: models, worked examples, case studies, sensitivity analysis
  • 📊 Course slides — 83 slides, the whole content of the notes in compact form

Installation and licence

python3 -m pip install gurobipy

The pip package ships with a demo licence (up to 2000 variables and 2000 constraints): enough for every model in this lab. At start-up the line Restricted license - for non-production use only appears: this is normal.

Full academic licence (free of charge): 1. register at https://portal.gurobi.com with your institutional email (@uniroma1.it); 2. request a Named-User Academic License; 3. run the command grbgetkey XXXXXXXX-... shown by the portal (you need the university network or a VPN); 4. the licence is saved in ~/gurobi.lic and from that moment there are no size limits.

Quick check:

import gurobipy as gp
print(gp.gurobi.version())        # e.g. (13, 0, 3)

Quick start

python3 -m pip install gurobipy matplotlib pandas scipy   # scipy: statistical functions only
python3 python/run_all.py             # regenerates data, results and figures

Or with nothing to install: every chapter has a notebook that opens in Colab and runs in the browser.

In the repository you will find all the Python scripts and the case study data in CSV format.


Teaching material by Fabio FuriniDIAG, Sapienza University of Rome.