This page contains a list of bugs and suggested workarounds. Please submit to galib-bugs@mit.edu a bug report if the problem you're having is not on this list.
configuration issues
206  void
207  sran1(unsigned int seed) {
208    int j;
209    long k;
210
211    idum = seed;
212    if (idum < 1) idum=1;
213    for (j=NTAB+7;j>=0;j--) {
214      k=(idum)/IQ;
215      idum=IA*(idum-k*IQ)-IR*k;
216      if (idum < 0) idum += IM;
217      if (j < NTAB) iv[j] = idum;
218    }
219    iy=iv[0];
220  }
...
280  void 
281  sran2(unsigned int seed) {
282    int j;
283    long k;
284
285    idum = STA_CAST(long,seed);
286    if (idum < 1) idum=1;
287    idum2=(idum);
288    for (j=NTAB+7;j>=0;j--) {
289      k=(idum)/IQ1;
290      idum=IA1*(idum-k*IQ1)-k*IR1;
291      if (idum < 0) idum += IM1;
292      if (j < NTAB) iv[j] = idum;
293    }
294    iy=iv[0];
295  }
becomes this:
206  void
207  sran1(unsigned int seed) {
208    int j;
209    long k;
210
211    idum = seed;
212    if (idum == 0) idum=1;
       if (idum < 0) idum = -idum;
213    for (j=NTAB+7;j>=0;j--) {
214      k=(idum)/IQ;
215      idum=IA*(idum-k*IQ)-IR*k;
216      if (idum < 0) idum += IM;
217      if (j < NTAB) iv[j] = idum;
218    }
219    iy=iv[0];
220  }
...
280  void 
281  sran2(unsigned int seed) {
282    int j;
283    long k;
284
285    idum = STA_CAST(long,seed);
286    if (idum == 0) idum=1;
       if (idum < 0) idum = -idum;
287    idum2=(idum);
288    for (j=NTAB+7;j>=0;j--) {
289      k=(idum)/IQ1;
290      idum=IA1*(idum-k*IQ1)-k*IR1;
291      if (idum < 0) idum += IM1;
292      if (j < NTAB) iv[j] = idum;
293    }
294    iy=iv[0];
295  }
  353 mj=MSEED-idum;becomes this:
353 mj=labs(MSEED-labs(idum));
76 evaldata = (GAEvalData*)0; 77 } ... 104 evaldata = (GAEvalData*)0; 105 }becomes this:
76        evaldata = (GAEvalData*)0;
          ga = (GAGeneticAlgorithm*)0;
77      }
...
104       evaldata = (GAEvalData*)0;
          ga = (GAGeneticAlgorithm*)0;
105     }
  313 if(ival) os << "true\n"; 314 else os << "false\n";becomes this:
313 if(ival) os << "1\n"; 314 else os << "0\n";
95         case STRING:
96           {
97             char* ptr=0;
       becomes this:
95         case STRING:
96           if(v != val.sval) {
97             char* ptr=0;
       
  which not val.
       do...while loop into a while loop.  This should be done in GA1DBinStringGenome.C, GA2DBinStringGenome.C, and GA3DBinStringGenome.C.
       _evaluated flag is not properly reset in the initialize, mutate, and crossover methods.  In any custom-defined genome, you must set _evaluated to gaFalse whenever you change the state of a genome, otherwise the genome's evaluator will not be invoked (the cached score will be used instead).
       
101       } while(rsquare >= 1.0 || rsquare == 0.0);
102
103       factor = sqrt( -2.0 * log(rsquare) / rsquare );
104
105       cachevalue = var1 * factor;
       
       becomes this:
       
101       } while(rsquare >= 1.0 || rsquare == 0.0);
102
          double val = -2.0 * log(rsquare) / rsquare;
          if(val > 0.0) factor = sqrt(val);
          else           factor = 0.0;
104
105       cachevalue = var1 * factor;
       
       
  
264         }
265         return npop;
266       }
       
       becomes this:
       
264         }
            pop->size(npop);
265         return npop;
266       }
       
       
  
69  CompositeGenome(int element, int bond, GABin2DecPhenotype& p, 
70  		  GAGenome::Evaluator f, void* u) :
71  		  GAGenome.cppompositeInitializer,
72  			   CompositeMutator,
73			   CompositeComparator) {
       
       to:
       
69  CompositeGenome(int element, int bond, GABin2DecPhenotype& p, 
70		  GAGenome::Evaluator f, void* u) :
71		  GAGenome(CompositeInitializer,
72			   CompositeMutator,
73			   CompositeComparator) {
       
56    for(unsigned int i=0; i<sizeof(unsigned int); i++) {
       
       to:
       
56    for(unsigned int i=0; i<BITS_IN_WORD * sizeof(unsigned int); i++) {
       
  
69  if(node->prev != node) iter.eldest();
70  else if(node->parent) iter.parent();
71  else iter.node = (GANodeBASE *)0;
72  t->insert((GANode<T> *)GATreeBASE::remove(node), (GANode<T> *)0, 
73	    GATreeBASE::ROOT);
74
75  return t;
76 }
       
       should be modified to
       
69  if(node->prev != node) iter.eldest();
70  else if(node->parent) iter.parent();
71  else iter.node = (GANodeBASE *)0;
    GANode<T> *tmpnode = (GANode<T>*)GATreeBASE::remove(node);
    tmpnode->prev = tmpnode;
    tmpnode->next = tmpnode;
    tmpnode->parent = (GANodeBASE *)0;
    t->insert(tmpnode, (GANode<T> *)0, GATreeBASE::ROOT);
74
75  return t;
76 }
       
       
       
  Change lines 83 and 114 in array1.op.C. The first change is in GA1DArrayFlipMutator:
83     for(n=1; n<nMut; n++){
should be
83     for(n=0; n<nMut; n++){
The second change is in GA1DArraySwapMutator:
114 for(n=1; n<nMut; n++)should be
114 for(n=0; n<nMut; n++)
See Numerical Recipes in C for details about the issues of using various random number generators. These issues have been resolved in the 2.4 release of GAlib.
In the scaling member function in population.C, add one line of code so that
275 sm->resize(n); 276 return *sm;becomes
275  sm->resize(n);
     if(evaluated) sm->evaluate(*this);
276  return *sm;
In population.C, change 0 to an i in line 153 so that
151 ind = new GAGenome * [N]; 152 for(i=0; i<n; i++) 153 ind[i] = arg.ind[0]->clone(); 154 155 if(arg.sm) sm = arg.sm->clone();becomes
151 ind = new GAGenome * [N]; 152 for(i=0; i<n; i++) 153 ind[i] = arg.ind[i]->clone(); 154 155 if(arg.sm) sm = arg.sm->clone();
In population.C, insert a line and modify a line to change
209 sm->resize(pops); 210 statted = sorted = evaluated = gaFalse; 211 n = pops;to
209  sm->resize(pops);
210  statted = sorted = gaFalse;
211  n = pops;
     if(evaluated == gaTrue) evaluate(gaTrue);
and in the file scaling.C, insert a single line to change
102 fitSum = fitAve = fitMax = fitMin = fitVar = fitDev = 0.0; 103 return(n = popsize);to
102  fitSum = fitAve = fitMax = fitMin = fitVar = fitDev = 0.0;
     evaluated = gaFalse;
103  return(n = popsize);
GAGenome * GAPopulation::replace(GAGenome * repl, const int which),
      if(sorted)
	rawMax = ind[n-1]->score();
      else if(orig->score() == rawMax){
	rawMax = ind[0]->score();
	for(i=1; i<n; i++)
	  rawMax = Min(rawMax, ind[i]->score());
      }
      else
	rawMax = Max(rawMax, repl->score());
The 'Min' should be 'Max':
          rawMax = Max(rawMax, ind[i]->score());
GAGenome * GAPopulation::replace(GAGenome * repl, const int which))