anyoptimization / pymoo

NSGA2, NSGA3, R-NSGA3, MOEAD, Genetic Algorithms (GA), Differential Evolution (DE), CMAES, PSO
https://pymoo.org
Apache License 2.0
2.21k stars 381 forks source link

Tolfun is not working in CMA-ES #484

Closed xdhcode closed 9 months ago

xdhcode commented 11 months ago

algorithm = CMAES(x0=x0, sigma=0.25, tolfun=1000, restarts=9, popsize=30, restart_from_best='False', bipop=True) My objective function is between 10^8 to 0. I set tolfun to 10^3, however, f_min freezed about 75 generations and CMA-ES still keeps running. And, the introduction https://pymoo.org/interface/termination.html is not detailed. Can anyone help me stop CMA-ES with tolfun? I just want to let bipop and restart work. And I set minimize(problem, algorithm, ('n_gen', 99999)). Does n_gen overwrite tolfun? The last question is, should sigma set smaller than 1? I ask this because the range of x is not normalized, it is confusing to set sigma in a normalized range between 0 and 1. Thank you for your advice.

blankjul commented 11 months ago

For details about the CMAES parameters please also see the original implementation: https://github.com/CMA-ES/pycma In pymoo, we just interface this library for convenience, however, not all functionalities are supported.

Is it possible that for you the issue is just restarts=9? Does it work if you set it so zero?

blankjul commented 11 months ago

By default CMAES does normalize your X space, however, you can turn it off by setting normalize=False. I personally believe it is easier to set sigma in the normalized space, but if you turn off normalization all can be set in the original one.

No termination criterion is overwritten. But the pymoo once can be added in addition.

xdhcode commented 11 months ago

Thank you for your comments. I tried a larger tolfun like 5000 and CMAES restarted three times in thousands of iters, but I haven't figure out why CMAES doesn't restart precisely as I expected. The answer may be in PYCMA as you pointed. Anyway, it restarts. If you are interested in my work, you can check out opt_PYMOO.py.