00001
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #include <iostream>
00017 using namespace std;
00018
00019
00020 #include "eo"
00021
00022 #include "utils/eoRealVectorBounds.h"
00023
00024
00025
00026
00030 #include "eoOneMax.h"
00031
00035 #include "eoOneMaxInit.h"
00036
00042 #include "eoOneMaxEvalFunc.h"
00043
00044
00045
00046
00047
00048
00049 typedef eoMinimizingFitness MyFitT ;
00050
00051
00052
00053
00054 typedef eoOneMax<MyFitT> Indi;
00055
00056
00057
00058 #include "make_genotype_OneMax.h"
00059 eoInit<Indi> & make_genotype(eoParser& _parser, eoState&_state, Indi _eo)
00060 {
00061 return do_make_genotype(_parser, _state, _eo);
00062 }
00063
00064
00065 #include "make_op_OneMax.h"
00066 eoGenOp<Indi>& make_op(eoParser& _parser, eoState& _state, eoInit<Indi>& _init)
00067 {
00068 return do_make_op(_parser, _state, _init);
00069 }
00070
00071
00072
00073
00074
00075 eoPop<Indi >& make_pop(eoParser& _parser, eoState& _state, eoInit<Indi> & _init);
00076
00077
00078 eoContinue<Indi>& make_continue(eoParser& _parser, eoState& _state, eoEvalFuncCounter<Indi> & _eval);
00079
00080
00081 eoCheckPoint<Indi>& make_checkpoint(eoParser& _parser, eoState& _state, eoEvalFuncCounter<Indi>& _eval, eoContinue<Indi>& _continue);
00082
00083
00084 eoAlgo<Indi>& make_algo_scalar(eoParser& _parser, eoState& _state, eoEvalFunc<Indi>& _eval, eoContinue<Indi>& _continue, eoGenOp<Indi>& _op);
00085
00086
00087
00088 void run_ea(eoAlgo<Indi>& _ga, eoPop<Indi>& _pop);
00089
00090
00091
00092 void make_help(eoParser & _parser);
00093
00094
00095
00096 int main(int argc, char* argv[])
00097 {
00098
00099 try
00100 {
00101 eoParser parser(argc, argv);
00102
00103 eoState state;
00104
00105
00107 eoOneMaxEvalFunc<Indi> plainEval;
00108
00109 eoEvalFuncCounter<Indi> eval(plainEval);
00110
00111
00112 eoInit<Indi>& init = make_genotype(parser, state, Indi());
00113
00114
00115 eoGenOp<Indi>& op = make_op(parser, state, init);
00116
00117
00119
00120
00121
00123
00124
00125
00126 eoPop<Indi>& pop = make_pop(parser, state, init);
00127
00128
00129 eoContinue<Indi> & term = make_continue(parser, state, eval);
00130
00131 eoCheckPoint<Indi> & checkpoint = make_checkpoint(parser, state, eval, term);
00132
00133 eoAlgo<Indi>& ga = make_algo_scalar(parser, state, eval, checkpoint, op);
00134
00136
00138
00139 make_help(parser);
00140
00143
00144 apply<Indi>(eval, pop);
00145
00146 cout << "Initial Population\n";
00147 pop.sortedPrintOn(cout);
00148 cout << endl;
00149
00150 run_ea(ga, pop);
00151
00152 cout << "Final Population\n";
00153 pop.sortedPrintOn(cout);
00154 cout << endl;
00155
00156 }
00157 catch(exception& e)
00158 {
00159 cout << e.what() << endl;
00160 }
00161 return 0;
00162 }