简体   繁体   中英

Can I make this CLP(FD) query terminate in a shorter time?

I have the following CLP(FD) query:

?- use_module(library(clpfd)).
?- [I,N,M,J] ins -2147483648..2147483647, 
I - 3*N #= X, X in 1..2, 
I - 5*M #= Y, Y in 1..4, 
I - 15*J #= 0.

In SWI-Prolog already when posing the query without a label/1 goal, the interpreter practically hangs. I don't expect it to terminate in a short time.

How can I modify the query, some reordering etc.. so that it delivers the expected answer "false"?

Bye

PS: After pressing ^C and t after some while, I see that the CLP(FD) system is still busy.

Very easy:

First, replace I by J*15 ; and put the big domains last:

?- 15*J - 3*N #= X, X in 1..2, 
   15*J - 5*M #= Y, Y in 1..4, 
   I #= 15*J,
   [I,N,M,J] ins -2147483648..2147483647.
false.

Factors as above are not always detected, and propagation as such is weak since it could easily blow up the representation of the domain.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM