Finish 2012-11-07 16:00:00 UTC

try03

by Alfonso Nieto-Castanon

Status: Passed
Results: 2926 (cyc: 3, node: 349)
CPU Time: 4.655
Score: 2936.29
Submitted at: 2012-11-01 09:19:42 UTC
Scored at: 2012-11-01 17:52:34 UTC

Current Rank: 1523rd (Highest: 1st )

Comments
Please login or create a profile.
Code
function xyOut = solver(a, xyIn, wts)

N=size(xyIn,1);
D=min(N,mindist(a));

mD=mean(D,1);
D=D-repmat(mD,[size(D,1),1])-repmat(mD',[1,size(D,2)])+mean(mD);
[x,nill]=svd(D);
xyOut0=x(:,1:2); 

lambda=.1; 
beta=1e3;
a(1:size(a,1)+1:end)=1;
M=(1-lambda)*eye(N)+lambda*bsxfun(@rdivide,a,max(1,sum(a,2)));
xyOut0=(M^beta)*xyOut0; 

xyOut0=sqrt(N)*detrend(xyOut0,'constant')*diag(1./max(eps,std(xyOut0,1,1)));

K=10;
k=1;
[sxyOut0,idxequal]=sortrows(round(K*xyOut0)/K);
idxequal=idxequal(all(~diff(sxyOut0,1,1),2));
xyOut=round(xyOut0*k);
while size(unique(xyOut,'rows'),1)~=N
    k=k*2;
    xyOut=xyOut0*k;
    xyOut(idxequal,:)=(xyOut0(idxequal,:)+randn(numel(idxequal),2)/K)*k;
    xyOut=round(xyOut);
end
xyOut=bsxfun(@plus,xyOut,round(median(xyIn,1)-median(xyOut,1)));

end

function D=mindist(C)

N=size(C,1);
X=logical(speye(N));
D=inf(N,N);

D(X)=0;
for n=1:N,
    X=(C*X)>0;
    X=X&(D>n);
    if ~any(X(:)),break;end
    D(X)=n;
end

end