Skip to content

Commit 99ae2ff

Browse files
committed
Update
1 parent 8fb6daa commit 99ae2ff

3 files changed

Lines changed: 25 additions & 25 deletions

File tree

ext/MathOptInterfaceCliqueTreesExt.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ import LinearAlgebra
1111
import MathOptInterface as MOI
1212
import SparseArrays
1313

14-
MOI.Bridges.Constraint.is_defined(::MOI.Bridges.Constraint.CliqueTrees) = true
14+
MOI.Bridges.Constraint.is_defined(::MOI.Bridges.Constraint._CliqueTrees) = true
1515

16-
function MOI.Bridges.Constraint.compute_sparse_sqrt(
17-
::MOI.Bridges.Constraint.CliqueTrees,
16+
function MOI.Bridges.Constraint._compute_sparse_sqrt(
17+
::MOI.Bridges.Constraint._CliqueTrees,
1818
Q::AbstractMatrix,
1919
)
2020
G = LinearAlgebra.cholesky!(

src/Bridges/Constraint/bridges/QuadtoSOCBridge.jl

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -60,17 +60,17 @@ end
6060
const QuadtoSOC{T,OT<:MOI.ModelLike} =
6161
SingleBridgeOptimizer{QuadtoSOCBridge{T},OT}
6262

63-
abstract type AbstractExt end
63+
abstract type _AbstractExt end
6464

65-
is_defined(::AbstractExt) = false
65+
is_defined(::_AbstractExt) = false
6666

67-
struct CliqueTrees <: AbstractExt end
67+
struct _CliqueTrees <: _AbstractExt end
6868

69-
struct LinearAlgebraExt <: AbstractExt end
69+
struct _LinearAlgebra <: _AbstractExt end
7070

71-
is_defined(::LinearAlgebraExt) = true
71+
is_defined(::_LinearAlgebra) = true
7272

73-
function compute_sparse_sqrt(::LinearAlgebraExt, Q::AbstractMatrix)
73+
function _compute_sparse_sqrt(::_LinearAlgebra, Q::AbstractMatrix)
7474
factor = LinearAlgebra.cholesky(Q; check = false)
7575
if !LinearAlgebra.issuccess(factor)
7676
return nothing
@@ -85,7 +85,7 @@ function compute_sparse_sqrt(::LinearAlgebraExt, Q::AbstractMatrix)
8585
end
8686

8787
"""
88-
compute_sparse_sqrt(Q::AbstractMatrix)
88+
_compute_sparse_sqrt(Q::AbstractMatrix)
8989
9090
Attempts to compute a sparse square root such that `Q = A' * A`.
9191
@@ -101,20 +101,20 @@ If unsuccessful, this function returns `nothing`.
101101
By default, this function attempts to use a Cholesky decomposition. If that
102102
fails, it may optionally use various extension packages.
103103
104-
These extension packages must be loaded before calling `compute_sparse_sqrt`.
104+
These extension packages must be loaded before calling `_compute_sparse_sqrt`.
105105
106106
The extensions currently supported are:
107107
108108
* The pivoted Cholesky in `CliqueTrees.jl`
109109
"""
110-
function compute_sparse_sqrt(Q::AbstractMatrix)
110+
function _compute_sparse_sqrt(Q::AbstractMatrix)
111111
# There's a big try-catch here because Cholesky can fail even if
112112
# `check = false`. The try-catch isn't a performance concern because the
113113
# alternative is not being able to reformulate the problem.
114-
for ext in (LinearAlgebraExt(), CliqueTrees())
114+
for ext in (_LinearAlgebra(), _CliqueTrees())
115115
if is_defined(ext)
116116
try
117-
if (ret = compute_sparse_sqrt(ext, Q)) !== nothing
117+
if (ret = _compute_sparse_sqrt(ext, Q)) !== nothing
118118
return ret
119119
end
120120
catch
@@ -175,7 +175,7 @@ function bridge_constraint(
175175
MOI.ScalarAffineTerm(scale * term.coefficient, term.variable),
176176
) for term in func.affine_terms
177177
]
178-
sqrt_ret = compute_sparse_sqrt(LinearAlgebra.Symmetric(Q))
178+
sqrt_ret = _compute_sparse_sqrt(LinearAlgebra.Symmetric(Q))
179179
if sqrt_ret === nothing
180180
msg = _get_sqrt_error_message(is_defined(CliqueTrees()))
181181
return throw(MOI.UnsupportedConstraint{typeof(func),typeof(set)}(msg))

test/Bridges/Constraint/test_QuadtoSOCBridge.jl

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -341,13 +341,13 @@ function test_semidefinite_cholesky_fail()
341341
end
342342

343343
function test_linear_algebra_compute_sparse_sqrt_edge_cases()
344-
ext = MOI.Bridges.Constraint.LinearAlgebraExt()
344+
ext = MOI.Bridges.Constraint._LinearAlgebra()
345345
for A in AbstractMatrix[
346346
[1.0 0.0; 0.0 2.0],
347347
[1.0 0.0 1.0; 0.0 1.0 1.0; 1.0 1.0 3.0],
348348
]
349349
Q = SparseArrays.sparse(A)
350-
I, J, V = MOI.Bridges.Constraint.compute_sparse_sqrt(ext, Q)
350+
I, J, V = MOI.Bridges.Constraint._compute_sparse_sqrt(ext, Q)
351351
U = zeros(eltype(A), size(A))
352352
for (i, j, v) in zip(I, J, V)
353353
U[i, j] += v
@@ -361,13 +361,13 @@ function test_linear_algebra_compute_sparse_sqrt_edge_cases()
361361
BigFloat[-1.0 0.0; 0.0 1.0],
362362
[1.0 1.0 0.0; 1.0 1.0 0.0; 0.0 0.0 1.0],
363363
]
364-
@test MOI.Bridges.Constraint.compute_sparse_sqrt(ext, A) === nothing
364+
@test MOI.Bridges.Constraint._compute_sparse_sqrt(ext, A) === nothing
365365
end
366366
return
367367
end
368368

369369
function test_clique_trees_compute_sparse_sqrt_edge_cases()
370-
ext = MOI.Bridges.Constraint.CliqueTrees()
370+
ext = MOI.Bridges.Constraint._CliqueTrees()
371371
for A in AbstractMatrix[
372372
[1.0 0.0; 0.0 2.0],
373373
[1.0 0.0 1.0; 0.0 1.0 1.0; 1.0 1.0 3.0],
@@ -379,7 +379,7 @@ function test_clique_trees_compute_sparse_sqrt_edge_cases()
379379
BigFloat[1.0 1.0; 1.0 1.0],
380380
]
381381
Q = SparseArrays.sparse(A)
382-
I, J, V = MOI.Bridges.Constraint.compute_sparse_sqrt(ext, Q)
382+
I, J, V = MOI.Bridges.Constraint._compute_sparse_sqrt(ext, Q)
383383
U = zeros(eltype(A), size(A))
384384
for (i, j, v) in zip(I, J, V)
385385
U[i, j] += v
@@ -393,7 +393,7 @@ function test_clique_trees_compute_sparse_sqrt_edge_cases()
393393
BigFloat[-1.0 0.0; 0.0 1.0],
394394
]
395395
Q = SparseArrays.sparse(A)
396-
@test MOI.Bridges.Constraint.compute_sparse_sqrt(ext, Q) === nothing
396+
@test MOI.Bridges.Constraint._compute_sparse_sqrt(ext, Q) === nothing
397397
end
398398
return
399399
end
@@ -410,7 +410,7 @@ function test_compute_sparse_sqrt_edge_cases()
410410
BigFloat[1.0 1.0; 1.0 1.0],
411411
]
412412
Q = SparseArrays.sparse(A)
413-
I, J, V = MOI.Bridges.Constraint.compute_sparse_sqrt(Q)
413+
I, J, V = MOI.Bridges.Constraint._compute_sparse_sqrt(Q)
414414
U = zeros(eltype(A), size(A))
415415
for (i, j, v) in zip(I, J, V)
416416
U[i, j] += v
@@ -424,7 +424,7 @@ function test_compute_sparse_sqrt_edge_cases()
424424
BigFloat[-1.0 0.0; 0.0 1.0],
425425
]
426426
Q = SparseArrays.sparse(A)
427-
@test MOI.Bridges.Constraint.compute_sparse_sqrt(Q) === nothing
427+
@test MOI.Bridges.Constraint._compute_sparse_sqrt(Q) === nothing
428428
end
429429
return
430430
end
@@ -470,14 +470,14 @@ function test_clique_trees_error_message()
470470
return
471471
end
472472

473-
struct _DummyCliqueTrees <: MOI.Bridges.Constraint.AbstractExt end
473+
struct _DummyCliqueTrees <: MOI.Bridges.Constraint._AbstractExt end
474474

475475
function test_is_defined_default_fallback()
476476
@test !MOI.Bridges.Constraint.is_defined(_DummyCliqueTrees())
477477
Q = ones(2, 2)
478478
@test_throws(
479479
MethodError,
480-
MOI.Bridges.Constraint.compute_sparse_sqrt(_DummyCliqueTrees(), Q),
480+
MOI.Bridges.Constraint._compute_sparse_sqrt(_DummyCliqueTrees(), Q),
481481
)
482482
return
483483
end

0 commit comments

Comments
 (0)