This repository has been archived on 2025-03-06. You can view files and clone it, but cannot push or open issues or pull requests.

31 lines
846 B
MiniZinc

predicate pareto_optimal(var int: obj1, var int: obj2) =
let {
int: ms = 1000; % max solutions
var 0..ms: nsol; % number of solutions
set of int: SOL = 1..ms;
array[SOL] of var lb(obj1)..ub(obj1): s1;
array[SOL] of var lb(obj2)..ub(obj2): s2;
} in if status() = START then
nsol = 0
elseif status() = UNSAT then
complete() % we are finished!
elseif status() = SAT then
nsol = sol(nsol) + 1 /\
s1[nsol] = sol(obj1) /\
s2[nsol] = sol(obj2)
endif
/\ for(i in 1..nsol) (
obj1 < lastval(s1[i]) \/ obj2 < lastval(s2[i])
) /\ for(i in 1..ms) (
if i in 1..nsol-1 then
s1[i] = lastval(s1[i]) /\
s2[i] = lastval(s2[i]) /\
elsif i = nsol /\ status() != SAT then
s1[i] = lastval(s1[i]) /\
s2[i] = lastval(s2[i]) /\
elseif i in nsol+1..ms then
s1[i] = lb(obj1) /\
s2[i] = lb(obj2)
endif
);