简体   繁体   English

我可以在更短的时间内终止此CLP(FD)查询吗?

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

I have the following CLP(FD) query: 我有以下CLP(FD)查询:

?- 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. 在SWI-Prolog已经在没有标签/ 1目标的情况下提出查询时,解释器几乎挂起。 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. PS:经过一段时间后按^ C和t后,我看到CLP(FD)系统仍然忙。

Very easy: 很容易:

First, replace I by J*15 ; 首先,用J*15替换I ; 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. 上述因素并不总是被检测到,因此传播很弱,因为它很容易炸毁域的表示。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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