CLPFD: Introduction to Solving Problems with Limited Resources (SWISH)

Whenever I’ve bumped into tutorials on using library(clpfd), they always seem to be solving something like a Sudoku puzzle or fathing about with a bunch of queens. Never having seen any application of library(clpfd) that resembled the kind of thing I was doing in my studies of Management Science/Operational Research or Combinatorial Optimisation, I thought I’d put together a quick (?!) tutorial.

Well, one day later and we have a SWISH notebook that goes from scenario description, to mathematical model, to Prolog, to solution for 3 different scenarios. Each scenario is around minimizing cost or maximizing profit given some constraints. Along the way we encounter a few modelling tricks and use labeling/2 sensibly to find a solution efficiently, rather than use our computer as a substitute radiator.

Back when this was part of my curriculum of study, I looked around for a nice solver but to no avail. I have to say, library(clpfd) is very nice because the syntax is so close to the mathematical notation.