eoFlight.h

00001 // -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
00002 
00003 //-----------------------------------------------------------------------------
00004 // eoFlight.h
00005 // (c) OPAC 2007
00006 /*
00007     Contact: paradiseo-help@lists.gforge.inria.fr
00008  */
00009 //-----------------------------------------------------------------------------
00010 
00011 #ifndef EOFLIGHT_H
00012 #define EOFLIGHT_H
00013 
00014 //-----------------------------------------------------------------------------
00015 #include <eoFunctor.h>
00016 #include <utils/eoRealVectorBounds.h>
00017 //-----------------------------------------------------------------------------
00018 
00022 template < class POT > class eoFlight:public eoUF < POT &, void >
00023 {
00024 public:
00025 
00029     virtual void apply (eoPop < POT > &_pop)
00030     {
00031         for (unsigned i = 0; i < _pop.size (); i++)
00032         {
00033             operator  ()(_pop[i]);
00034         }
00035 
00036     }
00037 };
00038 
00043 template < class POT > class eoStandardFlight:public eoFlight < POT >
00044 {
00045 
00046 public:
00047 
00049     eoStandardFlight ():bounds (eoDummyVectorNoBounds){}
00050 
00055     eoStandardFlight (eoRealVectorBounds & _bounds):bounds (_bounds){}
00056 
00059     eoStandardFlight (const double & _min,const double & _max ):bounds (eoRealVectorBounds(_min,_max)){}
00060 
00064     void operator  () (POT & _po)
00065     {
00066         for (unsigned j = 0; j < _po.size (); j++)
00067         {
00068             double newPosition;
00069 
00070             // tmp flight
00071             newPosition = _po[j] + _po.velocities[j];
00072 
00073             /* check bounds */
00074             if (bounds.isMinBounded(j))
00075                 newPosition=std::max(newPosition,bounds.minimum(j));
00076             if (bounds.isMaxBounded(j))
00077                 newPosition=std::min(newPosition,bounds.maximum(j));
00078 
00079             _po[j]=newPosition;
00080 
00081             // invalidate the fitness because the positions has changed
00082             _po.invalidate();
00083         }
00084     }
00085 
00086 protected:
00087     eoRealVectorBounds & bounds;
00088 };
00089 
00090 #endif /*EOFLIGHT_H */

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