Skip to content

Commit e9b6db5

Browse files
committed
Fix error message for LDL factorization failures
1 parent c574485 commit e9b6db5

2 files changed

Lines changed: 13 additions & 7 deletions

File tree

ext/MathOptInterfaceLDLFactorizationsExt.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ function MOI.Bridges.Constraint.compute_sparse_sqrt_fallback(
2121
) where {F<:MOI.ScalarQuadraticFunction,S<:MOI.AbstractSet}
2222
n = LinearAlgebra.checksquare(Q)
2323
factor = LDLFactorizations.ldl(Q)
24-
if minimum(factor.D) < 0
24+
if !LDLFactorizations.factorized(factor) || minimum(factor.D) < 0
2525
msg = """
2626
Unable to transform a quadratic constraint into a SecondOrderCone
2727
constraint because the quadratic constraint is not convex.

test/Bridges/Constraint/test_QuadtoSOCBridge.jl

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -378,12 +378,18 @@ function test_compute_sparse_sqrt_edge_cases()
378378
end
379379
@test isapprox(A, U' * U; atol = 1e-10)
380380
end
381-
A = [-1.0 0.0; 0.0 1.0]
382-
B = SparseArrays.sparse(A)
383-
@test_throws(
384-
MOI.UnsupportedConstraint{typeof(f),typeof(s)},
385-
MOI.Bridges.Constraint.compute_sparse_sqrt(B, f, s),
386-
)
381+
# Test failures
382+
for A in [
383+
[-1.0 0.0; 0.0 1.0],
384+
# Found from test_quadratic_nonconvex_constraint_basic
385+
[0.0 -1.0; -1.0 0.0],
386+
]
387+
B = SparseArrays.sparse(A)
388+
@test_throws(
389+
MOI.UnsupportedConstraint{typeof(f),typeof(s)},
390+
MOI.Bridges.Constraint.compute_sparse_sqrt(B, f, s),
391+
)
392+
end
387393
return
388394
end
389395

0 commit comments

Comments
 (0)