Message Boards Message Boards


How to incorporate crossover probability in my program?

Posted 6 years ago
0 Replies
0 Total Likes

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]}]; 

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

Thanks in advance. :)

Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
or Discard

Group Abstract Group Abstract