Handle including from contrib/MGE nicely.
This commit is contained in:
parent
c563e2c302
commit
7c3702f6a6
7 changed files with 145 additions and 124 deletions
|
|
@ -2,20 +2,24 @@
|
|||
// t-eoMGE.cpp
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#ifndef __GNUG__
|
||||
// to avoid long name warnings
|
||||
#pragma warning(disable:4786)
|
||||
#endif // __GNUG__
|
||||
|
||||
#include <eo>
|
||||
#include <ga/eoBitOp.h>
|
||||
#include "eo"
|
||||
#include "ga/eoBitOp.h"
|
||||
|
||||
#include "RoyalRoad.h"
|
||||
|
||||
// Viri
|
||||
#include "../contrib/MGE/VirusOp.h"
|
||||
#include "../contrib/MGE/eoVirus.h"
|
||||
#include "../contrib/MGE/eoInitVirus.h"
|
||||
#include "VirusOp.h"
|
||||
#include "eoVirus.h"
|
||||
#include "eoInitVirus.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
|
@ -29,25 +33,25 @@ int main()
|
|||
unsigned i;
|
||||
eoBooleanGenerator gen;
|
||||
|
||||
// the populations:
|
||||
eoPop<Chrom> pop;
|
||||
// the populations:
|
||||
eoPop<Chrom> pop;
|
||||
|
||||
// Evaluation
|
||||
RoyalRoad<Chrom> rr( 8 );
|
||||
RoyalRoad<Chrom> rr( 8 );
|
||||
eoEvalFuncCounter<Chrom> eval( rr );
|
||||
|
||||
eoInitVirus<float> random(CHROM_SIZE, gen);
|
||||
eoInitVirus<float> random(CHROM_SIZE, gen);
|
||||
for (i = 0; i < POP_SIZE; ++i) {
|
||||
Chrom chrom;
|
||||
random(chrom);
|
||||
eval(chrom);
|
||||
pop.push_back(chrom);
|
||||
}
|
||||
|
||||
|
||||
std::cout << "population:" << std::endl;
|
||||
for (i = 0; i < pop.size(); ++i)
|
||||
std::cout << "\t" << pop[i] << " " << pop[i].fitness() << std::endl;
|
||||
|
||||
|
||||
// selection
|
||||
eoStochTournamentSelect<Chrom> lottery(0.9 );
|
||||
|
||||
|
|
@ -58,14 +62,14 @@ int main()
|
|||
eoGeneralBreeder<Chrom> breeder( lottery, propSel );
|
||||
propSel.add(vm, 0.2);
|
||||
propSel.add(xover, 0.8);
|
||||
|
||||
|
||||
// Replace a single one
|
||||
eoCommaReplacement<Chrom> replace;
|
||||
|
||||
// Terminators
|
||||
eoGenContinue<Chrom> continuator1(10);
|
||||
eoFitContinue<Chrom> continuator2(CHROM_SIZE);
|
||||
eoCombinedContinue<Chrom> continuator(continuator1, continuator2);
|
||||
eoCombinedContinue<Chrom> continuator(continuator1, continuator2);
|
||||
eoCheckPoint<Chrom> checkpoint(continuator);
|
||||
eoStdoutMonitor monitor;
|
||||
checkpoint.add(monitor);
|
||||
|
|
@ -88,7 +92,7 @@ int main()
|
|||
std::cout << "exception: " << e.what() << std::endl;;
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
|
||||
std::cout << "pop" << std::endl;
|
||||
for (i = 0; i < pop.size(); ++i)
|
||||
std::cout << "\t" << pop[i] << " " << pop[i].fitness() << std::endl;
|
||||
|
|
|
|||
Reference in a new issue