25 #include "esoptimizer.h"
26 #include "cmastrategy.h"
27 #include "ipopcmastrategy.h"
28 #include "bipopcmastrategy.h"
34 template <
class TGenoPheno=GenoPheno<NoBoundStrategy>>
35 CMASolutions cmaes(FitFunc &func,
36 CMAParameters<TGenoPheno> ¶meters,
37 ProgressFunc<CMAParameters<TGenoPheno>,CMASolutions> &pfunc=CMAStrategy<CovarianceUpdate,TGenoPheno>::_defaultPFunc,
38 GradFunc gfunc=
nullptr,
39 const CMASolutions &solutions=CMASolutions(),
40 PlotFunc<CMAParameters<TGenoPheno>,CMASolutions> &pffunc=CMAStrategy<CovarianceUpdate,TGenoPheno>::_defaultFPFunc)
42 switch(parameters.get_algo())
47 if (solutions.cov().size()==0)
49 ESOptimizer<CMAStrategy<CovarianceUpdate,TGenoPheno>,CMAParameters<TGenoPheno>,CMASolutions> cmaes_vanilla(func,parameters);
51 cmaes_vanilla.set_gradient_func(gfunc);
52 cmaes_vanilla.set_progress_func(pfunc);
53 cmaes_vanilla.set_plot_func(pffunc);
54 cmaes_vanilla.optimize();
55 return cmaes_vanilla.get_solutions();
59 ESOptimizer<CMAStrategy<CovarianceUpdate,TGenoPheno>,CMAParameters<TGenoPheno>,CMASolutions> cmaes_vanilla(func,parameters,solutions);
61 cmaes_vanilla.set_gradient_func(gfunc);
62 cmaes_vanilla.set_progress_func(pfunc);
63 cmaes_vanilla.set_plot_func(pffunc);
64 cmaes_vanilla.optimize();
65 return cmaes_vanilla.get_solutions();
70 if (solutions.cov().size()==0)
72 ESOptimizer<IPOPCMAStrategy<CovarianceUpdate,TGenoPheno>,CMAParameters<TGenoPheno>,CMASolutions> ipop(func,parameters);
74 ipop.set_gradient_func(gfunc);
75 ipop.set_progress_func(pfunc);
76 ipop.set_plot_func(pffunc);
78 return ipop.get_solutions();
82 ESOptimizer<IPOPCMAStrategy<CovarianceUpdate,TGenoPheno>,CMAParameters<TGenoPheno>,CMASolutions> ipop(func,parameters,solutions);
84 ipop.set_gradient_func(gfunc);
85 ipop.set_progress_func(pfunc);
86 ipop.set_plot_func(pffunc);
88 return ipop.get_solutions();
93 if (solutions.cov().size()==0)
95 ESOptimizer<BIPOPCMAStrategy<CovarianceUpdate,TGenoPheno>,CMAParameters<TGenoPheno>,CMASolutions> bipop(func,parameters);
97 bipop.set_gradient_func(gfunc);
98 bipop.set_progress_func(pfunc);
99 bipop.set_plot_func(pffunc);
101 return bipop.get_solutions();
105 ESOptimizer<BIPOPCMAStrategy<CovarianceUpdate,TGenoPheno>,CMAParameters<TGenoPheno>,CMASolutions> bipop(func,parameters,solutions);
106 if (gfunc !=
nullptr)
107 bipop.set_gradient_func(gfunc);
108 bipop.set_progress_func(pfunc);
109 bipop.set_plot_func(pffunc);
111 return bipop.get_solutions();
116 if (solutions.cov().size()==0)
118 ESOptimizer<CMAStrategy<ACovarianceUpdate,TGenoPheno>,CMAParameters<TGenoPheno>,CMASolutions> acmaes(func,parameters);
119 if (gfunc !=
nullptr)
120 acmaes.set_gradient_func(gfunc);
121 acmaes.set_progress_func(pfunc);
122 acmaes.set_plot_func(pffunc);
124 return acmaes.get_solutions();
128 ESOptimizer<CMAStrategy<ACovarianceUpdate,TGenoPheno>,CMAParameters<TGenoPheno>,CMASolutions> acmaes(func,parameters,solutions);
129 if (gfunc !=
nullptr)
130 acmaes.set_gradient_func(gfunc);
131 acmaes.set_progress_func(pfunc);
132 acmaes.set_plot_func(pffunc);
134 return acmaes.get_solutions();
139 if (solutions.cov().size()==0)
141 ESOptimizer<IPOPCMAStrategy<ACovarianceUpdate,TGenoPheno>,CMAParameters<TGenoPheno>,CMASolutions> aipop(func,parameters);
142 if (gfunc !=
nullptr)
143 aipop.set_gradient_func(gfunc);
144 aipop.set_progress_func(pfunc);
145 aipop.set_plot_func(pffunc);
147 return aipop.get_solutions();
151 ESOptimizer<IPOPCMAStrategy<ACovarianceUpdate,TGenoPheno>,CMAParameters<TGenoPheno>,CMASolutions> aipop(func,parameters,solutions);
152 if (gfunc !=
nullptr)
153 aipop.set_gradient_func(gfunc);
154 aipop.set_progress_func(pfunc);
155 aipop.set_plot_func(pffunc);
157 return aipop.get_solutions();
162 if (solutions.cov().size()==0)
164 ESOptimizer<BIPOPCMAStrategy<ACovarianceUpdate,TGenoPheno>,CMAParameters<TGenoPheno>,CMASolutions> abipop(func,parameters);
165 if (gfunc !=
nullptr)
166 abipop.set_gradient_func(gfunc);
167 abipop.set_progress_func(pfunc);
168 abipop.set_plot_func(pffunc);
170 return abipop.get_solutions();
174 ESOptimizer<BIPOPCMAStrategy<ACovarianceUpdate,TGenoPheno>,CMAParameters<TGenoPheno>,CMASolutions> abipop(func,parameters,solutions);
175 if (gfunc !=
nullptr)
176 abipop.set_gradient_func(gfunc);
177 abipop.set_progress_func(pfunc);
178 abipop.set_plot_func(pffunc);
180 return abipop.get_solutions();
185 if (!parameters.is_sep())
186 parameters.set_sep();
187 if (solutions.cov().size()==0)
189 ESOptimizer<CMAStrategy<CovarianceUpdate,TGenoPheno>,CMAParameters<TGenoPheno>,CMASolutions> sepcmaes(func,parameters);
190 if (gfunc !=
nullptr)
191 sepcmaes.set_gradient_func(gfunc);
192 sepcmaes.set_progress_func(pfunc);
193 sepcmaes.set_plot_func(pffunc);
195 return sepcmaes.get_solutions();
199 ESOptimizer<CMAStrategy<CovarianceUpdate,TGenoPheno>,CMAParameters<TGenoPheno>,CMASolutions> sepcmaes(func,parameters,solutions);
200 if (gfunc !=
nullptr)
201 sepcmaes.set_gradient_func(gfunc);
202 sepcmaes.set_progress_func(pfunc);
203 sepcmaes.set_plot_func(pffunc);
205 return sepcmaes.get_solutions();
210 if (!parameters.is_sep())
211 parameters.set_sep();
212 if (solutions.cov().size()==0)
214 ESOptimizer<IPOPCMAStrategy<CovarianceUpdate,TGenoPheno>,CMAParameters<TGenoPheno>,CMASolutions> ipop(func,parameters);
215 if (gfunc !=
nullptr)
216 ipop.set_gradient_func(gfunc);
217 ipop.set_progress_func(pfunc);
218 ipop.set_plot_func(pffunc);
220 return ipop.get_solutions();
224 ESOptimizer<IPOPCMAStrategy<CovarianceUpdate,TGenoPheno>,CMAParameters<TGenoPheno>,CMASolutions> ipop(func,parameters,solutions);
225 if (gfunc !=
nullptr)
226 ipop.set_gradient_func(gfunc);
227 ipop.set_progress_func(pfunc);
228 ipop.set_plot_func(pffunc);
230 return ipop.get_solutions();
235 if (!parameters.is_sep())
236 parameters.set_sep();
237 if (solutions.cov().size()==0)
239 ESOptimizer<BIPOPCMAStrategy<CovarianceUpdate,TGenoPheno>,CMAParameters<TGenoPheno>,CMASolutions> bipop(func,parameters);
240 if (gfunc !=
nullptr)
241 bipop.set_gradient_func(gfunc);
242 bipop.set_progress_func(pfunc);
243 bipop.set_plot_func(pffunc);
245 return bipop.get_solutions();
249 ESOptimizer<BIPOPCMAStrategy<CovarianceUpdate,TGenoPheno>,CMAParameters<TGenoPheno>,CMASolutions> bipop(func,parameters,solutions);
250 if (gfunc !=
nullptr)
251 bipop.set_gradient_func(gfunc);
252 bipop.set_progress_func(pfunc);
254 return bipop.get_solutions();
259 if (!parameters.is_sep())
260 parameters.set_sep();
261 if (solutions.cov().size()==0)
263 ESOptimizer<CMAStrategy<ACovarianceUpdate,TGenoPheno>,CMAParameters<TGenoPheno>,CMASolutions> sepcmaes(func,parameters);
264 if (gfunc !=
nullptr)
265 sepcmaes.set_gradient_func(gfunc);
266 sepcmaes.set_progress_func(pfunc);
267 sepcmaes.set_plot_func(pffunc);
269 return sepcmaes.get_solutions();
273 ESOptimizer<CMAStrategy<ACovarianceUpdate,TGenoPheno>,CMAParameters<TGenoPheno>,CMASolutions> sepcmaes(func,parameters,solutions);
274 if (gfunc !=
nullptr)
275 sepcmaes.set_gradient_func(gfunc);
276 sepcmaes.set_progress_func(pfunc);
278 return sepcmaes.get_solutions();
283 if (!parameters.is_sep())
284 parameters.set_sep();
285 if (solutions.cov().size() == 0)
287 ESOptimizer<IPOPCMAStrategy<ACovarianceUpdate,TGenoPheno>,CMAParameters<TGenoPheno>,CMASolutions> ipop(func,parameters);
288 if (gfunc !=
nullptr)
289 ipop.set_gradient_func(gfunc);
290 ipop.set_progress_func(pfunc);
291 ipop.set_plot_func(pffunc);
293 return ipop.get_solutions();
297 ESOptimizer<IPOPCMAStrategy<ACovarianceUpdate,TGenoPheno>,CMAParameters<TGenoPheno>,CMASolutions> ipop(func,parameters,solutions);
298 if (gfunc !=
nullptr)
299 ipop.set_gradient_func(gfunc);
300 ipop.set_progress_func(pfunc);
302 return ipop.get_solutions();
305 case sepaBIPOP_CMAES:
307 if (!parameters.is_sep())
308 parameters.set_sep();
309 if (solutions.cov().size() == 0)
311 ESOptimizer<BIPOPCMAStrategy<ACovarianceUpdate,TGenoPheno>,CMAParameters<TGenoPheno>,CMASolutions> bipop(func,parameters);
312 if (gfunc !=
nullptr)
313 bipop.set_gradient_func(gfunc);
314 bipop.set_progress_func(pfunc);
315 bipop.set_plot_func(pffunc);
317 return bipop.get_solutions();
321 ESOptimizer<BIPOPCMAStrategy<ACovarianceUpdate,TGenoPheno>,CMAParameters<TGenoPheno>,CMASolutions> bipop(func,parameters,solutions);
322 if (gfunc !=
nullptr)
323 bipop.set_gradient_func(gfunc);
324 bipop.set_progress_func(pfunc);
326 return bipop.get_solutions();
331 if (!parameters.is_vd())
333 ESOptimizer<CMAStrategy<VDCMAUpdate,TGenoPheno>,CMAParameters<TGenoPheno>> vdcma(func,parameters);
334 if (gfunc !=
nullptr)
335 vdcma.set_gradient_func(gfunc);
336 vdcma.set_progress_func(pfunc);
337 vdcma.set_plot_func(pffunc);
339 return vdcma.get_solutions();
343 if (!parameters.is_vd())
345 ESOptimizer<IPOPCMAStrategy<VDCMAUpdate,TGenoPheno>,CMAParameters<TGenoPheno>> ipop(func,parameters);
346 if (gfunc !=
nullptr)
347 ipop.set_gradient_func(gfunc);
348 ipop.set_progress_func(pfunc);
349 ipop.set_plot_func(pffunc);
351 return ipop.get_solutions();
355 if (!parameters.is_vd())
357 ESOptimizer<BIPOPCMAStrategy<VDCMAUpdate,TGenoPheno>,CMAParameters<TGenoPheno>> bipop(func,parameters);
358 if (gfunc !=
nullptr)
359 bipop.set_gradient_func(gfunc);
360 bipop.set_progress_func(pfunc);
361 bipop.set_plot_func(pffunc);
363 return bipop.get_solutions();
366 return CMASolutions();
linear scaling of the parameter space to achieve similar sensitivity across all components.
Definition: acovarianceupdate.cc:25