Skip to content
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

Fix deleting ZeroOne constraints after MOI.optimize #188

Merged
merged 1 commit into from
Oct 25, 2023
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
4 changes: 4 additions & 0 deletions src/MOI_wrapper.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2338,6 +2338,10 @@ function MOI.delete(
info = _info(model, ci)
info.type = _TYPE_CONTINUOUS
Highs_changeColIntegrality(model, info.column, kHighsVarTypeContinuous)
# optimize! sets bounds to [0, 1] if not present, so if we delete the
# ZeroOne constraint after a call to optimize!, then we need to reset the
# bounds.
Highs_changeColBounds(model, info.column, info.lower, info.upper)
delete!(model.binaries, info)
return
end
Expand Down
17 changes: 17 additions & 0 deletions test/MOI_wrapper.jl
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,23 @@ function test_copy_to_bug_172()
return
end

function test_relax_integrality_after_solve()
model = HiGHS.Optimizer()
MOI.set(model, MOI.Silent(), true)
x = MOI.add_variable(model)
MOI.add_constraint(model, x, MOI.LessThan(2.0))
c = MOI.add_constraint(model, x, MOI.ZeroOne())
MOI.set(model, MOI.ObjectiveSense(), MOI.MAX_SENSE)
f = 1.0 * x
MOI.set(model, MOI.ObjectiveFunction{typeof(f)}(), f)
MOI.optimize!(model)
@test ≈(MOI.get(model, MOI.VariablePrimal(), x), 1.0; atol = 1e-6)
MOI.delete(model, c)
MOI.optimize!(model)
@test ≈(MOI.get(model, MOI.VariablePrimal(), x), 2.0; atol = 1e-6)
return
end

end

TestMOIHighs.runtests()
Loading