-
Notifications
You must be signed in to change notification settings - Fork 78
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to limit the optimization up to feval, using a restart strategy? #184
Comments
Somewhat a sidestep, but indeed in the Python implementation by default MAXFEVALS quits the BIPOP/IPOP restart loop, as if irun - runs_with_small > fmin_opts['restarts'] or 'ftarget' in es.stop() \
or 'maxfevals' in es.stop(check=False) or 'callback' in es.stop(check=False):
break |
I see, thank you. Unfortunately I have to use the C++ implementation, do you think there is a "simple" way to implement the same behavior there? Otherwise I will have to dig into the code to understand a way to do this. |
@DalcaTN Hi, let me see if I understand correctly: you'd like the number of total number of function evaluations of restart strategies to add up across restarts so that the function evaluation budget would apply to the cumulation of runs and not just to each of the runs separately. Is that correct ? |
@beniz if I have understood correctly what you mean, yes. My target is that any CMAES algorithm with restarts, given a total function evaluation budget, stops when that budget is over (and so yes, the number of used function evaluations should add up across restarts). |
@beniz hello again; have you perhaps found a way to solve my problem? Just to know, because otherwise I will dig into the code again and try to find a solution. Thank you! |
Hi I couldn't find time to look at it closely enough. Look at https://github.com/beniz/libcmaes/blob/master/examples/sample-code-ask-tell.cc as an example for building your own loop. Counting the evals from there and stopping should be easy. Another solution, internal to the library, would be to stop bipop and ipop on an additional counter across runs. It shouldn't be toot difficult to add this, and if you do it, please PR your code for addition. |
@beniz Thank you for the answer. I am working on the internal library and I think that this issue might be happening because of a bug. In https://github.com/beniz/libcmaes/blob/5d59cefd643a6e18fd24dffa15491811fa96c5eb/src/ipopcmastrategy.cc#L61-L80 reset_search_state(), that even sets _niter back to 0, is called before the if structure that would break the loop in the case that the max budget function is reached. As a result, even _nevals is set back to 0 and the loop is never going to be broken. If the original purpose of this if structure was to achieve what I am as well looking for (as your comments suggest), it would be sufficient to introduce a new variable that counts function evaluations across restarts, and to insert it in place of _nevals in this if structure. Unless max_fevals should be the maximum number of function evaluations per iteration and not for the entire run of the algorithm; in that case, the fix should be different. Let me know what you think. I can eventually fix it without too much trouble (I have already done it locally). By the way this is what actually happens in the IPOP strategy; in the BIPOP strategy, this structure that checks if max_evals has been reached is not present, and should be introduced. |
Thanks, make the changes that work for you so that my lag is not slowing you down. That being said I guess max_fevals should have the same semantics everywhere and capture the total number of calls across restarts in this particular two cases of ipop and bipop. |
Hi. I would like to use any flavour of CMA-ES with BIPOP or IPOP restart strategies, but only up to a certain number of function evaluations. The problem is that, while using any restart strategy, once the MAXFEVALS stopping criteria is triggered the algorithm just restarts again; instead I would like it to terminate when MAXFEVALS triggers (but not when other stopping criteria trigger). So terminating the optimization when a given function evaluation budget is over. Is there a way to do this? I checked documentation and code, but I am facing quite some trouble. Thank you!
The text was updated successfully, but these errors were encountered: