File tree Expand file tree Collapse file tree 2 files changed +25
-2
lines changed Expand file tree Collapse file tree 2 files changed +25
-2
lines changed Original file line number Diff line number Diff line change @@ -102,7 +102,15 @@ function MOI.get(
102102 bridge:: MultiSetMapBridge{T,S1,G} ,
103103) where {T,S1,G}
104104 mapped_func = MOI. get (model, attr, bridge. constraint)
105- func = MOI. Bridges. inverse_map_function (bridge, mapped_func)
105+ func = try
106+ MOI. Bridges. inverse_map_function (bridge, mapped_func)
107+ catch err
108+ if err isa MOI. Bridges. MapNotInvertible
109+ throw (MOI. GetAttributeNotAllowed (attr))
110+ else
111+ rethrow (err)
112+ end
113+ end
106114 return MOI. Utilities. convert_approx (G, func)
107115end
108116
@@ -146,7 +154,16 @@ function MOI.get(
146154 if value === nothing
147155 return nothing
148156 end
149- return MOI. Bridges. inverse_map_function (bridge, value)
157+ return try
158+ MOI. Bridges. inverse_map_function (bridge, value)
159+ catch err
160+ if err isa MOI. Bridges. MapNotInvertible
161+ throw (MOI. GetAttributeNotAllowed (attr))
162+ else
163+ rethrow (err)
164+ end
165+ end
166+
150167end
151168
152169function MOI. set (
Original file line number Diff line number Diff line change 44# Use of this source code is governed by an MIT-style license that can be found
55# in the LICENSE.md file or at https://opensource.org/licenses/MIT.
66
7+ struct MapNotInvertible <: Exception end
8+
79"""
810 map_set(::Type{BT}, set) where {BT}
911
@@ -44,6 +46,10 @@ the [`MOI.VariablePrimal`](@ref) and
4446"""
4547function map_function end
4648
49+ function map_function (bridge:: AbstractBridge , func)
50+ return map_function (typeof (bridge), func)
51+ end
52+
4753function map_function (:: Type{BT} , func, i:: IndexInVector ) where {BT}
4854 return MOI. Utilities. eachscalar (map_function (BT, func))[i. value]
4955end
You can’t perform that action at this time.
0 commit comments