Skip to content

Commit ee2feee

Browse files
committed
Fix floating point comparison in TambyVanderpooten
1 parent 9363a93 commit ee2feee

File tree

2 files changed

+31
-4
lines changed

2 files changed

+31
-4
lines changed

src/algorithms/TambyVanderpooten.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -187,12 +187,12 @@ function minimize_multiobjective!(
187187
bounds_to_remove = Vector{Float64}[]
188188
for u_i in keys(U_N)
189189
for k in 1:n
190-
if u_i[k] == yI[k]
190+
if isapprox(u_i[k], yI[k]; atol = 1e-6)
191191
push!(bounds_to_remove, u_i)
192192
else
193193
for (u_j, y_j) in V[k]
194194
if all(_project(u_i, k) .<= _project(u_j, k)) &&
195-
(y_j[k] == u_i[k])
195+
isapprox(y_j[k], u_i[k]; atol = 1e-6)
196196
push!(bounds_to_remove, u_i)
197197
end
198198
end
@@ -205,6 +205,6 @@ function minimize_multiobjective!(
205205
end
206206
end
207207
end
208-
solutions = [SolutionPoint(X, Y) for (Y, X) in solutions]
209-
return status, solutions
208+
solutions_vec = [SolutionPoint(X, Y) for (Y, X) in solutions]
209+
return status, filter_nondominated(MOI.MIN_SENSE, solutions_vec)
210210
end

test/problems.jl

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -472,4 +472,31 @@ function test_issue_122(model)
472472
return
473473
end
474474

475+
function test_issue_133()
476+
#!format: off
477+
p = Float64[
478+
33 90 96 75 1 69 100 50 63 61 59 95 58 10 77 30 86 89 82 51 38 33 73 54 91 89 95 82 48 67
479+
55 36 80 58 20 96 75 57 24 68 37 58 8 85 27 25 71 53 47 72 57 64 1 8 12 68 3 80 20 90
480+
22 40 50 73 44 65 12 26 13 77 14 68 71 35 54 98 45 95 98 19 18 38 14 51 37 48 35 97 95 36
481+
]
482+
w = Float64[
483+
22, 13, 10, 25, 4, 15, 17, 15, 15, 28, 14, 13, 2, 23, 6, 22, 18, 6, 23,
484+
21, 7, 7, 14, 4, 3, 27, 10, 5, 9, 10
485+
]
486+
#!format: on
487+
model = MOA.Optimizer(HiGHS.Optimizer)
488+
MOI.set(model, MOA.Algorithm(), MOA.TambyVanderpooten())
489+
MOI.set(model, MOI.Silent(), true)
490+
x = MOI.add_variables(model, length(w))
491+
MOI.add_constraint.(model, x, MOI.ZeroOne())
492+
MOI.set(model, MOI.ObjectiveSense(), MOI.MAX_SENSE)
493+
f = MOI.Utilities.vectorize(p * x)
494+
MOI.set(model, MOI.ObjectiveFunction{typeof(f)}(), f)
495+
MOI.add_constraint(model, w' * x, MOI.LessThan(204.0))
496+
MOI.optimize!(model)
497+
@test MOI.get(model, MOI.TerminationStatus()) == MOI.OPTIMAL
498+
@test MOI.get(model, MOI.ResultCount()) == 95
499+
return
500+
end
501+
475502
end # module Problems

0 commit comments

Comments
 (0)