diff --git a/ext/MultiObjectiveAlgorithmsPolyhedraExt.jl b/ext/MultiObjectiveAlgorithmsPolyhedraExt.jl index 39b6fd5..efaadc9 100644 --- a/ext/MultiObjectiveAlgorithmsPolyhedraExt.jl +++ b/ext/MultiObjectiveAlgorithmsPolyhedraExt.jl @@ -45,9 +45,10 @@ function MOA.minimize_multiobjective!( n = MOI.output_dimension(model.f) scalars = MOI.Utilities.scalarize(model.f) status = MOI.OPTIMAL - optimizer = typeof(model.inner.optimizer) - δ_OPS_optimizer = optimizer() - MOI.set(δ_OPS_optimizer, MOI.Silent(), true) + δ_OPS_optimizer = MOI.instantiate(model.optimizer_factory) + if MOI.supports(δ_OPS_optimizer, MOI.Silent()) + MOI.set(δ_OPS_optimizer, MOI.Silent(), true) + end y = MOI.add_variables(δ_OPS_optimizer, n) anchors = Dict{Vector{Float64},Dict{MOI.VariableIndex,Float64}}() yI, yUB = zeros(n), zeros(n) diff --git a/src/MultiObjectiveAlgorithms.jl b/src/MultiObjectiveAlgorithms.jl index 8c2fb3b..b9498da 100644 --- a/src/MultiObjectiveAlgorithms.jl +++ b/src/MultiObjectiveAlgorithms.jl @@ -124,6 +124,7 @@ mutable struct Optimizer <: MOI.AbstractOptimizer ideal_point::Vector{Float64} compute_ideal_point::Bool subproblem_count::Int + optimizer_factory::Any function Optimizer(optimizer_factory) return new( @@ -137,6 +138,7 @@ mutable struct Optimizer <: MOI.AbstractOptimizer Float64[], default(ComputeIdealPoint()), 0, + optimizer_factory, ) end end diff --git a/src/algorithms/Sandwiching.jl b/src/algorithms/Sandwiching.jl index a53af81..3bc79dd 100644 --- a/src/algorithms/Sandwiching.jl +++ b/src/algorithms/Sandwiching.jl @@ -6,7 +6,10 @@ """ Sandwiching(precision::Float64) -An algorithm that implemennts the paper described in Koenen, M., Balvert, M., & Fleuren, H. A. (2023). A Renewed Take on Weighted Sum in Sandwich Algorithms: Modification of the Criterion Space. (Center Discussion Paper; Vol. 2023-012). CentER, Center for Economic Research. +An algorithm that implemennts the paper described in Koenen, M., Balvert, M., & +Fleuren, H. A. (2023). A Renewed Take on Weighted Sum in Sandwich Algorithms: +Modification of the Criterion Space. (Center Discussion Paper; Vol. 2023-012). +CentER, Center for Economic Research. ## Compat diff --git a/test/algorithms/Sandwiching.jl b/test/algorithms/Sandwiching.jl index b496475..ff74b1f 100644 --- a/test/algorithms/Sandwiching.jl +++ b/test/algorithms/Sandwiching.jl @@ -12,6 +12,8 @@ import MultiObjectiveAlgorithms as MOA import MultiObjectiveAlgorithms: MOI import Polyhedra +include(joinpath(dirname(@__DIR__), "mock_optimizer.jl")) + function run_tests() for name in names(@__MODULE__; all = true) if startswith("$name", "test_") @@ -190,6 +192,35 @@ function test_time_limit() return end +function test_solve_failures() + m, n = 2, 10 + p1 = [5.0 1 10 8 3 5 3 3 7 2; 10 6 1 6 8 3 2 10 6 1] + p2 = [4.0 6 4 3 1 6 8 2 9 7; 8 8 8 2 4 8 8 1 10 1] + w = [5.0 9 3 5 10 5 7 10 7 8; 4 8 8 6 10 8 10 7 5 1] + b = [34.0, 33.0] + for fail_after in 0:4 + model = MOA.Optimizer(mock_optimizer(fail_after)) + MOI.set(model, MOA.Algorithm(), MOA.Sandwiching(0.0)) + x_ = MOI.add_variables(model, m * n) + x = reshape(x_, m, n) + MOI.add_constraint.(model, x, MOI.Interval(0.0, 1.0)) + f = MOI.Utilities.operate(vcat, Float64, sum(p1 .* x), sum(p2 .* x)) + MOI.set(model, MOI.ObjectiveSense(), MOI.MAX_SENSE) + MOI.set(model, MOI.ObjectiveFunction{typeof(f)}(), f) + for i in 1:m + f_i = sum(w[i, j] * x[i, j] for j in 1:n) + MOI.add_constraint(model, f_i, MOI.LessThan(b[i])) + end + for j in 1:n + MOI.add_constraint(model, sum(1.0 .* x[:, j]), MOI.EqualTo(1.0)) + end + MOI.optimize!(model) + @test MOI.get(model, MOI.TerminationStatus()) == MOI.NUMERICAL_ERROR + @test MOI.get(model, MOI.ResultCount()) == 0 + end + return +end + end # TestSandwiching TestSandwiching.run_tests()