Skip to content

Commit 4ca120b

Browse files
committed
Update
1 parent aee9ec2 commit 4ca120b

File tree

6 files changed

+40
-50
lines changed

6 files changed

+40
-50
lines changed

src/Bridges/Constraint/bridge.jl

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ additionally implement:
1919
"""
2020
abstract type AbstractBridge <: MOI.Bridges.AbstractBridge end
2121

22-
@nospecialize
2322
"""
2423
MOI.supports_constraint(
2524
BT::Type{<:AbstractBridge},
@@ -37,13 +36,12 @@ Return a `Bool` indicating whether the bridges of type `BT` support bridging
3736
constraint types that the bridge implements.
3837
"""
3938
function MOI.supports_constraint(
40-
::Type{<:AbstractBridge},
41-
::Type{<:MOI.AbstractFunction},
42-
::Type{<:MOI.AbstractSet},
39+
@nospecialize(BT::Type{<:AbstractBridge}),
40+
@nospecialize(F::Type{<:MOI.AbstractFunction}),
41+
@nospecialize(S::Type{<:MOI.AbstractSet}),
4342
)
4443
return false
4544
end
46-
@specialize
4745

4846
"""
4947
concrete_bridge_type(

src/Bridges/Constraint/single_bridge_optimizer.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,9 @@ function MOI.Bridges.supports_bridging_constrained_variable(
105105
end
106106

107107
function MOI.Bridges.supports_bridging_constraint(
108-
::SingleBridgeOptimizer{BT},
109-
F::Type{<:MOI.AbstractFunction},
110-
S::Type{<:MOI.AbstractSet},
108+
@nospecialize(b::SingleBridgeOptimizer{BT}),
109+
@nospecialize(F::Type{<:MOI.AbstractFunction}),
110+
@nospecialize(S::Type{<:MOI.AbstractSet}),
111111
) where {BT}
112112
return MOI.supports_constraint(BT, F, S)
113113
end

src/Bridges/lazy_bridge_optimizer.jl

Lines changed: 24 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -149,54 +149,52 @@ function _reset_bridge_graph(b::LazyBridgeOptimizer)
149149
return
150150
end
151151

152-
@nospecialize
153152
"""
154153
_variable_nodes(b::LazyBridgeOptimizer, ::Type{BT}) where {BT}
155154
156155
Return the list of `VariableNode` that would be added if `BT` is used in `b`.
157156
"""
158157
function _variable_nodes(
159-
b::LazyBridgeOptimizer,
160-
::Type{BT},
161-
) where {BT<:AbstractBridge}
158+
@nospecialize(b::LazyBridgeOptimizer),
159+
@nospecialize(BT::Type{<:AbstractBridge}),
160+
)
162161
return map(added_constrained_variable_types(BT)) do (S,)
163162
return node(b, S)::VariableNode
164163
end
165164
end
166-
@specialize
167165

168-
@nospecialize
169166
"""
170167
_constraint_nodes(b::LazyBridgeOptimizer, ::Type{BT}) where {BT}
171168
172169
Return the list of `ConstraintNode` that would be added if `BT` is used in `b`.
173170
"""
174171
function _constraint_nodes(
175-
b::LazyBridgeOptimizer,
176-
::Type{BT},
177-
) where {BT<:AbstractBridge}
172+
@nospecialize(b::LazyBridgeOptimizer),
173+
@nospecialize(BT::Type{<:AbstractBridge}),
174+
)
178175
return ConstraintNode[
179176
node(b, F, S) for (F, S) in added_constraint_types(BT)
180177
]
181178
end
182-
@specialize
183179

184-
@nospecialize
185180
"""
186181
_edge(b::LazyBridgeOptimizer, index::Int, BT::Type{<:AbstractBridge})
187182
188183
Return the `Edge` or `ObjectiveEdge` in the hyper-graph associated with the
189184
bridge `BT`, where `index` is the index of `BT` in the list of bridges.
190185
"""
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+
)
192191
return Edge(
193192
index,
194193
_variable_nodes(b, BT),
195194
_constraint_nodes(b, BT),
196195
bridging_cost(BT),
197196
)
198197
end
199-
@specialize
200198

201199
# Method for objective bridges because they produce ObjectiveEdge.
202200
function _edge(
@@ -310,9 +308,9 @@ end
310308
Return the `ConstraintNode` associated with constraint `F`-in-`S` in `b`.
311309
"""
312310
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}),
316314
)
317315
# If we support the constraint type, the node is 0.
318316
if MOI.supports_constraint(b.model, F, S)
@@ -382,14 +380,12 @@ function _bridge_types(
382380
return b.variable_bridge_types
383381
end
384382

385-
@nospecialize
386383
function _bridge_types(
387-
b::LazyBridgeOptimizer,
388-
::Type{<:Constraint.AbstractBridge},
384+
@nospecialize(b::LazyBridgeOptimizer),
385+
@nospecialize(BT::Type{<:Constraint.AbstractBridge}),
389386
)
390387
return b.constraint_bridge_types
391388
end
392-
@specialize
393389

394390
function _bridge_types(
395391
b::LazyBridgeOptimizer,
@@ -398,20 +394,21 @@ function _bridge_types(
398394
return b.objective_bridge_types
399395
end
400396

401-
@nospecialize
402397
"""
403398
add_bridge(b::LazyBridgeOptimizer, BT::Type{<:AbstractBridge})
404399
405400
Enable the use of the bridges of type `BT` by `b`.
406401
"""
407-
function add_bridge(b::LazyBridgeOptimizer, BT::Type{<:AbstractBridge})
402+
function add_bridge(
403+
@nospecialize(b::LazyBridgeOptimizer),
404+
@nospecialize(BT::Type{<:AbstractBridge}),
405+
)
408406
if !has_bridge(b, BT)
409407
push!(_bridge_types(b, BT), BT)
410408
_reset_bridge_graph(b)
411409
end
412410
return
413411
end
414-
@specialize
415412

416413
"""
417414
remove_bridge(b::LazyBridgeOptimizer, BT::Type{<:AbstractBridge})
@@ -432,16 +429,17 @@ function remove_bridge(b::LazyBridgeOptimizer, BT::Type{<:AbstractBridge})
432429
return
433430
end
434431

435-
@nospecialize
436432
"""
437433
has_bridge(b::LazyBridgeOptimizer, BT::Type{<:AbstractBridge})
438434
439435
Return a `Bool` indicating whether the bridges of type `BT` are used by `b`.
440436
"""
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
442441
return findfirst(isequal(BT), _bridge_types(b, BT)) !== nothing
443442
end
444-
@specialize
445443

446444
# It only bridges when the constraint is not supporting, hence the name "Lazy"
447445
function is_bridged(b::LazyBridgeOptimizer, S::Type{<:MOI.AbstractScalarSet})

src/Test/Test.jl

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -499,17 +499,15 @@ function _test_attribute_value_type(
499499
return
500500
end
501501

502-
@nospecialize
503502
function _test_attribute_value_type(
504-
model::MOI.ModelLike,
505-
attribute::MOI.AbstractConstraintAttribute,
506-
ci::MOI.ConstraintIndex,
503+
@nospecialize(model::MOI.ModelLike),
504+
@nospecialize(attribute::MOI.AbstractConstraintAttribute),
505+
@nospecialize(ci::MOI.ConstraintIndex),
507506
)
508507
T = MOI.attribute_value_type(attribute)
509508
@test @inferred(T, MOI.get(model, attribute, ci)) isa T
510509
return
511510
end
512-
@specialize
513511

514512
function _test_attribute_value_type(
515513
model::MOI.ModelLike,

src/Utilities/model.jl

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -302,15 +302,13 @@ function MOI.is_valid(model::AbstractModel, ci::MOI.ConstraintIndex)
302302
return MOI.is_valid(constraints(model, ci), ci)
303303
end
304304

305-
@nospecialize
306305
function MOI.supports_constraint(
307-
model::AbstractModel,
308-
::Type{F},
309-
::Type{S},
310-
) where {F<:MOI.AbstractFunction,S<:MOI.AbstractSet}
306+
@nospecialize(model::AbstractModel),
307+
@nospecialize(F::Type{<:MOI.AbstractFunction}),
308+
@nospecialize(S::Type{<:MOI.AbstractSet}),
309+
)
311310
return MOI.supports_constraint(model.constraints, F, S)
312311
end
313-
@specialize
314312

315313
function MOI.add_constraint(
316314
model::AbstractModel,

src/constraints.jl

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
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-
@nospecialize
87
"""
98
supports_constraint(
109
model::ModelLike,
@@ -19,13 +18,12 @@ supported in specific circumstances, for example, `F`-in-`S` constraints cannot
1918
combined with another type of constraint, it should still return `true`.
2019
"""
2120
function supports_constraint(
22-
::ModelLike,
23-
::Type{<:AbstractFunction},
24-
::Type{<:AbstractSet},
21+
@nospecialize(::ModelLike),
22+
@nospecialize(F::Type{<:AbstractFunction}),
23+
@nospecialize(S::Type{<:AbstractSet}),
2524
)
2625
return false
2726
end
28-
@specialize
2927

3028
"""
3129
struct UnsupportedConstraint{F<:AbstractFunction,S<:AbstractSet} <: UnsupportedError

0 commit comments

Comments
 (0)