Solving SDP problem with cxv - difference between MATLAB and R solution

17 vues (au cours des 30 derniers jours)
Breden Anwar
Breden Anwar le 15 Nov 2021
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/2 >= 0;
cvx_end
where Lhs and S are appropriate matrices. 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. Thus, I exploited the dual formulation to write the problem as
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)
Unfortunately, the result is totally wrong. Where is the mistake?

Réponses (0)

Catégories

En savoir plus sur Linear Model Identification dans Help Center et File Exchange

Tags

Produits


Version

R2020b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by