8
8
abstract type MultiSetMapBridge{T,S1,G} <: AbstractBridge end
9
9
10
10
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:
16
18
```julia
17
19
function MOI.Bridges.added_constraint_types(
18
20
::Type{<:BridgeType{T,F2,F3}},
@@ -26,7 +28,7 @@ function MOI.supports(
26
28
::Type{<:BridgeType{T,F2,F3}},
27
29
) where {T,F2,F3}
28
30
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})
30
32
end
31
33
```
32
34
"""
68
70
69
71
# Attributes, Bridge acting as a model
70
72
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
-
86
73
function MOI. get (
87
74
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
91
78
end
92
79
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}[]
95
88
end
96
89
97
90
# References
0 commit comments