Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
odow committed Dec 14, 2023
1 parent 2203a18 commit 275f03a
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 31 deletions.
1 change: 1 addition & 0 deletions docs/src/submodules/Bridges/reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ Bridges.Constraint.SingleBridgeOptimizer
Bridges.Constraint.add_all_bridges
Bridges.Constraint.FlipSignBridge
Bridges.Constraint.AbstractToIntervalBridge
Bridges.Constraint.MultiSetMapBridge
Bridges.Constraint.SetMapBridge
Bridges.Constraint.conversion_cost
```
Expand Down
5 changes: 0 additions & 5 deletions src/Bridges/Constraint/bridges/soc_to_psd.jl
Original file line number Diff line number Diff line change
Expand Up @@ -244,11 +244,6 @@ function MOI.Bridges.inverse_map_set(
return MOI.RotatedSecondOrderCone(2)
end

function _rsoc_to_psd_too_small_message(n)
return "Unable to bridge RotatedSecondOrderCone to PSD because the " *
"dimension is too small: got $n, expected >= 2."
end

function MOI.Bridges.map_function(::Type{<:RSOCtoPSDBridge{T}}, func) where {T}
scalars = MOI.Utilities.eachscalar(func)
if length(scalars) < 2
Expand Down
45 changes: 19 additions & 26 deletions src/Bridges/Constraint/set_map.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@
abstract type MultiSetMapBridge{T,S1,G} <: AbstractBridge end
Same as `SetMapBridge` but the output constraint type does not only depend on
the input constraint type. When subtyping `MultiSetMapBridge`,
`added_constraint_types` and `supports` should additionally be implemented by
the bridge. For instance, if a bridge `BridgeType` may create either a
constraint of type `F2`-in-`S2` or `F3`-in-`S3`, these methods may be
implemented as follows:
the input constraint type.
When subtyping `MultiSetMapBridge`, `added_constraint_types` and `supports`
should additionally be implemented by the bridge.
For example, if a bridge `BridgeType` may create either a constraint of type
`F2`-in-`S2` or `F3`-in-`S3`, these methods should be implemented as follows:
```julia
function MOI.Bridges.added_constraint_types(
::Type{<:BridgeType{T,F2,F3}},
Expand All @@ -26,7 +28,7 @@ function MOI.supports(
::Type{<:BridgeType{T,F2,F3}},
) where {T,F2,F3}
return MOI.supports(model, attr, MOI.ConstraintIndex{F2,S2}) ||
MOI.supports(model, attr, MOI.ConstraintIndex{F3,S3})
MOI.supports(model, attr, MOI.ConstraintIndex{F3,S3})
end
```
"""
Expand Down Expand Up @@ -68,30 +70,21 @@ end

# Attributes, Bridge acting as a model

_get(::MOI.ConstraintIndex, ::MOI.NumberOfConstraints) = 0
_get(::MOI.ConstraintIndex{F,S}, ::MOI.NumberOfConstraints{F,S}) where {F,S} = 1
function _get(
::MOI.ConstraintIndex,
::MOI.ListOfConstraintIndices{F,S},
) where {F,S}
return MOI.ConstraintIndex{F,S}[]
end
function _get(
ci::MOI.ConstraintIndex{F,S},
::MOI.ListOfConstraintIndices{F,S},
) where {F,S}
return [ci]
end

function MOI.get(
bridge::MultiSetMapBridge,
attr::MOI.NumberOfConstraints,
)::Int64
return _get(bridge.constraint, attr)
::MOI.NumberOfConstraints{F,S},
)::Int64 where {F,S}
return bridge.constraint isa MOI.ConstraintIndex{F,S} ? 1 : 0
end

function MOI.get(bridge::MultiSetMapBridge, attr::MOI.ListOfConstraintIndices)
return _get(bridge.constraint, attr)
function MOI.get(
bridge::MultiSetMapBridge,
::MOI.ListOfConstraintIndices{F,S},
) where {F,S}
if bridge.constraint isa MOI.ConstraintIndex{F,S}
return MOI.ConstraintIndex{F,S}[bridge.constraint]
end
return MOI.ConstraintIndex{F,S}[]
end

# References
Expand Down

0 comments on commit 275f03a

Please sign in to comment.