[galib] Bug in CycleCrossover

Bobbadoc@aol.com Bobbadoc at aol.com
Tue Oct 11 22:30:48 EDT 2005


I believe that the implementation of CycleCrossover in GA1DArrayGenome.c  
contains an error.
 
Briefly, I believe that the variable "current" in the segment of code  
beginning with 
      if (c1 && c2)
should be reinitialized before the "bro" child genome is created, that  is, 
that the line
     current = 0;
should be added between
     mask.clear();
 and
     bro.gene(0, dad.gene(0));
 
As the code reads now, the cycle for "bro" is resought starting at the  last 
new cycle-member's position in the earlier code (denoted by the value of  
<current> left over from seeking the cycle during creation of  the "sis" genome) 
but the corresponding mask bit is not set, as it should be  (rather, the mask 
bit at position 0 is set, as it was in the code for  "sis").  As a result, the 
"bro" child, which presumably is supposed to  represent a permutation, may 
contain a duplicate value (and a  corresponding omission).  On a subsequent 
crossover attempt,  the bogus chromosome can cause the program to hang up, 
presumably in an  infinite loop.
 
If anyone thinks that I am in error or would like a more detailed  
explanation, please let me know.  I have very much enjoyed working with  this library.
 
Sincerely,
Bob Moss
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.mit.edu/pipermail/galib/attachments/20051011/04eaaaec/attachment.htm


More information about the galib mailing list