optimization of location using GA
Show older comments
hello guys i really need help I'm trying to distribute circles within location area so the distribution offer less overlap and less holes between the circles my fitness function codes are
function [fit] = cost_xy_ary_by_Dist(xy_cor,r,area,w1,w2)
w1=0.3;
w2=0.7;
[row col]=size(xy_cor);
cost=0;
for i=1:row
cost(i)=0;
out(i)=0;
x1=xy_cor(i,1);
y1=xy_cor(i,2);
% xy_cor(i,:)=[]
a= ( sqrt( (((xy_cor(:,1) - x1).^2 )) + (((xy_cor(:,2) - y1).^2 )) ));
if(a<2*r)
cost(i)=cost(i)+1;
% cost(i)=cost(i)+( sqrt( (((xy_cor(:,1)-1) - x1).^2 ) + (((xy_cor(xy_cor(:,2) - y1).^2 )) )- 2*r));
% ov= find( ( sqrt( (((xy_cor(:,1) - x1).^2 )) + (((xy_cor(:,2) - y1).^2 )) ))<2*r);
% if(find(ov==i))
% ov(find(ov==i))=[];
% end
else
if(a>2*r)
out(i)=outter(i)+1;
end
end
%pdecirc(x1,y1,r)
end
cost_all=cost./area;
outter=out./area;
fit=w1*cost_all+w2*outter;
end
but it's doesn't work any one can tell me why i'll be very thankful
Accepted Answer
More Answers (0)
Categories
Find more on Choose a Solver in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!