Skip to content

Fix PrimalStatus when multiple solutions are available in DUAL_INFEASIBLE #623

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 2 commits into from
Mar 14, 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
6 changes: 1 addition & 5 deletions src/MOI_wrapper/MOI_wrapper.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2923,12 +2923,8 @@ function MOI.get(model::Optimizer, attr::MOI.PrimalStatus)
_throw_if_optimize_in_progress(model, attr)
term = MOI.get(model, MOI.TerminationStatus())
if term == MOI.DUAL_INFEASIBLE || term == MOI.INFEASIBLE_OR_UNBOUNDED
if attr.result_index != 1
return MOI.NO_SOLUTION
elseif _has_primal_ray(model)
if attr.result_index == 1 && _has_primal_ray(model)
return MOI.INFEASIBILITY_CERTIFICATE
else
return MOI.NO_SOLUTION
end
end
# Check SolCount explicitly instead of ResultCount to avoid returning 1 when
Expand Down
19 changes: 19 additions & 0 deletions test/MOI/MOI_wrapper.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1599,6 +1599,25 @@ function test_precompile()
return
end

function test_multiple_solutions_when_dual_infeasible()
if Gurobi._GUROBI_VERSION < v"11"
return
end
model = Gurobi.Optimizer(GRB_ENV)
MOI.set(model, MOI.Silent(), true)
x, _ = MOI.add_constrained_variable(model, MOI.Interval(0.0, 1.0))
y = MOI.add_variable(model)
MOI.set(model, MOI.ObjectiveSense(), MOI.MIN_SENSE)
f = 0.25 * y * y - 1.0 * x * y - 1.0 * y + 1.0
MOI.set(model, MOI.ObjectiveFunction{typeof(f)}(), f)
MOI.optimize!(model)
@test MOI.get(model, MOI.TerminationStatus()) == MOI.DUAL_INFEASIBLE
for i in MOI.get(model, MOI.ResultCount())
@test MOI.get(model, MOI.PrimalStatus()) == MOI.FEASIBLE_POINT
end
return
end

end # TestMOIWrapper

TestMOIWrapper.runtests()
Loading