00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #ifndef _EOSSPSO_H
00012 #define _EOSSPSO_H
00013
00014
00015 #include <eoPSO.h>
00016 #include <eoContinue.h>
00017 #include <eoStandardFlight.h>
00018 #include <eoStarTopology.h>
00019 #include <eoStandardVelocity.h>
00020 #include <utils/eoRealVectorBounds.h>
00021 #include <eoRealBoundModifier.h>
00022
00023
00030 template < class POT > class eoSSPSO:public eoPSO < POT >
00031 {
00032 public:
00033
00034
00035 typedef typename POT::ParticleVelocityType VelocityType;
00036
00046 eoSSPSO (
00047 eoContinue < POT > &_continuator,
00048 eoEvalFunc < POT > &_eval,
00049 const VelocityType & _c1,
00050 const VelocityType & _c2 ,
00051 eoRealVectorBounds & _bounds,
00052 eoRealBoundModifier & _bndsModifier):
00053 continuator (_continuator),
00054 eval (_eval),
00055 velocity(eoStandardVelocity<POT>(topology,_c1,_c2,_bounds,_bndsModifier)),
00056 bounds(_bounds),
00057 boundsModifier(_bndsModifier)
00058 {}
00059
00068 eoSSPSO (
00069 eoContinue < POT > &_continuator,
00070 eoEvalFunc < POT > &_eval,
00071 const VelocityType & _c1,
00072 const VelocityType & _c2 ,
00073 eoRealVectorBounds & _bounds):
00074 continuator (_continuator),
00075 eval (_eval),
00076 velocity(eoStandardVelocity<POT>(topology,_c1,_c2,_bounds)),
00077 bounds(_bounds),
00078 boundsModifier(dummyModifier)
00079 {}
00080
00081
00089 eoSSPSO (
00090 eoContinue < POT > &_continuator,
00091 eoEvalFunc < POT > &_eval,
00092 const VelocityType & _c1,
00093 const VelocityType & _c2):
00094 continuator (_continuator),
00095 eval (_eval),
00096 velocity(eoStandardVelocity<POT>(topology,_c1,_c2)),
00097 bounds(*(new eoRealVectorNoBounds(0))),
00098 boundsModifier(dummyModifier)
00099 {}
00100
00101
00103 virtual void operator () (eoPop < POT > &_pop)
00104 {
00105 try
00106 {
00107
00108 topology.setup(_pop);
00109
00110 do
00111 {
00112
00113 for (unsigned idx = 0; idx < _pop.size (); idx++)
00114 {
00115
00116 velocity (_pop[idx],idx);
00117
00118
00119 flight (_pop[idx]);
00120
00121
00122 eval (_pop[idx]);
00123
00124
00125 velocity.updateNeighborhood(_pop[idx],idx);
00126 }
00127 } while (continuator (_pop));
00128
00129 }catch (std::exception & e)
00130 {
00131 std::string s = e.what ();
00132 s.append (" in eoSSPSO");
00133 throw std::runtime_error (s);
00134 }
00135 }
00136
00137 protected:
00138 eoContinue < POT > &continuator;
00139 eoEvalFunc < POT > &eval;
00140
00141 eoStandardVelocity < POT > velocity;
00142 eoStandardFlight < POT > flight;
00143 eoStarTopology<POT> topology;
00144
00145 eoRealVectorBounds bounds;
00146 eoRealBoundModifier & boundsModifier;
00147
00148
00149 eoDummyRealBoundModifier dummyModifier;
00150
00151 };
00152
00153
00154 #endif