function [A] = match(cost)

%Input: a cost matrix (m x m )
%Output: A permutation matrix A that gives 
%the maximum assignment

m = size(cost,1);
prob.c = reshape(cost,m*m,1);
prob.blx = sparse(m*m,1);
prob.bux =   ones(m*m,1);
prob.a = sparse([ kron(eye(m),ones(1,m)) ;
           repmat(eye(m),1,m) ]);
prob.blc = ones(2*m,1);
prob.buc = ones(2*m,1);
[r,res]=mosekopt('echo(0) maximize',prob);
A = reshape(res.sol.itr.xx(1:m*m),m,m);


