Questions regarding the result of the cvxpy
I want to optimize the function $$\min_{X \in \mathbb{S}^{n}_{+}} tr(C^TX) + tr(X^{-1}),$$
of which I optimize the equivalent problem $$\min tr(C^TX) + tr(Z)$$
$$\text{s.t.} \begin{matrix} \begin{pmatrix} Z & I\ I & X \ \end{pmatrix} \end{matrix} \succeq 0 $$
so that it follows the dcp form of cvxpy. Moreover, note that the function has the gradient $C - X^{-2}$. So I define $C$ to be $X_0^{-2}$ for some symmetric positive definite matrix $X_0$. Since the problem is convex, we have that the gradient is $0$ at $X = X_0$. 563
And in this way I can check the performance of the optimization. However, as I put the code in cvxpy, the algorithm suggests that the optimal point is another point. Below is the code and the output.
``` import cvxpy as cp import numpy as np import random def symm(A): #symmetric operator return 0.5 *(A + A.T)
np.random.seed(1) n = 50 CN = 10 data_choice = 'sparse' solver_choice = 'CG'
D = 1000 * np.diag(np.logspace(-np.log(CN), 0, n)) Q, R = np.linalg.qr(np.random.normal(size = (n,n))) A = Q @ D @ Q A = (A.T + A)/2 C= np.linalg.inv(A) @ np.linalg.inv(A)
X = cp.Variable((n, n) , symmetric=True) Z = cp.Variable((n, n) , symmetric=True) V = cp.bmat([[Z, np.eye(n)], [np.eye(n), X]])
constraints = [V >> 0] obj = cp.Minimize(cp.trace(C.T @ X) + cp.trace(Z)) prob = cp.Problem(obj,constraints)
history = prob.solve(verbose = True) ```
```
CVXPY
v1.1.18
=============================================================================== (CVXPY) Feb 14 12:43:40 AM: Your problem has 5000 variables, 1 constraints, and 0 parameters. (CVXPY) Feb 14 12:43:40 AM: It is compliant with the following grammars: DCP, DQCP (CVXPY) Feb 14 12:43:40 AM: (If you need to solve this problem multiple times, but with different data, consider using parameters.) (CVXPY) Feb 14 12:43:40 AM: CVXPY will first compile your problem; then, it will invoke a numerical solver to obtain a solution.
Compilation
(CVXPY) Feb 14 12:43:40 AM: Compiling problem (target solver=SCS). (CVXPY) Feb 14 12:43:40 AM: Reduction chain: Dcp2Cone -> CvxAttr2Constr -> ConeMatrixStuffing -> SCS (CVXPY) Feb 14 12:43:40 AM: Applying reduction Dcp2Cone (CVXPY) Feb 14 12:43:40 AM: Applying reduction CvxAttr2Constr (CVXPY) Feb 14 12:43:40 AM: Applying reduction ConeMatrixStuffing (CVXPY) Feb 14 12:43:40 AM: Applying reduction SCS (CVXPY) Feb 14 12:43:40 AM: Finished problem compilation (took 3.301e-02 seconds).
Numerical solver
(CVXPY) Feb 14 12:43:40 AM: Invoking solver SCS to obtain a solution.
SCS v3.1.0 - Splitting Conic Solver
(c) <PERSON>, Stanford University, 2012
problem: variables n: 2550, constraints m: 5050 cones: s: psd vars: 5050, ssize: 1 settings: eps_abs: 1.0e-05, eps_rel: 1.0e-05, eps_infeas: 1.0e-07 alpha: 1.50, scale: 1. 509