From 9842ec46bd5f74046220a0b1020db0648ef5b805 Mon Sep 17 00:00:00 2001 From: Oscar Dowson Date: Wed, 4 Dec 2024 15:56:28 +1300 Subject: [PATCH 1/2] Fix dual objective value with free variable --- src/MOI_wrapper.jl | 5 +++-- test/MOI_wrapper.jl | 2 ++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/MOI_wrapper.jl b/src/MOI_wrapper.jl index 37310f1..17dd080 100644 --- a/src/MOI_wrapper.jl +++ b/src/MOI_wrapper.jl @@ -2271,9 +2271,10 @@ function _active_bound(l, x, u, d) end elseif isfinite(l) return l - else - @assert isfinite(u) + elseif isfinite(u) return u + else + return 0.0 end end diff --git a/test/MOI_wrapper.jl b/test/MOI_wrapper.jl index 11b0482..f80a196 100644 --- a/test/MOI_wrapper.jl +++ b/test/MOI_wrapper.jl @@ -941,11 +941,13 @@ function test_active_bound() (0.0, 1.0, 1.0, -2.0) => 1.0, (0.0, 0.6, 1.0, -2.0) => 1.0, (0.0, 0.6, 1.0, 2.0) => 1.0, # incorrect d but doesn't matter + (-Inf, 0.0, Inf, 0.0) => 0.0, # It's a ray. Choose based on sign (0.0, NaN, 1.0, 2.0) => 0.0, (0.0, NaN, 1.0, 1e-10) => 0.0, (0.0, NaN, 1.0, -2.0) => 1.0, (0.0, NaN, 1.0, -1e-10) => 1.0, + (-Inf, NaN, Inf, 0.0) => 0.0, # It's a one-sided ray (0.0, NaN, Inf, 2.0) => 0.0, (0.0, NaN, Inf, -1e-10) => 0.0, From 9d3c9c02015f119c069c9cef6762600464d41f05 Mon Sep 17 00:00:00 2001 From: Oscar Dowson Date: Wed, 4 Dec 2024 16:40:01 +1300 Subject: [PATCH 2/2] Update --- test/MOI_wrapper.jl | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/test/MOI_wrapper.jl b/test/MOI_wrapper.jl index f80a196..bd272ad 100644 --- a/test/MOI_wrapper.jl +++ b/test/MOI_wrapper.jl @@ -974,6 +974,18 @@ function test_add_constrained_variable_tuple() return end +function test_dual_objective_value_infeasible() + model = HiGHS.Optimizer() + x = MOI.add_variable(model) + MOI.set(model, MOI.ObjectiveSense(), MOI.MIN_SENSE) + f = 1.0 * x + MOI.set(model, MOI.ObjectiveFunction{typeof(f)}(), f) + MOI.optimize!(model) + @test MOI.get(model, MOI.DualStatus()) == MOI.INFEASIBLE_POINT + @test MOI.get(model, MOI.DualObjectiveValue()) == 0.0 + return +end + end # module TestMOIHighs.runtests()