@@ -149,54 +149,52 @@ function _reset_bridge_graph(b::LazyBridgeOptimizer)
149
149
return
150
150
end
151
151
152
- @nospecialize
153
152
"""
154
153
_variable_nodes(b::LazyBridgeOptimizer, ::Type{BT}) where {BT}
155
154
156
155
Return the list of `VariableNode` that would be added if `BT` is used in `b`.
157
156
"""
158
157
function _variable_nodes (
159
- b:: LazyBridgeOptimizer ,
160
- :: Type{BT} ,
161
- ) where {BT <: AbstractBridge }
158
+ @nospecialize ( b:: LazyBridgeOptimizer ) ,
159
+ @nospecialize (BT :: Type{<:AbstractBridge} ) ,
160
+ )
162
161
return map (added_constrained_variable_types (BT)) do (S,)
163
162
return node (b, S):: VariableNode
164
163
end
165
164
end
166
- @specialize
167
165
168
- @nospecialize
169
166
"""
170
167
_constraint_nodes(b::LazyBridgeOptimizer, ::Type{BT}) where {BT}
171
168
172
169
Return the list of `ConstraintNode` that would be added if `BT` is used in `b`.
173
170
"""
174
171
function _constraint_nodes (
175
- b:: LazyBridgeOptimizer ,
176
- :: Type{BT} ,
177
- ) where {BT <: AbstractBridge }
172
+ @nospecialize ( b:: LazyBridgeOptimizer ) ,
173
+ @nospecialize (BT :: Type{<:AbstractBridge} ) ,
174
+ )
178
175
return ConstraintNode[
179
176
node (b, F, S) for (F, S) in added_constraint_types (BT)
180
177
]
181
178
end
182
- @specialize
183
179
184
- @nospecialize
185
180
"""
186
181
_edge(b::LazyBridgeOptimizer, index::Int, BT::Type{<:AbstractBridge})
187
182
188
183
Return the `Edge` or `ObjectiveEdge` in the hyper-graph associated with the
189
184
bridge `BT`, where `index` is the index of `BT` in the list of bridges.
190
185
"""
191
- function _edge (b:: LazyBridgeOptimizer , index:: Int , BT:: Type{<:AbstractBridge} )
186
+ function _edge (
187
+ @nospecialize (b:: LazyBridgeOptimizer ),
188
+ @nospecialize (index:: Int ),
189
+ @nospecialize (BT:: Type{<:AbstractBridge} ),
190
+ )
192
191
return Edge (
193
192
index,
194
193
_variable_nodes (b, BT),
195
194
_constraint_nodes (b, BT),
196
195
bridging_cost (BT),
197
196
)
198
197
end
199
- @specialize
200
198
201
199
# Method for objective bridges because they produce ObjectiveEdge.
202
200
function _edge (
310
308
Return the `ConstraintNode` associated with constraint `F`-in-`S` in `b`.
311
309
"""
312
310
function node (
313
- b:: LazyBridgeOptimizer ,
314
- F:: Type{<:MOI.AbstractFunction} ,
315
- S:: Type{<:MOI.AbstractSet} ,
311
+ @nospecialize ( b:: LazyBridgeOptimizer ) ,
312
+ @nospecialize ( F:: Type{<:MOI.AbstractFunction} ) ,
313
+ @nospecialize ( S:: Type{<:MOI.AbstractSet} ) ,
316
314
)
317
315
# If we support the constraint type, the node is 0.
318
316
if MOI. supports_constraint (b. model, F, S)
@@ -382,14 +380,12 @@ function _bridge_types(
382
380
return b. variable_bridge_types
383
381
end
384
382
385
- @nospecialize
386
383
function _bridge_types (
387
- b:: LazyBridgeOptimizer ,
388
- :: Type{<:Constraint.AbstractBridge} ,
384
+ @nospecialize ( b:: LazyBridgeOptimizer ) ,
385
+ @nospecialize (BT :: Type{<:Constraint.AbstractBridge} ) ,
389
386
)
390
387
return b. constraint_bridge_types
391
388
end
392
- @specialize
393
389
394
390
function _bridge_types (
395
391
b:: LazyBridgeOptimizer ,
@@ -398,20 +394,21 @@ function _bridge_types(
398
394
return b. objective_bridge_types
399
395
end
400
396
401
- @nospecialize
402
397
"""
403
398
add_bridge(b::LazyBridgeOptimizer, BT::Type{<:AbstractBridge})
404
399
405
400
Enable the use of the bridges of type `BT` by `b`.
406
401
"""
407
- function add_bridge (b:: LazyBridgeOptimizer , BT:: Type{<:AbstractBridge} )
402
+ function add_bridge (
403
+ @nospecialize (b:: LazyBridgeOptimizer ),
404
+ @nospecialize (BT:: Type{<:AbstractBridge} ),
405
+ )
408
406
if ! has_bridge (b, BT)
409
407
push! (_bridge_types (b, BT), BT)
410
408
_reset_bridge_graph (b)
411
409
end
412
410
return
413
411
end
414
- @specialize
415
412
416
413
"""
417
414
remove_bridge(b::LazyBridgeOptimizer, BT::Type{<:AbstractBridge})
@@ -432,16 +429,17 @@ function remove_bridge(b::LazyBridgeOptimizer, BT::Type{<:AbstractBridge})
432
429
return
433
430
end
434
431
435
- @nospecialize
436
432
"""
437
433
has_bridge(b::LazyBridgeOptimizer, BT::Type{<:AbstractBridge})
438
434
439
435
Return a `Bool` indicating whether the bridges of type `BT` are used by `b`.
440
436
"""
441
- function has_bridge (b:: LazyBridgeOptimizer , BT:: Type{<:AbstractBridge} ):: Bool
437
+ function has_bridge (
438
+ @nospecialize (b:: LazyBridgeOptimizer ),
439
+ @nospecialize (BT:: Type{<:AbstractBridge} ),
440
+ ):: Bool
442
441
return findfirst (isequal (BT), _bridge_types (b, BT)) != = nothing
443
442
end
444
- @specialize
445
443
446
444
# It only bridges when the constraint is not supporting, hence the name "Lazy"
447
445
function is_bridged (b:: LazyBridgeOptimizer , S:: Type{<:MOI.AbstractScalarSet} )
0 commit comments