Message Boards Message Boards

How to incorporate crossover probability in my program?

Posted 9 years ago

I am working with genetic algorithm for optimization. I feel problem in crossover of binary chromosomes. I actually succeeded in making code for crossover of chromosome but now I failed to incorporate crossover probability in it. I want crossover probability of 0.85 which; in my program means, about 3 binary sets (elements) out of 18 are copies as same without cross overing. Here, I share my program which I made until now; I need incorporation of cross over probability in it.

crossover[c1_List, c2_List] /; Length @ c1 == Length @ c2 := 
  Module[{cut, c1a, c1p, c2a, c2p}, 
    cut = RandomInteger[{2, Length @ c1 - 1}]; 
    {c1a, c1p} = {c1[[1 ;; cut]], c1[[cut + 1 ;; -1]]}; 
    {c2a, c2p} = {c2[[1 ;; cut]], c2[[cut + 1 ;; -1]]}; 
    {cut, Join[c1a, c2p], Join[c2a, c1p]}]; 

SeedRandom[42];
genome1 = RandomInteger[1, {6, 8}]
genome2 = RandomInteger[1, {6, 8}]
MapThread[crossover, {genome1, genome2}]

Thanks in advance. :)

POSTED BY: mamoona arshad
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract