k=10000;
nF = sizeExR;

nm = size(G,1) + size(indices,1);
mosekYMPtime = tic;

% prm = setParams;
MAX_ITER = 150;
cvx_quiet(false);

%diary('mosekProgress.txt');

sdpCVXtimeMS = tic;
cvx_begin

variable v(n+1, 1);

F = G*v(1:n,1);
{[ F- exR; sqrt(k)*(v(indices) - exV(indices))], v(n+1,1)} == lorentz(nm);
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)];    
    curR'*curF+curF'*curR == semidefinite(2);
end
sdpCVXtimeM  = toc(sdpCVXtimeMS);

sdpCVXtimeSS = tic;
minimize( v(n+1,1) );
cvx_end
sdpCVXtimeS  = toc(sdpCVXtimeSS);

fprintf('cvx+mosek modeling time = %f\n',sdpCVXtimeM);
fprintf('cvx+mosek solving time = %f\n',sdpCVXtimeS);


v_value=v(1:n,1);

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('cvx+mosek modeling time = %f\n',sdpCVXtimeM);
fprintf('cvx+mosek solving time = %f\n',sdpCVXtimeS);


