Skip to content

Commit

Permalink
Change bridge weight
Browse files Browse the repository at this point in the history
  • Loading branch information
odow committed Dec 30, 2024
1 parent 9b26dd8 commit b9048fa
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
12 changes: 6 additions & 6 deletions src/Bridges/Constraint/Constraint.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand All @@ -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})
Expand All @@ -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})
Expand Down
2 changes: 2 additions & 0 deletions src/Bridges/Variable/bridges/RSOCtoPSDBridge.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
10 changes: 5 additions & 5 deletions test/Bridges/lazy_bridge_optimizer.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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}).
""",
)
Expand Down

0 comments on commit b9048fa

Please sign in to comment.