两个 objective 函数

Two objective functions

如果我们在 Eclipse CLP 中有两个 objective 函数 Cost1Cost2 更重要,那么下面是真的吗?

minimize(minimize(labeling(Vars), Cost1), Costs2).

是的,只要你告诉内部最小化计算所有最优解,而不是只计算第一个最优解(使用 minimizebb_min/3 变体):

:- 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),然后最小化Cost2Cost1固定在最小值):

?- 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)