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 This library is free software; you can redistribute it and/or 00008 modify it under the terms of the GNU Lesser General Public 00009 License as published by the Free Software Foundation; either 00010 version 2 of the License, or (at your option) any later version. 00011 00012 This library is distributed in the hope that it will be useful, 00013 but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00015 Lesser General Public License for more details. 00016 00017 You should have received a copy of the GNU Lesser General Public 00018 License along with this library; if not, write to the Free Software 00019 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00020 00021 Contact: thomas.legrand@lifl.fr 00022 */ 00023 //----------------------------------------------------------------------------- 00024 00025 #ifndef EOSTANDARDFLIGHT_H 00026 #define EOSTANDARDFLIGHT_H 00027 00028 //----------------------------------------------------------------------------- 00029 #include <eoFlight.h> 00030 //----------------------------------------------------------------------------- 00031 00032 00033 00038 template < class POT > class eoStandardFlight:public eoFlight < POT > 00039 { 00040 00041 public: 00042 00043 /* 00044 * Each element for the postion evaluation is expected to be of type PositionType. 00045 */ 00046 typedef typename POT::AtomType PositionType; 00047 00048 00052 eoStandardFlight ():bnds (*(new eoRealVectorNoBounds(0))){} 00053 00054 00059 eoStandardFlight (eoRealVectorBounds & _bounds):bnds (_bounds){} 00060 00061 00069 eoStandardFlight (const unsigned _dim,const double & _min,const double & _max ):bnds (*(new eoRealVectorBounds(_dim,_min,_max))){} 00070 00071 00076 void operator () (POT & _po) 00077 { 00078 // need to resize the bounds even if there are dummy because of "isBounded" call 00079 bnds.adjust_size(_po.size()); 00080 00081 for (unsigned j = 0; j < _po.size (); j++) 00082 { 00083 PositionType newPosition; 00084 00085 // tmp position 00086 newPosition = _po[j] + _po.velocities[j]; 00087 00088 /* check bounds */ 00089 if (bnds.isMinBounded(j)) 00090 newPosition=std::max(newPosition,bnds.minimum(j)); 00091 if (bnds.isMaxBounded(j)) 00092 newPosition=std::min(newPosition,bnds.maximum(j)); 00093 00094 _po[j]=newPosition; 00095 } 00096 // invalidate the fitness because the positions have changed 00097 _po.invalidate(); 00098 } 00099 00100 protected: 00101 eoRealVectorBounds & bnds; 00102 }; 00103 00104 00105 00106 00107 #endif /*EOSTANDARDFLIGHT_H */