00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037 #ifndef __peoEA_h
00038 #define __peoEA_h
00039
00040 #include <eoContinue.h>
00041 #include <eoEvalFunc.h>
00042 #include <eoSelect.h>
00043 #include <eoPopEvalFunc.h>
00044 #include <eoReplacement.h>
00045
00046 #include "peoPopEval.h"
00047 #include "peoTransform.h"
00048 #include "core/runner.h"
00049 #include "core/peo_debug.h"
00050
00052
00082 template < class EOT > class peoEA : public Runner {
00083
00084 public:
00085
00097 peoEA(
00098 eoContinue< EOT >& __cont,
00099 peoPopEval< EOT >& __pop_eval,
00100 eoSelect< EOT >& __select,
00101 peoTransform< EOT >& __trans,
00102 eoReplacement< EOT >& __replace
00103 );
00104
00107 void run();
00108
00112 void operator()( eoPop< EOT >& __pop );
00113
00114 private:
00115
00116
00117 eoContinue< EOT >& cont;
00118 peoPopEval< EOT >& pop_eval;
00119 eoSelect< EOT >& select;
00120 peoTransform< EOT >& trans;
00121 eoReplacement< EOT >& replace;
00122 eoPop< EOT >* pop;
00123 };
00124
00125
00126 template < class EOT > peoEA< EOT > :: peoEA(
00127
00128 eoContinue< EOT >& __cont,
00129 peoPopEval< EOT >& __pop_eval,
00130 eoSelect< EOT >& __select,
00131 peoTransform< EOT >& __trans,
00132 eoReplacement< EOT >& __replace
00133
00134 ) : cont( __cont ), pop_eval( __pop_eval ), select( __select ), trans( __trans ), replace( __replace )
00135 {
00136
00137 trans.setOwner( *this );
00138 pop_eval.setOwner( *this );
00139 }
00140
00141
00142 template< class EOT > void peoEA< EOT > :: operator ()( eoPop< EOT >& __pop ) {
00143
00144 pop = &__pop;
00145 }
00146
00147
00148 template< class EOT > void peoEA< EOT > :: run() {
00149
00150 printDebugMessage( "performing the first evaluation of the population." );
00151 pop_eval( *pop );
00152
00153 do {
00154
00155 eoPop< EOT > off;
00156
00157 printDebugMessage( "performing the selection step." );
00158 select( *pop, off );
00159 trans( off );
00160
00161 printDebugMessage( "performing the evaluation of the population." );
00162 pop_eval( off );
00163
00164 printDebugMessage( "performing the replacement of the population." );
00165 replace( *pop, off );
00166
00167 printDebugMessage( "deciding of the continuation." );
00168
00169 } while ( cont( *pop ) );
00170 }
00171
00172
00173 #endif