00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #ifndef _EOEASYPSO_H
00012 #define _EOEASYPSO_H
00013
00014
00015 #include <eoContinue.h>
00016 #include <eoPSO.h>
00017 #include <eoVelocity.h>
00018 #include <eoFlight.h>
00019 #include <eoParticleBestUpdater.h>
00020
00021
00026 template < class POT > class eoEasyPSO:public eoPSO < POT >
00027 {
00028 public:
00029
00033 eoEasyPSO (
00034 eoContinue < POT > &_continuator,
00035 eoEvalFunc < POT > &_eval,
00036 eoVelocity < POT > &_velocity,
00037 eoFlight < POT > &_flight,
00038 eoParticleBestUpdater < POT > &_particleUpdater,
00039 eoParticleBestUpdater < POT > &_globalUpdater):
00040 continuator (_continuator),
00041 eval (_eval),
00042 velocity (_velocity),
00043 flight (_flight),
00044 particleUpdater (_particleUpdater),
00045 globalUpdater (_globalUpdater){}
00046
00047
00049 virtual void operator () (eoPop < POT > &_pop)
00050 {
00051
00052 for (unsigned idx = 0; idx < _pop.size (); idx++)
00053 eval (_pop[idx]);
00054
00055 do
00056 {
00057 try
00058 {
00059
00060 for (unsigned idx = 0; idx < _pop.size (); idx++)
00061 {
00062
00063 velocity (_pop[idx]);
00064
00065
00066 flight (_pop[idx]);
00067
00068
00069 eval (_pop[idx]);
00070
00071
00072 particleUpdater (_pop[idx]);
00073
00074
00075 globalUpdater (_pop[idx]);
00076 }
00077 }
00078 catch (std::exception & e)
00079 {
00080 std::string s = e.what ();
00081 s.append (" in eoEasyPSO");
00082 throw std::runtime_error (s);
00083 }
00084 }
00085 while (continuator (_pop));
00086 }
00087
00088 protected:
00089 eoContinue < POT > &continuator;
00090 eoEvalFunc < POT > &eval;
00091 eoVelocity < POT > &velocity;
00092 eoFlight < POT > &flight;
00093 eoParticleBestUpdater < POT > &particleUpdater;
00094 eoParticleBestUpdater < POT > &globalUpdater;
00095 };
00096
00097
00098 #endif