English | Français | 日本語 | Español | Deutsch
A ready-made optimisation lab for teaching operations research, linear programming and constraint programming with PuLP and Google OR-Tools, from the MitsuruTech Learning Platform, where schools and colleges give every student their own machine and terminal in the browser. Each student gets an Ubuntu VM with PuLP, the CBC and GLPK solvers and OR-Tools CP-SAT. They read a linear programme and its shadow prices, see why an integer programme needs its own solver and why rounding a fractional plan breaks a limit, and run a CP-SAT rota. Then they write two models of their own. Nothing is installed on the student's computer, and a model solves in well under a second.
The lab leaves a folder ~/optimisation of files to work on and a README.md in the home folder that says what to do and gives none of the answers. It has five parts:
- A linear programme: the given
lp.pymakes tables and chairs from limited wood, hours and storage.opt lp.pyprints the status first, then the plan, then the slack and the shadow price of every limit. - Whole numbers: the given
integer.pypicks projects inside a budget and a number of hours, once with fractions allowed and once with whole projects only, and shows that the rounded plan breaks a limit. - A constraint model: the given
shifts.pymakes a nurse rota with OR-Tools CP-SAT and reads OPTIMAL, FEASIBLE or INFEASIBLE from the solver. - Change the three models by hand and predict what the solver will say.
- Two models the student writes:
plan.py(project selection with PuLP, printing the best profit, the plan and the linear bound) androta.py(a nurse rota with CP-SAT that breaks as few wishes as possible, and says INFEASIBLE when nobody could meet the need).
opt reset FILE puts a file back as it was given. A Basics lesson on the platform works in this lab and leaves the two models to the student. It complements the operations research module, which solves its problems with SciPy in the JupyterLab lab.
Ubuntu 26.04's archive has python3-pulp 2.7.0, coinor-cbc and glpk-utils, and no OR-Tools. PyPI has OR-Tools wheels for Python 3.14 on both arm64 and amd64, so nothing is compiled. The setup installs PuLP and the solvers with apt, and OR-Tools, pinned, with pip into a virtual environment, /opt/optlab, that can also see PuLP, because Ubuntu refuses pip into the system Python. The whole install takes about a minute. A student's VM reaches Ubuntu's archive and PyPI, so this works on the free guest size.
The lab has a check, a script that marks a handed-in VM without the teacher reading it. It runs on a copy of the saved machine after a fresh start. It runs both programs as the student, through a wrapper that counts the calls to the solver, so a program that prints a figure and never solves anything fails.
It runs plan.py on three project-selection instances it draws afresh. The profit must be the best there is, which the check finds by trying every plan, the plan must obey the budget and the hours, and the printed linear bound must match what GLPK, a different solver from CBC, says. It runs rota.py on two nurse rotas it draws afresh and on one that cannot be met. The cost must be the fewest broken wishes, which the check works out by dynamic programming, every rule of the rota is checked, and the impossible one must print INFEASIBLE. A program that starts another program, or has no PuLP or OR-Tools in it, is refused. The first line of what it prints says what is not right.
What it does not do: it does not read the answers to the questions in the README, and a student with root on their own VM could tamper with the tools. It is a check for a classroom, not a proof.
optimisation-lab.lab.yaml is a whole VM lab definition, exactly what the platform runs:
| Key | What it is |
|---|---|
cpus, memory, disk |
the size of each student's VM: 1 CPU, 1024 MB and 10 GB |
open |
the ports that open in the browser: none, the lab is the terminal |
setup |
a script run once, as root, the first time each student's VM starts: it installs the solvers, writes the opt helper, the models to work on and the README |
check |
the marking script, run as root on a copy of the saved disk after a fresh boot; its exit status is the result and 0 passes |
To set it as work for a class:
- In your module, add a task and choose the Ubuntu VM lab card.
- Press the Optimisation sample, or paste the contents of
optimisation-lab.lab.yaml. Using a sample replaces the text, and Undo brings yours back. - Publish and try your own copy first. Every student gets a VM of their own, kept between sessions.
- Assign it like any task. When it is handed in, run the check on a student's row in the class list: it starts a copy of their saved machine that is not saved back, and shows whether it passed and what it printed. The student is not told the result.
The help manual's page for this lab, its guide to Ubuntu VM labs and its sample labs page cover the rest.
No college account yet? Your first year is free for up to 50 students, and signing up takes an email address.
On every push, .github/workflows/check.yml checks that the file is valid YAML with the keys cpus, memory, disk, setup and check, and that setup and check are each inside the platform's 16 KB limit. It does not boot a VM: that is done on the platform's own machines. The setup, the Basics lesson's commands and the check, with each way of faking it, were run in an Ubuntu 26.04 container standing in for the VM, so one try in a booted student VM, and with the amd64 packages, before a class is worth it.
A student's VM reaches Ubuntu's package archive and a short list of learning sites, including the Python package index, and nothing else. There is no desktop in a terminal VM, so results are read as text. The models are small on purpose: this lab teaches how to write and read a model, and is not a benchmark.
Made by Mitsuru Technologies for the MitsuruTech Learning Platform: Python, Java, Go, Node, SQL and Linux in the browser for schools and colleges, with container labs, VM labs, web apps deployed from GitHub, and quizzes that mark themselves. Try code with no account in the playground.
More labs from the same place: lab-ns3-lab, lab-hdl-lab, lab-formal-lab, lab-sdn-lab, lab-reverse-lab, lab-k3s-lab, lab-tofu-lab and lab-ansible-roles.
This work is licensed under CC BY-NC-SA 4.0. You may share it and adapt it for learning and teaching, if you credit Mitsuru Technologies Ltd, do not use it commercially, and share anything you make from it under the same licence. The full text is in the LICENSE file.
OR-Tools (Apache-2.0), PuLP (MIT), CBC (EPL-2.0) and GLPK (GPL-3.0 or later) are installed from Ubuntu's archive and PyPI when a VM starts; nothing of them is distributed here.