如果我(装有clpfd):
test1(Ps):-
permutation(Ps,[(a,1,1),(b,2,2),(c,3,1),(d,4,2)]),
Ps =[(L1,W1,X1),(L2,W2,X2),(L3,W3,Y1),(L4,W4,Y2)],
chain([W1,W2,W3,W4],#<).
并查询:
?-test1(P).
P = [(a,1,1), (b,2,2), (c,3,1), (d,4,2)]
false
哪个给出了我期望的答案,但是带有:
test2(Ps):-
permutation(Ps,[(a,1,1),(b,2,2),(c,3,1),(d,4,2)]),
Ps =[(L1,W1,X1),(L2,W2,X2),(L3,W3,Y1),(L4,W4,Y2)],
chain([X1,X2],#<).
查询:
?-test2(P):-
P = [(a,1,1), (b,2,2), (c,3,1), (d,4,2)]
P = [(a,1,1), (b,2,2), (d,4,2), (c,3,1)]
P = [(a,1,1), (d,4,2), (b,2,2), (c,3,1)]
P = [(a,1,1), (d,4,2), (c,3,1), (b,2,2)]
P = [(c,3,1), (b,2,2), (a,1,1), (d,4,2)]
P = [(c,3,1), (d,4,2), (a,1,1), (b,2,2)]
P = [(c,3,1), (b,2,2), (d,4,2), (a,1,1)]
P = [(c,3,1), (d,4,2), (b,2,2), (a,1,1)]
false
我不希望像这样的答案
P = [(c,3,1), (b,2,2), (d,4,2), (a,1,1)]
P = [(c,3,1), (d,4,2), (b,2,2), (a,1,1)]
其中带有as的术语位于带有bs的术语之后。 我有什么误会?
答案 0 :(得分:1)
我现在可以看到我做错了。
作为答案:
P = [(c,3,1), (b,2,2), (d,4,2), (a,1,1)]
P = [(c,3,1), (d,4,2), (b,2,2), (a,1,1)]
在前两个元素的第三个参数中显然有1和2,因此满足链约束。