how do i code parent selection automatically?
    1 view (last 30 days)
  
       Show older comments
    
i want to make acoding on ga GA parent selection to using crossover rate
RS is the parent that i have already sorted the fist collumn is the numbering for the result, 2nd collumn is the value and 3rd untill 14th collumn is the result arrangement 
RS =
1       31868          11           4           7           5          12           3           9           1         2           8           6          10
2       35816           8          10          11           6           9           4           5           1         7           3           2          12
3       39008          10           4           5           2           9           7           3          11         6          12           1           8
4       39674           4           9           2           6           5          11          10          12         1           7           8           3
5       42110           3           5           9          11           7           4           2           8         1          10          12           6
6       45418           6           3          11           7           8           5           1           2         4           9          10          12
7       47514           8           9          12           2          10           3           7           4         1          11           5           6
8       50936           8           7          12           2           5           9           6           4         3          10           1          11
9       53966           7           6          12           3          10           8          11           5         4           1           2           9
10      57422           5           2           6           4           9           8          12          11         7           1          10           3
 after the sorting i want to choose parent to make a crossover using 0.4 as a crossover persentage 
%% parent selection 
cp=0.4;              % Crossover Percentage
np=2*round(cp*r/2);  % Number of Offsprings (Parents)
from the calcuation i need to chhose 4 out of 10 parent  so i want to choose  parent 1 and 2 then 9 and 10
then i do it like this
 p1 = RS(1,3:end)
 p2 = RS(2,3:end)
 p3 = RS(9,3:end)
 p4 = RS(10,3:end)
however when i do it like this, if i change the crossover persentage to other number i need to do it manually.. 
so how can i make it automatically choose whatever i change the crossover rate?
for example if i change the crossover rate to 0.6 so i need to choose 6 parent 
when i run the coding will automatically choose 3 parent from top and 3 parent from bellow..
0 Comments
Answers (0)
See Also
Categories
				Find more on Shifting and Sorting Matrices 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!