This repo contains examples from an Introduction to Constraint Programming talk:
https://speakerdeck.com/paulk/groovy-constraint-programming
You have 4 options to run the examples:
- running locally on the command-line or in an IDE
- running via gitpod
- running as a Jupyter/BeakerX notebook
- running in the Groovy Console or Groovy Web Console
The Pythagorean subproject is an introductory example comparing an imperative style solution (using a brute-force approach), and a constraint-programming solution (using Choco[1]).
Run Choco solution via Jupyter/BeakerX:
Command-line arguments for Gradle to run the script:
:Pythagorean:run
The McNuggets subproject illustrates solving a fairly simple Frobenius numbers puzzle using Choco[1] and Ojalgo[2].
Command-line arguments for Gradle to see the task names for the available solutions:
:McNuggets:tasks --group="Application"
Then pick one of those tasks to run, e.g. to run the Ojalgo solution:
:McNuggets:runOjalgo
This example solves a classic cryptarithmetic puzzle using constraint programming. The Groovy solution is contrasted with brute-force approaches and solutions in other JVM languages.
See the SendMoreMoney subproject for all the details.
Constraint-programming libraries covered: Choco
Programming languages covered: Clojure, Groovy, Frege, Java, Nashorn, JRuby, Jython, Kotlin, Luaj, Scala, tuprolog.
This example solves an optimization/linear programming problem. Numerous technologies and approaches are used to solve the problem.
See the Diet subproject for all the details.
Technologies illustrated: Apache Commons Math, Hipparchus, Choco (with and without ibex integration), JaCoP (using scalar-product/weighted-sum and knapsack algorithms), Ojalgo, OptaPlanner, OrTools, SAS/OR.
This example uses genetic algorithms to explore the infinite monkey theorem.
See the Monkeys subproject for all the details.
Technologies illustrated: Apache Commons Math, Jenetics.
Libraries used:
Choco, Hipparchus, Apache Commons Math, JaCoP, OptaPlanner, OrTools, Jenetics, SAS/OR (commercial product).