6

I'm trying to get familiar with constraint programming.

All documentation/videos I've seen so far just contain description of top-level concepts and code examples based on CP-libraries utilization (like Choko, Gecode, JaCoP etc).

I'd like to implement at least something simple in Java without any libraries.

Are there any resources where I can find working code in Java/C#/C++/Python which implements main CP ideas? (at least "send more money" problem solution).

(or, maybe, if somebody can explain it here, it would be great).

4

3 回答 3

7

It depends on what are you trying to do.

1- If you want to get started with Constraint Programming (CP) tools, you need first to understand modelling in this approach. For that, you have be able to define a given problem as a set of constraints then you post your model to a solver (that already knows how to deal with these constraints).

I personally find the G12_MiniZinc_Distribution (available via http://www.minizinc.org/) and its latest tutorial a very good way to start (the latest distribution cames with a lot of models). There is also online models if you want to see how a CP model looks like (w.r.t minizinc syntax) : http://www.hakank.org/minizinc.

2- If you have an advanced theoretical understanding of CP, you may directly see the implementation of some techniques (e.g. propagators) from available libraries since developing a CP Solver from scratch is (IMO) a foolish idea. These are some open-source solvers/libraries : G12, Choco, Mistral, Or-Tools.

于 2013-06-26T17:23:21.350 回答
3

FWIW, the OptaPlanner (open source, java) documentation has a in depth explanation of a few algorithms, such as Simulated Annealing and Tabu Search.

Here's an image from there:

Simulated Annealing

于 2017-03-28T15:16:28.070 回答
0

If there is still someone look for something like this:

You might want to check out Minicp where you can find slides and it's a solver written in Java.

If you want to write your own solver from scratch in a high level but fast programming language please check out my blog series: ConstraintSolver.jl blog posts

于 2019-09-07T08:24:28.570 回答