users-prolog
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

FD constraints - strange behavior


From: bapstf80
Subject: FD constraints - strange behavior
Date: Wed, 19 Dec 2007 13:07:17 +0100
User-agent: Thunderbird 1.5.0.12 (Windows/20070509)

Hi, Fred
thank you for report.
it is due to how big expressions are split into simpler ones. This is done with new brand intermediate variables whose initial domain is 0..max_int. When 2 of these variables are multiplied (non-linearity) an overflow occurs and resulting in an empty domain (max < min). This is clearly a behavior we don"t want. I add it to my TODO list. A workaround consists in splitting by hand the _expression_ (as you did).

Ok, fine ! Now I understand.
By the way, my original code (for a CLP problem taken from a book) showing the "bug" was :

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).

Strange, I have no problem with this one !

Sorry, I mean the bug  appears when  we do not define  the auxiliary variables BC, EF and HI... And now it is clear why this happens.

Thanks for your work (I use gprolog for several years for my course on logic programming, and I really appreciate it).

PS - Funny that the problem is finally due to an overflow : we have just finished a diploma work where we instrument java bytecode so that overflows are reported at runtime. So I'm particularly interested in examples of overflow-related bugs...



reply via email to

[Prev in Thread] Current Thread [Next in Thread]