From e19d417b34f801716d16fc1cd45ca0c5b4f26775 Mon Sep 17 00:00:00 2001 From: odow Date: Sun, 26 May 2024 11:31:18 +1200 Subject: [PATCH 1/2] [Bridges] fix supports_constraint for IndicatorSOS1Bridge --- src/Bridges/Constraint/bridges/indicator_sos.jl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Bridges/Constraint/bridges/indicator_sos.jl b/src/Bridges/Constraint/bridges/indicator_sos.jl index c0148eaa01..37320573f7 100644 --- a/src/Bridges/Constraint/bridges/indicator_sos.jl +++ b/src/Bridges/Constraint/bridges/indicator_sos.jl @@ -60,10 +60,10 @@ function bridge_constraint( end function MOI.supports_constraint( - ::Type{<:IndicatorSOS1Bridge}, - ::Type{<:MOI.AbstractVectorFunction}, + ::Type{<:IndicatorSOS1Bridge{T}}, + ::Type{MOI.VectorAffineFunction{T}}, ::Type{<:MOI.Indicator{MOI.ACTIVATE_ON_ONE,<:MOI.AbstractScalarSet}}, -) +) where {T} return true end From 01f799af3a37e86b457683dee6c966e051861b36 Mon Sep 17 00:00:00 2001 From: odow Date: Sun, 26 May 2024 11:38:35 +1200 Subject: [PATCH 2/2] Add test --- src/Bridges/Constraint/bridges/indicator_sos.jl | 2 +- test/Bridges/Constraint/indicator_sos.jl | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/Bridges/Constraint/bridges/indicator_sos.jl b/src/Bridges/Constraint/bridges/indicator_sos.jl index 37320573f7..ce87ff8de7 100644 --- a/src/Bridges/Constraint/bridges/indicator_sos.jl +++ b/src/Bridges/Constraint/bridges/indicator_sos.jl @@ -113,7 +113,7 @@ end function concrete_bridge_type( ::Type{<:IndicatorSOS1Bridge{T}}, - ::Type{<:MOI.AbstractVectorFunction}, + ::Type{MOI.VectorAffineFunction{T}}, ::Type{MOI.Indicator{MOI.ACTIVATE_ON_ONE,S}}, ) where {T,S} return IndicatorSOS1Bridge{T,S} diff --git a/test/Bridges/Constraint/indicator_sos.jl b/test/Bridges/Constraint/indicator_sos.jl index d66036c80b..fe592488af 100644 --- a/test/Bridges/Constraint/indicator_sos.jl +++ b/test/Bridges/Constraint/indicator_sos.jl @@ -332,6 +332,20 @@ function test_runtests() [y, z] in SOS1([0.4, 0.6]) """, ) + # Test that the bridge does nothing for VectorQuadraticFunctions + MOI.Bridges.runtests( + MOI.Bridges.Constraint.IndicatorSOS1Bridge, + """ + variables: x, z + [z, 2.0 * x * x] in Indicator{ACTIVATE_ON_ONE}(LessThan(2.0)) + z in ZeroOne() + """, + """ + variables: x, z + [z, 2.0 * x * x] in Indicator{ACTIVATE_ON_ONE}(LessThan(2.0)) + z in ZeroOne() + """, + ) return end