# Solving the KKT system in CVX?

‎I want solve this system primal-dual interior point system semi-definite programming with Matlab, but I can’t, can you help me?

$$\begin{gathered} A_{i}\bullet X=b_{i}‎ ~‎~i=1,…,m‎ ~‎X\succeq 0\ \sum y_{i}A_{i}+S=c~~~S\succeq 0 \ XS=0 \end{gathered}$$

thank you.
‎‏

It’s unclear what your question is…

Do you have problems specifying a basic SDP in CVX? or is the problem in recovering dual variables to verify optimality? You wrote the optimality conditions for standard SDP, but
normally you specify a primal problem

\begin{array}{ll} \mbox{minimize} & C\bullet X \\ \mbox{subject to} & A_i \bullet X = b_i, \quad i=1,\dots,m\\ & X\succeq 0. \end{array}

If your question is about how to formulate and solve a basic SDP in CVX, then you should look at documentation: http://cvxr.com/cvx/doc/

It’s all documented there…

You can solve a problem in primal form as listed above, and then access the dual variables. This example from the documentation outlines the concept:

In general ADP problem we have, the primal problem
\begin{array}{ll} \mbox{minimize} & C\bullet X \ \mbox{subject to} & A_i \bullet X = b_i, \quad i=1,\dots,m\ & X\succeq 0.
\end{array} and dual problem associated is
\begin{array}{ll} \mbox{maximize} & b‎^{T}‎ y \ \mbox{subject to} & \sum A_i y_i+S = C, \quad i=1,\dots,m\ & S\succeq 0.
\end{array},
in interior point method we solve both these problem in below system

‎$A‎_{i}‎\bullet X‎=b‎_{i}~~~~X‎\succ 0‎‎‎$‎

\sum y_{i}A_{i}+S=c~~~S\succ 0,
XS=mu,
where mu is parameter such that mu>=0;
now I want solve current system with CVX.

You cannot solve this KKT system directly in CVX—it is not convex. However, you can obtain the solution to the KKT system, or at least a numerically approximate one, by solving the primal and dual problems separately. Or, you can use the dual variables command in CVX to obtain both the primal and dual solutions simultaneously.

Joachim is on the right track here, but let me share a little trick that avoids the use of CVX’s indexed dual variables, which I admit are a bit clumsy. Let’s assume the A matrices are stored in an n\times n\times m array. In other words, A_i is found in the slice A(:,:,i). Then here’s a clean way to specify the primal SDP, augmented with dual variables:

cvx_begin sdp
variables X(n,n) symmetric
dual variables y S
reshape( A, n*n, m )' * X(:) == b : y;
X >= 0 : S;
cvx_end


The downside to this construction is that the n\times n\times m array A can get quite large—and unnecessarily so if the A_i matrices are sparse. But you can always construct the sparse version of the “matrixified” version reshape( A, n*n, m ) by hand if you want.

Having said all this, it’s not clear to me why you would ever want to do this with CVX. One of the very points of a system like CVX is so that you can stop concerning yourself with the standard forms of the underlying conic problems, and just specify the problem you want to solve, in at least roughly the form you conceive it to be. Few problems naturally present themselves in SDP standard form.