4 ms·
Do you know of anyone combining prolog with integer linear programming? I modelled quite a complex convex optimisation problem as a mixed integer linear program
by 0db532a0 8y ago
Do you know of anyone combining prolog with integer linear programming? I modelled quite a complex convex optimisation problem as a mixed integer linear programme, but it was very buggy at the beginning to say the least.
I was left wishing that there was a better way to express the logical constraints, which in any case can be converted to integer linear equations, while keeping the linear equations where needed and possible.
- yaantc 8y agoECLiPSe CLP [1] (no relation with the IDE) is a Prolog implementation with constraint logic programming support and interfaces to lots of solvers, including MIP ones [2]. So I guess the answer is yes, although you may not find lots of public use-cases. Eclipse CLP was bought and open sourced by Cisco. [1] http://eclipseclp.org/ http://eclipseclp.org/ [2] From http://eclipseclp.org/features.html http://eclipseclp.org/features.html: "Solver Interfaces. ECLiPSe interfaces to the COIN-OR, CPLEX, Gurobi and XPRESS-MP linear and mixed-integer programming solvers, and the Gecode finite-domain solver. Other interfaces are under development."
- 0db532a0 8y agoSeems to be exactly what I was looking for. Thanks.
- YeGoblynQueenne 8y agoMarkus Triska, the author of the Lisp interpreter above has also contributed library(simplex), a linear programming library for Swi-Prolog: http://www.swi-prolog.org/pldoc/man?section=simplex http://www.swi-prolog.org/pldoc/man?section=simplex
- 0db532a0 8y agoFrom first look, this library doesn't seem to provide a way of translating logical constraints into MIP constraints. I'm sure that could be implemented in terms of the library though.
- 0db532a0 8y agoThanks to all for the sources.
- tom_mellior 8y ago> I was left wishing that there was a better way to express the logical constraints, which in any case can be converted to integer linear equations, while keeping the linear equations where needed and possible. SWI-Prolog's clpfd library allows you to mix linear and non-linear integer constraints with "reified" versions that allow you to write implications and such. Silly example: ?- [A, B, C] ins 0..3, A #< B #==> C #= A * B, A #>= B #<==> C #\= B. This means "for values A, B, C each in the range 0 to 3, if A is less than B, then C is equal to A * B, and A is greater than or equal to B if and only if C is different from B". Is this the kind of constraints you were thinking of?
- rscho 8y agoI read in several places (that I don't remember unfortunately) that prolog experts discouraged the use of SWI clpqr because it contained major mistakes. Does anyone know if it is still the case and if clpfd suffers from the same issues?
- tom_mellior 8y agoI doubt that, but it's hard to tell as this is kind of vague. CLP(FD) talks about integers, CLP(Q) and CLP(R) talk about rationals and reals, respectively. If you approximate rationals or reals with floating point, you will get into situations where you compute nonsense, so in that sense at least CLP(R) has issues, but that kind of issue would have nothing to do with CLP(FD).
- rscho 8y agohttps://github.com/SWI-Prolog/packages-clpqr/issues/4 https://github.com/SWI-Prolog/packages-clpqr/issues/4 Also cited at https://www.metalevel.at/swissues https://www.metalevel.at/swissues I also read it on SO, but can't find it. I do however remember that it was said that the SWI lib was ported from the SICSTUS one, and that mistakes were added in the process, and that it couldn't be recommended for that reason.
- 8y ago