Skip to content

Commit

Permalink
sort bridges
Browse files Browse the repository at this point in the history
  • Loading branch information
odow committed Dec 21, 2024
1 parent 21a4768 commit 75d59ea
Show file tree
Hide file tree
Showing 2 changed files with 87 additions and 94 deletions.
169 changes: 81 additions & 88 deletions src/Bridges/Constraint/Constraint.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,122 +22,115 @@ for filename in readdir(joinpath(@__DIR__, "bridges"); join = true)
end

"""
add_all_bridges(bridged_model, ::Type{T}) where {T}
add_all_bridges(model, ::Type{T}) where {T}
Add all bridges defined in the `Bridges.Constraint` submodule to
`bridged_model`.
Add all bridges defined in the `Bridges.Constraint` submodule to `model`.
The coefficient type used is `T`.
"""
function add_all_bridges(bridged_model, ::Type{T}) where {T}
if T <: AbstractFloat
MOI.Bridges.add_bridge(bridged_model, GreaterToIntervalBridge{T})
MOI.Bridges.add_bridge(bridged_model, LessToIntervalBridge{T})
end
MOI.Bridges.add_bridge(bridged_model, GreaterToLessBridge{T})
MOI.Bridges.add_bridge(bridged_model, LessToGreaterBridge{T})
MOI.Bridges.add_bridge(bridged_model, NonnegToNonposBridge{T})
MOI.Bridges.add_bridge(bridged_model, NonposToNonnegBridge{T})
MOI.Bridges.add_bridge(bridged_model, ScalarizeBridge{T})
MOI.Bridges.add_bridge(bridged_model, VectorizeBridge{T})
MOI.Bridges.add_bridge(bridged_model, ScalarSlackBridge{T})
MOI.Bridges.add_bridge(bridged_model, VectorSlackBridge{T})
MOI.Bridges.add_bridge(bridged_model, ScalarFunctionizeBridge{T})
MOI.Bridges.add_bridge(bridged_model, VectorFunctionizeBridge{T})
MOI.Bridges.add_bridge(bridged_model, ToScalarQuadraticBridge{T})
MOI.Bridges.add_bridge(bridged_model, ToVectorQuadraticBridge{T})
MOI.Bridges.add_bridge(bridged_model, ToScalarNonlinearBridge{T})
MOI.Bridges.add_bridge(bridged_model, SplitHyperRectangleBridge{T})
MOI.Bridges.add_bridge(bridged_model, SplitIntervalBridge{T})
MOI.Bridges.add_bridge(bridged_model, SplitComplexEqualToBridge{T})
MOI.Bridges.add_bridge(bridged_model, SplitComplexZerosBridge{T})
MOI.Bridges.add_bridge(bridged_model, QuadtoSOCBridge{T})
MOI.Bridges.add_bridge(bridged_model, NormInfinityBridge{T})
MOI.Bridges.add_bridge(bridged_model, NormOneBridge{T})
MOI.Bridges.add_bridge(bridged_model, GeoMeantoRelEntrBridge{T})
MOI.Bridges.add_bridge(bridged_model, GeoMeanBridge{T})
MOI.Bridges.add_bridge(bridged_model, GeoMeanToPowerBridge{T})
MOI.Bridges.add_bridge(bridged_model, NormToPowerBridge{T})
MOI.Bridges.add_bridge(bridged_model, NormOneConeToNormConeBridge{T})
MOI.Bridges.add_bridge(bridged_model, SecondOrderConeToNormConeBridge{T})
MOI.Bridges.add_bridge(bridged_model, NormInfinityConeToNormConeBridge{T})
MOI.Bridges.add_bridge(
bridged_model,
ComplexNormInfinityToSecondOrderConeBridge{T},
)
MOI.Bridges.add_bridge(bridged_model, RelativeEntropyBridge{T})
MOI.Bridges.add_bridge(bridged_model, NormSpectralBridge{T})
MOI.Bridges.add_bridge(bridged_model, NormNuclearBridge{T})
MOI.Bridges.add_bridge(bridged_model, HermitianToSymmetricPSDBridge{T})
MOI.Bridges.add_bridge(bridged_model, SquareBridge{T})
MOI.Bridges.add_bridge(bridged_model, SetDotScalingBridge{T})
MOI.Bridges.add_bridge(bridged_model, SetDotInverseScalingBridge{T})
MOI.Bridges.add_bridge(bridged_model, LogDetBridge{T})
MOI.Bridges.add_bridge(bridged_model, RootDetBridge{T})
MOI.Bridges.add_bridge(bridged_model, RSOCtoSOCBridge{T})
MOI.Bridges.add_bridge(bridged_model, SOCtoRSOCBridge{T})
MOI.Bridges.add_bridge(bridged_model, RSOCtoPSDBridge{T})
MOI.Bridges.add_bridge(bridged_model, IndicatorActiveOnFalseBridge{T})
MOI.Bridges.add_bridge(bridged_model, IndicatorSOS1Bridge{T})
MOI.Bridges.add_bridge(bridged_model, IndicatorLessToGreaterThanBridge{T})
MOI.Bridges.add_bridge(bridged_model, IndicatorGreaterToLessThanBridge{T})
MOI.Bridges.add_bridge(bridged_model, SemiToBinaryBridge{T})
MOI.Bridges.add_bridge(bridged_model, ZeroOneBridge{T})
MOI.Bridges.add_bridge(bridged_model, IntegerToZeroOneBridge{T})
MOI.Bridges.add_bridge(bridged_model, InequalityToComplementsBridge{T})
MOI.Bridges.add_bridge(bridged_model, AllDifferentToCountDistinctBridge{T})
function add_all_bridges(model, ::Type{T}) where {T}
MOI.Bridges.add_bridge(model, AllDifferentToCountDistinctBridge{T})
MOI.Bridges.add_bridge(model, BinPackingToMILPBridge{T})
MOI.Bridges.add_bridge(model, CircuitToMILPBridge{T})
MOI.Bridges.add_bridge(model, ComplexNormInfinityToSecondOrderConeBridge{T})
MOI.Bridges.add_bridge(model, CountAtLeastToCountBelongsBridge{T})
MOI.Bridges.add_bridge(model, CountBelongsToMILPBridge{T})
MOI.Bridges.add_bridge(model, CountDistinctToMILPBridge{T})
MOI.Bridges.add_bridge(model, CountGreaterThanToMILPBridge{T})
MOI.Bridges.add_bridge(
bridged_model,
ReifiedAllDifferentToCountDistinctBridge{T},
)
MOI.Bridges.add_bridge(bridged_model, BinPackingToMILPBridge{T})
MOI.Bridges.add_bridge(bridged_model, CircuitToMILPBridge{T})
MOI.Bridges.add_bridge(bridged_model, CountAtLeastToCountBelongsBridge{T})
MOI.Bridges.add_bridge(bridged_model, CountBelongsToMILPBridge{T})
MOI.Bridges.add_bridge(bridged_model, CountDistinctToMILPBridge{T})
MOI.Bridges.add_bridge(bridged_model, ReifiedCountDistinctToMILPBridge{T})
MOI.Bridges.add_bridge(bridged_model, CountGreaterThanToMILPBridge{T})
MOI.Bridges.add_bridge(bridged_model, TableToMILPBridge{T})
MOI.Bridges.add_bridge(bridged_model, SOS1ToMILPBridge{T})
MOI.Bridges.add_bridge(bridged_model, SOS2ToMILPBridge{T})
MOI.Bridges.add_bridge(bridged_model, IndicatorToMILPBridge{T})
MOI.Bridges.add_bridge(
bridged_model,
model,
ExponentialConeToScalarNonlinearFunctionBridge{T},
)
# Bridges not added by default:
#
# * FunctionConversionBridge
# * FunctionConversionBridge{T}
# This bridge is not added because, even though it is not abstract, it
# is highly parameterized, and parameterized versions such as
# ScalarFunctionizeBridge are added.
# * IndicatorSetMapBridge
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})
MOI.Bridges.add_bridge(model, IndicatorGreaterToLessThanBridge{T})
MOI.Bridges.add_bridge(model, IndicatorLessToGreaterThanBridge{T})
# * IndicatorSetMapBridge{T}
# This bridge is not added because, even though it is not abstract, it
# is highly parameterized, and parameterized versions such as
# IndicatorGreaterToLessThanBridge are added.
# * NormSpecialCaseBridge
MOI.Bridges.add_bridge(model, IndicatorSOS1Bridge{T})
MOI.Bridges.add_bridge(model, IndicatorToMILPBridge{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})
MOI.Bridges.add_bridge(model, NormInfinityBridge{T})
MOI.Bridges.add_bridge(model, NormInfinityConeToNormConeBridge{T})
MOI.Bridges.add_bridge(model, NormNuclearBridge{T})
MOI.Bridges.add_bridge(model, NormOneBridge{T})
MOI.Bridges.add_bridge(model, NormOneConeToNormConeBridge{T})
# * NormSpecialCaseBridge{T}
# This bridge is not added because, even though it is not abstract, it
# is highly parameterized, and parameterized versions such as
# NormOneConeToNormConeBridge are added.
# * NumberConversionBridge
MOI.Bridges.add_bridge(model, NormSpectralBridge{T})
MOI.Bridges.add_bridge(model, NormToPowerBridge{T})
# * NumberConversionBridge{T}
# This bridge is not added by default because it would silently enable
# models with mixed precision. In most cases, this is a bug in the
# user's code, so we leave this bridge as opt-in.
# * RSOCtoNonConvexQuadBridge
MOI.Bridges.add_bridge(model, QuadtoSOCBridge{T})
MOI.Bridges.add_bridge(model, ReifiedAllDifferentToCountDistinctBridge{T})
MOI.Bridges.add_bridge(model, ReifiedCountDistinctToMILPBridge{T})
MOI.Bridges.add_bridge(model, RelativeEntropyBridge{T})
MOI.Bridges.add_bridge(model, RootDetBridge{T})
# * RSOCtoNonConvexQuadBridge{T}
# This bridge is not added by default because it starts with a convex
# conic constraint and generate a non-convex constraint (in the QCP
# interpretation).
# * SOCtoNonConvexQuadBridge
MOI.Bridges.add_bridge(model, RSOCtoPSDBridge{T})
MOI.Bridges.add_bridge(model, RSOCtoSOCBridge{T})
MOI.Bridges.add_bridge(model, ScalarFunctionizeBridge{T})
MOI.Bridges.add_bridge(model, ScalarizeBridge{T})
MOI.Bridges.add_bridge(model, ScalarSlackBridge{T})
MOI.Bridges.add_bridge(model, SecondOrderConeToNormConeBridge{T})
MOI.Bridges.add_bridge(model, SemiToBinaryBridge{T})
# * SetConversionBridge{T}
# This bridge is not added because, even though it is not abstract, it
# is highly parameterized, and it intended for use by MOI extensions.
MOI.Bridges.add_bridge(model, SetDotInverseScalingBridge{T})
MOI.Bridges.add_bridge(model, SetDotScalingBridge{T})
# * SOCtoNonConvexQuadBridge{T}
# This bridge is not added by default because it starts with a convex
# conic constraint and generate a non-convex constraint (in the QCP
# interpretation).
# * SOCtoPSDBridge
# * SOCtoPSDBridge{T}
# This bridge is not added because transforming the `SOC` to `RSOC` and
# then to `PSD` produces a smaller SDP constraint. `RSOCtoPSDBridge` is
# added by default.
# * SetConversionBridge
# This bridge is not added because, even though it is not abstract, it
# is highly parameterized, and it intended for use by MOI extensions.
MOI.Bridges.add_bridge(model, SOCtoRSOCBridge{T})
MOI.Bridges.add_bridge(model, SOS1ToMILPBridge{T})
MOI.Bridges.add_bridge(model, SOS2ToMILPBridge{T})
MOI.Bridges.add_bridge(model, SplitComplexEqualToBridge{T})
MOI.Bridges.add_bridge(model, SplitComplexZerosBridge{T})
MOI.Bridges.add_bridge(model, SplitHyperRectangleBridge{T})
MOI.Bridges.add_bridge(model, SplitIntervalBridge{T})
MOI.Bridges.add_bridge(model, SquareBridge{T})
MOI.Bridges.add_bridge(model, TableToMILPBridge{T})
MOI.Bridges.add_bridge(model, ToScalarNonlinearBridge{T})
MOI.Bridges.add_bridge(model, ToScalarQuadraticBridge{T})
MOI.Bridges.add_bridge(model, ToVectorQuadraticBridge{T})
MOI.Bridges.add_bridge(model, VectorFunctionizeBridge{T})
MOI.Bridges.add_bridge(model, VectorizeBridge{T})
MOI.Bridges.add_bridge(model, VectorSlackBridge{T})
MOI.Bridges.add_bridge(model, ZeroOneBridge{T})
return
end

Expand Down
12 changes: 6 additions & 6 deletions src/Bridges/Variable/Variable.jl
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ Add all bridges defined in the `Bridges.Variable` submodule to `model`.
The coefficient type used is `T`.
"""
function add_all_bridges(model, ::Type{T}) where {T}
MOI.Bridges.add_bridge(model, ZerosBridge{T})
MOI.Bridges.add_bridge(model, FreeBridge{T})
MOI.Bridges.add_bridge(model, NonposToNonnegBridge{T})
MOI.Bridges.add_bridge(model, VectorizeBridge{T})
MOI.Bridges.add_bridge(model, SOCtoRSOCBridge{T})
MOI.Bridges.add_bridge(model, RSOCtoSOCBridge{T})
MOI.Bridges.add_bridge(model, RSOCtoPSDBridge{T})
MOI.Bridges.add_bridge(model, HermitianToSymmetricPSDBridge{T})
MOI.Bridges.add_bridge(model, NonposToNonnegBridge{T})
MOI.Bridges.add_bridge(model, ParameterToEqualToBridge{T})
MOI.Bridges.add_bridge(model, RSOCtoPSDBridge{T})
MOI.Bridges.add_bridge(model, RSOCtoSOCBridge{T})
MOI.Bridges.add_bridge(model, SOCtoRSOCBridge{T})
MOI.Bridges.add_bridge(model, VectorizeBridge{T})
MOI.Bridges.add_bridge(model, ZerosBridge{T})
return
end

Expand Down

0 comments on commit 75d59ea

Please sign in to comment.