Skip to content

Commit ab8aa54

Browse files
committed
Sort based on optimization sense
1 parent eee9a90 commit ab8aa54

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/MultiObjectiveAlgorithms.jl

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,16 @@ function dominates(
4242
end
4343
end
4444

45-
_sort!(solutions::Vector{SolutionPoint}) = sort!(solutions; by = x -> x.y)
45+
function _sort!(solutions::Vector{SolutionPoint}, sense::MOI.OptimizationSense)
46+
return sort!(solutions; by = x -> x.y, rev = sense == MOI.MAX_SENSE)
47+
end
4648

4749
function filter_nondominated(
4850
sense,
4951
solutions::Vector{SolutionPoint};
5052
atol::Float64 = 1e-6,
5153
)
52-
_sort!(solutions)
54+
_sort!(solutions, sense)
5355
nondominated_solutions = SolutionPoint[]
5456
for candidate in solutions
5557
if any(test -> dominates(sense, test, candidate; atol), solutions)
@@ -681,7 +683,7 @@ function _optimize!(model::Optimizer)
681683
model.termination_status = status
682684
if solutions !== nothing
683685
model.solutions = solutions
684-
_sort!(model.solutions)
686+
_sort!(model.solutions, MOI.get(model, MOI.ObjectiveSense()))
685687
end
686688
if MOI.get(model, ComputeIdealPoint())
687689
_compute_ideal_point(model, start_time)

0 commit comments

Comments
 (0)