diff --git a/src/algorithms/DominguezRios.jl b/src/algorithms/DominguezRios.jl index e5d8d4c..64ec5a8 100644 --- a/src/algorithms/DominguezRios.jl +++ b/src/algorithms/DominguezRios.jl @@ -148,6 +148,10 @@ function _update!( return end +_isapprox(::Nothing, ::_DominguezRiosBox) = false + +_isapprox(A::_DominguezRiosBox, B::_DominguezRiosBox) = A.l ≈ B.l && A.u ≈ B.u + function minimize_multiobjective!(algorithm::DominguezRios, model::Optimizer) @assert MOI.get(model.inner, MOI.ObjectiveSense()) == MOI.MIN_SENSE n = MOI.output_dimension(model.f) @@ -190,6 +194,7 @@ function minimize_multiobjective!(algorithm::DominguezRios, model::Optimizer) solutions = SolutionPoint[] k = 0 status = MOI.OPTIMAL + B_prev = Vector{Union{Nothing,_DominguezRiosBox}}(nothing, n) while any(!isempty(l) for l in L) if (ret = _check_premature_termination(model)) !== nothing status = ret @@ -197,6 +202,14 @@ function minimize_multiobjective!(algorithm::DominguezRios, model::Optimizer) end i, k = _select_next_box(L, k) B = L[k][i] + # We check for the repeated search of similar boxes in the same + # optimization direction. If the same box was searched before, we delete + # it from the list of boxes. + if _isapprox(B_prev[k], B) + deleteat!(L[k], i) + continue + end + B_prev[k] = B # We're going to scale `w` here by `scale` instead of the usual # `1 / max(...)`. It will show up in a few places bbelow. w = scale ./ max.(1, B.u - yI) diff --git a/test/algorithms/DominguezRios.jl b/test/algorithms/DominguezRios.jl index e9970d0..d0c9f92 100644 --- a/test/algorithms/DominguezRios.jl +++ b/test/algorithms/DominguezRios.jl @@ -152,6 +152,25 @@ function test_vector_of_variables_objective() return end +function test_lp() + model = MOI.instantiate(; with_bridge_type = Float64) do + return MOA.Optimizer(HiGHS.Optimizer) + end + MOI.set(model, MOA.Algorithm(), MOA.DominguezRios()) + MOI.set(model, MOI.Silent(), true) + x = MOI.add_variables(model, 2) + MOI.add_constraint(model, x[1], MOI.GreaterThan(0.0)) + MOI.add_constraint(model, x[2], MOI.Interval(0.0, 3.0)) + MOI.add_constraint(model, 3.0 * x[1] - 1.0 * x[2], MOI.LessThan(6.0)) + MOI.set(model, MOI.ObjectiveSense(), MOI.MIN_SENSE) + f = MOI.Utilities.vectorize([3.0 1.0; -1.0 -2.0] * x) + MOI.set(model, MOI.ObjectiveFunction{typeof(f)}(), f) + MOI.optimize!(model) + @test MOI.get(model, MOI.TerminationStatus()) == MOI.OPTIMAL + @test MOI.get(model, MOI.ResultCount()) > 1 + return +end + end # module TestDominguezRios TestDominguezRios.run_tests()