[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: FD and Multiplication
From: |
Daniel Diaz |
Subject: |
Re: FD and Multiplication |
Date: |
Tue, 17 Apr 2012 15:27:31 +0200 |
Hi jan,
in CSP, each variable is (before anything else) associated with its domain.
This domain is expected to be finite (hence the name FD). Any clp(FD) program
should begin with the definition of the domains. After that constraints can be
added. Even if GNU Prolog allows the user to omit SOME domain declarations it
is not a good idea to systematically avoid ALL of them. In particular if you
use non-linear constraints (BTW we are here really far from what CSP was
designed for). For efficiency reasons, GNU Prolog does not check integer
operations overflows. Thus, without domain definition, a constraint like X*Y #=
0 fails.
| ?- X*Y#=0.
no
Indeed, when the max(X) (a big value since no domain is declared for X) is
multiplied by max(Y) (the same big value), an overflow occurs which is not
detected thus the result: no.
To avoid this, simply declare a (decent) domain for X (initially in CSP a
finite domain meant "some dozens/hundreds values").
E.g.
| ?- fd_domain([X,Y],0,10000),X*Y#=0.
X = _#3(0..10000)
Y = _#24(0..10000)
On you example:
| ?- fd_domain([X,Y],0,10),(Y-5)*(X-6) #= 0, fd_labeling([X,Y]).
X = 0
Y = 5 ? ;
X = 1
Y = 5 ? ;
X = 2
Y = 5 ? ;
...
Currently, there is no way to obtain the constraint store (I agree this could
be useful).
Daniel
Le 16 avr. 2012 à 20:58, Jan Burse a écrit :
> Hi,
>
> Any reason that the following fails:
>
> ?- (Y-5)*(X-6) #= 0.
> No
>
> Best Regards
>
> P.S.: On the other the following works:
>
> ?- (X-5)*(X-6) #= 0, fd_labeling(X).
> X = 5 ? ;
> X = 6
>
> But I didn't figure out how to list the
> actual constraint store, and also I didn't
> figure out how to get heuristic information
> that is for example used in labeling, such
> as the weight used in "most constraints".
>
> Listing the constraint store and/or
> heuristic information would also help
> debugging the query that fails.
>
>
> _______________________________________________
> Bug-prolog mailing list
> address@hidden
> https://lists.gnu.org/mailman/listinfo/bug-prolog
>
> --
> Ce message a ete verifie par MailScanner
> pour des virus ou des polluriels et rien de
> suspect n'a ete trouve.
>
--
Ce message a ete verifie par MailScanner
pour des virus ou des polluriels et rien de
suspect n'a ete trouve.