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 
00022 template < class POT > class eoParticleBestInit:public eoUF < POT &, void >
00023 {
00024 public:
00025 
00027     virtual void apply (eoPop < POT > &_pop)
00028     {
00029         for (unsigned i = 0; i < _pop.size (); i++)
00030         {
00031             operator  ()(_pop[i]);
00032         }
00033 
00034     }
00035 
00036 };
00037 
00042 template < class POT > class eoFirstIsBestInit:public eoParticleBestInit <POT>
00043 {
00044 
00045 public:
00046 
00048     eoFirstIsBestInit (){}
00049 
00050     void operator  () (POT & _po1)
00051     {
00052         for (unsigned i = 0; i < _po1.size (); i++)
00053             _po1.bestPositions[i] = _po1[i];
00054 
00055         // set the fitness
00056         _po1.best(_po1.fitness());
00057     }
00058 
00059 };
00060 
00061 #endif /*_EOPARTICLEBESTINIT_H */
00062 
00063 

Generated on Fri Jun 22 10:17:02 2007 for EO-PSO by  doxygen 1.4.7