I have been trying to apply library(clpq) (same with clpr) to this problem: https://www.youtube.com/watch?v=ABj3IC9pYlQ
You don’t need to watch this, the question which is posed is this:
Alice and Bob take 2 hours to finish a job. Alice and Charlie take three hours. Bob and Charlie take four hours. How long does it take when they work all together?
In the end, I found out that it worked with the formulation of the equations that Presh uses in the video, namely:
?- {1=2*(A+B), 3*(A+C)=1, 4*(B+C)=1, X*(A+B+C)=1}.
A = 7r24,
B = 5r24,
C = 1r24,
X = 24r13.
However, I had originally written the equations like 1/(A+B)=2
instead of 1=2*(A+B)
. This doesn’t work at all:
?- {1/(A+B)=2, 3*(A+C)=1, 4*(B+C)=1, X*(A+B+C)=1}.
{B=1r4-C, A=1r3-C, -1+A*X+B*X+C*X=0, -2+1/(A+B)=0},
{-1+A*X+B*X+C*X=0, -2+1/(A+B)=0},
{-1+A*X+B*X+C*X=0, -2+1/(A+B)=0},
{-1+A*X+B*X+C*X=0, -2+1/(A+B)=0},
{-1+A*X+B*X+C*X=0, -2+1/(A+B)=0}.
?- {1/(A+B)=2, 3*(A+C)=1, 4*(B+C)=1, X*(A+B+C)=1}, minimize(X).
false.
Being unexperienced with this library, that surprised me, because I would have thought that constraints would be converted to some canonical form anyway. Should this be expected? Perhaps some kind of warning in the documentation would be appropriate?