t-eoReal.cpp

00001 #include <iostream>
00002 
00003 #include <es/make_real.h>
00004 #include "real_value.h"
00005 #include <apply.h>
00006 
00007 using namespace std;
00008 
00009 int main(int argc, char* argv[])
00010 {
00011 
00012   try
00013   {
00014   typedef eoReal<eoMinimizingFitness> EOT;
00015 
00016   eoParser parser(argc, argv);  // for user-parameter reading
00017 
00018   eoState state;    // keeps all things allocated
00019 
00022 
00023   // The evaluation fn - encapsulated into an eval counter for output 
00024   eoEvalFuncPtr<EOT, double, const std::vector<double>&> 
00025                mainEval( real_value );
00026   eoEvalFuncCounter<EOT> eval(mainEval);
00027 
00028   // the genotype - through a genotype initializer
00029   eoRealInitBounded<EOT>& init = make_genotype(parser, state, EOT());
00030 
00031   // Build the variation operator (any seq/prop construct)
00032   eoGenOp<EOT>& op = make_op(parser, state, init);
00033 
00036 
00037   // initialize the population - and evaluate
00038   // yes, this is representation indepedent once you have an eoInit
00039   eoPop<EOT>& pop   = make_pop(parser, state, init);
00040 
00041   // stopping criteria
00042   eoContinue<EOT> & term = make_continue(parser, state, eval);
00043   // output
00044   eoCheckPoint<EOT> & checkpoint = make_checkpoint(parser, state, eval, term);
00045   // algorithm (need the operator!)
00046   eoAlgo<EOT>& ea = make_algo_scalar(parser, state, eval, checkpoint, op);
00047 
00050   // to be called AFTER all parameters have been read!!!
00051   make_help(parser);
00052 
00055   // evaluate intial population AFTER help and status in case it takes time
00056   apply<EOT>(eval, pop);
00057   // print it out
00058   std::cout << "Initial Population\n";
00059   pop.sortedPrintOn(std::cout);
00060   std::cout << std::endl;
00061 
00062   run_ea(ea, pop); // run the ea
00063 
00064   std::cout << "Final Population\n";
00065   pop.sortedPrintOn(std::cout);
00066   std::cout << std::endl;
00067   }
00068   catch(std::exception& e)
00069   {
00070     std::cout << e.what() << std::endl;
00071   }
00072 }

Generated on Thu Oct 19 05:06:43 2006 for EO by  doxygen 1.3.9.1