Hi guys!
How to solve this constraint in Julia in JuMP, where the Q is a 2×2 Hessian matrix of a convex function, so it is a positive semidefinite matrix.
I know it can be reformulated as a second-order cone constraint, but I don’t know how to transfer.
If you are using Gurobi, you can just write it without reformulation.
If your Q is real:
if it is positive definite, then it is easy—a cholesky decomposition is sufficient.
if it is positive semidefinite, then maybe you can do a spectral decomposition
something like
# This `A` is a PSD matrix
A = [36 -26 -18 -24 -4; -26 59 -32 81 -15; -18 -32 62 -60 37; -24 81 -60 117 -30; -4 -15 37 -30 93]
using LinearAlgebra
vals, Q = eigen(A); # spectral decomposition
D = Diagonal(vals);
Q = Matrix(Q');
# @assert (Q'D)Q == A
# suppose you want to add this constr
t ≥ (x'A)x
# you can define
JuMP.@expression(model, y, (Q)x)
# then the constr becomes
t ≥ (y'D)y
# since `D` is Diagonal, this constr can be converted to SOC form
Then after removing 0 entries in D, then followed by a cholesky decomposition, you can write the last constraint as a rotated second order cone here.
Then you can in turn transform that rotated second order cone to a standard SOC.
PS to know whether a given symmetric matrix is positive definite, you can do cholesky directly, if success, then it is PD, otherwise you can do spectral decomposition as a recourse.
Thank you!
I use Gurobi in JuMP, so how to write it without reformulation.
In addition, if I have the JuMP.@expression(model, y, (Q)x) and then how to write a soc constraint in JuMP.