eoParticleBestInit.h

00001 // -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
00002 
00003 //-----------------------------------------------------------------------------
00004 // eoParticleBestInit.h
00005 // (c) OPAC 2007
00006 /*
00007     Contact: paradiseo-help@lists.gforge.inria.fr
00008  */
00009 //-----------------------------------------------------------------------------
00010 
00011 #ifndef _EOPARTICLEBESTINIT_H
00012 #define _EOPARTICLEBESTINIT_H
00013 
00014 //-----------------------------------------------------------------------------
00015 #include <eoFunctor.h>
00016 //-----------------------------------------------------------------------------
00017 
00019 template < class POT > class eoParticleBestInit:public eoUF < POT &, void >
00020 {
00021 public:
00022 
00024     virtual void apply (eoPop < POT > &_pop)
00025     {
00026         for (unsigned i = 0; i < _pop.size (); i++)
00027         {
00028             operator  ()(_pop[i]);
00029         }
00030 
00031     }
00032 
00033 };
00034 
00038 template < class POT > class eoFirstIsBestInit:public eoParticleBestInit <POT>
00039 {
00040 
00041 public:
00042 
00044     eoFirstIsBestInit (){}
00045 
00046     void operator  () (POT & _po1)
00047     {
00048         for (unsigned i = 0; i < _po1.size (); i++)
00049             _po1.bestPositions[i] = _po1[i];
00050 
00051         // set the fitness
00052         _po1.best(_po1.fitness());
00053     }
00054 
00055 };
00056 
00057 #endif /*_EOPARTICLEBESTINIT_H */
00058 
00059 

Generated on Thu Apr 19 11:02:27 2007 for EO by  doxygen 1.4.7