optimagic: Add wrappers for Nevergrad
Wrap the gradient free optimizers from nevergrad in optimagic.
Nevergrad implements the following algorithms:
NgIohTunedis “meta”-optimizer which adapts to the provided settings (budget, number of workers, parametrization) and should therefore be a good default.TwoPointsDEis excellent in many cases, including very highnum_workers.PortfolioDiscreteOnePlusOneis excellent in discrete settings of mixed settings when high precision on parameters is not relevant; it’s possibly a good choice for hyperparameter choice.OnePlusOneis a simple robust method for continuous parameters withnum_workers< 8.CMAis excellent for control (e.g. neurocontrol) when the environment is not very noisy (num_workers ~50 ok) and when the budget is large (e.g. 1000 x the dimension).TBPSAis excellent for problems corrupted by noise, in particular overparameterized (neural) ones; very highnum_workersok).PSOis excellent in terms of robustness, highnum_workersok.ScrHammersleySearchPlusMiddlePointis excellent for super parallel cases (fully one-shot, i.e.num_workers= budget included) or for very multimodal cases (such as some of our MLDA problems); don’t use softmax with this optimizer.RandomSearchis the classical random search baseline; don’t use softmax with this optimizer.
In the long run we want to wrap all of them, but if you are tackling this as your first issue you should focus on one. In that case please coment below which optimizer you are going to work on so we don’t duplicate efforts.
About this issue
- Original URL
- State: open
- Created 2 years ago
- Comments: 17 (12 by maintainers)
@r3kste, @gulshan-123 unless you have already worked on this we can postpone the implementation of nonlinear constraints until all active nevergrad PRs are merged and we did some refactoring to avoid duplicated code.
@r3kste thanks for the clarification.
Sure, if we cannot make it work with
minimizewe can use the ask-and-tell interface. Long run that is probably also the better choice if we want to have a more sophisticated outer loop.I think here we should have
range(min(optimizer.budget-optimizer.num_ask, optimizer.num_workers)), for strict budget constraint.We actually want to collect histories for all optimizers. The main benefit of history collection is to compare how efficient different optimizers are, i.e. how fast (in terms of function evaluations) they make progress.
There are a few optimizers where we have not found ways to do it yet, but in nevergrad it seems to be quite easy, so we definitely want to do it.
This would for example allow users to compare the efficiency of PSO with a random search algorithm.
@gulshan-123 and @r3kste, thanks for your PRs. In both PRs we currently have the problem that they way you implement parallelism is not compatible with our history collection. I first thought that the only way around this is to use the lower level ask-and-tell inferface, but I think there is a better solution you can try.
Background
Optimagic’s
InternalOptimizationProblemautomatically adds history collection to the objective function. The collected history forms the basis ofom.criterion_plotand other important visualizations. For history collection to work in a parallel case, it is important to useproblem.batch_fun(which automatically parallelizes) instead of just using multiprocessing onproblem.fun.Implementation Idea
Nevergrad has the
batch_modeandexecutorarguments for parallelization. An example is here. Theexecutorneeds to be compatible with theExecutorinterface fromconcurrent.futures.I think the simplest way to make history collection work with nevergrad is to implement a custom
Executorthat callsproblem.batch_funinternally.