|
From: | Ludovic Langevine |
Subject: | Re: constraints... |
Date: | Wed, 23 Apr 2003 11:52:37 +0200 |
User-agent: | Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.3) Gecko/20030312 |
ax_plus_by_eq_z(100, var(4), 10, var(5), var(6))( 100 * I + 10 * J #= K where I, J, K are intermediate variables in [0..268435455] )
and this constraint fails before making any domain reduction. Source code of the constraint: ax_plus_by_eq_z(int A,fdv X,int B,fdv Y,fdv Z) { start X in (min(Z) - B*max(Y)) /> A .. (max(Z) - B*min(Y)) /< A start Y in (min(Z) - A*max(X)) /> B .. (max(Z) - A*min(X)) /< B start Z in A*min(X) + B*min(Y) .. A*max(X) + B*max(Y) }your example does not work for A = 100 and B in [9,15]... [2^3+1, 2^4-1] : maybe an arithmetic overflow?
This 'by hand' splitting works:fd_domain([A,B,C], 1, 9), A10 #= 10*A, B10#=10*B, D #= A10*B10, Q #= D + A10 * C.
but this is not very satisfactory! PRADOS Julien wrote:
yes it looks like a bug... in gprolog v 1.2.16 this predicate succeed fd_domain([A,B,C],1,9), Q #= 8*A*(10*B + C). and this one fail !!! fd_domain([A,B,C],1,9), Q #= 10*A*(10*B + C). why ??? fred bapst wrote:The constraints (A#=10*B+C) should be identical to (Z#=10*B, A#=Z+C), no ? (Ok, I'm aware of differences in the propagation and of overflow risk...). Does anybody know why the following fraction0 fails whereas fractions1 succeeds (with gnu prolog 1.2.8) ? Thanks in advance. ----------------------------------------------- fractions0(Ls) :- Ls = [A,B,C,D,E,F,G,H,I], fd_domain(Ls, 1, 9), fd_all_different(Ls), A*(10*E+F)*(10*H+I) + D*(10*B+C)*(10*H+I) + G*(10*B+C)*(10*E+F) #= (10*B+C)*(10*E+F)*(10*H+I), fd_labelingff(Ls). fractions1(Ls) :- Ls = [A,B,C,D,E,F,G,H,I], fd_domain(Ls, 1, 9), fd_all_different(Ls), BC #= 10*B+C, EF #= 10*E+F, HI #= 10*H+I, A*EF*HI + D*BC*HI + G*BC*EF #= BC*EF*HI, fd_labelingff(Ls). ___________________________________________________________ Do You Yahoo!? -- Une adresse @yahoo.fr gratuite et en français ! Yahoo! Mail : http://fr.mail.yahoo.com _______________________________________________ Users-prolog mailing list address@hidden http://mail.gnu.org/mailman/listinfo/users-prolog_______________________________________________ Users-prolog mailing list address@hidden http://mail.gnu.org/mailman/listinfo/users-prolog
[Prev in Thread] | Current Thread | [Next in Thread] |