Skip to content

Commit 0134a7c

Browse files
committed
isbridged -> is_bridged
1 parent 8694f95 commit 0134a7c

File tree

4 files changed

+29
-29
lines changed

4 files changed

+29
-29
lines changed

src/Bridges/bridgeoptimizer.jl

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -16,28 +16,28 @@ abstract type AbstractBridgeOptimizer <: MOI.AbstractOptimizer end
1616
# AbstractBridgeOptimizer interface
1717

1818
"""
19-
isbridged(b::AbstractBridgeOptimizer, F::Type{<:MOI.AbstractFunction},
19+
is_bridged(b::AbstractBridgeOptimizer, F::Type{<:MOI.AbstractFunction},
2020
S::Type{<:MOI.AbstractSet})::Bool
2121
2222
Return a `Bool` indicating whether `b` tries to bridge `F`-in-`S` constraints
2323
instead of passing it as is to its internal model.
2424
"""
25-
function isbridged end
25+
function is_bridged end
2626
# Syntactic sugar
27-
function isbridged(b::AbstractBridgeOptimizer, ::Type{CI{F, S}}) where {F, S}
28-
return isbridged(b, F, S)
27+
function is_bridged(b::AbstractBridgeOptimizer, ::Type{CI{F, S}}) where {F, S}
28+
return is_bridged(b, F, S)
2929
end
3030
# We don't bridge variables.
31-
isbridged(b::AbstractBridgeOptimizer, ::Type{VI}) = false
31+
is_bridged(b::AbstractBridgeOptimizer, ::Type{VI}) = false
3232

3333
"""
34-
supportsbridgingconstraint(b::AbstractBridgeOptimizer,
34+
supports_bridging_constraint(b::AbstractBridgeOptimizer,
3535
F::Type{<:MOI.AbstractFunction},
3636
S::Type{<:MOI.AbstractSet})::Bool
3737
3838
Return a `Bool` indicating whether `b` supports bridging `F`-in-`S` constraints.
3939
"""
40-
function supportsbridgingconstraint(::AbstractBridgeOptimizer,
40+
function supports_bridging_constraint(::AbstractBridgeOptimizer,
4141
::Type{<:MOI.AbstractFunction},
4242
::Type{<:MOI.AbstractSet})
4343
return false
@@ -49,7 +49,7 @@ end
4949
S::Type{<:MOI.AbstractSet})
5050
5151
Return the `AbstractBridge` type to be used to bridge `F`-in-`S` constraints.
52-
This function should only be called if `isbridged(b, F, S)`.
52+
This function should only be called if `is_bridged(b, F, S)`.
5353
"""
5454
function bridge_type end
5555

@@ -94,15 +94,15 @@ end
9494
# References
9595
MOI.is_valid(b::AbstractBridgeOptimizer, vi::VI) = MOI.is_valid(b.model, vi)
9696
function MOI.is_valid(b::AbstractBridgeOptimizer, ci::CI)
97-
if isbridged(b, typeof(ci))
97+
if is_bridged(b, typeof(ci))
9898
return MOI.is_valid(b.bridged, ci)
9999
else
100100
return MOI.is_valid(b.model, ci)
101101
end
102102
end
103103
MOI.delete(b::AbstractBridgeOptimizer, vi::VI) = MOI.delete(b.model, vi)
104104
function MOI.delete(b::AbstractBridgeOptimizer, ci::CI)
105-
if isbridged(b, typeof(ci))
105+
if is_bridged(b, typeof(ci))
106106
if !MOI.is_valid(b, ci)
107107
throw(MOI.InvalidIndex(ci))
108108
end
@@ -117,7 +117,7 @@ end
117117
# Attributes
118118
function MOI.get(b::AbstractBridgeOptimizer,
119119
attr::MOI.ListOfConstraintIndices{F, S}) where {F, S}
120-
if isbridged(b, F, S)
120+
if is_bridged(b, F, S)
121121
list = MOI.get(b.bridged, attr)
122122
else
123123
list = MOI.get(b.model, attr)
@@ -145,7 +145,7 @@ function MOI.get(b::AbstractBridgeOptimizer, attr::MOI.NumberOfVariables)
145145
end
146146
function MOI.get(b::AbstractBridgeOptimizer,
147147
attr::MOI.NumberOfConstraints{F, S}) where {F, S}
148-
if isbridged(b, F, S)
148+
if is_bridged(b, F, S)
149149
# The constraints contained in `b.bridged` may have been added by
150150
# bridges
151151
return _numberof(b, b.bridged, attr)
@@ -209,7 +209,7 @@ end
209209
function MOI.get(b::AbstractBridgeOptimizer,
210210
attr::MOI.AbstractConstraintAttribute,
211211
ci::CI)
212-
if isbridged(b, typeof(ci))
212+
if is_bridged(b, typeof(ci))
213213
if MOIU.is_result_attribute(attr)
214214
MOI.get(b, attr, bridge(b, ci))
215215
else
@@ -222,15 +222,15 @@ end
222222
## Setting names
223223
function MOI.supports(b::AbstractBridgeOptimizer, attr::MOI.ConstraintName,
224224
Index::Type{<:CI})
225-
if isbridged(b, Index)
225+
if is_bridged(b, Index)
226226
return MOI.supports(b.bridged, attr, Index)
227227
else
228228
return MOI.supports(b.model, attr, Index)
229229
end
230230
end
231231
function MOI.set(b::AbstractBridgeOptimizer, attr::MOI.ConstraintName,
232232
constraint_index::CI, name::String)
233-
if isbridged(b, typeof(constraint_index))
233+
if is_bridged(b, typeof(constraint_index))
234234
MOI.set(b.bridged, attr, constraint_index, name)
235235
else
236236
MOI.set(b.model, attr, constraint_index, name)
@@ -240,7 +240,7 @@ end
240240
function MOI.supports(b::AbstractBridgeOptimizer,
241241
attr::Union{MOI.ConstraintFunction, MOI.ConstraintSet},
242242
::Type{CI{F, S}}) where {F, S}
243-
if isbridged(b, CI{F, S})
243+
if is_bridged(b, CI{F, S})
244244
return MOI.supports(b.bridged, attr, CI{F, S}) &&
245245
MOI.supports(b, attr, concrete_bridge_type(b, F, S))
246246
else
@@ -249,7 +249,7 @@ function MOI.supports(b::AbstractBridgeOptimizer,
249249
end
250250
function MOI.set(b::AbstractBridgeOptimizer, ::MOI.ConstraintSet,
251251
constraint_index::CI{F, S}, set::S) where {F, S}
252-
if isbridged(b, typeof(constraint_index))
252+
if is_bridged(b, typeof(constraint_index))
253253
MOI.set(b, MOI.ConstraintSet(), bridge(b, constraint_index), set)
254254
MOI.set(b.bridged, MOI.ConstraintSet(), constraint_index, set)
255255
else
@@ -258,7 +258,7 @@ function MOI.set(b::AbstractBridgeOptimizer, ::MOI.ConstraintSet,
258258
end
259259
function MOI.set(b::AbstractBridgeOptimizer, ::MOI.ConstraintFunction,
260260
constraint_index::CI{F, S}, func::F) where {F, S}
261-
if isbridged(b, typeof(constraint_index))
261+
if is_bridged(b, typeof(constraint_index))
262262
MOI.set(b, MOI.ConstraintFunction(), bridge(b, constraint_index), func)
263263
MOI.set(b.bridged, MOI.ConstraintFunction(), constraint_index, func)
264264
else
@@ -269,7 +269,7 @@ end
269269
# Name
270270
function MOI.get(b::AbstractBridgeOptimizer, IdxT::Type{<:MOI.Index},
271271
name::String)
272-
if isbridged(b, IdxT)
272+
if is_bridged(b, IdxT)
273273
return MOI.get(b.bridged, IdxT, name)
274274
else
275275
return MOI.get(b.model, IdxT, name)
@@ -292,16 +292,16 @@ end
292292
function MOI.supports_constraint(b::AbstractBridgeOptimizer,
293293
F::Type{<:MOI.AbstractFunction},
294294
S::Type{<:MOI.AbstractSet})
295-
if isbridged(b, F, S)
296-
return supportsbridgingconstraint(b, F, S) &&
295+
if is_bridged(b, F, S)
296+
return supports_bridging_constraint(b, F, S) &&
297297
MOI.supports_constraint(b.bridged, F, S)
298298
else
299299
return MOI.supports_constraint(b.model, F, S)
300300
end
301301
end
302302
function MOI.add_constraint(b::AbstractBridgeOptimizer, f::MOI.AbstractFunction,
303303
s::MOI.AbstractSet)
304-
if isbridged(b, typeof(f), typeof(s))
304+
if is_bridged(b, typeof(f), typeof(s))
305305
ci = MOI.add_constraint(b.bridged, f, s)
306306
@assert !haskey(b.bridges, ci)
307307
b.bridges[ci] = concrete_bridge_type(b, typeof(f), typeof(s))(b, f, s)
@@ -312,7 +312,7 @@ function MOI.add_constraint(b::AbstractBridgeOptimizer, f::MOI.AbstractFunction,
312312
end
313313
function MOI.modify(b::AbstractBridgeOptimizer, ci::CI,
314314
change::MOI.AbstractFunctionModification)
315-
if isbridged(b, typeof(ci))
315+
if is_bridged(b, typeof(ci))
316316
MOI.modify(b, bridge(b, ci), change)
317317
MOI.modify(b.bridged, ci, change)
318318
else

src/Bridges/lazybridgeoptimizer.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,10 @@ function add_bridge(b::LazyBridgeOptimizer, BT::Type{<:AbstractBridge})
9696
end
9797

9898
# It only bridges when the constraint is not supporting, hence the name "Lazy"
99-
function isbridged(b::LazyBridgeOptimizer, F::Type{<:MOI.AbstractFunction}, S::Type{<:MOI.AbstractSet})
99+
function is_bridged(b::LazyBridgeOptimizer, F::Type{<:MOI.AbstractFunction}, S::Type{<:MOI.AbstractSet})
100100
!MOI.supports_constraint(b.model, F, S)
101101
end
102-
function supportsbridgingconstraint(b::LazyBridgeOptimizer, F::Type{<:MOI.AbstractFunction}, S::Type{<:MOI.AbstractSet})
102+
function supports_bridging_constraint(b::LazyBridgeOptimizer, F::Type{<:MOI.AbstractFunction}, S::Type{<:MOI.AbstractSet})
103103
update_constraint!(b, F, S)
104104
(F, S) in keys(b.best)
105105
end

src/Bridges/singlebridgeoptimizer.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ function SingleBridgeOptimizer{BT, MT}(model::OT) where {BT, MT, OT <: MOI.Model
1313
SingleBridgeOptimizer{BT, MT, OT}(model, MT(), Dict{CI, BT}())
1414
end
1515

16-
isbridged(b::SingleBridgeOptimizer, ::Type{<:MOI.AbstractFunction}, ::Type{<:MOI.AbstractSet}) = false
16+
is_bridged(b::SingleBridgeOptimizer, ::Type{<:MOI.AbstractFunction}, ::Type{<:MOI.AbstractSet}) = false
1717
bridge_type(b::SingleBridgeOptimizer{BT}, F::Type{<:MOI.AbstractFunction}, S::Type{<:MOI.AbstractSet}) where BT = BT
1818

1919
# :((Zeros, SecondOrderCone)) -> (:(MOI.Zeros), :(MOI.SecondOrderCone))
@@ -45,7 +45,7 @@ macro bridge(modelname, bridge, ss, sst, vs, vst, sf, sft, vf, vft)
4545
esc(quote
4646
$MOIU.@model $bridgedmodelname $ss $sst $vs $vst $sf $sft $vf $vft
4747
const $modelname{T, OT<:MOI.ModelLike} = $MOIB.SingleBridgeOptimizer{$bridge{T}, $bridgedmodelname{T}, OT}
48-
isbridged(::$modelname, ::Type{<:$bridgedfuns}, ::Type{<:$bridgedsets}) = true
49-
supportsbridgingconstraint(::$modelname, ::Type{<:$bridgedfuns}, ::Type{<:$bridgedsets}) = true
48+
is_bridged(::$modelname, ::Type{<:$bridgedfuns}, ::Type{<:$bridgedsets}) = true
49+
supports_bridging_constraint(::$modelname, ::Type{<:$bridgedfuns}, ::Type{<:$bridgedsets}) = true
5050
end)
5151
end

test/bridge.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ end
7272

7373
@testset "Custom test" begin
7474
model = MOIB.SplitInterval{Int}(SimpleModel{Int}())
75-
@test !MOIB.supportsbridgingconstraint(model, MOI.VectorAffineFunction{Float64}, MOI.Interval{Float64})
75+
@test !MOIB.supports_bridging_constraint(model, MOI.VectorAffineFunction{Float64}, MOI.Interval{Float64})
7676

7777
x, y = MOI.add_variables(model, 2)
7878
@test MOI.get(model, MOI.NumberOfVariables()) == 2

0 commit comments

Comments
 (0)