function optiX = mosekSDPEpigraph(GstarCut, exR, consVIndices, exV, kk )


nF = size(GstarCut,1)/4;  % nF
nV = size(GstarCut,2)/2;  % nV


mapObj = containers.Map('KeyType','int32', 'ValueType','any');

for i=1:size(consVIndices,1)
    mapObj(consVIndices(i)) = [exV(2*i-1) exV(2*i)];
end

perTriRot = zeros(2,2,nF);
for fi=1:nF
    perTriRot(:,:,fi) = [exR(4*fi-3) exR(4*fi-1); exR(4*fi-2) exR(4*fi)];  %%!!!!!!!!!!!!!!!!! Perhaps it's required to tranpose it!!!!!!!!!!!!!!!!!!!
end

% new_insideT = FList;
% TV = VList;
% 
% new_outsideT = [];
% num_insideV = 0;
% boneRot = 90;


facesSize = nF;
restVSize = nV;

%Gstar = calc_Gi_stack(Faces, restV);
%GstarCut = extractG(restV, Faces);

k = zeros(4*facesSize, 1);
for i = 1:(facesSize)
    kIdx = 4*(i-1) + 1;
    Ri = perTriRot(:,:,i);
    k(kIdx:kIdx+3) = [Ri(1); Ri(2); Ri(3); Ri(4)];
end

l = -1 * transpose(GstarCut) * k;
numConstrainedVtx = size(mapObj.keys,2);
% Number of constraints given to MOSEK is 2 times the number of constrained
% vertices in 2D, because there is one constraint per dimension.
numConstraints = 2*numConstrainedVtx;
Aeq = zeros(numConstraints, 2*restVSize); %neq by #x linear equality matrix
beq = zeros(numConstraints, 1); %neq by 1 linear equality rhs

constraintCount = 0;
for idx = mapObj.keys
    mapValue = mapObj(idx{1});
    %which column to insert constraint into.
    xCol = 2*idx{1} - 1;
    yCol = 2*idx{1};
    constraintIdx = 2*constraintCount + 1;
    Aeq(constraintIdx, xCol) = 1;
    Aeq(constraintIdx + 1, yCol) = 1;
    beq(constraintIdx) = mapValue(1);
    beq(constraintIdx + 1) = mapValue(2);
    constraintCount = constraintCount + 1;
end

consM = [];
consb = [];


%kk = 10000;
consM = [sqrt(kk)*sparse(Aeq)];
consb = -kk*sparse(Aeq)'*beq;
TAeq = Aeq;
Tbeq = beq;
Aeq = [];
beq = [];

GstarCut=[GstarCut;consM];
%Setup parameters to feed to 'conic'
F = [GstarCut];
c = l + consb;
Aleq = [];
bleq = [];
lx = -Inf * ones(size(F,2),1);
ux = Inf * ones(size(F,2),1);
b = [];
bc = [];

GstarRows = size(GstarCut,1);
GPrimeStack = [GstarCut,  sparse([],[],[],GstarRows, GstarRows), sparse([],[],[],GstarRows,1), sparse([],[],[],GstarRows,1)];

%toc;
%disp('SETUP 1 TIME ^');
v = conic_semidefinite_multi(F, c, Aeq, beq, Aleq, bleq, lx, ux, b, bc, GPrimeStack, facesSize,k);
optiX = transpose(reshape(v, 2, restVSize));
