k=10000;

mosekYMPtime = tic;

Options = sdpsettings('verbose',1,'solver','mosek-sdp');
%Options = sdpsettings('verbose',1,'solver','mosek-sdp', 'mosek.MSK_IPAR_INTPNT_MAX_ITERATIONS', 20, 'showprogress', 1);
%Options.mosek


v = sdpvar(n,1); 
F = G*v;

z = [F - exR; sqrt(k)*(v(indices) - exV(indices))]; % z'*z
t = sdpvar;

%
% Conic programming
%
objective = t;
objectiveConstraints = cone(z,t);
c = [objectiveConstraints];

%c = [c (v(indices) == exV(indices))];

% %
% % Quadratic programming
% %
% objective = z'*z;
% c = [];

if bNoninversion

nF = sizeExR;
for i=1:nF
    curR = [exR(4*i-3) exR(4*i-2);exR(4*i-1) exR(4*i)];
    curF = [F(4*i-3) F(4*i-2);F(4*i-1) F(4*i)];
    c = [c, (curR'*curF+curF'*curR>=0)];
end

end

sdpYalTime  = toc(mosekYMPtime);
fprintf('sdp feed to Yalmip time = %f\n',sdpYalTime);

%diary('mosekProgress.txt');
sdpYMPtime = tic;
res = solvesdp(c,objective,Options);
sdpYMTime  = toc(sdpYMPtime);
%diary off

fprintf('sdp yalmip+mosek time = %f\n',sdpYMTime);


v_value=value(v);

checkSolution(v_value, exR, exV, indices, G, k);

optiV = x2vt(v_value);

write2obj(optiV, FList, 'MosekM.obj');


visualizeDistort( VList, FList, optiV, exR );
axis equal;

fprintf('sdp feed to Yalmip time = %f\n',sdpYalTime);
fprintf('sdp yalmip+mosek time = %f\n',sdpYMTime);


