我已经使用 ECLiPSe 解决了有关在会议中分配文章的问题。目标是:相似的文章应该在同一个会话中。这是适用于 ECLiPSe 的解决方案:
:- lib(fd).
paper(1, 'An Empirical Study on Using Stereotypes to Improve Understanding of UML Models').
paper(2, 'Tool-Supported Customization of UML Class Diagrams for Learning Complex System Models').
paper(3, 'Understanding Class Evolution in Object-Oriented Software').
paper(4, 'A Simple Static Model for Understanding the Dynamic Behavior of Programs').
paper(5, 'Reuse in Reverse Engineering').
paper(6, 'Working in Pairs as a Means for Design Knowledge Building: An Empirical Study').
like(X, Y) :-
element(I, [1, 1, 2, 4, 4, 5], X),
element(I, [2, 3, 3, 5, 6, 6], Y).
conference([T1, T2, T3], [T4, T5, T6]) :-
% --- domains
L = [1, 2, 3, 4, 5, 6],
X1::L, X2::L, X3::L, X4::L, X5::L, X6::L,
% --- constraints
alldifferent([X1, X2, X3, X4, X5, X6]),
like(X1, X2), like(X1, X3), like(X2, X3), like(X4, X5), like(X4, X6), like(X5, X6),
% --- searching
labeling([X1, X2, X3, X4, X5, X6]),
% --- converting ids to titles
paper(X1, T1), paper(X2, T2), paper(X3, T3), paper(X4, T4), paper(X5, T5), paper(X6, T6).
在 prolog 中,问题是约束的定义和标签。我知道 ECLiPSe 使用传播算法,但在序言中我必须使用回溯策略。
如何在 prolog 中移植此代码?