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

**URL:** <https://swi-prolog.discourse.group/t/clpfd-introduction-to-solving-problems-with-limited-resources-swish/1002>\
**Category:** Resources\
**Tags:** swish\
**Created:** [July 29, 2019, 4:03pm UTC](https://swi-prolog.discourse.group/t/clpfd-introduction-to-solving-problems-with-limited-resources-swish/1002 "2019-07-29T16:03:41Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![PaulBrownMagic](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/paulbrownmagic/32/211_2.png) [@PaulBrownMagic](https://swi-prolog.discourse.group/u/PaulBrownMagic)\
**Post date:** [July 29, 2019, 4:03pm UTC](https://swi-prolog.discourse.group/t/clpfd-introduction-to-solving-problems-with-limited-resources-swish/1002/1 "2019-07-29T16:03:41Z")

</div>

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](https://swish.swi-prolog.org/p/CLPFD%3A%20Introduction%20to%20Solving%20Problems%20with%20Limited%20Resources.swinb) 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.
