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

조회 수: 17 (최근 30일)
Breden Anwar
Breden Anwar 2021년 11월 15일
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?

답변 (0개)

카테고리

Help CenterFile Exchange에서 Linear Model Identification에 대해 자세히 알아보기

태그

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by