Prolog 两个目标函数
如果我们在Eclipse CLP中有两个目标函数,Prolog 两个目标函数,prolog,eclipse-clp,Prolog,Eclipse Clp,如果我们在Eclipse CLP中有两个目标函数,Cost1比Cost2更重要,那么下面的结果是真的吗 minimize(minimize(labeling(Vars), Cost1), Costs2). 是的,如果您告诉内部最小化计算所有最优解,而不仅仅是第一个(使用minimize)的变体,这是可行的: 操作行为是首先最小化成本1(忽略成本2),然后最小化成本2(成本1固定在其最小值): :- lib(ic). :- lib(branch_and_bound). minmin(X, Y)
Cost1
比Cost2
更重要,那么下面的结果是真的吗
minimize(minimize(labeling(Vars), Cost1), Costs2).
是的,如果您告诉内部最小化计算所有最优解,而不仅仅是第一个(使用
minimize
)的变体,这是可行的:
操作行为是首先最小化成本1(忽略成本2),然后最小化成本2(成本1固定在其最小值):
:- 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}
).
?- 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)