Extracting solution of SDP problem in CVX

cvxMATLABoptimizationsemidefinite-programming

Assume we are given the following semidefinite program (SDP) written in MATLAB using CVX:

A=[1 0 1; 0 3 7; 1 7 5];
C=[1 2 3; 2 9 0; 3 0 7];
n=size(C,1);
cvx_begin
 variable X(n,n) symmetric;
 minimize trace(C*X)
 subject to
 trace(A*X) == 1;
 X == semidefinite(n);
cvx_end

where the optimum is found to be -0.385827. How can one extract the solution for $X$, that is the values of the elements of the matrix $X$?

Best Answer

If CVX status is Solved , after CVX execution completes, the declared variables become double precision MATLAB variables, numerically populated with the optimal variable values. So X is a double precision variable containing the optimal value of X. You can display it, assign it to another variable, or anything else you can do with it in standard MATLAB.

In your problem,

>> disp(X)
   0.689622560343423  -0.072049779098121  -0.239704801944837
  -0.072049779098121   0.007527553887307   0.025043667211789
  -0.239704801944837   0.025043667211789   0.083318608945303

This is covered in the CVX users' Guide

Related Question