How many leaves of Victoria regia fit into this pond in Gothenburg's Palm house? MiniZinc can compute the answer.
In operations research, ILPsolvers (integer linear programming) are a standard tool to find optimized configurations in constrained environments. It can answer questions like:
The hard thing is to reformulate the problem with constraint equations and a cost function. But once you did that, the ILPsolver does it’s magic and finds a solution. The problem with ILPsolvers is that their input language is often verbose and thus hard to maintain.
The people at Monash University & co have developed a highlevel, solverindependent language to interface with a range of open source and commercial ILPsolvers: MiniZinc. I highly recommend taking their free, fun and challenging online course where you need to help out protagonists in the novel Romance of the Three Kingdoms with problems such as maximizing the force of their armies or organizing a glorious banquet.
I believe we should use equation solvers more often in our apps and services. For my startup idea Chaski, I’m using it to solve packing problems to derive pickup and delivery constraints (which items fit into the truck) that will influence the delivery tour.
Ok 🤔, I admit, solving packing problems with an ILPsolver is a classic. But the next time I find myself developing a complicated heuristic in my day job, I will try to come up with some equations first and let MiniZinc do the heavy lifting. Chances are that the ILP solver is better, faster and more stable than my algorithm. 😉
I created a dockerized Python web service around MiniZinc so that I can hook it up easily in my projects.
To build and run the service run the following on a system with Docker installed:


We want to run the following optimization program written in MiniZinc language:


To do that run the following cURL command:


It should yield:


Have fun!