1

I solved the following Linear Matrix Inequality (LMI) problem using cvx in Matlab:

Lhs = [19.467593196, 1.82394007, 0.1625838, 0.01685267, 0.002495194;
1.823940068, 1.78664305, 0.9845668, 0.32951706, 0.010431878;
0.162583843, 0.98456679, 1.2333818, 0.92276329, 0.132643463;
0.016852668, 0.32951706, 0.9227633, 1.55698000, 0.848190932;
0.002495194, 0.01043188, 0.1326435, 0.84819093, 0.638889503];

S = [0.001, -0.001, 0, 0, 0;
-0.001, 0.001, 0, 0, 0;
0, 0, 0, 0, 0;
0, 0, 0, 0.001 -0.001;
0, 0, 0, -0.001,  0.001];


cvx_begin sdp
   variable t;
   minimize t;
   Lhs+t*S >= 0;
cvx_end

The result makes sense.

I need to solve the same problem in R. As far as I understood, it can't be expressed as a LMI with CVXR. Thus, I exploited the dual formulation to write the problem as

cvx_begin sdp
    variable X(5,5) symmetric;
    maximize -trace(Lhs*X);
    trace(S*X) == 1;
    X >= 0;
cvx_end

As expected, the result in Matlab is the same as in the primal formulation.

However, if I solve the dual problem in R:

Lhs = matrix(c(19.467593196, 1.82394007, 0.1625838, 0.01685267, 0.002495194,
1.823940068, 1.78664305, 0.9845668, 0.32951706, 0.010431878,
0.162583843, 0.98456679, 1.2333818, 0.92276329, 0.132643463,
0.016852668, 0.32951706, 0.9227633, 1.55698000, 0.848190932,
0.002495194, 0.01043188, 0.1326435, 0.84819093, 0.638889503), ncol = 5, byrow = T)

S = matrix(c(0.001, -0.001, 0, 0, 0,
-0.001, 0.001, 0, 0, 0,
0, 0, 0, 0, 0,
0, 0, 0, 0.001, -0.001,
0, 0, 0, -0.001,  0.001), ncol = 5, byrow = T)

X = Variable(k, k, PSD = T)
constr = list(matrix_trace(S%*%X) == 1,
             X >= 0)
prob = Problem(Maximize(-matrix_trace(Lhs%*%X)), constr)

the result is totally wrong. Where is the mistake?

momomi
  • 23
  • 9
  • Please read the information at the top of the [tag:r] tag and note that examples should be complete, self contained and reproducible including all code and input so that others can run them. – G. Grothendieck Nov 15 '21 at 16:49
  • Now the code is fully reproducible. – momomi Nov 15 '21 at 17:08

0 Answers0