diff --git a/src/MOI_wrapper.jl b/src/MOI_wrapper.jl index 293946710..ec711e8f0 100644 --- a/src/MOI_wrapper.jl +++ b/src/MOI_wrapper.jl @@ -132,6 +132,23 @@ function MOI.supports_constraint( return true end +function MOI.get( + ::Optimizer, + ::MOI.ConstraintBridgingCost{ + MOI.VectorNonlinearFunction, + <:MOI.AbstractVectorSet, + }, +) + # Must agree with `supports_constraint` above: the generic + # `MOI.get(::Optimizer, ::AbstractModelAttribute)` would otherwise forward + # this query to the inner model, which does not handle + # `VectorNonlinearFunction` and would return `Inf`. `LazyBridgeOptimizer` + # then sees `supports = true, cost = Inf` and treats the node as + # unreachable when building the bridge graph. + # See https://github.com/jump-dev/MathOptInterface.jl/pull/3001 + return 0.0 +end + function _expr(::Optimizer, v::Value) return Constant(v) end diff --git a/test/MOI_wrapper.jl b/test/MOI_wrapper.jl index 66f8c7dd5..7fa25d27b 100644 --- a/test/MOI_wrapper.jl +++ b/test/MOI_wrapper.jl @@ -58,6 +58,25 @@ function test_issue_564() return end +function test_constraint_bridging_cost_vector_nonlinear() + model = Convex.Optimizer(ECOS.Optimizer) + for S in ( + MOI.Nonnegatives, + MOI.Nonpositives, + MOI.Zeros, + MOI.SecondOrderCone, + MOI.PositiveSemidefiniteConeTriangle, + MOI.ExponentialCone, + ) + @test MOI.supports_constraint(model, MOI.VectorNonlinearFunction, S) + @test MOI.get( + model, + MOI.ConstraintBridgingCost{MOI.VectorNonlinearFunction,S}(), + ) == 0.0 + end + return +end + function test_scalar_nonlinear_function() model = Convex.Optimizer(ECOS.Optimizer) x = MOI.add_variable(model)