how do i avoid repeated value in crossover?

1 view (last 30 days)
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
sharifah shuthairah syed abdullah
RS =
Columns 1 through 10
1 30016 7 5 4 11 12 3 1 2
2 39570 9 10 7 1 12 8 4 11
3 41260 1 9 3 11 5 2 8 4
4 41482 12 10 9 5 11 8 7 6
5 41582 11 3 9 10 5 7 8 4
6 42118 8 9 5 7 6 12 1 10
7 43574 10 3 8 5 4 11 12 6
8 49386 12 6 3 5 1 8 2 10
9 55566 3 12 8 6 11 2 10 5
10 62880 11 3 10 8 7 6 1 9
Columns 11 through 14
9 8 6 10
6 3 2 5
7 6 12 10
3 2 4 1
6 2 1 12
4 2 3 11
1 9 2 7
11 4 9 7
9 4 1 7
12 5 4 2
i take P1 and P2 from RS

Sign in to comment.

Accepted Answer

Walter Roberson
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
sharifah shuthairah syed abdullah
thank you so much... i change the point crossover to cycle crossover and it work.. thank you so much for your explaination :)
Ibrahim Fares
Ibrahim Fares on 24 Aug 2019
how you change the crossover to cycle crossover?

Sign in to comment.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!