Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Order Crossover (OX) - genetic algorithm

Can someone explain me how Order Crossover works? I will give this example and I want to understand it in a generic way to implement after.

Parent 1 = 1 2 3 | 4 5 6 7 | 8 9

Parent 2 = 4 5 2 | 1 8 7 6 | 9 3

and the solution are two childreen:

Children 1 = 2 1 8 | 4 5 6 7 | 9 3

Children 2 = 3 4 5 | 1 8 7 6 | 9 2

I understand some parts but others not.

Thanks

like image 307
Silva_PT_SCP Avatar asked Oct 22 '14 22:10

Silva_PT_SCP


2 Answers

Basically, a swath of consecutive alleles from parent 1 drops down, and remaining values are placed in the child in the order which they appear in parent 2.

enter image description here

Step 1: Select a random swath of consecutive alleles from parent 1. (underlined)

Step 2: Drop the swath down to Child 1 and mark out these alleles in Parent 2.

Step 3: Starting on the right side of the swath, grab alleles from parent 2 and insert them in Child 1 at the right edge of the swath. Since 8 is in that position in Parent 2, it is inserted into Child 1 first at the right edge of the swath. Notice that alleles 1, 2 and 3 are skipped because they are marked out and 4 is inserted into the 2nd spot in Child 1.

Step 4: If you desire a second child from the two parents, flip Parent 1 and Parent 2 and go back to Step 1.

like image 181
Niko Adrianus Yuwono Avatar answered Oct 04 '22 01:10

Niko Adrianus Yuwono


One such solution for Ordered Crossover is detailed in this post.

This answer provides some sample java code with documentation detailing the processes used for the Ordered Crossover.

Additionally, this paper from Moscato provides a breakdown of the OX Process.

Hope this helps!

like image 28
Matthew Spencer Avatar answered Oct 03 '22 23:10

Matthew Spencer