The initial individuals were evaluated directly using binary_value

This resulted in the fitness NOT being set, and some abort or segmentation fault later
Only eoEvalFunc shouydl be used to evaluate individuals!!!
This commit is contained in:
marc 2000-06-22 03:23:15 +00:00
commit b03bd951e0

View file

@ -22,14 +22,19 @@ main()
const unsigned POP_SIZE = 8, CHROM_SIZE = 16;
unsigned i;
// a chromosome randomizer
eoBinRandom<Chrom> random;
// the populations:
eoPop<Chrom> pop;
// Evaluation
eoEvalFuncPtr<Chrom> eval( binary_value );
for (i = 0; i < POP_SIZE; ++i)
{
Chrom chrom(CHROM_SIZE);
random(chrom);
binary_value(chrom);
eval(chrom);
pop.push_back(chrom);
}
@ -52,9 +57,6 @@ main()
// replacement
eoInclusion<Chrom> inclusion;
// Evaluation
eoEvalFuncPtr<Chrom> eval( binary_value );
// Terminators
eoFitTerm<Chrom> term( pow(2.0, CHROM_SIZE), 1 );