Skip to content

Commit 348ceb1

Browse files
authored
Fix dual objective value with free variable (#255)
1 parent 6914b62 commit 348ceb1

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

src/MOI_wrapper.jl

+3-2
Original file line numberDiff line numberDiff line change
@@ -2271,9 +2271,10 @@ function _active_bound(l, x, u, d)
22712271
end
22722272
elseif isfinite(l)
22732273
return l
2274-
else
2275-
@assert isfinite(u)
2274+
elseif isfinite(u)
22762275
return u
2276+
else
2277+
return 0.0
22772278
end
22782279
end
22792280

test/MOI_wrapper.jl

+14
Original file line numberDiff line numberDiff line change
@@ -941,11 +941,13 @@ function test_active_bound()
941941
(0.0, 1.0, 1.0, -2.0) => 1.0,
942942
(0.0, 0.6, 1.0, -2.0) => 1.0,
943943
(0.0, 0.6, 1.0, 2.0) => 1.0, # incorrect d but doesn't matter
944+
(-Inf, 0.0, Inf, 0.0) => 0.0,
944945
# It's a ray. Choose based on sign
945946
(0.0, NaN, 1.0, 2.0) => 0.0,
946947
(0.0, NaN, 1.0, 1e-10) => 0.0,
947948
(0.0, NaN, 1.0, -2.0) => 1.0,
948949
(0.0, NaN, 1.0, -1e-10) => 1.0,
950+
(-Inf, NaN, Inf, 0.0) => 0.0,
949951
# It's a one-sided ray
950952
(0.0, NaN, Inf, 2.0) => 0.0,
951953
(0.0, NaN, Inf, -1e-10) => 0.0,
@@ -972,6 +974,18 @@ function test_add_constrained_variable_tuple()
972974
return
973975
end
974976

977+
function test_dual_objective_value_infeasible()
978+
model = HiGHS.Optimizer()
979+
x = MOI.add_variable(model)
980+
MOI.set(model, MOI.ObjectiveSense(), MOI.MIN_SENSE)
981+
f = 1.0 * x
982+
MOI.set(model, MOI.ObjectiveFunction{typeof(f)}(), f)
983+
MOI.optimize!(model)
984+
@test MOI.get(model, MOI.DualStatus()) == MOI.INFEASIBLE_POINT
985+
@test MOI.get(model, MOI.DualObjectiveValue()) == 0.0
986+
return
987+
end
988+
975989
end # module
976990

977991
TestMOIHighs.runtests()

0 commit comments

Comments
 (0)