55# in the LICENSE.md file or at https://opensource.org/licenses/MIT.
66
77"""
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)
823 map_set(::Type{BT}, set) where {BT}
924
1025Return 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).
1430"""
15- function map_set end
31+ map_set (bridge :: AbstractBridge , set) = map_set ( typeof (bridge), set)
1632
1733"""
34+ inverse_map_set(bridge::MOI.Bridges.AbstractBridge, set)
1835 inverse_map_set(::Type{BT}, set) where {BT}
1936
2037Return 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.
2344"""
24- function inverse_map_set end
45+ function inverse_map_set (bridge:: AbstractBridge , set)
46+ return inverse_map_set (typeof (bridge), set)
47+ end
2548
2649"""
50+ map_function(bridge::MOI.Bridges.AbstractBridge, func)
2751 map_function(::Type{BT}, func) where {BT}
2852
2953Return 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
3257bridges. 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).
3660
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+ """
3771 map_function(::Type{BT}, func, i::IndexInVector) where {BT}
3872
3973Return 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
4276the [`MOI.VariablePrimal`](@ref) and
4377[`MOI.VariablePrimalStart`](@ref) of variable bridges.
4478"""
45- function map_function end
46-
4779function map_function (:: Type{BT} , func, i:: IndexInVector ) where {BT}
4880 return MOI. Utilities. eachscalar (map_function (BT, func))[i. value]
4981end
5082
5183"""
84+ inverse_map_function(bridge::MOI.Bridges.AbstractBridge, func)
5285 inverse_map_function(::Type{BT}, func) where {BT}
5386
5487Return 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
6093[`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.
61100"""
62- function inverse_map_function end
101+ function inverse_map_function (bridge:: AbstractBridge , func)
102+ return inverse_map_function (typeof (bridge), func)
103+ end
63104
64105"""
106+ adjoint_map_function(bridge::MOI.Bridges.AbstractBridge, func)
65107 adjoint_map_function(::Type{BT}, func) where {BT}
66108
67109Return 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
70113[`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.
71117"""
72- function adjoint_map_function end
118+ function adjoint_map_function (bridge:: AbstractBridge , func)
119+ return adjoint_map_function (typeof (bridge), func)
120+ end
73121
74122"""
123+ inverse_adjoint_map_function(bridge::MOI.Bridges.AbstractBridge, func)
75124 inverse_adjoint_map_function(::Type{BT}, func) where {BT}
76125
77126Return 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.
82137"""
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