00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #ifndef _EOUPDATEIUNDERCONSTRAINT_H
00012 #define _EOUPDATEIUNDERCONSTRAINT_H
00013
00014
00015 #include <eoParticleBestUpdater.h>
00016
00017
00021 template < class POT , class CSTYPE > class eoUpdateUnderConstraint:public eoParticleBestUpdater < POT >
00022 {
00023
00024 public:
00025
00029 eoUpdateUnderConstraint(const CSTYPE & _epsilon):epsilon(_epsilon) {}
00030
00031 void operator () (POT & _po)
00032 {
00033 if ((_po.fitness () - _po.best ()) >= epsilon)
00034 {
00035
00036 for (unsigned i = 0; i < _po.size (); i++){
00037 _po.bestPositions[i] = _po[i];
00038 }
00039
00040 _po.invalidateBest();
00041
00042
00043 _po.best (_po.fitness ());
00044 }
00045 }
00046
00047 protected:
00048 const CSTYPE & epsilon;
00049
00050 };
00051
00052 #endif