1
$\begingroup$

I am learning genetic algorithms. I am trying to demonstrate one GA interation process for the problem as follows: X, Y and Z are the three integer variables ranges between 0 to 3, and there are initial population (Po) given as

x y z
1 0 3
1 2 0

Now I am trying to find the binary representation of the variables and apply crossover and mutation.

x=1 y=0 z=3              001 000 011
x=1 y=2 z=0              001 010 000

Next generation

Crossover

001 000 011
001 010 000

After crossover 

010 000 011
001 001 000

I am not sure if I did the two point crossover correctly. Please correct me if am wrong and help me get the result after mutation. So, that I can apply the fitness function to get the best solution found in the next generation.

$\endgroup$

1 Answer 1

0
$\begingroup$

I didn't quite follow how you applied the cross over, but there are probably many variations of this. Here is one method of binary GA's where Crossover and Mutation on binary variables work similarly as with regular variables.

First join the 3 genes into a single chromosome. Then choose two cross over points in the chromosome.

Parent 1 : 001 000 011 => 001000011
Parent 2 : 001 010 000 => 001010000

Lets suppose we choose the first crossover point between bits 2-3 and the second point between 7-8.

Parent 1 : 00 100001 1
Parent 2 : 00 101000 0

Then we create the first child by selecting the first and third sections from parent one, then the second section from parent two. Vice Versa for the second child.

Child 1 : 00 101000 1 => 001010001
Child 2 : 00 100001 0 => 001000010

Mutation is also similar but it happens at the bit level. Lets say child 2's 5th bit was selected for mutation. Then it becomes

Child 2 : 001010010

After this, the children are broken down back into genes and the fitness function can be computed

Child 1 : 001010001 => 001 010 001 => 1 2 1
Child 2 : 001010010 => 001 010 010 => 1 2 2

Here is a nice article describing the entire binary GA algorithm

$\endgroup$
2
  • $\begingroup$ I have another question for you. Does mutation and crossover happen between random genes ? $\endgroup$
    – BigB
    Commented May 8, 2015 at 20:29
  • $\begingroup$ Yes, mutation and crossover can happen at the gene level instead of the bit level. Wikipedia has a discussion about chromosome repesentaiton $\endgroup$
    – Eric Farng
    Commented May 9, 2015 at 11:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.