|
276 | 276 | with 0 constraint bridges |
277 | 277 | with inner model $(MOIU.MockOptimizer{NoIntervalModel{Float64}})""") |
278 | 278 | end |
| 279 | + |
| 280 | +MOI.Utilities.@model(AffineOnlyModel, (), (MOI.Interval,), (MOI.PositiveSemidefiniteConeTriangle,), (), (), (MOI.ScalarAffineFunction,), (), (MOI.VectorAffineFunction,), true) |
| 281 | +MOI.supports_constraint(::AffineOnlyModel{T}, ::Type{MOI.SingleVariable}, ::Type{MOI.LessThan{T}}) where T = false |
| 282 | +MOI.supports_constraint(::AffineOnlyModel{T}, ::Type{MOI.SingleVariable}, ::Type{MOI.Interval{T}}) where T = false |
| 283 | +@testset "Double deletion of nested bridged SingleVariable constraint" begin |
| 284 | + @testset "Scalar" begin |
| 285 | + # The variable is bridged to `SingleVariable`-in-`Interval` and then `ScalarAffineFunction`-in-`Interval`. |
| 286 | + # Hence there is two bridged `SingleVariable` constraints on the same variables and we need to be |
| 287 | + # careful not to delete the second one twice, see https://github.com/jump-dev/MathOptInterface.jl/issues/1231 |
| 288 | + model = MOI.instantiate(AffineOnlyModel{Float64}, with_bridge_type=Float64) |
| 289 | + x = MOI.add_variable(model) |
| 290 | + c = MOI.add_constraint(model, MOI.SingleVariable(x), MOI.LessThan(1.0)) |
| 291 | + # Need to test the bridging to make sure it's not functionized first as otherwise, |
| 292 | + # this test would not cover the case we want to test |
| 293 | + b1 = MOI.Bridges.bridge(model, c) |
| 294 | + @test b1 isa MOI.Bridges.Constraint.LessToIntervalBridge |
| 295 | + b2 = MOI.Bridges.bridge(model, b1.constraint) |
| 296 | + @test b2 isa MOI.Bridges.Constraint.ScalarFunctionizeBridge |
| 297 | + @test !MOI.Bridges.is_bridged(model, b2.constraint) |
| 298 | + MOI.delete(model, x) |
| 299 | + @test !MOI.is_valid(model, x) |
| 300 | + end |
| 301 | + @testset "Vector" begin |
| 302 | + model = MOI.instantiate(AffineOnlyModel{Float64}, with_bridge_type=Float64) |
| 303 | + x = MOI.add_variables(model, 4) |
| 304 | + c = MOI.add_constraint(model, MOI.VectorOfVariables(x), MOI.PositiveSemidefiniteConeSquare(2)) |
| 305 | + b1 = MOI.Bridges.bridge(model, c) |
| 306 | + @test b1 isa MOI.Bridges.Constraint.SquareBridge |
| 307 | + b2 = MOI.Bridges.bridge(model, b1.triangle) |
| 308 | + @test b2 isa MOI.Bridges.Constraint.VectorFunctionizeBridge |
| 309 | + @test !MOI.Bridges.is_bridged(model, b2.constraint) |
| 310 | + MOI.delete(model, x) |
| 311 | + @test all(vi -> !MOI.is_valid(model, vi), x) |
| 312 | + end |
| 313 | +end |
0 commit comments