Filter löschen
Filter löschen

optimization of location using GA

1 Ansicht (letzte 30 Tage)
m. muner
m. muner am 11 Mär. 2016
Beantwortet: Alan Weiss am 11 Mär. 2016
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

Akzeptierte Antwort

Alan Weiss
Alan Weiss am 11 Mär. 2016
It would help me to understand what you are doing, and might help you, if you would do the following:
  • Define exactly what your control variables are, meaning the variables you want to move in order to optimize something. Are there any constraints, such as bounds, on your variables?
  • Define exactly, in words or a formula (not code) what the objective function is. I mean, give a formula or exact description so that we can understand exactly what you are trying to minimize.
  • After you have given us those two things, show us the code that is supposed to calculate your objective function. Not minimize your objective function, just evaluate the thing as a function of the control variables.
  • After all that, maybe you will have the problem well-formulated enough that it will be possible to optimize.
Good luck,
Alan Weiss
MATLAB mathematical toolbox documentation

Weitere Antworten (0)

Kategorien

Mehr zu Problem-Based Optimization Setup finden Sie in Help Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by