Crossposted on Mathematics SE

CVXPY is a famous software as a solver for optimization problems. Nowadays, I use it to run a program presented in a paper, the Example 7.1, and the program runs as follows (I haven't found out how to insert my codes here, otherwise I would post them) all matrices are $4 \times 4$: $O_0$ and $O_3$ are varibles, the target function is $\min\text{tr}(O_0+O_3)$ and the constraints are

$$O_0 \succeq 0, \qquad O_3 \succeq 0, \qquad O_0 \preceq I, \qquad O_3 \preceq I$$

$$\left( \begin{matrix}0&0.707&0&0.707\\0&0&0&0\\0&0.707&0&-0.707\\0&0&0&0 \end{matrix}\right)O_0\left( \begin{matrix}0&0&0&0\\0.707&0&0.707&0\\0&0&0&0\\0.707&0&-0.707&0 \end{matrix}\right)+\left(\begin{matrix}0&0&0&0\\0&1&0&0\\0&0&0&0\\0&0&0&1 \end{matrix}\right)O_3\left(\begin{matrix}0&0&0&0\\0&1&0&0\\0&0&0&0\\0&0&0&1 \end{matrix}\right)\succeq\left(\begin{matrix}1&0&0&0\\0&0&0&0\\0&0&0&0\\0&0&0&0 \end{matrix}\right)\\ \left( \begin{matrix}0&0.707&0&0.707\\0&0&0&0\\0&0.707&0&-0.707\\0&0&0&0 \end{matrix}\right)O_0\left( \begin{matrix}0&0&0&0\\0.707&0&0.707&0\\0&0&0&0\\0.707&0&-0.707&0 \end{matrix}\right)-O_0+\left(\begin{matrix}0&0&0&0\\0&1&0&0\\0&0&0&0\\0&0&0&1 \end{matrix}\right)O_3\left(\begin{matrix}0&0&0&0\\0&1&0&0\\0&0&0&0\\0&0&0&1 \end{matrix}\right)\succeq 0$$

The output of the program is: the optimal value is $1.9999988116689815$, and

$$O_0=O_3=\left(\begin{matrix}0&0&0&0\\0&0.5&0&0.5\\0&0&0&0\\0&0.5&0&0.5 \end{matrix}\right)$$

It is not hard to see that the constraints are all in the form of $$\sum\limits_i\sum\limits_j A_{ij} X_i A_{ij}^T \preceq \text{(or} \succeq\text{)} B$$ where $X_i$ are variables. However, for SDP algorithms(such as interior point method and cutting plane method) what we are dealing with are SDP is in the form of the standard or the dual form.However the above CVXPY solver can directly give the output without converting to standard form or dual form, so I wonder what algorithm does CVXPY actually take. I have read the guidebook of CVXPY but haven't found out where it is mentioned.I am interested in this problem because I once studied such semidefinite programs.

  • $\begingroup$ No need to use \left( \begin{matrix}. Just use \begin{pmatrix}. $\endgroup$ Jun 14 at 14:56

1 Answer 1


Cvxpy cannot solve SDPs by it itself. It feeds the problem into an optimizer such as Mosek. Therefore, you should consult the documentation of the optimizer you are using.

Btw it is trivial to convert your SDP to any standard form. That is precisely the thing that cvxpy does.

  • $\begingroup$ Then how does cvxpy transform it to the standard form? $\endgroup$
    – qmww987
    Jun 13 at 11:04
  • $\begingroup$ Maybe you can be specific about exactly you do not know how to transfer to standard form. It is bit like you are asking how to convert a linear equality to an equality. (Add a slack variable is the answer.) $\endgroup$ Jun 13 at 11:10
  • $\begingroup$ Well actually I do have known how to convert,but I want to make sure that cvxpy does it in the same way so I want to know if there are something like the source code or the guidebook or publications talking about this,etc. $\endgroup$
    – qmww987
    Jun 13 at 12:33
  • $\begingroup$ You find the complete Cvxpy source code at github.com/cvxpy. $\endgroup$ Jun 14 at 10:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.