# A SDP problem- sometimes Inaccurate solved, another time Failed to solve. How to diagnose the issue and reach an accurate solution?

Hello. I’d be grateful if anyone helps me conquering this problem:

Foreword
Using cvx in MATLAB, I aim to apply SDP for synthesizing a sparse dynamic structure. The method is proposed in this journal article : Babazadeh, Nobakhti-2016.
The article presents a systematic approach for the design of sparse dynamic output feedback control structures, i.e. dynamic precompensator. A supplementary complexity cost function term is used to promote sparsity in the structure while optimizing an H2 performance cost simultaneously.
I have tested validity of my code by applying it to some other transfer functions matrices.

Problem
However, When I applied the code to my model, which was a 5state model of a wind turbine, different alerts were shown in the optimization process. By “alert” I mean the messages which appear in the command window while the optimization part of the code is being executed.
A confusing matter is that these alert are not always the same. Indeed, they vary depending on how 2 vectors are initialized. The vectors on which the result is depended are named dr1 and dr2 in my code and can be arbitrarily chosen.
Here I’ve sorted some examples of initialization and their corresponding result:

for dr1 = dr2 = [2, 0.9, 0.0001], the result would be:

## number of iterations = 23 primal objective value = 1.68042074e-09 …

Status: Inaccurate/Solved
Optimal value (cvx_optval): +7.01212e-06

for dr1 = dr2 = [1, 0.9, 0.0001], the result would be:

## number of iterations = 22 primal objective value = 7.28254273e-08 …

Status: Inaccurate/Solved
Optimal value (cvx_optval): +1.00974e-05

for dr1 = dr2 = [1, 1.1, 0.0001], the result would be:

## number of iterations = 21 primal objective value = 2.12550106e-06 …

Status: Failed
Optimal value (cvx_optval): NaN

for dr1 = dr2 = [2.5, 0.9, 0.0001], the result would be:

## number of iterations = 25 primal objective value = 2.89646652e-09 …

Status: Inaccurate/Solved
Optimal value (cvx_optval): +6.66678e-06

I just don’t know how to pursue an accurate solution?
the matlab code is:
(G_minimal represents my transfer function)

landa = 0;
close all
clc
m=2;
r=3;
nx =5;
M0=[eye(m), zeros(m,m*(r-1))]
N0 = [eye(m) zeros(m,m); zeros(m,m), eye(m); zeros(m,m*(r-1))]

dr1 = [2.5 0.9 0.0001];
dr2 = [2.5 0.9 0.0001];

F1 = [dr1(1)*eye(m,m) dr1(2)*eye(m,m) dr1(3)*eye(m,m)]'
F2 = transpose([dr2(1)*eye(m,m) dr2(2)*eye(m,m) dr2(3)*eye(m,m)])
S1 = [-F1 , N0]
S2 = [-F2 , N0]
I_hat1 = [0 0;0 1];
I_hat2 = [1 0;0 0];
E = ones(m,1);
GT = transpose(G_minimal);

G_hat1 = GTI_hat1;
G_hat2 = GT
I_hat2;
[A_hat1 B_hat1 C_hat1 D_hat1] = ssdata(G_hat1);
[A_hat2 B_hat2 C_hat2 D_hat2] = ssdata(G_hat2);
dim1 = length(A_hat1);
dim2 = length(A_hat2);

``````       cvx_begin SDP

variable W1(m,m) symmetric
variable W2(m,m) symmetric
variable P111(dim1,dim1) symmetric
variable P112(dim2,dim2) symmetric
variable P221(m*r,m*r) symmetric
variable P222(m*r,m*r) symmetric
variable P121(dim1,m*r)
variable P122(dim2,m*r)
variable M(m*r,m)
variable D(m,m) symmetric
variable  Y(m,m) symmetric  ;
minimize(trace(W1)+trace(W2)+landa*(E'*(Y - diag(diag(Y)))*E))
subject to
for j=1:m
for i=1:m
if i~=j
M(m*(r-1)+j,j)==1;

[Y(i,j)*eye(r+1) [D(i,j);[M(i,j) M(i+m,j) M(i+2*m,j)]'] ; [D(i,j),[M(i,j) M(i+m,j) M(i+2*m,j)]] Y(i,j)] >= 0;
end
end
end

[P111*A_hat1 + A_hat1'*P111 + P121*M0'*C_hat1 + C_hat1'*M0*P121' , A_hat1'*P121+C_hat1'*M0*P221+P121*S1' , C_hat1'*D(:,1);
(A_hat1'*P121+C_hat1'*M0*P221+P121*S1')'                         , P221*S1'+S1*P221                      , M(:,1) - F1*D(:,1) ;
(C_hat1'*D(:,1))'                                               , (M(:,1) - F1*D(:,1))'                 , -1] <= 0;

[P112*A_hat2 + A_hat2'*P112 + P122*M0'*C_hat2 + C_hat2'*M0*P122' , A_hat2'*P122+C_hat2'*M0*P222+P122*S2' , C_hat2'*D(:,2);
(A_hat2'*P122+C_hat2'*M0*P222+P122*S2')'                        , P222*S2'+S2*P222                      , M(:,2) - F2*D(:,2);
(C_hat2'*D(:,2))'                                               , (M(:,2) - F2*D(:,2))'                 , -1] <= 0;

[W1,                               B_hat1'*P111+D_hat1'*M0*P121'   ,   B_hat1'*P121+D_hat1'*M0*P221;
(B_hat1'*P111+D_hat1'*M0*P121')' , P111                           ,   P121;
(B_hat1'*P121+D_hat1'*M0*P221)'  , P121'                          ,  P221] >= 0;

[W2,                               B_hat2'*P112+D_hat2'*M0*P122'   ,   B_hat2'*P122+D_hat2'*M0*P222;
(B_hat2'*P112+D_hat2'*M0*P122')' , P112                           ,   P122;
(B_hat2'*P122+D_hat2'*M0*P222)'  , P122'                          ,  P222] >= 0;

cvx_end
``````

Thank you.