Simple constraint programming solver

柔情痞子 提交于 2020-05-29 02:39:12

问题


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).


回答1:


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.




回答2:


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:




回答3:


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



来源:https://stackoverflow.com/questions/17321436/simple-constraint-programming-solver

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!