Gradient-Free-Optimizers icon indicating copy to clipboard operation
Gradient-Free-Optimizers copied to clipboard

API changes for v2

Open SimonBlanke opened this issue 3 years ago • 2 comments

In this issue the progress for the API-changes for v2 is shown.

The objective-function parameter might make more sense in the optimizer-class instead of the search-method. Parameters in the method should be data you would want to change from one search to the next. It does not make sense to me to change the objective-function but not the search-space. So the new API-design would look like this:

import numpy as np
from gradient_free_optimizers import RandomSearchOptimizer

def parabola_function(para):
    loss = para["x"] * para["x"]
    return -loss

search_space = {"x": np.arange(-10, 10, 0.1)}

opt = RandomSearchOptimizer(parabola_function, search_space)
opt.search(n_iter=100000)

SimonBlanke avatar Nov 06 '22 09:11 SimonBlanke

since there are multiple kinds of "powell's methods", the existing "powell's method" in GFO will be renames to "Powell's Conjugate Direction Method" in v2.0

SimonBlanke avatar Jul 07 '24 10:07 SimonBlanke

The objective-function and the search-space are not optimizer specific parameters. It makes more sense to move the search-space argument to the search-method. So the v2 API could look like this:

import numpy as np
from gradient_free_optimizers import RandomSearchOptimizer

def parabola_function(para):
    loss = para["x"] * para["x"]
    return -loss

search_space = {"x": np.arange(-10, 10, 0.1)}

opt = RandomSearchOptimizer()
opt.search(parabola_function, search_space, n_iter=100000)

This is also true for initialize and constraints and the random_state.

SimonBlanke avatar Nov 27 '24 14:11 SimonBlanke