# Status:infeasible in cvx

This is my function, What I want to get is an optimal matrix Z of dimensions 7x7, but the cvx_status is infeasible, I don’t know what is wrong??

function [EDM,X]=sdr(T)
n=5;
k=2;
T=time_matrix;
T2=time_matrix.time_matrix;
e=ones(n,1);
Ik=eye(k);
cvx_begin
variable Z(n+k,n+k) symmetric
K=diag(Z(k+1:k+n,k+1:k+n))e’+ediag(Z(k+1:k+n,k+1:k+n))’-2
Z(k+1:k+n,k+1:k+n);
minimize square_pos(norm((T-K),‘fro’));

``````for i=1:n
for j=1:n
if i==j
eij=zeros(n,1);
else
eij=zeros(n,1);
eij(i)=1;
eij(j)=-1;
end
Eij=zeros(k+n,1);
Eij(k+1:k+n)=eij;
Eij2=Eij*(Eij');
E=Eij2*Z;
Et=trace(E);
K=diag(Z(k+1:k+n,k+1:k+n))*e'+e*diag(Z(k+1:k+n,k+1:k+n))'-2*Z(k+1:k+n,k+1:k+n);
subject to
Et== T2(i,j);
Z == semidefinite(n+k);
Z(1:k,1:k)==Ik;
end
end
``````

cvx_end
EDM=Z;
X=Z(k+1:k+n,k+1:k+n);

end

HERE IS THE RESULTS:

Status: Infeasible
Optimal value (cvx_optval): +Inf

ans =

NaN 0 NaN NaN NaN NaN NaN
0 NaN NaN NaN NaN NaN NaN
NaN NaN NaN NaN NaN NaN NaN
NaN NaN NaN NaN NaN NaN NaN
NaN NaN NaN NaN NaN NaN NaN
NaN NaN NaN NaN NaN NaN NaN
NaN NaN NaN NaN NaN NaN NaN

it is probably better numerically to not apply the square to the norm in the objective function. In the event of numerical difficulties due to a large objective function, coupling into the constraints, the first thing to try is to eliminate the objective and see whether it is still reported as infeasible. Then follow the advice (suitable adjusted for CVX vs. YALMIP) in https://yalmip.github.io/debugginginfeasible .

Thank u for your answer. I checked my code. It seems that the mistake is the constraint Z==semidefinite(k+n). When I replace it with Z>=0, it seems to work. So what’s the difference of these two?

The result is still wrong.This is the first two rows of I’ve got. What I need are different values. How to correct it?
1.0e+05 *

``````0.0000         0    7.6772    7.6772    7.6772    7.6772    7.6772
0    0.0000    7.6772    7.6772    7.6772    7.6772    7.6772``````

Because you are not using sdp mode (i.e., `cvx_begin sdp`), , `Z >= 0` specifies that all elements of `Z` are nonegative. It does NOT constrain Z to be positive semidefinite. If you had used sdp mode, then `Z >= 0` and `Z == semidefinite(n+k)` would both be ways of constraining `Z` to be positive semidefinite.