00001 #ifndef _Rosenbrock_h 00002 #define _Rosenbrock_h 00003 00004 #include <eo> 00005 #include <es.h> 00006 #include <es/eoRealInitBounded.h> 00007 #include <es/eoRealOp.h> 00008 #include <es/eoEsChromInit.h> 00009 #include <es/eoRealOp.h> 00010 #include <es/make_real.h> 00011 #include <apply.h> 00012 #include <eoProportionalCombinedOp.h> 00013 00014 template < typename EOT > 00015 class Rosenbrock : public eoEvalFunc< EOT > 00016 { 00017 public: 00018 typedef typename EOT::AtomType AtomType; 00019 00020 virtual void operator()( EOT& p ) 00021 { 00022 if (!p.invalid()) 00023 return; 00024 00025 p.fitness( _evaluate( p ) ); 00026 } 00027 00028 private: 00029 AtomType _evaluate( EOT& p ) 00030 { 00031 AtomType r = 0.0; 00032 00033 for (unsigned int i = 0; i < p.size() - 1; ++i) 00034 { 00035 r += p[i] * p[i]; 00036 } 00037 00038 return r; 00039 } 00040 }; 00041 00042 #endif // !_Rosenbrock_h