EvolvingObjects
|
00001 // -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*- 00002 00003 //----------------------------------------------------------------------------- 00004 // eoInitializer.h 00005 // (c) OPAC Team, INRIA, 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: clive.canape@inria.fr 00022 00023 00024 */ 00025 //----------------------------------------------------------------------------- 00026 00027 #ifndef _eoInitializer_H 00028 #define _eoInitializer_H 00029 00030 #include <utils/eoRealVectorBounds.h> 00031 #include <eoVelocityInit.h> 00032 #include <eoPop.h> 00033 #include <eoParticleBestInit.h> 00034 #include <eoTopology.h> 00035 00045 template <class POT> class eoInitializerBase : public eoFunctorBase 00046 { 00047 public : 00048 00049 virtual ~eoInitializerBase() 00050 {} 00051 00052 virtual void operator()() 00053 {}; 00054 }; 00055 00061 template <class POT> class eoInitializer : public eoInitializerBase <POT> 00062 { 00063 public: 00064 00071 eoInitializer( 00072 eoUF<POT&, void>& _proc, 00073 eoVelocityInit < POT > &_initVelo, 00074 eoParticleBestInit <POT> &_initBest, 00075 eoTopology <POT> &_topology, 00076 eoPop < POT > &_pop 00077 ) : proc(_proc), initVelo(_initVelo), procPara(dummyEval), initBest(_initBest), topology(_topology), pop(_pop) 00078 {} 00079 00086 eoInitializer( 00087 eoPopEvalFunc <POT>& _proc, 00088 eoVelocityInit < POT > &_initVelo, 00089 eoParticleBestInit <POT> &_initBest, 00090 eoTopology <POT> &_topology, 00091 eoPop < POT > &_pop 00092 ) : proc(dummy), initVelo(_initVelo), procPara(_proc), initBest(_initBest), topology(_topology), pop(_pop) 00093 {} 00094 00095 00098 virtual std::string className (void) const 00099 { 00100 return "eoInitializer"; 00101 } 00102 00103 00104 00105 virtual void operator() () 00106 { 00107 eoPop<POT> empty_pop; 00108 apply(proc, pop); 00109 procPara(empty_pop, pop); 00110 apply < POT > (initVelo, pop); 00111 apply < POT > (initBest, pop); 00112 topology.setup(pop); 00113 } 00114 00115 private : 00116 00117 /* 00118 @param proc First evaluation 00119 @param initVelo Initialization of the velocity 00120 @param initBest Initialization of the best 00121 */ 00122 eoUF<POT&, void>& proc; 00123 eoVelocityInit < POT > & initVelo; 00124 eoPopEvalFunc <POT>& procPara; 00125 eoParticleBestInit <POT> & initBest; 00126 eoTopology <POT> & topology; 00127 eoPop < POT > & pop; 00128 00129 class eoDummyEval : public eoPopEvalFunc<POT> 00130 { 00131 public: 00132 void operator()(eoPop<POT> &,eoPop<POT> &/*_pop*/) 00133 {} 00134 } 00135 dummyEval; 00136 class eoDummy : public eoUF<POT&, void> 00137 { 00138 public: 00139 void operator()(POT &) 00140 {} 00141 00142 } 00143 dummy; 00144 }; 00145 #endif 00146