Skip to content

Commit 275f03a

Browse files
committed
Update
1 parent 2203a18 commit 275f03a

File tree

3 files changed

+20
-31
lines changed

3 files changed

+20
-31
lines changed

docs/src/submodules/Bridges/reference.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ Bridges.Constraint.SingleBridgeOptimizer
3636
Bridges.Constraint.add_all_bridges
3737
Bridges.Constraint.FlipSignBridge
3838
Bridges.Constraint.AbstractToIntervalBridge
39+
Bridges.Constraint.MultiSetMapBridge
3940
Bridges.Constraint.SetMapBridge
4041
Bridges.Constraint.conversion_cost
4142
```

src/Bridges/Constraint/bridges/soc_to_psd.jl

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -244,11 +244,6 @@ function MOI.Bridges.inverse_map_set(
244244
return MOI.RotatedSecondOrderCone(2)
245245
end
246246

247-
function _rsoc_to_psd_too_small_message(n)
248-
return "Unable to bridge RotatedSecondOrderCone to PSD because the " *
249-
"dimension is too small: got $n, expected >= 2."
250-
end
251-
252247
function MOI.Bridges.map_function(::Type{<:RSOCtoPSDBridge{T}}, func) where {T}
253248
scalars = MOI.Utilities.eachscalar(func)
254249
if length(scalars) < 2

src/Bridges/Constraint/set_map.jl

Lines changed: 19 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,13 @@
88
abstract type MultiSetMapBridge{T,S1,G} <: AbstractBridge end
99
1010
Same as `SetMapBridge` but the output constraint type does not only depend on
11-
the input constraint type. When subtyping `MultiSetMapBridge`,
12-
`added_constraint_types` and `supports` should additionally be implemented by
13-
the bridge. For instance, if a bridge `BridgeType` may create either a
14-
constraint of type `F2`-in-`S2` or `F3`-in-`S3`, these methods may be
15-
implemented as follows:
11+
the input constraint type.
12+
13+
When subtyping `MultiSetMapBridge`, `added_constraint_types` and `supports`
14+
should additionally be implemented by the bridge.
15+
16+
For example, if a bridge `BridgeType` may create either a constraint of type
17+
`F2`-in-`S2` or `F3`-in-`S3`, these methods should be implemented as follows:
1618
```julia
1719
function MOI.Bridges.added_constraint_types(
1820
::Type{<:BridgeType{T,F2,F3}},
@@ -26,7 +28,7 @@ function MOI.supports(
2628
::Type{<:BridgeType{T,F2,F3}},
2729
) where {T,F2,F3}
2830
return MOI.supports(model, attr, MOI.ConstraintIndex{F2,S2}) ||
29-
MOI.supports(model, attr, MOI.ConstraintIndex{F3,S3})
31+
MOI.supports(model, attr, MOI.ConstraintIndex{F3,S3})
3032
end
3133
```
3234
"""
@@ -68,30 +70,21 @@ end
6870

6971
# Attributes, Bridge acting as a model
7072

71-
_get(::MOI.ConstraintIndex, ::MOI.NumberOfConstraints) = 0
72-
_get(::MOI.ConstraintIndex{F,S}, ::MOI.NumberOfConstraints{F,S}) where {F,S} = 1
73-
function _get(
74-
::MOI.ConstraintIndex,
75-
::MOI.ListOfConstraintIndices{F,S},
76-
) where {F,S}
77-
return MOI.ConstraintIndex{F,S}[]
78-
end
79-
function _get(
80-
ci::MOI.ConstraintIndex{F,S},
81-
::MOI.ListOfConstraintIndices{F,S},
82-
) where {F,S}
83-
return [ci]
84-
end
85-
8673
function MOI.get(
8774
bridge::MultiSetMapBridge,
88-
attr::MOI.NumberOfConstraints,
89-
)::Int64
90-
return _get(bridge.constraint, attr)
75+
::MOI.NumberOfConstraints{F,S},
76+
)::Int64 where {F,S}
77+
return bridge.constraint isa MOI.ConstraintIndex{F,S} ? 1 : 0
9178
end
9279

93-
function MOI.get(bridge::MultiSetMapBridge, attr::MOI.ListOfConstraintIndices)
94-
return _get(bridge.constraint, attr)
80+
function MOI.get(
81+
bridge::MultiSetMapBridge,
82+
::MOI.ListOfConstraintIndices{F,S},
83+
) where {F,S}
84+
if bridge.constraint isa MOI.ConstraintIndex{F,S}
85+
return MOI.ConstraintIndex{F,S}[bridge.constraint]
86+
end
87+
return MOI.ConstraintIndex{F,S}[]
9588
end
9689

9790
# References

0 commit comments

Comments
 (0)