-
Notifications
You must be signed in to change notification settings - Fork 94
Closed
Labels
Milestone
Description
A key problem in LazyBridgeOptimizer is things like
variable_map::Variable.Map |
Two important definitions are
MathOptInterface.jl/src/Bridges/lazy_bridge_optimizer.jl
Lines 79 to 81 in 7923c60
function Variable.bridges(bridge::LazyBridgeOptimizer) | |
return bridge.variable_map | |
end |
has_bridges(map::Map) = !isempty(map.info) |
So in methods like
MathOptInterface.jl/src/Bridges/bridge_optimizer.jl
Lines 328 to 343 in 7923c60
function MOI.empty!(b::AbstractBridgeOptimizer) | |
MOI.empty!(b.model) | |
if Variable.has_bridges(Variable.bridges(b)) | |
empty!(b.var_to_name) | |
b.name_to_var = nothing | |
end | |
if Variable.has_bridges(Variable.bridges(b)) || | |
Constraint.has_bridges(Constraint.bridges(b)) | |
empty!(b.con_to_name) | |
b.name_to_con = nothing | |
end | |
empty!(Variable.bridges(b)) | |
empty!(Constraint.bridges(b)) | |
empty!(Objective.bridges(b)) | |
return | |
end |
the compiler has to do a run-time check to see if there are bridges.
If we made the field ::Union{Nothing,Map}
, the compiler may be clever enough to compile away the branches based on the Nothing
. As an alternative, we could pass map
as a function argument to force it to specialize.