diff --git a/src/Bridges/Constraint/Constraint.jl b/src/Bridges/Constraint/Constraint.jl index 8b67cf9904..996934c359 100644 --- a/src/Bridges/Constraint/Constraint.jl +++ b/src/Bridges/Constraint/Constraint.jl @@ -29,6 +29,12 @@ Add all bridges defined in the `Bridges.Constraint` submodule to `model`. The coefficient type used is `T`. """ function add_all_bridges(model, ::Type{T}) where {T} + if T <: AbstractFloat + # Out of order: put these bridges at the start for backwards + # compatibility. + MOI.Bridges.add_bridge(model, GreaterToIntervalBridge{T}) + MOI.Bridges.add_bridge(model, LessToIntervalBridge{T}) + end MOI.Bridges.add_bridge(model, AllDifferentToCountDistinctBridge{T}) MOI.Bridges.add_bridge(model, BinPackingToMILPBridge{T}) MOI.Bridges.add_bridge(model, CircuitToMILPBridge{T}) @@ -48,9 +54,6 @@ function add_all_bridges(model, ::Type{T}) where {T} MOI.Bridges.add_bridge(model, GeoMeanBridge{T}) MOI.Bridges.add_bridge(model, GeoMeanToPowerBridge{T}) MOI.Bridges.add_bridge(model, GeoMeantoRelEntrBridge{T}) - if T <: AbstractFloat - MOI.Bridges.add_bridge(model, GreaterToIntervalBridge{T}) - end MOI.Bridges.add_bridge(model, GreaterToLessBridge{T}) MOI.Bridges.add_bridge(model, HermitianToSymmetricPSDBridge{T}) MOI.Bridges.add_bridge(model, IndicatorActiveOnFalseBridge{T}) @@ -65,9 +68,6 @@ function add_all_bridges(model, ::Type{T}) where {T} MOI.Bridges.add_bridge(model, InequalityToComplementsBridge{T}) MOI.Bridges.add_bridge(model, IntegerToZeroOneBridge{T}) MOI.Bridges.add_bridge(model, LessToGreaterBridge{T}) - if T <: AbstractFloat - MOI.Bridges.add_bridge(model, LessToIntervalBridge{T}) - end MOI.Bridges.add_bridge(model, LogDetBridge{T}) MOI.Bridges.add_bridge(model, NonnegToNonposBridge{T}) MOI.Bridges.add_bridge(model, NonposToNonnegBridge{T}) diff --git a/src/Bridges/Variable/bridges/RSOCtoPSDBridge.jl b/src/Bridges/Variable/bridges/RSOCtoPSDBridge.jl index cc3b30ca86..a58464abc1 100644 --- a/src/Bridges/Variable/bridges/RSOCtoPSDBridge.jl +++ b/src/Bridges/Variable/bridges/RSOCtoPSDBridge.jl @@ -56,6 +56,8 @@ end const RSOCtoPSD{T,OT<:MOI.ModelLike} = SingleBridgeOptimizer{RSOCtoPSDBridge{T},OT} +MOI.Bridges.bridging_cost(::Type{<:RSOCtoPSDBridge}) = 1.5 + function bridge_constrained_variable( ::Type{RSOCtoPSDBridge{T}}, model::MOI.ModelLike, diff --git a/test/Bridges/lazy_bridge_optimizer.jl b/test/Bridges/lazy_bridge_optimizer.jl index f6b4ebb4e1..1d629f13d2 100644 --- a/test/Bridges/lazy_bridge_optimizer.jl +++ b/test/Bridges/lazy_bridge_optimizer.jl @@ -1041,13 +1041,13 @@ Objective function of type `MOI.ScalarQuadraticFunction{$T}` is not supported an """ Bridge graph with 2 variable nodes, 5 constraint nodes and 2 objective nodes. [1] constrained variables in `MOI.Reals` are bridged (distance 1) by $(MOI.Bridges.Variable.FreeBridge{T}). - [2] constrained variables in `MOI.RotatedSecondOrderCone` are bridged (distance 2) by $(MOI.Bridges.Variable.RSOCtoPSDBridge{T}). - (1) `MOI.ScalarQuadraticFunction{$T}`-in-`MOI.GreaterThan{$T}` constraints are bridged (distance 5) by $(MOI.Bridges.Constraint.QuadtoSOCBridge{T}). - (2) `MOI.VectorAffineFunction{$T}`-in-`MOI.RotatedSecondOrderCone` constraints are bridged (distance 4) by $(MOI.Bridges.Constraint.VectorSlackBridge{T,MOI.VectorAffineFunction{T},MOI.RotatedSecondOrderCone}). + [2] constrained variables in `MOI.RotatedSecondOrderCone` are bridged (distance 2.5) by $(MOI.Bridges.Variable.RSOCtoPSDBridge{T}). + (1) `MOI.ScalarQuadraticFunction{$T}`-in-`MOI.GreaterThan{$T}` constraints are bridged (distance 5.5) by $(MOI.Bridges.Constraint.QuadtoSOCBridge{T}). + (2) `MOI.VectorAffineFunction{$T}`-in-`MOI.RotatedSecondOrderCone` constraints are bridged (distance 4.5) by $(MOI.Bridges.Constraint.VectorSlackBridge{T,MOI.VectorAffineFunction{T},MOI.RotatedSecondOrderCone}). (3) `MOI.VariableIndex`-in-`MOI.EqualTo{$T}` constraints are bridged (distance 1) by $(MOI.Bridges.Constraint.ScalarFunctionizeBridge{T,MOI.EqualTo{T}}). (4) `MOI.VectorAffineFunction{$T}`-in-`MOI.Zeros` constraints are bridged (distance 1) by $(MOI.Bridges.Constraint.ScalarizeBridge{T,MOI.ScalarAffineFunction{T},MOI.EqualTo{T}}). - (5) `MOI.ScalarQuadraticFunction{$T}`-in-`MOI.LessThan{$T}` constraints are bridged (distance 5) by $(MOI.Bridges.Constraint.QuadtoSOCBridge{T}). - |1| objective function of type `MOI.ScalarQuadraticFunction{$T}` is bridged (distance 13) by $(MOI.Bridges.Objective.SlackBridge{T,MOI.ScalarQuadraticFunction{T},MOI.ScalarQuadraticFunction{T}}). + (5) `MOI.ScalarQuadraticFunction{$T}`-in-`MOI.LessThan{$T}` constraints are bridged (distance 5.5) by $(MOI.Bridges.Constraint.QuadtoSOCBridge{T}). + |1| objective function of type `MOI.ScalarQuadraticFunction{$T}` is bridged (distance 14) by $(MOI.Bridges.Objective.SlackBridge{T,MOI.ScalarQuadraticFunction{T},MOI.ScalarQuadraticFunction{T}}). |2| objective function of type `MOI.VariableIndex` is bridged (distance 1) by $(MOI.Bridges.Objective.FunctionizeBridge{T,MOI.VariableIndex}). """, )