Skip to content

MOI.is_valid can be falsely positive for bridged constraints #2696

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

Open
odow opened this issue Mar 25, 2025 · 1 comment
Open

MOI.is_valid can be falsely positive for bridged constraints #2696

odow opened this issue Mar 25, 2025 · 1 comment
Labels
Submodule: Bridges About the Bridges submodule

Comments

@odow
Copy link
Member

odow commented Mar 25, 2025

Found as part of #2695. But it does't need to hold that up merging.

The last MOI.is_valid should return false:

julia> import MathOptInterface as MOI

julia> include("test/Bridges/sdpa_models.jl")

julia> model = MOI.instantiate(StandardSDPAModel{Float64}; with_bridge_type = Float64);

julia> x = MOI.add_variables(model, 2);

julia> c = MOI.add_constraint(model, MOI.VectorOfVariables(x), MOI.Nonpositives(2));

julia> MOI.is_valid(model, c)
true

julia> MOI.is_valid(model, typeof(c)(c.value + 1))
true

See
https://github.com/jump-dev/MathOptInterface.jl/pull/2695/files#diff-87c703874f7251d45788070ce6ab50219cfe8b7561d08e6f6148d44afba24ccbR249-R251

@odow odow added the Submodule: Bridges About the Bridges submodule label Mar 25, 2025
@odow
Copy link
Member Author

odow commented Apr 2, 2025

julia> using Revise

julia> import MathOptInterface as MOI

julia> MOI.Utilities.@model(
           Model,
           (), (MOI.EqualTo,), (MOI.Nonnegatives,), (),
           (), (MOI.ScalarAffineFunction,), (MOI.VectorOfVariables,), (),
       )
MathOptInterface.Utilities.GenericModel{T, MathOptInterface.Utilities.ObjectiveContainer{T}, MathOptInterface.Utilities.VariablesContainer{T}, ModelFunctionConstraints{T}} where T

julia> MOI.supports_constraint(::Model, ::Type{MOI.VectorOfVariables}, ::Type{MOI.Reals}) = false

julia> MOI.supports_add_constrained_variables(::Model, ::Type{MOI.Nonnegatives}) = true

julia> MOI.supports_add_constrained_variables(::Model, ::Type{MOI.Reals}) = false

julia> model = MOI.instantiate(Model{Float64}; with_bridge_type = Float64);

julia> x = MOI.add_variables(model, 2);

julia> c = MOI.add_constraint(model, MOI.VectorOfVariables(x), MOI.Nonpositives(2));

julia> MOI.is_valid(model, c)
true

julia> ci = typeof(c)(c.value + 1)
MathOptInterface.ConstraintIndex{MathOptInterface.VectorOfVariables, MathOptInterface.Nonpositives}(-2)

julia> MOI.is_valid(model, ci)
true

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
Development

No branches or pull requests

1 participant