如果我们在 Eclipse CLP 中有两个Cost1
比 更重要的目标函数Cost2
,以下是否正确?
minimize(minimize(labeling(Vars), Cost1), Costs2).
如果我们在 Eclipse CLP 中有两个Cost1
比 更重要的目标函数Cost2
,以下是否正确?
minimize(minimize(labeling(Vars), Cost1), Costs2).
是的,只要您告诉内部最小化来计算所有最优解,而不仅仅是第一个(使用bb_min/3的变体minimize
),这可行:
:- lib(ic).
:- lib(branch_and_bound).
minmin(X, Y) :-
[X,Y] #:: 1..4,
Cost1 #= -2*X,
Cost2 #= -Y,
bb_min(
bb_min(
labeling([X,Y]),
Cost1,
bb_options{solutions:all}
),
Cost2,
bb_options{solutions:one}
).
操作行为是首先Cost1
最小化(忽略Cost2
),然后Cost2
最小化(Cost1
固定在其最小值):
?- minmin(X, Y).
Found a solution with cost -2
Found a solution with cost -4
Found a solution with cost -6
Found a solution with cost -8
Found a solution with cost -1
Found a solution with cost -2
Found a solution with cost -3
Found a solution with cost -4
X = 4
Y = 4
Yes (0.00s cpu)