Fork me on GitHub

bolero.optimizer.CMAESOptimizer

class bolero.optimizer.CMAESOptimizer(initial_params=None, variance=1.0, covariance=None, n_samples_per_update=None, active=False, bounds=None, maximize=True, min_variance=9.8607613152626476e-32, min_fitness_dist=4.4408920985006262e-16, max_condition=10000000.0, log_to_file=False, log_to_stdout=False, random_state=None)[source]

Covariance Matrix Adaptation Evolution Strategy.

See Wikipedia for details.

Plain CMA-ES [1] is considered to be useful for

  • non-convex,
  • non-separable,
  • ill-conditioned,
  • or noisy

objective functions. However, in some cases CMA-ES will be outperformed by other methods:

  • if the search space dimension is very small (e.g. less than 5), downhill simplex or surrogate-assisted methods will be better
  • easy functions (separable, nearly quadratic, etc.) will usually be solved faster by NEWUOA
  • multimodal objective functions require restart strategies
Parameters:
initial_params : array-like, shape = (n_params,), optional (default: 0s)

Initial parameter vector.

variance : float, optional (default: 1.0)

Initial exploration variance.

covariance : array-like, optional (default: None)

Either a diagonal (with shape (n_params,)) or a full covariance matrix (with shape (n_params, n_params)). A full covariance can contain information about the correlation of variables.

n_samples_per_update : integer, optional (default: 4+int(3*log(n_params)))

Number of roll-outs that are required for a parameter update.

active : bool, optional (default: False)

Active CMA-ES (aCMA-ES) with negative weighted covariance matrix update

bounds : array-like, shape (n_params, 2), optional (default: None)

Upper and lower bounds for each parameter.

maximize : boolean, optional (default: True)

Maximize return or minimize cost?

min_variance : float, optional (default: 2 * np.finfo(np.float).eps ** 2)

Minimum variance before restart

min_fitness_dist : float, optional (default: 2 * np.finfo(np.float).eps)

Minimum distance between fitness values before restart

max_condition : float optional (default: 1e7)

Maximum condition of covariance matrix

log_to_file: boolean or string, optional (default: False)

Log results to given file, it will be located in the $BL_LOG_PATH

log_to_stdout: boolean, optional (default: False)

Log to standard output

random_state : int or RandomState, optional (default: None)

Seed for the random number generator or RandomState object.

References

[1](1, 2) Hansen, N.; Ostermeier, A. Completely Derandomized Self-Adaptation in Evolution Strategies. In: Evolutionary Computation, 9(2), pp. 159-195. https://www.lri.fr/~hansen/cmaartic.pdf
__init__(initial_params=None, variance=1.0, covariance=None, n_samples_per_update=None, active=False, bounds=None, maximize=True, min_variance=9.8607613152626476e-32, min_fitness_dist=4.4408920985006262e-16, max_condition=10000000.0, log_to_file=False, log_to_stdout=False, random_state=None)[source]
get_args()

Get parameters for this estimator.

Returns:
params : mapping of string to any

Parameter names mapped to their values.

get_best_fitness()[source]

Get the best observed fitness.

Returns:
best_fitness : float

Best fitness (sum of feedbacks) so far. Corresponds to the parameters obtained by get_best_parameters(method=’best’). For maximize=True, this is the highest observed fitness, and for maximize=False, this is the lowest observed fitness.

get_best_parameters(method='best')[source]

Get the best parameters.

Parameters:
method : string, optional (default: ‘best’)

Either ‘best’ or ‘mean’

Returns:
best_params : array-like, shape (n_params,)

Best parameters

get_next_parameters(params)[source]

Get next individual/parameter vector for evaluation.

Parameters:
params : array_like, shape (n_params,)

Parameter vector, will be modified

init(n_params)[source]

Initialize the behavior search.

Parameters:
n_params : int

dimension of the parameter vector

is_behavior_learning_done()[source]

Check if the optimization is finished.

Returns:
finished : bool

Is the learning of a behavior finished?

set_evaluation_feedback(feedback)[source]

Set feedbacks for the parameter vector.

Parameters:
feedback : list of float

feedbacks for each step or for the episode, depends on the problem