problam with genetic algorithm individuals intialization
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
I'm working with genetic algorithm to optimize umts network at first i have BTS distribute randomly each has (x,y) coordinates i generate the candidates solutions using rand the solutions are numbers to be summed with the original x and y they i have tried this
clc
clearvars
ver_code=1; % Version of code -> for reference only
ga=1; % Counter
max=2000 ; %@ Maximum number of generationss
radius=2.5; %@ The exact value is 0.35
N=31; %@ Number of BS`s
limits=30; %@ The limits of the coverage area in Kilometer
pop_size=300; %@ The population size
% co_prob=0.8;
mutrate=0.01; %@ The Mutation rate
selection=0.5; % The persentage of survival
Generation_index=0; %-> for reference only
%__________________________________________________________________________
load('C:\Users\zaizafoon\Desktop\three.mat','ua'); % create random points
[xa,ya]=size(ua);
pop_x=((rand(pop_size,N)*limits)); % create random populatio for X points
pop_y=(((rand(pop_size,N)*limits))); % create random populatio for Y points
all_cost_ary=zeros(1,pop_size); % Initialise an array specifing the cost for each population -> for reference only
prev_cost=-1000; % This variable is used only for finding the best population;
%M=ceil((pop_size-keep)/2); % Number of parents
keep=floor(selection*pop_size); % number of mating
odds=1;
for ii=2:keep
odds=[odds ii*ones(1,ii)];
end
Nodds=length(odds);
odds=keep-odds+1;
%__________________________________________________________________________
while ga<max
ga=ga+1
cost=zeros(1,2);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%cost calculations
for t=1:pop_size
for i=1:N
%Shifting
test_ary(i,1)=ua(i,1)+pop_x(t,i);
test_ary(i,2)=ua(i,2)+pop_y(t,i);
if(test_ary(i,1)>limits)
test_ary(i,1)=test_ary(i,1)-limits;
end
if(test_ary(i,2)>limits)
test_ary(i,2)=test_ary(i,2)-limits;
end
end
cost_per_pop(t)=cost_xy_ary_by_Dist(test_ary,radius);
if prev_cost<cost_per_pop(t)
prev_cost=cost_per_pop(t);
best_cost_pop_x=pop_x(t,:);
best_cost_pop_y=pop_y(t,:);
Generation_index=ga;
end
but the candidates solution were all the same so the fitness function does not change for each individuals what I'm doing wrong ?
0 Kommentare
Antworten (0)
Siehe auch
Kategorien
Mehr zu Genetic Algorithm 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!