5
5
# in the LICENSE.md file or at https://opensource.org/licenses/MIT.
6
6
7
7
"""
8
+ struct MapNotInvertible <: Exception
9
+ message::String
10
+ end
11
+
12
+ An error thrown by [`inverse_map_function`](@ref) or
13
+ [`inverse_adjoint_map_function`](@ref) indicating that the linear map `A`
14
+ defined in [`Variable.SetMapBridge`](@ref) and [`Constraint.SetMapBridge`](@ref)
15
+ is not invertible.
16
+ """
17
+ struct MapNotInvertible <: Exception
18
+ message:: String
19
+ end
20
+
21
+ """
22
+ map_set(bridge::MOI.Bridges.AbstractBridge, set)
8
23
map_set(::Type{BT}, set) where {BT}
9
24
10
25
Return the image of `set` through the linear map `A` defined in
11
- [`Variable.SetMapBridge`](@ref) and [`Constraint.SetMapBridge`](@ref). This is
12
- used for bridging the constraint and setting
13
- the [`MOI.ConstraintSet`](@ref).
26
+ [`Variable.SetMapBridge`](@ref) and [`Constraint.SetMapBridge`](@ref).
27
+
28
+ This function is used for bridging the constraint and setting the
29
+ [`MOI.ConstraintSet`](@ref).
14
30
"""
15
- function map_set end
31
+ map_set (bridge :: AbstractBridge , set) = map_set ( typeof (bridge), set)
16
32
17
33
"""
34
+ inverse_map_set(bridge::MOI.Bridges.AbstractBridge, set)
18
35
inverse_map_set(::Type{BT}, set) where {BT}
19
36
20
37
Return the preimage of `set` through the linear map `A` defined in
21
- [`Variable.SetMapBridge`](@ref) and [`Constraint.SetMapBridge`](@ref). This is
22
- used for getting the [`MOI.ConstraintSet`](@ref).
38
+ [`Variable.SetMapBridge`](@ref) and [`Constraint.SetMapBridge`](@ref).
39
+
40
+ This function is used for getting the [`MOI.ConstraintSet`](@ref).
41
+
42
+ The method can alternatively be defined on the bridge type. This legacy
43
+ interface is kept for backward compatibility.
23
44
"""
24
- function inverse_map_set end
45
+ function inverse_map_set (bridge:: AbstractBridge , set)
46
+ return inverse_map_set (typeof (bridge), set)
47
+ end
25
48
26
49
"""
50
+ map_function(bridge::MOI.Bridges.AbstractBridge, func)
27
51
map_function(::Type{BT}, func) where {BT}
28
52
29
53
Return the image of `func` through the linear map `A` defined in
30
- [`Variable.SetMapBridge`](@ref) and [`Constraint.SetMapBridge`](@ref). This is
31
- used for getting the [`MOI.ConstraintPrimal`](@ref) of variable
54
+ [`Variable.SetMapBridge`](@ref) and [`Constraint.SetMapBridge`](@ref).
55
+
56
+ This function is used for getting the [`MOI.ConstraintPrimal`](@ref) of variable
32
57
bridges. For constraint bridges, this is used for bridging the constraint,
33
- setting the [`MOI.ConstraintFunction`](@ref) and
34
- [`MOI.ConstraintPrimalStart`](@ref) and
35
- modifying the function with [`MOI.modify`](@ref).
58
+ setting the [`MOI.ConstraintFunction`](@ref) and [`MOI.ConstraintPrimalStart`](@ref)
59
+ and modifying the function with [`MOI.modify`](@ref).
36
60
61
+ The default implementation of [`Constraint.bridge_constraint`](@ref) uses
62
+ [`map_function`](@ref) with the bridge type so if this function is defined
63
+ on the bridge type, [`Constraint.bridge_constraint`](@ref) does not need
64
+ to be implemented.
65
+ """
66
+ function map_function (bridge:: AbstractBridge , func)
67
+ return map_function (typeof (bridge), func)
68
+ end
69
+
70
+ """
37
71
map_function(::Type{BT}, func, i::IndexInVector) where {BT}
38
72
39
73
Return the scalar function at the `i`th index of the vector function that
@@ -42,42 +76,65 @@ would be returned by `map_function(BT, func)` except that it may compute the
42
76
the [`MOI.VariablePrimal`](@ref) and
43
77
[`MOI.VariablePrimalStart`](@ref) of variable bridges.
44
78
"""
45
- function map_function end
46
-
47
79
function map_function (:: Type{BT} , func, i:: IndexInVector ) where {BT}
48
80
return MOI. Utilities. eachscalar (map_function (BT, func))[i. value]
49
81
end
50
82
51
83
"""
84
+ inverse_map_function(bridge::MOI.Bridges.AbstractBridge, func)
52
85
inverse_map_function(::Type{BT}, func) where {BT}
53
86
54
87
Return the image of `func` through the inverse of the linear map `A` defined in
55
- [`Variable.SetMapBridge`](@ref) and [`Constraint.SetMapBridge`](@ref). This is
56
- used by [`Variable.unbridged_map`](@ref) and for setting the
57
- [`MOI.VariablePrimalStart `](@ref) of variable bridges
58
- and for getting the [`MOI.ConstraintFunction `](@ref),
59
- the [`MOI.ConstraintPrimal`](@ref) and the
88
+ [`Variable.SetMapBridge`](@ref) and [`Constraint.SetMapBridge`](@ref).
89
+
90
+ This function is used by [`Variable.unbridged_map `](@ref) and for setting the
91
+ [`MOI.VariablePrimalStart `](@ref) of variable bridges and for getting the
92
+ [`MOI.ConstraintFunction`](@ref), the [`MOI.ConstraintPrimal`](@ref) and the
60
93
[`MOI.ConstraintPrimalStart`](@ref) of constraint bridges.
94
+
95
+ If the linear map `A` is not invertible, the error [`MapNotInvertible`](@ref) is
96
+ thrown.
97
+
98
+ The method can alternatively be defined on the bridge type. This legacy
99
+ interface is kept for backward compatibility.
61
100
"""
62
- function inverse_map_function end
101
+ function inverse_map_function (bridge:: AbstractBridge , func)
102
+ return inverse_map_function (typeof (bridge), func)
103
+ end
63
104
64
105
"""
106
+ adjoint_map_function(bridge::MOI.Bridges.AbstractBridge, func)
65
107
adjoint_map_function(::Type{BT}, func) where {BT}
66
108
67
109
Return the image of `func` through the adjoint of the linear map `A` defined in
68
- [`Variable.SetMapBridge`](@ref) and [`Constraint.SetMapBridge`](@ref). This is
69
- used for getting the [`MOI.ConstraintDual`](@ref) and
110
+ [`Variable.SetMapBridge`](@ref) and [`Constraint.SetMapBridge`](@ref).
111
+
112
+ This function is used for getting the [`MOI.ConstraintDual`](@ref) and
70
113
[`MOI.ConstraintDualStart`](@ref) of constraint bridges.
114
+
115
+ The method can alternatively be defined on the bridge type. This legacy
116
+ interface is kept for backward compatibility.
71
117
"""
72
- function adjoint_map_function end
118
+ function adjoint_map_function (bridge:: AbstractBridge , func)
119
+ return adjoint_map_function (typeof (bridge), func)
120
+ end
73
121
74
122
"""
123
+ inverse_adjoint_map_function(bridge::MOI.Bridges.AbstractBridge, func)
75
124
inverse_adjoint_map_function(::Type{BT}, func) where {BT}
76
125
77
126
Return the image of `func` through the inverse of the adjoint of the linear map
78
- `A` defined in [`Variable.SetMapBridge`](@ref) and
79
- [`Constraint.SetMapBridge`](@ref). This is used for getting the
80
- [`MOI.ConstraintDual`](@ref) of variable bridges and setting the
81
- [`MOI.ConstraintDualStart`](@ref) of constraint bridges.
127
+ `A` defined in [`Variable.SetMapBridge`](@ref) and [`Constraint.SetMapBridge`](@ref).
128
+
129
+ This function is used for getting the [`MOI.ConstraintDual`](@ref) of variable
130
+ bridges and setting the [`MOI.ConstraintDualStart`](@ref) of constraint bridges.
131
+
132
+ If the linear map `A` is not invertible, the error [`MapNotInvertible`](@ref) is
133
+ thrown.
134
+
135
+ The method can alternatively be defined on the bridge type. This legacy
136
+ interface is kept for backward compatibility.
82
137
"""
83
- function inverse_adjoint_map_function end
138
+ function inverse_adjoint_map_function (bridge:: AbstractBridge , func)
139
+ return inverse_adjoint_map_function (typeof (bridge), func)
140
+ end
0 commit comments