Skip to content

Allow subproblem failures in DominguezRios #121

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jun 18, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions src/algorithms/DominguezRios.jl
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,12 @@ end

function _select_next_box(L::Vector{Vector{_DominguezRiosBox}}, k::Int)
p = length(L)
if any(.!isempty.(L))
@assert any(!isempty(l) for l in L)
k = k % p + 1
while isempty(L[k])
k = k % p + 1
while isempty(L[k])
k = k % p + 1
end
i = argmax([B.priority for B in L[k]])
end
i = argmax([B.priority for B in L[k]])
return i, k
end

Expand Down Expand Up @@ -190,7 +189,7 @@ function minimize_multiobjective!(algorithm::DominguezRios, model::Optimizer)
end
i, k = _select_next_box(L, k)
B = L[k][i]
# We're goign to scale `w` here by `scale` instead of the usual
# 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)
constraints = [
Expand Down Expand Up @@ -221,6 +220,13 @@ function minimize_multiobjective!(algorithm::DominguezRios, model::Optimizer)
else
deleteat!(L[k], i)
end
else
# In theory, this shouldn't happen, because this subproblem is meant
# to always be feasible. However, in some of our testing, HiGHS will
# fail and return something like OTHER_ERROR (e.g., because the
# numerics are challenging). Rather than error completely, let's
# just skip this box.
deleteat!(L[k], i)
end
MOI.delete.(model.inner, constraints)
end
Expand Down
10 changes: 6 additions & 4 deletions test/algorithms/DominguezRios.jl
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,12 @@ end

function test_vOptLib_runtests()
model = MOA.Optimizer(HiGHS.Optimizer)
MOI.set(model, MOA.Algorithm(), MOA.DominguezRios())
MOI.set(model, MOI.Silent(), true)
# TODO(odow): it doesn't terminate
# vOptLib.run_tests(model)
for (presolve, complete) in ["off" => true, "choose" => false]
MOI.set(model, MOI.RawOptimizerAttribute("presolve"), presolve)
MOI.set(model, MOA.Algorithm(), MOA.DominguezRios())
MOI.set(model, MOI.Silent(), true)
vOptLib.run_tests(model; complete)
end
return
end

Expand Down
25 changes: 17 additions & 8 deletions test/vOptLib.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,19 @@ using Test
import JSON
import MathOptInterface as MOI

function run_tests(model::MOI.ModelLike)
function run_tests(model::MOI.ModelLike; kwargs...)
for name in names(@__MODULE__; all = true)
if startswith("$name", "test_")
@testset "$name" begin
MOI.empty!(model)
getfield(@__MODULE__, name)(model)
getfield(@__MODULE__, name)(model; kwargs...)
end
end
end
return
end

function _test_vOptLib_instance(model, instance)
function _test_vOptLib_instance(model, instance; complete::Bool = true)
root = joinpath(dirname(@__DIR__), "instances")
src = MOI.FileFormats.MOF.Model()
MOI.read_from_file(src, joinpath(root, "models", instance * ".mof.json"))
Expand All @@ -38,7 +38,8 @@ function _test_vOptLib_instance(model, instance)
end
push!(solutions[Y], convert(Vector{Int}, sol["X"]))
end
@test MOI.get(model, MOI.ResultCount()) >= length(solutions)
min_solutions = complete ? length(solutions) : 1
@test MOI.get(model, MOI.ResultCount()) >= min_solutions
for i in 1:MOI.get(model, MOI.ResultCount())
Y = round.(Int, MOI.get(model, MOI.ObjectiveValue(i)))
@test haskey(solutions, Y)
Expand All @@ -48,12 +49,20 @@ function _test_vOptLib_instance(model, instance)
return
end

test_vOptLib_2KP50_11(model) = _test_vOptLib_instance(model, "2KP50-11")
function test_vOptLib_2KP50_11(model; kwargs...)
return _test_vOptLib_instance(model, "2KP50-11"; kwargs...)
end

test_vOptLib_2KP50_50(model) = _test_vOptLib_instance(model, "2KP50-50")
function test_vOptLib_2KP50_50(model; kwargs...)
return _test_vOptLib_instance(model, "2KP50-50"; kwargs...)
end

test_vOptLib_2KP50_92(model) = _test_vOptLib_instance(model, "2KP50-92")
function test_vOptLib_2KP50_92(model; kwargs...)
return _test_vOptLib_instance(model, "2KP50-92"; kwargs...)
end

test_vOptLib_2KP100_50(model) = _test_vOptLib_instance(model, "2KP100-50")
function test_vOptLib_2KP100_50(model; kwargs...)
return _test_vOptLib_instance(model, "2KP100-50"; kwargs...)
end

end # module vOptLib
Loading