6060const QuadtoSOC{T,OT<: MOI.ModelLike } =
6161 SingleBridgeOptimizer{QuadtoSOCBridge{T},OT}
6262
63- function _error_msg (:: MOI.Utilities.LDLFactorizationsExt )
64- return """
65- Unable to transform a quadratic constraint into a SecondOrderCone
66- constraint because the quadratic constraint is not strongly convex and
67- our Cholesky decomposition failed.
68-
69- If the constraint is convex but not strongly convex, you can work-around
70- this issue by manually installing and loading `LDLFactorizations.jl`:
71- ```julia
72- import Pkg; Pkg.add("LDLFactorizations")
73- using LDLFactorizations
74- ```
75-
76- LDLFactorizations.jl is not included by default because it is licensed
77- under the LGPL.
78- """
79- end
80-
81- function _error_msg (:: MOI.Utilities.CliqueTreesExt )
82- return """
83- Unable to transform a quadratic constraint into a SecondOrderCone
84- constraint because the quadratic constraint is not strongly convex and
85- our Cholesky decomposition failed.
86-
87- If the constraint is convex but not strongly convex, you can work-around
88- this issue by manually installing and loading `CliqueTrees.jl`:
89- ```julia
90- import Pkg; Pkg.add("CliqueTrees")
91- using CliqueTrees
92- ```
93-
94- CliqueTrees.jl is not included by default because it contains a number of
95- heavy dependencies.
96- """
97- end
98-
99- function compute_sparse_sqrt (Q, :: F , :: S ) where {F,S}
100- if (ret = MOI. Utilities. compute_sparse_sqrt (Q)) != = nothing
101- return ret
102- elseif ! MOI. Utilities. is_defined (MOI. Utilities. LDLFactorizationsExt ())
103- msg = _error_msg (MOI. Utilities. LDLFactorizationsExt ())
104- return throw (MOI. AddConstraintNotAllowed {F,S} (msg))
105- elseif ! MOI. Utilities. is_defined (MOI. Utilities. CliqueTreesExt ())
106- msg = _error_msg (MOI. Utilities. CliqueTreesExt ())
107- return throw (MOI. AddConstraintNotAllowed {F,S} (msg))
108- end
109- msg = """
110- Unable to transform a quadratic constraint into a SecondOrderCone
111- constraint because the quadratic constraint is not convex.
112- """
113- return throw (MOI. UnsupportedConstraint {F,S} (msg))
114- end
115-
11663function bridge_constraint (
11764 :: Type{QuadtoSOCBridge{T}} ,
11865 model,
@@ -137,8 +84,46 @@ function bridge_constraint(
13784 MOI. ScalarAffineTerm (scale * term. coefficient, term. variable),
13885 ) for term in func. affine_terms
13986 ]
140- I, J, V = compute_sparse_sqrt (LinearAlgebra. Symmetric (Q), func, set)
141- for (i, j, v) in zip (I, J, V)
87+ sqrt_ret = MOI. Utilities. compute_sparse_sqrt (LinearAlgebra. Symmetric (Q))
88+ if sqrt_ret === nothing
89+ msg = """
90+ ## SecondOrderCone reformulation
91+
92+ We tried to reformulate the quadratic constraint into a SecondOrderCone,
93+ but this failed because the quadratic constraint is not strongly convex
94+ and our matrix factorization failed.
95+
96+ ## Package extensions
97+
98+ If the constraint is convex but not strongly convex, you can work-around
99+ this issue by manually installing and loading one of the following
100+ packages.
101+
102+ ### LDLFactorizations.jl
103+
104+ Currently active: $(MOI. Utilities. is_defined (MOI. Utilities. LDLFactorizationsExt ()))
105+
106+ ```julia
107+ import Pkg; Pkg.add("LDLFactorizations")
108+ using LDLFactorizations
109+ ```
110+ LDLFactorizations.jl is not included by default because it is licensed
111+ under the LGPL.
112+
113+ ### CliqueTrees.jl
114+
115+ Currently active: $(MOI. Utilities. is_defined (MOI. Utilities. CliqueTreesExt ()))
116+
117+ ```julia
118+ import Pkg; Pkg.add("CliqueTrees")
119+ using CliqueTrees
120+ ```
121+ CliqueTrees.jl is not included by default because it contains a number of
122+ heavy dependencies.
123+ """
124+ return throw (MOI. UnsupportedConstraint {typeof(func),typeof(set)} (msg))
125+ end
126+ for (i, j, v) in zip (sqrt_ret[1 ], sqrt_ret[2 ], sqrt_ret[3 ])
142127 push! (
143128 vector_terms,
144129 MOI. VectorAffineTerm (
0 commit comments