Added the tags to generate html nice output
This commit is contained in:
parent
dcee458c27
commit
5881cab538
1 changed files with 23 additions and 3 deletions
|
|
@ -1,9 +1,12 @@
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
#include <ga/make_ga.h>
|
#include <ga/make_ga.h>
|
||||||
#include "binary_value.h"
|
|
||||||
#include <apply.h>
|
#include <apply.h>
|
||||||
|
|
||||||
|
// EVAL
|
||||||
|
#include "binary_value.h"
|
||||||
|
|
||||||
|
// GENERAL
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
int main(int argc, char* argv[])
|
int main(int argc, char* argv[])
|
||||||
|
|
@ -11,25 +14,34 @@ int main(int argc, char* argv[])
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
// REPRESENTATION
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// define your genotype and fitness types
|
||||||
typedef eoBit<double> EOT;
|
typedef eoBit<double> EOT;
|
||||||
|
|
||||||
|
// PARAMETRES
|
||||||
eoParser parser(argc, argv); // for user-parameter reading
|
eoParser parser(argc, argv); // for user-parameter reading
|
||||||
|
|
||||||
|
// GENERAL
|
||||||
eoState state; // keeps all things allocated
|
eoState state; // keeps all things allocated
|
||||||
|
|
||||||
///// FIRST, problem or representation dependent stuff
|
///// FIRST, problem or representation dependent stuff
|
||||||
//////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
// EVAL
|
||||||
// The evaluation fn - encapsulated into an eval counter for output
|
// The evaluation fn - encapsulated into an eval counter for output
|
||||||
eoEvalFuncPtr<EOT, float> mainEval( binary_value<EOT> );
|
eoEvalFuncPtr<EOT, float> mainEval( binary_value<EOT> );
|
||||||
eoEvalFuncCounter<EOT> eval(mainEval);
|
eoEvalFuncCounter<EOT> eval(mainEval);
|
||||||
|
|
||||||
|
// REPRESENTATION
|
||||||
// the genotype - through a genotype initializer
|
// the genotype - through a genotype initializer
|
||||||
eoInit<EOT>& init = make_genotype(parser, state, EOT());
|
eoInit<EOT>& init = make_genotype(parser, state, EOT());
|
||||||
|
|
||||||
|
// OPERATORS
|
||||||
// Build the variation operator (any seq/prop construct)
|
// Build the variation operator (any seq/prop construct)
|
||||||
eoGenOp<EOT>& op = make_op(parser, state, init);
|
eoGenOp<EOT>& op = make_op(parser, state, init);
|
||||||
|
|
||||||
|
// GENERAL
|
||||||
//// Now the representation-independent things
|
//// Now the representation-independent things
|
||||||
//////////////////////////////////////////////
|
//////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
@ -37,32 +49,40 @@ int main(int argc, char* argv[])
|
||||||
// yes, this is representation indepedent once you have an eoInit
|
// yes, this is representation indepedent once you have an eoInit
|
||||||
eoPop<EOT>& pop = make_pop(parser, state, init);
|
eoPop<EOT>& pop = make_pop(parser, state, init);
|
||||||
|
|
||||||
|
// STOP
|
||||||
// stopping criteria
|
// stopping criteria
|
||||||
eoContinue<EOT> & term = make_continue(parser, state, eval);
|
eoContinue<EOT> & term = make_continue(parser, state, eval);
|
||||||
// output
|
// output
|
||||||
eoCheckPoint<EOT> & checkpoint = make_checkpoint(parser, state, eval, term);
|
eoCheckPoint<EOT> & checkpoint = make_checkpoint(parser, state, eval, term);
|
||||||
|
// GENERATION
|
||||||
// algorithm (need the operator!)
|
// algorithm (need the operator!)
|
||||||
eoAlgo<EOT>& ga = make_algo_scalar(parser, state, eval, checkpoint, op);
|
eoAlgo<EOT>& ga = make_algo_scalar(parser, state, eval, checkpoint, op);
|
||||||
|
|
||||||
///// End of construction of the algorith
|
///// End of construction of the algorith
|
||||||
/////////////////////////////////////////
|
/////////////////////////////////////////
|
||||||
|
// PARAMETRES
|
||||||
// to be called AFTER all parameters have been read!!!
|
// to be called AFTER all parameters have been read!!!
|
||||||
make_help(parser);
|
make_help(parser);
|
||||||
|
|
||||||
//// GO
|
//// GO
|
||||||
///////
|
///////
|
||||||
|
// EVAL
|
||||||
// evaluate intial population AFTER help and status in case it takes time
|
// evaluate intial population AFTER help and status in case it takes time
|
||||||
apply<EOT>(eval, pop);
|
apply<EOT>(eval, pop);
|
||||||
// print it out
|
// STOP
|
||||||
|
// print it out (sort witout modifying)
|
||||||
cout << "Initial Population\n";
|
cout << "Initial Population\n";
|
||||||
pop.sortedPrintOn(cout);
|
pop.sortedPrintOn(cout);
|
||||||
cout << endl;
|
cout << endl;
|
||||||
|
|
||||||
|
// GENERATION
|
||||||
run_ea(ga, pop); // run the ga
|
run_ea(ga, pop); // run the ga
|
||||||
|
// STOP
|
||||||
|
// print it out (sort witout modifying)
|
||||||
cout << "Final Population\n";
|
cout << "Final Population\n";
|
||||||
pop.sortedPrintOn(cout);
|
pop.sortedPrintOn(cout);
|
||||||
cout << endl;
|
cout << endl;
|
||||||
|
// GENERAL
|
||||||
}
|
}
|
||||||
catch(exception& e)
|
catch(exception& e)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Reference in a new issue