diff --git a/src/Bridges/bridge_optimizer.jl b/src/Bridges/bridge_optimizer.jl index 23b155a402..48e3d19319 100644 --- a/src/Bridges/bridge_optimizer.jl +++ b/src/Bridges/bridge_optimizer.jl @@ -1347,30 +1347,15 @@ function MOI.supports( attr::MOI.AbstractConstraintAttribute, IndexType::Type{MOI.ConstraintIndex{F,S}}, ) where {F,S} - is_variable_function = F == MOI.Utilities.variable_function_type(S) - # A `F`-in-`S` constraint could be added to the model either if it this - # constraint is not bridged or if variables constrained on creations to `S` - # are not bridged and `F` is `VariableIndex` or `VectorOfVariables`. - if !is_bridged(b, F, S) || (is_variable_function && !is_bridged(b, S)) - if !MOI.supports(b.model, attr, IndexType) - return false - end - end - bridge = recursive_model(b) - # If variable bridged, get the indices from the variable bridges. - if is_variable_function && is_bridged(b, S) && is_variable_bridged(b, S) - if !MOI.supports(bridge, attr, Variable.concrete_bridge_type(b, S)) - return false - end - end - # If constraint bridged, get the indices from the constraint bridges. - if is_bridged(b, F, S) || - (is_variable_function && supports_constraint_bridges(b)) - if !MOI.supports(bridge, attr, Constraint.concrete_bridge_type(b, F, S)) - return false - end + if is_bridged(b, F, S) + bridge = Constraint.concrete_bridge_type(b, F, S) + return MOI.supports(recursive_model(b), attr, bridge) + elseif F == MOI.Utilities.variable_function_type(S) && is_bridged(b, S) + bridge = Variable.concrete_bridge_type(b, S) + return MOI.supports(recursive_model(b), attr, bridge) + else + return MOI.supports(b.model, attr, IndexType) end - return true end function MOI.set( diff --git a/test/Bridges/bridge_optimizer.jl b/test/Bridges/bridge_optimizer.jl index 17e07911d3..227a2c6056 100644 --- a/test/Bridges/bridge_optimizer.jl +++ b/test/Bridges/bridge_optimizer.jl @@ -821,6 +821,32 @@ function test_constant_modification_with_affine_variable_bridge() @test MOI.get(model, obj) ≈ new_inner_obj end +struct _IssueIpopt333 <: MOI.AbstractOptimizer end + +function MOI.supports( + ::_IssueIpopt333, + ::MOI.ConstraintDualStart, + ::Type{MOI.ConstraintIndex{MOI.VariableIndex,MOI.GreaterThan{Float64}}}, +) + return true +end + +function MOI.supports_constraint( + ::_IssueIpopt333, + ::Type{MOI.VariableIndex}, + ::Type{MOI.GreaterThan{Float64}}, +) + return true +end + +function test_IssueIpopt333_supports_ConstraintDualStart_VariableIndex() + model = MOI.Bridges.full_bridge_optimizer(_IssueIpopt333(), Float64) + attr = MOI.ConstraintDualStart() + IndexType = MOI.ConstraintIndex{MOI.VariableIndex,MOI.GreaterThan{Float64}} + @test MOI.supports(model, attr, IndexType) + return +end + end # module TestBridgeOptimizer.runtests()