please help me in order to make a one point crossover
P1 =
7 5 1 3 6 11 10 8 12 9 4 2
P2 =
3 5 4 6 2 7 9 11 8 1 10 12
than i do a coding like this
P1 = RS %RS is an result that i get from parent selection before
P2 = RSCrossoverIndex = 6; c1 = [P1(1:CrossoverIndex) P2(CrossoverIndex+1:end)]c2 = [P2(1:CrossoverIndex) P1(CrossoverIndex+1:end)]
then the result i get from the coding is like this
c1 =
7 5 1 3 6 11 9 11 8 1 10 12
c2 =
3 5 4 6 2 7 10 8 12 9 4 2
the result that i get from the coding is wrong because there are same value repeated in c1 number 11, 1 is reapeted and number 2, 4 is missing and also c2 which is 4, 2 is reapeated and mising 11, 1..
what can i do to make the number is not repeated ?
Best Answer