00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifndef _edoAlgoAdaptive_h
00029 #define _edoAlgoAdaptive_h
00030
00031 #include <eo>
00032
00033 #include <utils/eoRNG.h>
00034
00035 #include "edoAlgo.h"
00036 #include "edoEstimator.h"
00037 #include "edoModifierMass.h"
00038 #include "edoSampler.h"
00039 #include "edoContinue.h"
00040
00054 template < typename D >
00055 class edoAlgoAdaptive : public edoAlgo< D >
00056 {
00057 public:
00059 typedef typename D::EOType EOType;
00060
00062 typedef typename EOType::AtomType AtomType;
00063
00065 typedef typename EOType::Fitness Fitness;
00066
00067 public:
00068
00081 edoAlgoAdaptive(
00082 D & distrib,
00083 eoPopEvalFunc < EOType > & evaluator,
00084 eoSelect< EOType > & selector,
00085 edoEstimator< D > & estimator,
00086 edoSampler< D > & sampler,
00087 eoReplacement< EOType > & replacor,
00088 eoContinue< EOType > & pop_continuator,
00089 edoContinue< D > & distribution_continuator
00090 ) :
00091 _distrib(distrib),
00092 _evaluator(evaluator),
00093 _selector(selector),
00094 _estimator(estimator),
00095 _sampler(sampler),
00096 _replacor(replacor),
00097 _pop_continuator(pop_continuator),
00098 _dummy_continue(),
00099 _distribution_continuator(distribution_continuator)
00100 {}
00101
00102
00104
00115 edoAlgoAdaptive (
00116 D & distrib,
00117 eoPopEvalFunc < EOType > & evaluator,
00118 eoSelect< EOType > & selector,
00119 edoEstimator< D > & estimator,
00120 edoSampler< D > & sampler,
00121 eoReplacement< EOType > & replacor,
00122 eoContinue< EOType > & pop_continuator
00123 ) :
00124 _distrib( distrib ),
00125 _evaluator(evaluator),
00126 _selector(selector),
00127 _estimator(estimator),
00128 _sampler(sampler),
00129 _replacor(replacor),
00130 _pop_continuator(pop_continuator),
00131 _dummy_continue(),
00132 _distribution_continuator( _dummy_continue )
00133 {}
00134
00140 void operator ()(eoPop< EOType > & pop)
00141 {
00142 assert(pop.size() > 0);
00143
00144 eoPop< EOType > current_pop;
00145 eoPop< EOType > selected_pop;
00146
00147
00148
00149 _distrib = _estimator(pop);
00150
00151
00152
00153
00154
00155 do {
00156
00157 _selector(pop, selected_pop);
00158 assert( selected_pop.size() > 0 );
00159
00160
00161 _distrib = _estimator(selected_pop);
00162
00163
00164
00165
00166 current_pop.clear();
00167 for( unsigned int i = 0; i < pop.size(); ++i ) {
00168 current_pop.push_back( _sampler(_distrib) );
00169 }
00170
00171
00172 _evaluator( pop, current_pop );
00173
00174
00175 _replacor(pop, current_pop);
00176
00177 } while( _distribution_continuator( _distrib ) && _pop_continuator( pop ) );
00178 }
00179
00180
00181 protected:
00182
00184 D & _distrib;
00185
00187 eoPopEvalFunc<EOType> & _evaluator;
00188
00190 eoSelect<EOType> & _selector;
00191
00193 edoEstimator<D> & _estimator;
00194
00196 edoSampler<D> & _sampler;
00197
00199 eoReplacement<EOType> & _replacor;
00200
00202 eoContinue<EOType> & _pop_continuator;
00203
00205 edoDummyContinue<D> _dummy_continue;
00206
00208 edoContinue<D> & _distribution_continuator;
00209
00210 };
00211
00212 #endif // !_edoAlgoAdaptive_h
00213