function [w , b , xi ] = mossvm(X,Y,c)
%min 0.5*\|w\|^2 + c \sum \xi_i + \sum t_ij
% \xi_i \ge 0
% y_i(w^\topx_i + b ) \ge 1 - xi_i
% 

[row,col] = size(X);
%c = c/row;
prob.qosubi = [1:col]';
prob.qosubj = [1:col]';
prob.qoval = ones(1,col);

prob.c = [ sparse(col+1,1) ; c*ones(row,1) ]; 
prob.blx = [ -inf*ones(col+1,1) ;sparse(row,1); ];
prob.bux = [  inf*ones(col+1+row,1) ];

prob.a = [ (X.*repmat(Y,1,col)) Y speye(row)];
prob.blc = [ ones(row,1) ];
prob.buc = [ inf*ones(row,1) ];
param.MSK_DPAR_INTPNT_CO_TOL_PFEAS = 1.0e-12;

% Dual feasibility tolerance for the dual solution
param.MSK_DPAR_INTPNT_CO_TOL_DFEAS = 1.0e-12;

% Relative primal-dual gap tolerance.
param.MSK_DPAR_INTPNT_CO_TOL_REL_GAP = 1.0e-12;
param.MSK_IPAR_INTPNT_NUM_THREADS = 4;

[r,res]=mosekopt('echo(1) minimize',prob,param);
w=res.sol.itr.xx(1:col);
b = res.sol.itr.xx(col+1);
xi = res.sol.itr.xx(col+2:col+1+row);
