Skip to content

Commit e35c344

Browse files
committed
Update
1 parent 4b777a8 commit e35c344

File tree

1 file changed

+45
-6
lines changed

1 file changed

+45
-6
lines changed

src/Bridges/Variable/set_map.jl

Lines changed: 45 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,11 @@ function bridge_constrained_variable(
5050
model::MOI.ModelLike,
5151
set::S2,
5252
) where {T,S1,S2}
53-
variables, constraint =
54-
_add_constrained_var(model, MOI.Bridges.inverse_map_set(BT, set))
53+
# In a Variable.SetMapBridge:
54+
# map_set goes from Bridge -> User
55+
# inverse_map_set goes from User -> Bridge
56+
new_set = MOI.Bridges.inverse_map_set(BT, set)
57+
variables, constraint = _add_constrained_var(model, new_set)
5558
return BT(variables, constraint)
5659
end
5760

@@ -85,6 +88,9 @@ function MOI.get(
8588
if value === nothing
8689
return
8790
end
91+
# In a Variable.SetMapBridge:
92+
# map_function goes from Bridge -> User
93+
# inverse_map_function goes from User -> Bridge
8894
return MOI.Bridges.map_function(bridge, value)
8995
end
9096

@@ -98,6 +104,9 @@ function MOI.set(
98104
MOI.set(model, attr, bridge.constraint, nothing)
99105
return
100106
end
107+
# In a Variable.SetMapBridge:
108+
# map_function goes from Bridge -> User
109+
# inverse_map_function goes from User -> Bridge
101110
bridged_value = MOI.Bridges.inverse_map_function(bridge, value)
102111
MOI.set(model, attr, bridge.constraint, bridged_value)
103112
return
@@ -109,6 +118,9 @@ function MOI.get(
109118
bridge::SetMapBridge,
110119
)
111120
set = MOI.get(model, attr, bridge.constraint)
121+
# In a Variable.SetMapBridge:
122+
# map_set goes from Bridge -> User
123+
# inverse_map_set goes from User -> Bridge
112124
return MOI.Bridges.map_set(bridge, set)
113125
end
114126

@@ -118,8 +130,11 @@ function MOI.set(
118130
bridge::SetMapBridge{T,S1},
119131
set::S1,
120132
) where {T,S1}
121-
mapped = MOI.Bridges.inverse_map_set(bridge, set)
122-
MOI.set(model, attr, bridge.constraint, mapped)
133+
# In a Variable.SetMapBridge:
134+
# map_set goes from Bridge -> User
135+
# inverse_map_set goes from User -> Bridge
136+
mapped_set = MOI.Bridges.inverse_map_set(bridge, set)
137+
MOI.set(model, attr, bridge.constraint, mapped_set)
123138
return
124139
end
125140

@@ -132,7 +147,10 @@ function MOI.get(
132147
if value === nothing
133148
return
134149
end
135-
return MOI.Bridges.adjoint_map_function(bridge, value)
150+
# In a Variable.SetMapBridge:
151+
# inverse_adjoint_map_function goes from Bridge -> User
152+
# adjoint_map_function goes from User -> Bridge
153+
return MOI.Bridges.inverse_adjoint_map_function(bridge, value)
136154
end
137155

138156
function MOI.set(
@@ -145,7 +163,10 @@ function MOI.set(
145163
MOI.set(model, attr, bridge.constraint, nothing)
146164
return
147165
end
148-
bridged_value = MOI.Bridges.inverse_adjoint_map_function(bridge, value)
166+
# In a Variable.SetMapBridge:
167+
# inverse_adjoint_map_function goes from Bridge -> User
168+
# adjoint_map_function goes from User -> Bridge
169+
bridged_value = MOI.Bridges.adjoint_map_function(bridge, value)
149170
MOI.set(model, attr, bridge.constraint, bridged_value)
150171
return
151172
end
@@ -160,6 +181,9 @@ end
160181

161182
function unbridged_map(bridge::SetMapBridge{T}, vi::MOI.VariableIndex) where {T}
162183
F = MOI.ScalarAffineFunction{T}
184+
# In a Variable.SetMapBridge:
185+
# map_function goes from Bridge -> User
186+
# inverse_map_function goes from User -> Bridge
163187
mapped = MOI.Bridges.inverse_map_function(bridge, vi)
164188
return Pair{MOI.VariableIndex,F}[bridge.variable=>mapped]
165189
end
@@ -222,6 +246,9 @@ function MOI.get(
222246
if value === nothing
223247
return
224248
end
249+
# In a Variable.SetMapBridge:
250+
# map_function goes from Bridge -> User
251+
# inverse_map_function goes from User -> Bridge
225252
return MOI.Bridges.map_function(bridge, value)
226253
end
227254

@@ -235,6 +262,9 @@ function MOI.set(
235262
MOI.set(model, attr, bridge.variable, nothing)
236263
return
237264
end
265+
# In a Variable.SetMapBridge:
266+
# map_function goes from Bridge -> User
267+
# inverse_map_function goes from User -> Bridge
238268
bridged_value = MOI.Bridges.inverse_map_function(bridge, value)
239269
MOI.set(model, attr, bridge.variable, bridged_value)
240270
return
@@ -294,6 +324,9 @@ function MOI.get(
294324
if any(isnothing, value)
295325
return
296326
end
327+
# In a Variable.SetMapBridge:
328+
# map_function goes from Bridge -> User
329+
# inverse_map_function goes from User -> Bridge
297330
return MOI.Bridges.map_function(bridge, value, i)
298331
end
299332

@@ -308,6 +341,9 @@ function MOI.set(
308341
MOI.set(model, attr, bridge.variables[i.value], nothing)
309342
return
310343
end
344+
# In a Variable.SetMapBridge:
345+
# map_function goes from Bridge -> User
346+
# inverse_map_function goes from User -> Bridge
311347
bridged_value = MOI.Bridges.inverse_map_function(bridge, value)
312348
MOI.set(model, attr, bridge.variables[i.value], bridged_value)
313349
return
@@ -337,6 +373,9 @@ function unbridged_map(
337373
) where {T}
338374
F = MOI.ScalarAffineFunction{T}
339375
func = MOI.VectorOfVariables(vis)
376+
# In a Variable.SetMapBridge:
377+
# map_function goes from Bridge -> User
378+
# inverse_map_function goes from User -> Bridge
340379
funcs = MOI.Bridges.inverse_map_function(bridge, func)
341380
scalars = MOI.Utilities.eachscalar(funcs)
342381
# FIXME not correct for SetDotProducts, it won't recover the dot product variables

0 commit comments

Comments
 (0)