Skip to content

Commit d86822c

Browse files
authored
Fix PrimalStatus when multiple solutions are available in DUAL_INFEASIBLE (#623)
1 parent a6fc306 commit d86822c

File tree

2 files changed

+20
-5
lines changed

2 files changed

+20
-5
lines changed

src/MOI_wrapper/MOI_wrapper.jl

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2923,12 +2923,8 @@ function MOI.get(model::Optimizer, attr::MOI.PrimalStatus)
29232923
_throw_if_optimize_in_progress(model, attr)
29242924
term = MOI.get(model, MOI.TerminationStatus())
29252925
if term == MOI.DUAL_INFEASIBLE || term == MOI.INFEASIBLE_OR_UNBOUNDED
2926-
if attr.result_index != 1
2927-
return MOI.NO_SOLUTION
2928-
elseif _has_primal_ray(model)
2926+
if attr.result_index == 1 && _has_primal_ray(model)
29292927
return MOI.INFEASIBILITY_CERTIFICATE
2930-
else
2931-
return MOI.NO_SOLUTION
29322928
end
29332929
end
29342930
# Check SolCount explicitly instead of ResultCount to avoid returning 1 when

test/MOI/MOI_wrapper.jl

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1599,6 +1599,25 @@ function test_precompile()
15991599
return
16001600
end
16011601

1602+
function test_multiple_solutions_when_dual_infeasible()
1603+
if Gurobi._GUROBI_VERSION < v"11"
1604+
return
1605+
end
1606+
model = Gurobi.Optimizer(GRB_ENV)
1607+
MOI.set(model, MOI.Silent(), true)
1608+
x, _ = MOI.add_constrained_variable(model, MOI.Interval(0.0, 1.0))
1609+
y = MOI.add_variable(model)
1610+
MOI.set(model, MOI.ObjectiveSense(), MOI.MIN_SENSE)
1611+
f = 0.25 * y * y - 1.0 * x * y - 1.0 * y + 1.0
1612+
MOI.set(model, MOI.ObjectiveFunction{typeof(f)}(), f)
1613+
MOI.optimize!(model)
1614+
@test MOI.get(model, MOI.TerminationStatus()) == MOI.DUAL_INFEASIBLE
1615+
for i in MOI.get(model, MOI.ResultCount())
1616+
@test MOI.get(model, MOI.PrimalStatus()) == MOI.FEASIBLE_POINT
1617+
end
1618+
return
1619+
end
1620+
16021621
end # TestMOIWrapper
16031622

16041623
TestMOIWrapper.runtests()

0 commit comments

Comments
 (0)