00001 // -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*- 00002 00003 //----------------------------------------------------------------------------- 00004 // eoStandardFlight.h 00005 // (c) OPAC 2007 00006 /* 00007 Contact: paradiseo-help@lists.gforge.inria.fr 00008 */ 00009 //----------------------------------------------------------------------------- 00010 00011 #ifndef EOSTANDARDFLIGHT_H 00012 #define EOSTANDARDFLIGHT_H 00013 00014 //----------------------------------------------------------------------------- 00015 #include <eoFlight.h> 00016 //----------------------------------------------------------------------------- 00017 00018 00019 00024 template < class POT > class eoStandardFlight:public eoFlight < POT > 00025 { 00026 00027 public: 00028 00029 /* 00030 * Each element for the postion evaluation is expected to be of type PositionType. 00031 */ 00032 typedef typename POT::AtomType PositionType; 00033 00034 00038 eoStandardFlight ():bnds (*(new eoRealVectorNoBounds(0))){} 00039 00040 00045 eoStandardFlight (eoRealVectorBounds & _bounds):bnds (_bounds){} 00046 00047 00055 eoStandardFlight (const unsigned _dim,const double & _min,const double & _max ):bnds (*(new eoRealVectorBounds(_dim,_min,_max))){} 00056 00057 00062 void operator () (POT & _po) 00063 { 00064 // need to resize the bounds even if there are dummy because of "isBounded" call 00065 bnds.adjust_size(_po.size()); 00066 00067 for (unsigned j = 0; j < _po.size (); j++) 00068 { 00069 PositionType newPosition; 00070 00071 // tmp position 00072 newPosition = _po[j] + _po.velocities[j]; 00073 00074 /* check bounds */ 00075 if (bnds.isMinBounded(j)) 00076 newPosition=std::max(newPosition,bnds.minimum(j)); 00077 if (bnds.isMaxBounded(j)) 00078 newPosition=std::min(newPosition,bnds.maximum(j)); 00079 00080 _po[j]=newPosition; 00081 } 00082 // invalidate the fitness because the positions have changed 00083 _po.invalidate(); 00084 } 00085 00086 protected: 00087 eoRealVectorBounds & bnds; 00088 }; 00089 00090 00091 00092 00093 #endif /*EOSTANDARDFLIGHT_H */
1.4.7