# Wrong results with CVX (SDP)

Hello there,
I solved many SDPs with YALMIP and wanted to solve the same SDPs now with CVX.
The problem is that all obtained solutions from CVX differ from the YALMIP-solutions which are known to be correct. Also with CVXPY I obtain the same solution as in YALMIP.
After realizing this I tried to solve a very simple SDP with CVX and YALMIP with the same solver (here sedumi) to compare the solutions. As before the YALMIP-solution is correct and the CVX-solution is not.
Here is the code for this program:

``````%-----------------------------------------------------------------
clear all
format long g
B=[1 0 0 0.5 0 0; 0 0 0 -0.5 -1 0; 0 0 0.5 0 0 1; 0 0 0.5 0 1 0];
f=[0; -10; 0; 0];
E=100;
cvx_begin % sdp
cvx_solver sedumi
variables w t(6,1)
min(w);
subject to
% [w f'; f E*B*diag(t)*B'] >=0;
[w f'; f E*B*diag(t)*B']==semidefinite(5)
sum(t)<=1
t>=0
cvx_precision high
cvx_end
t
% Now with YALMIP
clear w t
sdpvar w;
t=sdpvar(6,1);

Model = [[w f';f E*B*diag(t)*B'] >= 0,
sum(t)<=1,
t>=0];
ops = sdpsettings('solver','sedumi');
sol = optimize(Model,w,ops);
value(t)
%-----------------------------------------------------------------
``````

I already changed the solver-precision, tried other versions of CVX, etc. without an effect.
I am very confused, what am I doing wrong?

You need `minimize(w)` . The expression `min(w)` is just the minimum of the elements of `w`, and because it is a scalar, that minimum is `w`, and if not terminated with `;` would print out that it is `cvx real affine expression (scalar)`. it does nothing, because it is just hanging in the program by itself.

So your CVX program solves a feasibility problem, because it has no `minimize` or `maximize` statement. Therefore any feasible solution is “optimal”. What you did is equivalent to
`sol = optimize(Model,[],ops);` in YALMIP.

Leave `cvx_precision` at default; Nothing good with come of changing to `high`, and some bad stuff might happen. The collective wisdom of this forum supersedes the CVX Users’ Guide on this matter.