Skip to content

Commit f1d87ee

Browse files
authored
Update DominguezRios to delete boxes that are already searched (#166)
1 parent 209ff1c commit f1d87ee

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

src/algorithms/DominguezRios.jl

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,10 @@ function _update!(
148148
return
149149
end
150150

151+
_isapprox(::Nothing, ::_DominguezRiosBox) = false
152+
153+
_isapprox(A::_DominguezRiosBox, B::_DominguezRiosBox) = A.l B.l && A.u B.u
154+
151155
function minimize_multiobjective!(algorithm::DominguezRios, model::Optimizer)
152156
@assert MOI.get(model.inner, MOI.ObjectiveSense()) == MOI.MIN_SENSE
153157
n = MOI.output_dimension(model.f)
@@ -190,13 +194,22 @@ function minimize_multiobjective!(algorithm::DominguezRios, model::Optimizer)
190194
solutions = SolutionPoint[]
191195
k = 0
192196
status = MOI.OPTIMAL
197+
B_prev = Vector{Union{Nothing,_DominguezRiosBox}}(nothing, n)
193198
while any(!isempty(l) for l in L)
194199
if (ret = _check_premature_termination(model)) !== nothing
195200
status = ret
196201
break
197202
end
198203
i, k = _select_next_box(L, k)
199204
B = L[k][i]
205+
# We check for the repeated search of similar boxes in the same
206+
# optimization direction. If the same box was searched before, we delete
207+
# it from the list of boxes.
208+
if _isapprox(B_prev[k], B)
209+
deleteat!(L[k], i)
210+
continue
211+
end
212+
B_prev[k] = B
200213
# We're going to scale `w` here by `scale` instead of the usual
201214
# `1 / max(...)`. It will show up in a few places bbelow.
202215
w = scale ./ max.(1, B.u - yI)

test/algorithms/DominguezRios.jl

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,25 @@ function test_vector_of_variables_objective()
152152
return
153153
end
154154

155+
function test_lp()
156+
model = MOI.instantiate(; with_bridge_type = Float64) do
157+
return MOA.Optimizer(HiGHS.Optimizer)
158+
end
159+
MOI.set(model, MOA.Algorithm(), MOA.DominguezRios())
160+
MOI.set(model, MOI.Silent(), true)
161+
x = MOI.add_variables(model, 2)
162+
MOI.add_constraint(model, x[1], MOI.GreaterThan(0.0))
163+
MOI.add_constraint(model, x[2], MOI.Interval(0.0, 3.0))
164+
MOI.add_constraint(model, 3.0 * x[1] - 1.0 * x[2], MOI.LessThan(6.0))
165+
MOI.set(model, MOI.ObjectiveSense(), MOI.MIN_SENSE)
166+
f = MOI.Utilities.vectorize([3.0 1.0; -1.0 -2.0] * x)
167+
MOI.set(model, MOI.ObjectiveFunction{typeof(f)}(), f)
168+
MOI.optimize!(model)
169+
@test MOI.get(model, MOI.TerminationStatus()) == MOI.OPTIMAL
170+
@test MOI.get(model, MOI.ResultCount()) > 1
171+
return
172+
end
173+
155174
end # module TestDominguezRios
156175

157176
TestDominguezRios.run_tests()

0 commit comments

Comments
 (0)