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 and test that Bridges.final_touch can be called multiple times #2089

Merged
merged 2 commits into from
Feb 6, 2023

Conversation

odow
Copy link
Member

@odow odow commented Feb 4, 2023

Closes #2088

So I think the previous implementation was technically correct, if a little slower than need be because it would always reformulate.

Now we cache the bounds and only reformulate if the bounds have changed since the last call.

This fixes the original SCIP issue:

julia> using JuMP, SCIP

julia> model = Model(SCIP.Optimizer)
A JuMP Model
Feasibility problem with:
Variables: 0
Model mode: AUTOMATIC
CachingOptimizer state: EMPTY_OPTIMIZER
Solver name: SCIP

julia> @variable(model, 0 <= s <= 2, Int)
s

julia> @variable(model, n)
n

julia> @constraint(model, s + n <= 3)
s + n  3.0

julia> @constraint(model, [n, s] in MOI.CountBelongs(2, Set([1])))
[n, s]  MathOptInterface.CountBelongs(2, Set([1]))

julia> optimize!(model)
presolving:
(round 1, fast)       1 del vars, 1 del conss, 0 add conss, 3 chg bounds, 0 chg sides, 0 chg coeffs, 0 upgd conss, 1 impls, 2 clqs
(round 2, fast)       2 del vars, 2 del conss, 0 add conss, 3 chg bounds, 0 chg sides, 0 chg coeffs, 0 upgd conss, 1 impls, 2 clqs
(round 3, fast)       2 del vars, 2 del conss, 0 add conss, 3 chg bounds, 2 chg sides, 1 chg coeffs, 0 upgd conss, 1 impls, 2 clqs
   (0.0s) running MILP presolver
   (0.0s) MILP presolver (2 rounds): 0 aggregations, 3 fixings, 0 bound changes
presolving (4 rounds: 4 fast, 1 medium, 1 exhaustive):
 5 deleted vars, 4 deleted constraints, 0 added constraints, 3 tightened bounds, 0 added holes, 2 changed sides, 1 changed coefficients
 1 implications, 0 cliques
transformed 1/1 original solutions to the transformed problem space
Presolving Time: 0.01

SCIP Status        : problem is solved [optimal solution found]
Solving Time (sec) : 0.01
Solving Nodes      : 0
Primal Bound       : +0.00000000000000e+00 (1 solutions)
Dual Bound         : +0.00000000000000e+00
Gap                : 0.00 %

But you can still break SCIP by modifying a variable bound between solves:

julia> set_lower_bound(s, 1)

julia> optimize!(model)
ERROR: MathOptInterface.DeleteNotAllowed{MathOptInterface.VariableIndex}: Deleting the index MathOptInterface.VariableIndex(3) cannot be performed: Can not delete variable while model contains constraints! You may want to use a `CachingOptimizer` in `AUTOMATIC` mode or you may need to call `reset_optimizer` before doing this operation if the `CachingOptimizer` is in `MANUAL` mode.
Stacktrace:
  [1] delete(o::SCIP.Optimizer, vi::MathOptInterface.VariableIndex)

@odow odow added Type: Bug Submodule: Bridges About the Bridges submodule Project: constraint programming Issues relating to constraint programming labels Feb 4, 2023
@odow odow requested a review from blegat February 5, 2023 06:21
@odow odow mentioned this pull request Feb 5, 2023
1 task
Copy link
Member

@blegat blegat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, I like the fact that it would also not do anything in case the problem is modified but not the bounds

@odow odow merged commit fbf833c into master Feb 6, 2023
@odow odow deleted the od/final-touch-bridges branch February 6, 2023 17:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Project: constraint programming Issues relating to constraint programming Submodule: Bridges About the Bridges submodule Type: Bug
Development

Successfully merging this pull request may close these issues.

Bridges and final_touch
2 participants