how do i avoid repeated value in crossover?
3 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Walter Roberson
2018-11-19
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 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Genetic Algorithm 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!