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:
parent
ff52d48ccd
commit
b03bd951e0
1 changed files with 7 additions and 5 deletions
|
|
@ -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 );
|
||||
|
||||
|
|
|
|||
Reference in a new issue