Skip to content

[Bridges] add a test_broken test for #2696 #2705

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 1 commit into from
Apr 2, 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
8 changes: 6 additions & 2 deletions src/Test/test_basic_constraint.jl
Original file line number Diff line number Diff line change
Expand Up @@ -246,8 +246,12 @@
### Test MOI.is_valid
###
@test MOI.is_valid(model, c)
# TODO(odow): we could improve this test by checking `c.value+1` and
# `c.value-1` but there is a bug in `LazyBridgeOptimizer`.
# We could improve this test by checking these are `== true` instead of
# `isa Bool`, but there is a bug in `LazyBridgeOptimizer`. See
# MathOptInterface.jl#2696 for details. At the very least, this test checks
# that they do not error, and hopefully helps hit some code paths.
@test !MOI.is_valid(model, typeof(c)(c.value + 1)) isa Bool
@test !MOI.is_valid(model, typeof(c)(c.value - 1)) isa Bool

Check warning on line 254 in src/Test/test_basic_constraint.jl

View check run for this annotation

Codecov / codecov/patch

src/Test/test_basic_constraint.jl#L253-L254

Added lines #L253 - L254 were not covered by tests
@test !MOI.is_valid(model, typeof(c)(c.value + 12345))
###
### Test MOI.ConstraintName
Expand Down
15 changes: 15 additions & 0 deletions test/Bridges/lazy_bridge_optimizer.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2238,6 +2238,21 @@ function test_bridge_complex_greatertoless()
return
end

function test_issue_2696()
b = MOI.instantiate(StandardSDPAModel{Float64}; with_bridge_type = Float64)
x = MOI.add_variables(b, 2)
c = MOI.add_constraint(b, MOI.VectorOfVariables(x), MOI.Nonpositives(2))
@test MOI.is_valid(b, c)
F, S = MOI.VectorOfVariables, MOI.Nonpositives
# See MathOptInterface.jl#2696
d = MOI.ConstraintIndex{F,S}(c.value + 1)
@test_broken !MOI.is_valid(b, d)
@test MOI.get(b, MOI.ListOfConstraintTypesPresent()) == [(F, S)]
@test only(MOI.get(b, MOI.ListOfConstraintIndices{F,S}())) == c
@test MOI.get(b, MOI.NumberOfConstraints{F,S}()) == 1
return
end

end # module

TestBridgesLazyBridgeOptimizer.runtests()
Loading