Winner Paulo Uribe (turbf1)

2002-05-23 00:00:00 UTC

freemov4

by freemov4

Status: Passed
Results: Average strain = 2087.702
CPU Time: 92.352
Score: 7914.56
Submitted at: 2002-05-23 16:18:16 UTC
Scored at: 2002-05-24 14:32:24 UTC

Current Rank: 587th

freemov4
23 May 2002
I will not be surprised if this wins. :)
Code
```function fx = solver(d,bx)
if ~any(d(:)>0), fx = repmat(bx([1 3]),size(d,1),1); return; end
m = size(d,1); [p,id] = sort(-sum(d)); p(id)=1:m; d = d(id,id);
r1 = (bx(2)-bx(1)); r2 = (bx(4)-bx(3));
xc = (bx(2)+bx(1))/2+i*(bx(4)+bx(3))/2;
[I,J,v] = find(triu(d)>0); td = d((J-1)*m+I); % required distances.
x = repmat(xc,m,1)+0.1*(rand(m,1)-0.5); x(1:2) = bx(1:2)+i*bx(3:4);
step = ceil(m/10);
for k = 3:step:m % find good position for each point.
in = (I<=k)&(J<=k);
[bestd,x(1:k)]=freemov(x(1:k),k,I(in),J(in),td(in),100,bx);
end
[bestd,x]=freemov(x,m,I,J,td,100,bx);
fx = [real(x(p)) imag(x(p))];

function [fd,fc] = freemov(c,m,I,J,td,iter,bx)
fc = c; fd = sum(abs(abs(c(I)-c(J))-td));
for k = 0:iter