Skip to content

Fix deletion before final_touch#2974

Merged
odow merged 3 commits intomasterfrom
bl/delete_before_final_touch
Mar 19, 2026
Merged

Fix deletion before final_touch#2974
odow merged 3 commits intomasterfrom
bl/delete_before_final_touch

Conversation

@blegat
Copy link
Member

@blegat blegat commented Mar 19, 2026

Without the fix, the test throws

test_delete_before_final_touch: Error During Test at /home/blegat/.julia/dev/MathOptInterface/test/Bridges/Constraint/test_IntegerToZeroOneBridge.jl:16
  Got exception outside of a @test
  The index MathOptInterface.ConstraintIndex{MathOptInterface.ScalarAffineFunction{Int64}, MathOptInterface.EqualTo{Int64}}(0) is invalid. Note that an index becomes invalid after it has been deleted.
  Stacktrace:
    [1] throw_if_not_valid
      @ ~/.julia/dev/MathOptInterface/src/indextypes.jl:116 [inlined]
    [2] delete(v::MathOptInterface.Utilities.VectorOfConstraints{MathOptInterface.ScalarAffineFunction{Int64}, MathOptInterface.EqualTo{Int64}}, ci::MathOptInterface.ConstraintIndex{MathOptInterface.ScalarAffineFunction{Int64}, MathOptInterface.EqualTo{Int64}})
      @ MathOptInterface.Utilities ~/.julia/dev/MathOptInterface/src/Utilities/vector_of_constraints.jl:94
    [3] delete
      @ ~/.julia/dev/MathOptInterface/src/Utilities/struct_of_constraints.jl:89 [inlined]
    [4] delete(model::MathOptInterface.Utilities.ModelFunctionConstraints{Int64}, ci::MathOptInterface.ConstraintIndex{MathOptInterface.ScalarAffineFunction{Int64}, MathOptInterface.EqualTo{Int64}})
      @ MathOptInterface.Utilities ~/.julia/dev/MathOptInterface/src/Utilities/struct_of_constraints.jl:89
    [5] delete
      @ ~/.julia/dev/MathOptInterface/src/Utilities/model.jl:572 [inlined]
    [6] delete
      @ ~/.julia/dev/MathOptInterface/src/Bridges/Constraint/bridges/IntegerToZeroOneBridge.jl:111 [inlined]
    [7] #12
      @ ~/.julia/dev/MathOptInterface/src/Bridges/bridge_optimizer.jl:768 [inlined]
    [8] call_in_context(::MathOptInterface.Bridges.Variable.EmptyMap, ::MathOptInterface.ConstraintIndex{MathOptInterface.VariableIndex, MathOptInterface.Integer}, f::MathOptInterface.Bridges.var"#12#13"{MathOptInterface.Bridges.Constraint.SingleBridgeOptimizer{MathOptInterface.Bridges.Constraint.IntegerToZeroOneBridge{Int64}, MathOptInterface.Utilities.Model{Int64}}, MathOptInterface.Bridges.Constraint.IntegerToZeroOneBridge{Int64}})
      @ MathOptInterface.Bridges.Variable ~/.julia/dev/MathOptInterface/src/Bridges/Variable/map.jl:707
    [9] delete(b::MathOptInterface.Bridges.Constraint.SingleBridgeOptimizer{MathOptInterface.Bridges.Constraint.IntegerToZeroOneBridge{Int64}, MathOptInterface.Utilities.Model{Int64}}, ci::MathOptInterface.ConstraintIndex{MathOptInterface.VariableIndex, MathOptInterface.Integer})
      @ MathOptInterface.Bridges ~/.julia/dev/MathOptInterface/src/Bridges/bridge_optimizer.jl:765
   [10] _delete_variables_in_variables_constraints(b::MathOptInterface.Bridges.Constraint.SingleBridgeOptimizer{MathOptInterface.Bridges.Constraint.IntegerToZeroOneBridge{Int64}, MathOptInterface.Utilities.Model{Int64}}, vis::Vector{MathOptInterface.VariableIndex})
      @ MathOptInterface.Bridges ~/.julia/dev/MathOptInterface/src/Bridges/bridge_optimizer.jl:603
   [11] delete
      @ ~/.julia/dev/MathOptInterface/src/Bridges/bridge_optimizer.jl:714 [inlined]
   [12] test_delete_before_final_touch()
      @ Main.TestConstraintIntegerToZeroOne ~/.julia/dev/MathOptInterface/test/Bridges/Constraint/test_IntegerToZeroOneBridge.jl:102
   [13] macro expansion
      @ ~/.julia/dev/MathOptInterface/test/Bridges/Constraint/test_IntegerToZeroOneBridge.jl:17 [inlined]

@blegat blegat added Submodule: Bridges About the Bridges submodule Type: Bug labels Mar 19, 2026
Copy link
Member

@odow odow left a comment

Choose a reason for hiding this comment

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

There are probably many other bridges with the same bug. I'll take a look before merging this.

@odow odow merged commit 5617783 into master Mar 19, 2026
29 of 30 checks passed
@odow odow deleted the bl/delete_before_final_touch branch March 19, 2026 22:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Submodule: Bridges About the Bridges submodule Type: Bug

Development

Successfully merging this pull request may close these issues.

2 participants