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

try39

by Thomas Meier

Status: Passed
Results: 1444 (cyc: 7, node: 414)
CPU Time: 10.832
Score: 1456.23
Submitted at: 2012-11-03 11:10:22 UTC
Scored at: 2012-11-03 11:15:33 UTC

Current Rank: 1189th (Highest: 1st )
Based on: Soyez prêtes (diff)
Basis for: try40 (diff)
Basis for: C'est l'histoire de la vie (diff)
Basis for: try41 (diff)
...and 5 others.

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

rand('seed',2) % Make xyIn cases independent. Currently optimizing as a whole set

N=length(wts);

X=logical(speye(N));
D=inf(N);

D(X)=0;
for n=1:20,
    X=((a*X)>0)&(D>n);
    D(X)=n;
end

mD=mean(D);
E=bsxfun(@minus,bsxfun(@minus,D,mD)',mD)'+mean(mD);

[xyOut ,nill]=svd(E);
xyOut=xyOut(:,1:2); 

for ncut=1:2
    Mbeta=(0.9*eye(N)+0.1*bsxfun(@rdivide,a+eye(N),sum(a,2)+1))^10;
    for n1=1:120
        xyOut=Mbeta*xyOut;
        [c1,D,c2]=svd(cov(xyOut,1));
        xyOut=(bsxfun(@minus,xyOut,mean(xyOut)))*c1*diag(1./sqrt(.1+diag(D)))*c2'; %sqrtm(pinv(.1*eye(2)+cxyOut));
    end
    [i,j]=find(a>0.009); 
    dd=sum((xyOut(i,:)-xyOut(j,:)).^2,2);
    k=find(dd>4*mean(dd));
    if isempty(k), break; end
    a(i(k)+N*(j(k)-1))=0.009;
end

xyOut0=sqrt(N)*detrend(xyOut,'constant')*diag(1./max(eps,std(xyOut,1,1)));
k=5;
[sxyOut0,idxequal]=sortrows(round(15*xyOut0)/15);
idxequal=idxequal(all(~diff(sxyOut0,1,1),2));
xyOut=round(xyOut0);
while size(unique(xyOut,'rows'),1)~=N
    k=k*1.1;
    xyOut=xyOut0*k;
    xyOut(idxequal,:)=(xyOut0(idxequal,:)+randn(numel(idxequal),2)/10)*k;
    xyOut=round(xyOut);
end
if N<35 % small map knot lines
 xyOut=3*xyOut+randi([-1,1],N,2);
end


xyOut = bsxfun(@minus,xyOut,round(wts*(xyOut-xyIn)./sum(wts))); % AV's

end