Skip to content

Commit b760048

Browse files
authored
[Bridges] remove last acronyms (#1912)
1 parent 294248b commit b760048

File tree

9 files changed

+101
-82
lines changed

9 files changed

+101
-82
lines changed

src/Bridges/Bridges.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import Printf
1212
import Test
1313

1414
const MOI = MathOptInterface
15-
const MOIU = MOI.Utilities
1615

1716
include("bridge.jl")
1817
include("set_map.jl")

src/Bridges/Constraint/Constraint.jl

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ import OrderedCollections: OrderedDict
1212
import SparseArrays
1313

1414
const MOI = MathOptInterface
15-
const MOIU = MOI.Utilities
16-
const MOIB = MOI.Bridges
1715

1816
include("bridge.jl")
1917
include("map.jl")

src/Bridges/Constraint/bridges/det.jl

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ function _extract_eigenvalues(
4141
end
4242
Z[MOI.Utilities.trimap(d + j, d + j)-n] = Δ[MOI.Utilities.trimap(j, j)]
4343
end
44-
Y = MOIU.operate(vcat, T, X, MOI.Utilities.vectorize(Z))
44+
Y = MOI.Utilities.operate(vcat, T, X, MOI.Utilities.vectorize(Z))
4545
set = MOI.PositiveSemidefiniteConeTriangle(2d)
4646
sdindex = MOI.add_constraint(model, Y, set)
4747
D = Δ[MOI.Utilities.trimap.(1:d, 1:d)]
@@ -162,10 +162,10 @@ function concrete_bridge_type(
162162
I::Type{<:MOI.AbstractVectorFunction},
163163
::Type{MOI.LogDetConeTriangle},
164164
) where {T}
165-
S = MOIU.scalar_type(I)
166-
G = MOIU.promote_operation(vcat, T, S, MOI.VariableIndex)
167-
F = MOIU.promote_operation(vcat, T, G, T)
168-
H = MOIU.promote_operation(+, T, S, MOI.ScalarAffineFunction{T})
165+
S = MOI.Utilities.scalar_type(I)
166+
G = MOI.Utilities.promote_operation(vcat, T, S, MOI.VariableIndex)
167+
F = MOI.Utilities.promote_operation(vcat, T, G, T)
168+
H = MOI.Utilities.promote_operation(+, T, S, MOI.ScalarAffineFunction{T})
169169
return LogDetBridge{T,F,G,H,I}
170170
end
171171

@@ -383,9 +383,9 @@ function concrete_bridge_type(
383383
H::Type{<:MOI.AbstractVectorFunction},
384384
::Type{MOI.RootDetConeTriangle},
385385
) where {T}
386-
S = MOIU.scalar_type(H)
387-
G = MOIU.promote_operation(vcat, T, S, MOI.VariableIndex)
388-
F = MOIU.promote_operation(vcat, T, G, T)
386+
S = MOI.Utilities.scalar_type(H)
387+
G = MOI.Utilities.promote_operation(vcat, T, S, MOI.VariableIndex)
388+
F = MOI.Utilities.promote_operation(vcat, T, G, T)
389389
return RootDetBridge{T,F,G,H}
390390
end
391391

src/Bridges/Constraint/bridges/quad_to_soc.jl

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -157,11 +157,13 @@ function MOI.supports_constraint(
157157
return true
158158
end
159159

160-
function MOIB.added_constrained_variable_types(::Type{<:QuadtoSOCBridge})
160+
function MOI.Bridges.added_constrained_variable_types(::Type{<:QuadtoSOCBridge})
161161
return Tuple{Type}[]
162162
end
163163

164-
function MOIB.added_constraint_types(::Type{QuadtoSOCBridge{T}}) where {T}
164+
function MOI.Bridges.added_constraint_types(
165+
::Type{QuadtoSOCBridge{T}},
166+
) where {T}
165167
return Tuple{Type,Type}[(
166168
MOI.VectorAffineFunction{T},
167169
MOI.RotatedSecondOrderCone,
@@ -280,16 +282,16 @@ function MOI.get(
280282
b::QuadtoSOCBridge{T},
281283
) where {T}
282284
f = MOI.get(model, attr, b.soc)
283-
fs = MOIU.eachscalar(f)
285+
fs = MOI.Utilities.eachscalar(f)
284286
q = zero(MOI.ScalarQuadraticFunction{T})
285287
for i in 3:MOI.output_dimension(f)
286-
term = MOIU.operate(*, T, fs[i], fs[i])
287-
term = MOIU.operate!(/, T, term, 2 * one(T))
288-
MOIU.operate!(+, T, q, term)
288+
term = MOI.Utilities.operate(*, T, fs[i], fs[i])
289+
term = MOI.Utilities.operate!(/, T, term, 2 * one(T))
290+
MOI.Utilities.operate!(+, T, q, term)
289291
end
290-
MOIU.operate!(-, T, q, fs[2])
292+
MOI.Utilities.operate!(-, T, q, fs[2])
291293
if !b.less_than
292-
MOIU.operate!(-, T, q)
294+
MOI.Utilities.operate!(-, T, q)
293295
end
294296
q.constant += b.set_constant
295297
return q

src/Bridges/bridge_optimizer.jl

Lines changed: 39 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -406,16 +406,16 @@ function MOI.supports(
406406
return MOI.supports(b.model, attr)
407407
end
408408

409-
function MOIU.pass_nonvariable_constraints(
409+
function MOI.Utilities.pass_nonvariable_constraints(
410410
dest::AbstractBridgeOptimizer,
411411
src::MOI.ModelLike,
412-
idxmap::MOIU.IndexMap,
412+
idxmap::MOI.Utilities.IndexMap,
413413
constraint_types,
414414
)
415415
if Variable.has_bridges(Variable.bridges(dest))
416416
# The functions may contained bridged variables which needs to be
417417
# substituted so we use the fallback.
418-
return MOIU.pass_nonvariable_constraints_fallback(
418+
return MOI.Utilities.pass_nonvariable_constraints_fallback(
419419
dest,
420420
src,
421421
idxmap,
@@ -431,29 +431,30 @@ function MOIU.pass_nonvariable_constraints(
431431
push!(not_bridged_types, (F, S))
432432
end
433433
end
434-
MOIU.pass_nonvariable_constraints(
434+
MOI.Utilities.pass_nonvariable_constraints(
435435
dest.model,
436436
src,
437437
idxmap,
438438
not_bridged_types,
439439
)
440-
MOIU.pass_nonvariable_constraints_fallback(dest, src, idxmap, bridged_types)
440+
MOI.Utilities.pass_nonvariable_constraints_fallback(
441+
dest,
442+
src,
443+
idxmap,
444+
bridged_types,
445+
)
441446
return
442447
end
443448

444-
function MOI.copy_to(
445-
dest::AbstractBridgeOptimizer,
446-
src::MOI.ModelLike;
447-
kwargs...,
448-
)
449-
return MOIU.default_copy_to(dest, src; kwargs...)
449+
function MOI.copy_to(dest::AbstractBridgeOptimizer, src::MOI.ModelLike)
450+
return MOI.Utilities.default_copy_to(dest, src)
450451
end
451452

452453
function MOI.supports_incremental_interface(b::AbstractBridgeOptimizer)
453454
return MOI.supports_incremental_interface(b.model)
454455
end
455-
function MOIU.final_touch(uf::AbstractBridgeOptimizer, index_map)
456-
return MOIU.final_touch(uf.model, index_map)
456+
function MOI.Utilities.final_touch(uf::AbstractBridgeOptimizer, index_map)
457+
return MOI.Utilities.final_touch(uf.model, index_map)
457458
end
458459

459460
# References
@@ -498,7 +499,7 @@ function _delete_variables_in_vector_of_variables_constraint(
498499
if MOI.supports_dimension_update(S)
499500
call_in_context(MOI.delete, b, ci, IndexInVector(i))
500501
else
501-
MOIU.throw_delete_variable_in_vov(vi)
502+
MOI.Utilities.throw_delete_variable_in_vov(vi)
502503
end
503504
end
504505
end
@@ -576,7 +577,7 @@ function MOI.delete(b::AbstractBridgeOptimizer, vi::MOI.VariableIndex)
576577
)
577578
call_in_context(MOI.delete, b, vi, _index(b, vi)...)
578579
else
579-
MOIU.throw_delete_variable_in_vov(vi)
580+
MOI.Utilities.throw_delete_variable_in_vov(vi)
580581
end
581582
else
582583
call_in_context(MOI.delete, b, vi)
@@ -657,7 +658,7 @@ function reduce_bridged(
657658
operate_variable_bridges!::Function,
658659
operate_constraint_bridges!::Function,
659660
)::T where {T}
660-
variable_function = F == MOIU.variable_function_type(S)
661+
variable_function = F == MOI.Utilities.variable_function_type(S)
661662
# A `F`-in-`S` could be added to the model either if it this constraint
662663
# is not bridged or if variables constrained on creations to `S` are not
663664
# bridged and `F` is `VariableIndex` or `VectorOfVariables`.
@@ -1308,7 +1309,7 @@ function MOI.get(
13081309
func = MOI.get(b.model, MOI.ConstraintFunction(), ci)
13091310
end
13101311
f = unbridged_function(b, func)
1311-
set = MOIU.shift_constant(set, -MOI.constant(f))
1312+
set = MOI.Utilities.shift_constant(set, -MOI.constant(f))
13121313
end
13131314
return set
13141315
end
@@ -1394,7 +1395,7 @@ function MOI.get(
13941395
vi::MOI.VariableIndex,
13951396
)
13961397
if is_bridged(b, vi)
1397-
return get(b.var_to_name, vi, MOIU.EMPTYSTRING)
1398+
return get(b.var_to_name, vi, MOI.Utilities.EMPTYSTRING)
13981399
else
13991400
return MOI.get(b.model, attr, vi)
14001401
end
@@ -1421,7 +1422,7 @@ function MOI.get(
14211422
constraint_index::MOI.ConstraintIndex,
14221423
)
14231424
if is_bridged(b, constraint_index)
1424-
return get(b.con_to_name, constraint_index, MOIU.EMPTYSTRING)
1425+
return get(b.con_to_name, constraint_index, MOI.Utilities.EMPTYSTRING)
14251426
else
14261427
return MOI.get(b.model, attr, constraint_index)
14271428
end
@@ -1478,11 +1479,11 @@ function MOI.get(
14781479
return vi
14791480
end
14801481
if b.name_to_var === nothing
1481-
b.name_to_var = MOIU.build_name_to_var_map(b.var_to_name)
1482+
b.name_to_var = MOI.Utilities.build_name_to_var_map(b.var_to_name)
14821483
end
14831484
vi_bridged = get(b.name_to_var, name, nothing)
1484-
MOIU.throw_if_multiple_with_name(vi_bridged, name)
1485-
return MOIU.check_type_and_multiple_names(
1485+
MOI.Utilities.throw_if_multiple_with_name(vi_bridged, name)
1486+
return MOI.Utilities.check_type_and_multiple_names(
14861487
MOI.VariableIndex,
14871488
vi_bridged,
14881489
vi,
@@ -1501,7 +1502,7 @@ function MOI.get(
15011502
return MOI.get(b.model, IdxT, name)
15021503
end
15031504
if b.name_to_con === nothing
1504-
b.name_to_con = MOIU.build_name_to_con_map(b.con_to_name)
1505+
b.name_to_con = MOI.Utilities.build_name_to_con_map(b.con_to_name)
15051506
end
15061507
if is_bridged(b, F, S)
15071508
# There is no `F`-in-`S` constraint in `b.model`, `ci` is only got
@@ -1511,8 +1512,13 @@ function MOI.get(
15111512
ci = MOI.get(b.model, IdxT, name)
15121513
end
15131514
ci_bridged = get(b.name_to_con, name, nothing)
1514-
MOIU.throw_if_multiple_with_name(ci_bridged, name)
1515-
return MOIU.check_type_and_multiple_names(IdxT, ci_bridged, ci, name)
1515+
MOI.Utilities.throw_if_multiple_with_name(ci_bridged, name)
1516+
return MOI.Utilities.check_type_and_multiple_names(
1517+
IdxT,
1518+
ci_bridged,
1519+
ci,
1520+
name,
1521+
)
15161522
end
15171523

15181524
function MOI.get(
@@ -1526,11 +1532,11 @@ function MOI.get(
15261532
return MOI.get(b.model, IdxT, name)
15271533
end
15281534
if b.name_to_con === nothing
1529-
b.name_to_con = MOIU.build_name_to_con_map(b.con_to_name)
1535+
b.name_to_con = MOI.Utilities.build_name_to_con_map(b.con_to_name)
15301536
end
15311537
ci_bridged = get(b.name_to_con, name, nothing)
1532-
MOIU.throw_if_multiple_with_name(ci_bridged, name)
1533-
return MOIU.check_type_and_multiple_names(
1538+
MOI.Utilities.throw_if_multiple_with_name(ci_bridged, name)
1539+
return MOI.Utilities.check_type_and_multiple_names(
15341540
IdxT,
15351541
ci_bridged,
15361542
MOI.get(b.model, IdxT, name),
@@ -1910,7 +1916,7 @@ function bridged_function(bridge::AbstractBridgeOptimizer, value)
19101916
# We assume that the type of `value` is not altered. This restricts
19111917
# variable bridges to only return `ScalarAffineFunction` but otherwise,
19121918
# the peformance would be bad.
1913-
return MOIU.substitute_variables(
1919+
return MOI.Utilities.substitute_variables(
19141920
vi -> bridged_variable_function(bridge, vi),
19151921
value,
19161922
)::typeof(value)
@@ -1929,7 +1935,7 @@ end
19291935
# Shortcut to avoid `Variable.throw_if_cannot_unbridge(Variable.bridges(b))`
19301936
function bridge_function(
19311937
::AbstractBridgeOptimizer,
1932-
value::MOIU.ObjectOrTupleOrArrayWithoutIndex,
1938+
value::MOI.Utilities.ObjectOrTupleOrArrayWithoutIndex,
19331939
)
19341940
return value
19351941
end
@@ -1974,7 +1980,7 @@ function unbridged_function(b::AbstractBridgeOptimizer, value)
19741980
# `unbridged_variable_function` hence it might silently return an incorrect
19751981
# value so we call `throw_if_cannot_unbridge` here.
19761982
Variable.throw_if_cannot_unbridge(Variable.bridges(b))
1977-
return MOIU.substitute_variables(
1983+
return MOI.Utilities.substitute_variables(
19781984
vi -> unbridged_variable_function(b, vi),
19791985
value,
19801986
)::typeof(value)
@@ -1990,7 +1996,7 @@ end
19901996
# Shortcut to avoid `Variable.throw_if_cannot_unbridge(Variable.bridges(b))`
19911997
function unbridged_function(
19921998
::AbstractBridgeOptimizer,
1993-
value::MOIU.ObjectOrTupleOrArrayWithoutIndex,
1999+
value::MOI.Utilities.ObjectOrTupleOrArrayWithoutIndex,
19942000
)
19952001
return value
19962002
end
@@ -2028,7 +2034,7 @@ function bridged_constraint_function(
20282034
# `MOI.ConstraintSet`. See `unbridged_constraint_function`.
20292035
MOI.throw_if_scalar_and_constant_not_zero(func, typeof(set))
20302036
f = bridged_function(b, func)::typeof(func)
2031-
return MOIU.normalize_constant(f, set)
2037+
return MOI.Utilities.normalize_constant(f, set)
20322038
end
20332039

20342040
function bridged_constraint_function(

0 commit comments

Comments
 (0)