All posts

Noël Vranckx • • 9 min read

Optimisation and simulation libraries for supply chain planning

PuLP, OR-Tools, Pyomo, SimPy and a dozen more are free, and AI now writes the code. The hard part is picking the right one, and knowing that the best plan on paper is often the most fragile.

Illustration of a 1950s planning office: a wooden Galton board behind glass on a sideboard, balls bouncing through brass pegs into bins that form a bell curve, one red ball falling alone, a wall planning board of blank cards, a slide rule, a stopwatch and index cards

In June 1947 the US Air Force set up a small team to mechanise its planning. Its chief mathematician, George Dantzig, wrote down the linear programming model that July. By the end of the summer he had the simplex method to solve it.

"Programming" meant planning. There was hardly a computer to program. Five years later, Charnes, Cooper and Mellon showed in Econometrica how an oil company could use the same maths to blend aviation fuel.

Blending, scheduling, routing, allocating scarce capacity: supply chain was one of the first customers of optimisation. Seventy-nine years on, the solvers are free, they run on a laptop, and an AI assistant will write the model for you in a minute.

What has not changed is the choice. There are now dozens of Python libraries for optimisation and simulation, with overlapping names and very different strengths. This post is a map: what exists, what each one is for, and which to reach for first.

What these libraries are

Two families do two different jobs.

Optimisation answers "what is the best plan, given my rules?" You describe decisions (how many to make, which truck goes where), constraints (capacity, due dates) and a goal (lowest cost). A solver searches for the best answer and proves how good it is.

Simulation answers "what happens to this plan when real life hits it?" You describe a process (a line, a dock, a returns desk) with its variability, and the library plays it out thousands of times. It does not find the best plan. It tells you how a given plan behaves.

Inside optimisation there is a second split that confuses most newcomers: the modelling layer versus the solver. The modelling layer is the language you write the problem in. The solver is the engine that crunches it. PuLP and Pyomo are languages. CBC, HiGHS and Gurobi are engines. You can usually swap the engine without rewriting the model.

Modelling layers

LibraryOwner and licenceGood atNotes
PuLPCOIN-OR, MITLinear and mixed-integer models, readable codeVersion 4.0 (September 2026) changed the syntax and no longer bundles the CBC solver. Older tutorials, and AI trained on them, may write code that breaks.
PyomoPyomo project, BSDLarge, structured or nonlinear modelsMore to learn than PuLP, but scales to serious models with many solver options.
CVXPYOpen source, Apache 2.0Convex problems: fitting, smoothing, portfolio-style trade-offsChecks that your problem is convex before it solves it.
linopyPyPSA, MITVery large models built from tables and arraysBorn in energy-system planning, fits network and capacity models.
python-mipCOIN-OR, EPL 2.0Mixed-integer models with fine controlWorks with CBC and Gurobi.

Solvers

SolverLicenceNotes
HiGHSMITFast open-source solver for linear and mixed-integer problems. SciPy's `milp` and `linprog` run on it, so if you have SciPy, you already have it.
CBCOpen source (COIN-OR)The old default behind PuLP. Still fine for small and medium models.
GurobiCommercialAmong the fastest for hard mixed-integer models. The pip version is capped at 2,000 variables and 2,000 constraints, for evaluation only. Free for academics.
HexalyCommercialFormerly LocalSolver. Strong on routing, scheduling and nonlinear problems.
NVIDIA cuOptApache 2.0 since 2025Runs on a GPU. Linear programs and vehicle routing at large scale. PuLP can call it.

Specialists for scheduling and routing

LibraryLicenceGood at
Google OR-ToolsApache 2.0CP-SAT for scheduling with sequencing, shifts and "if this, then not that" rules. A routing library for vehicle routing. Version 10 is in release candidate since 23 November 2026.
PyVRPMITVehicle routing with time windows, multiple depots, mixed fleets and pickups.
TimefoldApache 2.0Strong for rostering, but its Python version was discontinued in 2025. Java and Kotlin only now.

Simulation

LibraryLicenceGood at
SimPyMITDiscrete-event simulation of processes: lines, docks, forklifts, queues. The default choice.
salabimMITThe same kind of simulation, with built-in 2D and 3D animation to show stakeholders.
CiwMITQueueing networks: customer classes, priorities, people giving up and leaving the queue.
MesaApache 2.0Agent-based models, where many suppliers, customers or drivers each follow their own rules.
AnyLogic and anyLogistixCommercialVisual tools with a graphical editor, for network design and digital twins. AnyLogic models can be driven from Python.

And for people who live in spreadsheets: Excel's own Solver handles up to 200 decision cells. OpenSolver removes that limit, but its last release dates from 2020.

What it means for supply chain

The single most useful question is not "which library is best?" It is "what am I asking?"

If your question is...Reach forExample
What should I make, buy or ship, at lowest cost?PuLP with HiGHSWeekly production plan, purchase allocation across suppliers
In which order, on which machine, in which shift?OR-Tools CP-SATLine sequencing with changeovers, maintenance windows
Which truck visits which stops, and when?OR-Tools routing or PyVRPDaily delivery tours with time windows
The model works but takes hours, or will run every nightPyomo or linopy, with Gurobi or HexalyNetwork design, multi-echelon capacity plans
Will this plan survive delays and breakdowns?SimPyDock door count, line buffer size
How long will people wait, and how many give up?CiwCustomer service desk, returns counter
What happens when hundreds of actors react to each other?MesaBullwhip effect, supplier allocation in a shortage
I need to show it to a board, not to a developersalabim, or AnyLogicAnimated warehouse layout

A few patterns I see again and again:

  • Start with PuLP and HiGHS. It covers most planning problems a single team has, it is readable, and it costs nothing. Move up only when a model gets too big or too slow.
  • Scheduling is a different animal. Sequencing and shift rules are painful in a linear model and natural in CP-SAT. If your model has lots of "either this or that" binaries, try it there.
  • Do not build your own routing. Routing is a solved problem with excellent free libraries. Your time is better spent on clean addresses and real drive times.
  • Simulate before you commit. An optimiser assumes everything goes to plan. A simulation shows what happens when it doesn't. The two together are worth more than either alone.
  • Keep the Excel model as a check. For small problems, Solver in a spreadsheet is a fine way to show a manager that the Python answer makes sense.

That fourth point is the one most teams skip. So here is a way to see it for yourself.

Try this: optimise a plan, then try to break it

This prompt needs an AI assistant that can write and run Python (Claude with code execution, ChatGPT with data analysis, or your own setup). It builds a week's plan for one assembly line at a fictional bicycle maker, then stress-tests it. All numbers are illustrative.

You are an operations research analyst helping a production planner.

Task, part 1 (optimise): Build a weekly production plan for one assembly line, Monday to Friday, using PuLP with the HiGHS or CBC solver (if PuLP will not run, use scipy.optimize.milp). Show the code.

Rules:
- The line has 15 hours per day.
- Each model that runs on a day costs a changeover of 1 hour and 250 EUR.
- Hours per bike: Road 0.20, Gravel 0.25, E-road 0.40, E-gravel 0.45.
- Bikes left in stock overnight cost 3 EUR per bike per night.
- Demand must be met by the end of its day. No backorders. Early production is allowed.
- Minimise changeover plus holding cost.

Demand (bikes due by end of day):
model,Mon,Tue,Wed,Thu,Fri
Road,10,10,10,30,10
Gravel,0,20,20,0,24
E-road,8,8,8,8,8
E-gravel,0,0,10,10,0

Task, part 2 (simulate): Using SimPy, run the plan for 1,000 simulated weeks. Each changeover takes 75% to 125% of planned time, each bike 85% to 115% (uniform). Each day has a 10% chance of a stoppage of 1 to 3 hours. Overtime is any time beyond 15 hours on a day.

Task, part 3: Re-optimise with the planned load capped at 13.5 hours per day, simulate again, and compare.

Output: a table per plan (bikes per model per day, planned hours per day, cost), then a comparison table: cost, share of weeks with any overtime, average overtime hours per week. End with three sentences of advice to the planner, and list your assumptions.

What you should see

Run as written, the first plan costs 2,282 EUR and loads Monday, Wednesday and Thursday to exactly 15.0 hours. That is what optimisers do: they use every minute you give them. The exact split of bikes over the days can differ between runs, but the cost should not.

The simulation then shows the price of that precision. The 15-hour plan needed overtime in about 9 out of 10 weeks, on more than one and a half days per week on average. The capped plan cost 2,939 EUR, so 657 EUR more, and needed overtime in roughly 1 week in 4. Your simulated figures will move by a few points with the random draws.

Why this shows the point

Neither number is the answer on its own. The optimiser says the cheap plan is best. The simulation says it is best only if nothing ever goes wrong. Whether 657 EUR a week is worth fewer overtime calls is a business decision, and now it is one you can make with numbers instead of gut feel.

A good answer questions its own result. If the assistant calls the first plan "optimal" and stops, push it to part 2.

What it can't do, and the traps

  • Garbage in, optimal garbage out. A solver trusts your run rates and costs completely. One wrong changeover time gives you a confidently wrong plan.
  • AI writes old code. PuLP 4.0 changed its syntax in September 2026, and Timefold dropped Python in 2025. Ask the assistant to check the installed version and to run the code, not just write it.
  • "Optimal" means optimal for the model. Anything you left out (a skill constraint, a supplier's minimum order) the solver will happily violate. Show the plan to the person who runs the line before you trust it.
  • Simulation is only as good as its variability. Uniform 85% to 115% is a guess. Use real cycle times and stoppage logs where you have them.
  • Free licences have edges. Gurobi's pip licence stops at 2,000 variables, and production use needs a paid licence. Check before a pilot becomes a process.

Simulate the plan you already have

You do not need to start with optimisation. Take this week's real plan for one line, dock or desk, and ask an AI assistant to simulate it in SimPy with the stoppages you remember from last month. If it breaks in the simulation, it was going to break on Thursday.

Dantzig's team built linear programming to plan an air force. You can now run the same ideas on a laptop before your morning coffee. The maths is no longer the bottleneck; knowing which question to ask is.

Which planning decision in your team would you most like to see optimised, or stress-tested?

Sources

Illustration of a scale model of a small company on a workbench: two factories and a warehouse linked by roads with miniature lorries, beside a pair of callipers, a pencil and an open notebook

Read it, then try it

The posts on this blog are meant to be used, not only read. Each one ends in something to do: a prompt to run, a calculation to rebuild or a first step for this week. You learn what AI can do in supply chain by putting it to work on a real problem.

Meet Upshift

Most examples use Upshift, a fictional bicycle maker. It builds road and gravel bikes, each as a regular and an e-bike version, in two plants, and serves dealers and retail chains through five distribution hubs. Upshift isn’t a real company, and none of its data comes from one. Meet the company.

The dataset and the exercises

Behind Upshift sits a complete synthetic company dataset: products, suppliers, dealers, orders, stock, production and the transport network, all consistent with each other. Its dates follow a date you choose, so the data always looks current. The exercises on this site use the same company, each with a task, the files you need and a way to check your result.

A post keeps its example small enough to paste into a chat. The dataset and the exercises let you do the same work at the scale of a real company.

The dataset and the exercises are free with an account. The app is in early access for now: request an account from the sign-in screen and I’ll send you an invitation as soon as I can.

Pass it on

Know a colleague who should read this? Post it where they will see it, or send it to them directly.

More posts

Illustration of a long water pipe along a factory brick wall: a bucket and mop stand under the dripping tap at the far right, while the real leak is a crack spraying yellow water at a joint far upstream on the left, with a step ladder and pipe wrench beneath it

Noël Vranckx •

AI for root-cause analysis of late deliveries

Most late-delivery reports blame the carrier because that is the first box in the drop-down. An AI model that reads the dates and the notes together tells a different story, and you can test it in ten minutes.