误会chain/2?
Misunderstanding chain/2?
如果我有(加载了 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 的项之后。
我误会了什么?
我现在可以看到我做错了什么了。
作为答案:
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,因此满足链约束。
如果我有(加载了 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 的项之后。 我误会了什么?
我现在可以看到我做错了什么了。
作为答案:
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,因此满足链约束。