# Yalmip works CVX does not

When solving SDP problem, they uses same SeDuMi solver.
However, while Yalmip works fine, CVX prints indefeasible error.

Below is the optimization part of CVX and YALMIP

1. Yalmip

``````yalmip('clear');

nX=sdpvar(n,k);
nD=sdpvar(k,k);
nL=sdpvar(k,k);
Z=sdpvar(k,k);
gamma=sdpvar(1,1);

F=lmi(' J*(-nD)*J > 0 ');

for i=1:k-1,
for j=i+1:k,
F=F+lmi(' 2*(nX(:,i)-nX(:,j))''*(X(:,i)-X(:,j))  == nD(i,j)+D(i,j) ');
F=F+lmi(' nD(i,j) > Rho1' );
F=F+lmi(' nD(i,j) < 50' );
end
end

for i=1:k,
for j=1:n,
F=F+lmi(' nX(j,i)-X(j,i) < Lim ')+lmi(' nX(j,i)-X(j,i) > -Lim ');
end
F=F+lmi(' nD(i,i) == 0 ');
end

for i=1:k-1,
for j=i+1:k,
F=F+lmi(' Z(i,j) == L(i,j) - p*exp(q*D(i,j))*q*(nD(i,j)-D(i,j)) ');
F=F+lmi(' nL(i,j) == Z(i,j) ');
end
F=F+lmi(' Z(i,i) == 0 ');
F=F+lmi(' nL(i,i) == -sum(Z(i,:)) ');
end
F=F+lmi(' Z(k,k) == 0 ');
F=F+lmi(' nL(k,k) == -sum(Z(k,:)) ');

F=F+lmi(' Q*nL*Q'' > gamma*eye(k-1) ');

OPTIONS = sdpsettings('verbose', 1);
Sol=solvesdp(F,-gamma,OPTIONS);
``````

1. CVX

``````    cvx_begin sdp
variable nX(n, k);
variable nD(k, k);
variable nL(k, k);
variable Z(k, k);
variable Gamma(1, 1);

minimize (-Gamma)
subject to
J*(-nD)*J > 0
for i=1:k-1
for j=i+1:k
2*( nX(:,i)-nX(:,j) )'*(X(:,i)-X(:,j))  == nD(i,j)+D(i,j);
nD(i,j) > Rho1
nD(i,j) < 50
end
end
for i=1:k,
for j=1:n,
nX(j,i)-X(j,i) < Lim
nX(j,i)-X(j,i) > -Lim
end
nD(i,i) == 0
end
for i=1:k-1,
for j=i+1:k,
Z(i,j) == L(i,j) - p*exp(q*D(i,j))*q*(nD(i,j)-D(i,j))
nL(i,j) == Z(i,j)
end
Z(i,i) == 0
nL(i,i) == -sum(Z(i,:))
end
Z(k,k) == 0
nL(k,k) == -sum(Z(k,:))
Q*nL*Q' > Gamma*eye(k-1)
cvx_end``````

Have you tried both SDPT3 and SeDuMi; and if so, does it give the same answer?

Also, make sure you declare your variables such as `nD`, `nL`, and `Z` to be symmetric if that is what you intend for them to be.

You’re welcome to submit a bug report for this at http://support.cvxr.com, but if you do, please make sure to include not just the model but the data used as well. If I cannot reproduce the exact version of the model you are solving, I can’t solve it.