Joost Geurts wrote: > Dear people, > > I have the following CLP program which fails although I do not really > understand why. It fails in SWI-prolog at exactly the same point so I > assume it is me who made a mistake. Maybe somebody can explain, and > possibly suggest a way to solve it. ... > The last constraint, CX2 #= MinX2 fails. My guess is it has something to > do with the minlist constraint. I am using eclipse 5.7 with the ic > library. Indeed it does. ... > % set size for A , B ... > WB = 120, > > % width A,B ... > WB #= BX2 - BX1, This constrains BX2 to equal BX1 + 120 > % A before B > AX2 #=< BX1, This constrains BX1 to be no less than AX2, and thus BX2 to be no less than AX2 + 120. > % C contains A&B ... > BX1 #>= CX1, BX2 #=< CX2, This constrains CX2 to be no less than BX2. > % find minimum of A & B ... > minlist([AX2,BX2],MinX2), This constraints MinX2 to equal the minimum of AX2 and BX2, i.e. AX2 since BX2 is already constrained to be no less than AX2 + 120. ... > % C fits tightly ... > CX2 #= MinX2, % This constraint fails! And this constrains CX2 to equal MinX2, i.e. AX2. Since CX2 must be no less than BX2 this can only succeed if BX2 =< AX2, but BX2 is no less than AX2 + 120. What you need is not to find the minimum of A & B, but the extent of A & B, i.e. minlist([AX1,BX1],MinX1), maxlist([AX2,BX2],MaxX2), and then CX2 #= MaxX2, if you want tightest fit. -- Andrew Eremin Research Assistant Tel: +44 (0)20 7594 8299 IC-Parc, Imperial College London Fax: +44 (0)20 7594 8432 London SW7 2AZ Email: a.eremin@icparc.ic.ac.ukReceived on Fri Nov 19 17:44:52 2004
This archive was generated by hypermail 2.1.8 : Wed 16 Nov 2005 06:07:31 PM GMT GMT