peoEA.h

00001 // -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
00002 
00003 // "peoEA.h"
00004 
00005 // (c) OPAC Team, LIFL, August 2005
00006 
00007 /* This library is free software; you can redistribute it and/or
00008    modify it under the terms of the GNU Lesser General Public
00009    License as published by the Free Software Foundation; either
00010    version 2 of the License, or (at your option) any later version.
00011    
00012    This library is distributed in the hope that it will be useful,
00013    but WITHOUT ANY WARRANTY; without even the implied warranty of
00014    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015    Lesser General Public License for more details.
00016    
00017    You should have received a copy of the GNU Lesser General Public
00018    License along with this library; if not, write to the Free Software
00019    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00020    
00021    Contact: paradiseo-help@lists.gforge.inria.fr
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

Generated on Sat Dec 30 14:55:29 2006 for ParadisEO-PEO by  doxygen 1.4.7