# ParadisEO-MOEOMovingObjects: pmoeoEA.h Source File

# pmoeoEA.h

    00001 // "pmoeoEA.h"
    00002
    00003 // (c) OPAC Team, LIFL, August 2005
    00004
    00005 /*
    00006    Contact: paradiseo-help@lists.gforge.inria.fr
    00007 */
    00008
    00009 #ifndef __pmoeoEA_h
    00010 #define __pmoeoEA_h
    00011
    00012 #include <eoContinue.h>
    00013 #include <eoEvalFunc.h>
    00014 #include <eoSelect.h>
    00015 #include <eoPopEvalFunc.h>
    00016 #include <eoReplacement.h>
    00017
    00018 #include "peoPopEval.h"
    00019 #include "peoTransform.h"
    00020 #include "core/runner.h"
    00021 #include "core/peo_debug.h"
    00022
    00024
    00054 template < class EOT > class peoEA : public Runner {
    00055
    00056 public:
    00057
    00069         peoEA(
    00070                 eoContinue< EOT >& __cont,
    00071                 peoPopEval< EOT >& __pop_eval,
    00072                 eoSelect< EOT >& __select,
    00073                 peoTransform< EOT >& __trans,
    00074                 eoReplacement< EOT >& __replace
    00075         );
    00076
    00079         void run();
    00080
    00084         void operator()( eoPop< EOT >& __pop );
    00085
    00086 private:
    00087
    00088
    00089         eoContinue< EOT >& cont;
    00090         peoPopEval< EOT >& pop_eval;
    00091         eoSelect< EOT >& select;
    00092         peoTransform< EOT >& trans;
    00093         eoReplacement< EOT >& replace;
    00094         eoPop< EOT >* pop;
    00095 };
    00096
    00097
    00098 template < class EOT > peoEA< EOT > :: peoEA(
    00099
    00100                                 eoContinue< EOT >& __cont,
    00101                                 peoPopEval< EOT >& __pop_eval,
    00102                                 eoSelect< EOT >& __select,
    00103                                 peoTransform< EOT >& __trans,
    00104                                 eoReplacement< EOT >& __replace
    00105
    00106                 ) : cont( __cont ), pop_eval( __pop_eval ), select( __select ), trans( __trans ), replace( __replace )
    00107 {
    00108
    00109         trans.setOwner( *this );
    00110         pop_eval.setOwner( *this );
    00111 }
    00112
    00113
    00114 template< class EOT > void peoEA< EOT > :: operator ()( eoPop< EOT >& __pop ) {
    00115
    00116         pop = &__pop;
    00117 }
    00118
    00119
    00120 template< class EOT > void peoEA< EOT > :: run() {
    00121
    00122         printDebugMessage( "performing the first evaluation of the population." );
    00123         pop_eval( *pop );
    00124
    00125         do {
    00126
    00127                 eoPop< EOT > off;
    00128
    00129                 printDebugMessage( "performing the selection step." );
    00130                 select( *pop, off );
    00131                 trans( off );
    00132
    00133                 printDebugMessage( "performing the evaluation of the population." );
    00134                 pop_eval( off );
    00135
    00136                 printDebugMessage( "performing the replacement of the population." );
    00137                 replace( *pop, off );
    00138
    00139                 printDebugMessage( "deciding of the continuation." );
    00140
    00141         } while ( cont( *pop ) );
    00142 }
    00143
    00144
    00145 #endif