【发布时间】:2017-11-20 17:55:47
【问题描述】:
我正在使用 ECLiPSe 6.1 开发序言程序 (CLPFD)。该程序有很多变量,我想最小化某个值,但(显然)最小化步骤需要很多时间。如何打印在最小化阶段找到的每个解决方案?输出仅打印(例如)Found a solution with cost 22003482,但不打印解决方案本身。我想要:
Found a solution with cost 22003482
L = [[...],[...],...,[]] %L is the list of value to minimize
关于最小化过程的每一步。
我试过这种方法:
myLabeling([]).
myLabeling([H|T]):-
labeling(H),
myLabeling(T).
%code for the problem
%timeout(+Goal, ++TimeLimit, +TimeOutGoal)
timeout(minimize(myLabeling(AllNodesList),Result),TimeLimit,
myLabeling(AllNodesList)).
其中AllNodesList 是列表列表,TimeOutGoal 是TimeLimit 到期时运行的目标。此解决方案不会打印找到的最后一个解决方案,而是打印找到的第一个带有标签的非优化解决方案。
有什么建议吗? 谢谢。
【问题讨论】:
标签: prolog clpfd eclipse-clp