eoUpdateIfBetter.h

00001 // -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
00002 
00003 //-----------------------------------------------------------------------------
00004 // eoUpdateIfBetter.h
00005 // (c) OPAC 2007
00006 /*
00007     Contact: paradiseo-help@lists.gforge.inria.fr
00008  */
00009 //-----------------------------------------------------------------------------
00010 
00011 #ifndef _EOUPDATEIFBETTER_H
00012 #define _EOUPDATEIFBETTER_H
00013 
00014 //-----------------------------------------------------------------------------
00015 #include <eoParticleBestUpdater.h>
00016 
00017 
00021 template < class POT > class eoUpdateIfBetter:public eoParticleBestUpdater <
00022             POT >
00023 {
00024 
00025 public:
00026 
00028     eoUpdateIfBetter () {}
00029 
00030     void operator  () (POT & _po)
00031     {
00032         if (_po.fitness () > _po.best ())
00033         {
00034             // update positions
00035             for (unsigned i = 0; i < _po.size (); i++){
00036                 _po.bestPositions[i] = _po[i];
00037             }
00038             // invalidate the best fitness, just "semantic" because the best fitness is updated below
00039             _po.invalidateBest();
00040 
00041             // update local best fitness
00042             _po.best (_po.fitness ());
00043         }
00044     }
00045 
00046 };
00047 
00048 #endif /*_EOUPDATEIFBETTER_H */

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