I am trying to optimize the following part of my code that involves solving a semi-definite programming (SDP) in CVXPY.
# optimization variables X and V
V = cp.Variable((p,p))
X = cp.Variable((num,p))
# constraints
constraints = [cp.bmat([[V, X.T @ R.conj().T], [R @ X, np.identity(num)]]) >> 0]
constraints += [X.T @ dersmatrix == np.identity(p)]
# minimization
prob = cp.Problem(cp.Minimize(cp.trace(W @ V)), constraints)
prob.solve(solver=cp.MOSEK,verbose=True)
v1=prob.value
The SDP is formulated as follows. The optimization variables V
and X
are matrices of size p x p and num x p respectively, where num = d^2 is typically very large i.e., > 6000 and p=2
(for my case).
The constraint for positive semi-definiteness in terms of X
and V
is given through the positive semi-definiteness of the block matrix (say M
) M=cp.bmat([[V, X.T @ R.conj().T], [R @ X, np.identity(num)]]) >> 0
. This is inferred from the positive semi-definiteness condition on the Schur complement of the identity block of M
i.e., V - X.T @ R.conj().T @ R @ X
. Another constraint reads: X.T @ dersmatrix == np.identity(p)
.
R
and dersmatrix
are matrices of size num x num and num x p respectively, which are defined previously in my code. W
is a p x p weight matrix in the objective function cp.trace(W @ V)
.
For example, when d=81
, num=6561
, resulting in extremely large sizes for X
, R
, and dersmatrix
, which significantly slows down the solution.
As one possible solution to obtain speed-up, I identified that R
is quite sparse and tried to exploit its sparsity using R_spr=csr_matrix(R)
, which modifies the positive semi-definiteness constraint to cp.bmat([[V, X.T @ R_spr.conj().T], [R_spr @ X, np.identity(num)]]) >> 0
. However, this still does not seem to yield faster results. I am also wondering if the block matrix form of the constraint slows down the code. Note that I am using the MOSEK solver.
Hence, I am looking for some suggestions to optimize this aspect of my code when dealing with very large matrices, especially for d>=81. Any ideas on this would be much helpful. Thanks.