how do i avoid repeated value in crossover?
3 views (last 30 days)
Show older comments
sharifah shuthairah syed abdullah
on 19 Nov 2018
Commented: Ibrahim Fares
on 24 Aug 2019
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 = RS
CrossoverIndex = 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 ?
2 Comments
Accepted Answer
Walter Roberson
on 19 Nov 2018
There is no valid 1 point cross-over between P1 and P2 according to those rules.
You can get a valid 1 point cross-over only if you can identify some point, N > 1, such that P1(1:N-1) is a permutation of P2(1:N-1) and P1(N:end) is a permutation of P2(N:end). You can show that cannot happen with those P1 and P2.
6 Comments
More Answers (0)
See Also
Categories
Find more on Genetic Algorithm 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!