00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef __peoEA_h
00025 #define __peoEA_h
00026
00027 #include <eoContinue.h>
00028 #include <eoEvalFunc.h>
00029 #include <eoSelect.h>
00030 #include <eoPopEvalFunc.h>
00031 #include <eoReplacement.h>
00032
00033 #include "peoPopEval.h"
00034 #include "peoTransform.h"
00035 #include "core/runner.h"
00036 #include "core/peo_debug.h"
00037
00039
00069 template < class EOT > class peoEA : public Runner {
00070
00071 public:
00072
00084 peoEA(
00085 eoContinue< EOT >& __cont,
00086 peoPopEval< EOT >& __pop_eval,
00087 eoSelect< EOT >& __select,
00088 peoTransform< EOT >& __trans,
00089 eoReplacement< EOT >& __replace
00090 );
00091
00094 void run();
00095
00099 void operator()( eoPop< EOT >& __pop );
00100
00101 private:
00102
00103
00104 eoContinue< EOT >& cont;
00105 peoPopEval< EOT >& pop_eval;
00106 eoSelect< EOT >& select;
00107 peoTransform< EOT >& trans;
00108 eoReplacement< EOT >& replace;
00109 eoPop< EOT >* pop;
00110 };
00111
00112
00113 template < class EOT > peoEA< EOT > :: peoEA(
00114
00115 eoContinue< EOT >& __cont,
00116 peoPopEval< EOT >& __pop_eval,
00117 eoSelect< EOT >& __select,
00118 peoTransform< EOT >& __trans,
00119 eoReplacement< EOT >& __replace
00120
00121 ) : cont( __cont ), pop_eval( __pop_eval ), select( __select ), trans( __trans ), replace( __replace )
00122 {
00123
00124 trans.setOwner( *this );
00125 pop_eval.setOwner( *this );
00126 }
00127
00128
00129 template< class EOT > void peoEA< EOT > :: operator ()( eoPop< EOT >& __pop ) {
00130
00131 pop = &__pop;
00132 }
00133
00134
00135 template< class EOT > void peoEA< EOT > :: run() {
00136
00137 printDebugMessage( "performing the first evaluation of the population." );
00138 pop_eval( *pop );
00139
00140 do {
00141
00142 eoPop< EOT > off;
00143
00144 printDebugMessage( "performing the selection step." );
00145 select( *pop, off );
00146 trans( off );
00147
00148 printDebugMessage( "performing the evaluation of the population." );
00149 pop_eval( off );
00150
00151 printDebugMessage( "performing the replacement of the population." );
00152 replace( *pop, off );
00153
00154 printDebugMessage( "deciding of the continuation." );
00155
00156 } while ( cont( *pop ) );
00157 }
00158
00159
00160 #endif