Added missing files and updated old MGE files

This commit is contained in:
jmerelo 2001-05-17 07:29:50 +00:00
commit e32c52d332
4 changed files with 106 additions and 25 deletions

View file

@ -10,7 +10,7 @@
#include <eo>
#include <ga/eoBitOp.h>
#include "binary_value.h"
#include "RoyalRoad.h"
// Viri
#include <MGE/VirusOp.h>
@ -25,16 +25,17 @@ typedef eoVirus<float> Chrom;
int main()
{
const unsigned POP_SIZE = 100, CHROM_SIZE = 16;
const unsigned POP_SIZE = 1000, CHROM_SIZE = 128;
unsigned i;
eoBooleanGenerator gen;
// the populations:
eoPop<Chrom> pop;
// Evaluation
eoEvalFuncPtr<Chrom> eval( binary_value );
// Evaluation
RoyalRoad<Chrom> rr( 4 );
eoEvalFuncCounter<Chrom> eval( rr );
eoInitVirus<float> random(CHROM_SIZE, gen);
for (i = 0; i < POP_SIZE; ++i) {
Chrom chrom;
@ -46,31 +47,32 @@ int main()
cout << "population:" << endl;
for (i = 0; i < pop.size(); ++i)
cout << "\t" << pop[i] << " " << pop[i].fitness() << endl;
// selection
eoDetTournamentSelect<Chrom> lottery( 3) ;
eoStochTournamentSelect<Chrom> lottery(0.9 );
// breeder
eoOneBitFlip<Chrom> bf;
eoOneBitFlip<Chrom> vm;
eoUBitXover<Chrom> xover;
eoProportionalOp<Chrom> propSel;
eoGeneralBreeder<Chrom> breeder( lottery, propSel );
propSel.add(bf, 0.75);
propSel.add(xover, 0.25);
propSel.add(vm, 0.8);
propSel.add(xover, 0.1);
// Replace a single one
eoPlusReplacement<Chrom> replace;
eoCommaReplacement<Chrom> replace;
// Terminators
eoGenContinue<Chrom> continuator1(50);
eoFitContinue<Chrom> continuator2(65535.f);
eoGenContinue<Chrom> continuator1(500);
eoFitContinue<Chrom> continuator2(128);
eoCombinedContinue<Chrom> continuator(continuator1, continuator2);
eoCheckPoint<Chrom> checkpoint(continuator);
eoStdoutMonitor monitor;
checkpoint.add(monitor);
eoSecondMomentStats<Chrom> stats;
eoPopStat<Chrom> dumper( 10 );
monitor.add(stats);
checkpoint.add(dumper);
checkpoint.add(stats);
// GA generation
@ -90,7 +92,8 @@ int main()
cout << "pop" << endl;
for (i = 0; i < pop.size(); ++i)
cout << "\t" << pop[i] << " " << pop[i].fitness() << endl;
cout << "\n --> Number of Evaluations = " << eval.getValue() << endl;
return 0;
}