Roulette Wheel Selection in genetic algorithm -


i confusing roulette wheel selection in genetic algorithm. algorithm shown following

for i=1 n  x=random[0,1];  k=1;  while k<n&&x>cusum    k=k+1  end tmp_p[i]=p[k]; end 

is correct? confusing while condition

first way:

 while k<n&&x>cusum    k=k+1  end  tmp_p[i]=p[k]; 

or second way

 while k<n&&x>cusum    k=k+1;         tmp_p[i]=p[k]; end 

which correct? thank much

the first way correct.

you go through cumsum array until find 1 bigger random number , select individual.

however, expect cusum variable should array , use:

 while k<n && x>cusum[k] 

Comments

Popular posts from this blog

cakephp - simple blog with croogo -

How to group boxplot outliers in gnuplot -

bash - Performing variable substitution in a string -