Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
odow committed Dec 30, 2024
1 parent 950a540 commit eec3758
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 10 deletions.
17 changes: 7 additions & 10 deletions src/Bridges/Constraint/Constraint.jl
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,6 @@ 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 @@ -43,17 +37,19 @@ function add_all_bridges(model, ::Type{T}) where {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(
model,
ExponentialConeToScalarNonlinearFunctionBridge{T},
)
# * ExponentialConeToScalarNonlinearFunctionBridge{T}
# This bridge is not added by default because it starts with a convex
# conic constraint and adds a nonlinear constraint that local NLP
# solvers like Ipopt can struggle with because of log(x) when x is 0.
# In addition, the bridge does not support ConstraintDual.
# * 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.
MOI.Bridges.add_bridge(model, GeoMeanBridge{T})
MOI.Bridges.add_bridge(model, GeoMeanToPowerBridge{T})
MOI.Bridges.add_bridge(model, GeoMeantoRelEntrBridge{T})
MOI.Bridges.add_bridge(model, GreaterToIntervalBridge{T})
MOI.Bridges.add_bridge(model, GreaterToLessBridge{T})
MOI.Bridges.add_bridge(model, HermitianToSymmetricPSDBridge{T})
MOI.Bridges.add_bridge(model, IndicatorActiveOnFalseBridge{T})
Expand All @@ -68,6 +64,7 @@ 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})
MOI.Bridges.add_bridge(model, LessToIntervalBridge{T})
MOI.Bridges.add_bridge(model, LogDetBridge{T})
MOI.Bridges.add_bridge(model, NonnegToNonposBridge{T})
MOI.Bridges.add_bridge(model, NonposToNonnegBridge{T})
Expand Down
14 changes: 14 additions & 0 deletions test/Bridges/bridge_optimizer.jl
Original file line number Diff line number Diff line change
Expand Up @@ -567,6 +567,20 @@ function test_double_deletion_scalar()
# careful not to delete the second one twice, see https://github.com/jump-dev/MathOptInterface.jl/issues/1231
model =
MOI.instantiate(AffineOnlyModel{Float64}, with_bridge_type = Float64)
# If LessToGreaterBridge exists, this goes from:
# VariableIndex(x) in LessThan(1.0)
# ScalarAffineFunction(-1.0x) in GreaterThan(-1.0) (LessToGreater)
# ScalarAffineFunction(-1.0x) in Interval(-1.0, Inf) (GreaterToInterval)
# we want instead
# VariableIndex(x) in LessThan(1.0)
# VariableIndex(x) in Interval(-Inf, 1.0) (LessToInterval)
# ScalarAffineFunction(1.0x) in Interval(-Inf, 1.0) (FunctionConversion)
# To check that we handle the LessThan and Interval sets on the same
# VariableIndex correctly.
MOI.Bridges.remove_bridge(
model,
MOI.Bridges.Constraint.LessToGreaterBridge{Float64},
)
x = MOI.add_variable(model)
c = MOI.add_constraint(model, x, MOI.LessThan(1.0))
# Need to test the bridging to make sure it's not functionized first as otherwise,
Expand Down

0 comments on commit eec3758

Please sign in to comment.