Live data from Hacker News

Constraint Programming

en.wikipedia.org

61–63 of 63 posts

Re: Constraint Programming

#61
post #60
post #3

MiniZinc is a fairly simple-to-understand and open source constraint language: https://www.minizinc.org I learned about it when a friend gave me a programming challenge: https://gcanyon.wordpress.com/2009/10/28/a-programming-puzzl... She was going to work in PHP, I wrote a solution in J, and a commenter solved it in MiniZinc. Here is their solution in MiniZinc: http://www.hakank.org/minizinc/einav_puzzle.mzn

Ha I just started the course in MiniZinc on Coursera and it is very nice and creative. One tidbit for someone with a mostly econometrics background that (for me, a starter in the language with some exposure to linear optimization in the past) it was hard getting it to perform operations that use floats. For me that took away most toy problems I am interested in. But it’s blazing fast for complex discrete optimization…

Constraint programming solvers tends to focus on finite domain (integers) but there are some solvers that has some supports for floats as decision variables. You can try some of these solvers.

For non linear models:

* Gecode (included in the MiniZincIDE distribtion)

* JaCoP (https://github.com/radsz/jacop)

* OptiMathSAT (https://optimathsat.disi.unitn.it/pages/fznreference.html)

For linear models:

* CBC (included in the MiniZincIDE distribution)

Re: Constraint Programming

#62
post #20
post #17

There's also a Python library for constraint programming. Very easy to get started. https://github.com/python-constraint/python-constraint

Doesn't seem be be actively maintained, last commits were 4 years ago.

OptaPy (open source, https://www.optapy.org) solves similar use cases in Python, but using metaheuristics instead of traditional CP techniques, which helps for scaling out.

Re: Constraint Programming

#63

A very interesting application of constraint programming is the Unison compiler https://unison-code.github.io/ , which uses constraint models to solve compiler backend problems for llvm. As a simple example, register allocation can be modeled as a graph coloring problem for which there is an edge between every variable which must be live at the same time and colors represent registers, but he unison model is sophisti…

By the way, there is a similar work to Unison project. Its basic idea is to automate the compiler backend generation with help of SMT solver. The article: https://link.springer.com/epdf/10.1134/S0361768821070082?sha...
Post reply on HN