00001
00041
00042
00043 #ifndef CMA_OPTIMIZER_H
00044 #define CMA_OPTIMIZER_H
00045
00046
00047 #include <ReClaM/Optimizer.h>
00048 #include <EALib/CMA.h>
00049 #include <EALib/ElitistCMA.h>
00050 #include <EALib/UncertaintyQuantification.h>
00051
00052
00059 class CMAOptimizer : public Optimizer
00060 {
00061 public:
00062 enum eMode
00063 {
00064 modeRankMuUpdate = 1,
00065 modeRankOneUpdate = 2,
00066 modeOnePlusOne = 4,
00067 };
00068
00069
00071 CMAOptimizer(int verbosity = 0);
00072
00074 ~CMAOptimizer();
00075
00076
00079 void init(Model& model);
00080
00088 void init(Model& model, double sigma, eMode mode = modeRankMuUpdate, bool best = true, int lambda = 0, int mu = 0);
00089
00097 void init(Model& model, const Array<double>& sigma, eMode mode = modeRankMuUpdate, bool best = true, int lambda = 0, int mu = 0);
00098
00109 void initUncertainty(Model& model, double sigma = 0.01, unsigned int maxEvals = 1000, double alpha = 1.5, double theta = 0.1, eMode mode = modeRankMuUpdate, int lambda = 0, int mu = 0);
00110
00120 void initUncertainty(Model& model, const Array<double>& sigma, unsigned int maxEvals = 1000, double alpha = 1.5, double theta = 0.1, eMode mode = modeRankMuUpdate, int lambda = 0, int mu = 0);
00121
00123 double optimize(Model& model, ErrorFunction& errorfunction, const Array<double>& input, const Array<double>& target);
00124
00128 int getLambda();
00129
00130 protected:
00131 class ModelFitness : public NoisyFitnessFunction
00132 {
00133 public:
00134 void Set(Model& model, ErrorFunction& errorfunction, const Array<double>& input, const Array<double>& target);
00135 double fitness(const std::vector<double>& v);
00136
00137 protected:
00138 Model* m;
00139 ErrorFunction* e;
00140 const Array<double>* i;
00141 const Array<double>* t;
00142 };
00143 ModelFitness objective;
00144
00145 void Ind2Model(Individual& ind, Model& model);
00146
00148 bool bFirstIteration;
00149
00151 CMA cma;
00152
00154 ElitistCMA ecma;
00155
00157 Population* parents;
00158
00160 Population* offspring;
00161
00163 eMode cmaMode;
00164
00166 bool returnBestIndividual;
00167
00169 double bestFitness;
00170
00172 Array<double> bestParameters;
00173
00175 int verbosity;
00176
00178 bool uncertaintyHandling;
00179
00181 unsigned int maxEvals;
00182
00184 double alpha;
00185
00187 double theta;
00188 };
00189
00190
00191 #endif
00192