Fork me on GitHub

bolero.optimizer.RestartCMAESOptimizer

class bolero.optimizer.RestartCMAESOptimizer(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]

CMA-ES with restarts.

This will outperform plain CMA-ES on multimodal functions.

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_samples, 2), optional (default: None)

Upper and lower bounds for each parameter.

maximize : optional, boolean (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: optional, boolean or string (default: False)

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

log_to_stdout: optional, boolean (default: False)

Log to standard output

random_state : optional, int

Seed for the random number generator.

__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()

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')

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)

Get next individual/parameter vector for evaluation.

Parameters:
params : array_like, shape (n_params,)

Parameter vector, will be modified

init(n_params)

Initialize the behavior search.

Parameters:
n_params : int

dimension of the parameter vector

is_behavior_learning_done()[source]

Returns false because we will restart and not stop.

Returns:
finished : bool

Is the learning of a behavior finished?

set_evaluation_feedback(feedback)

Set feedbacks for the parameter vector.

Parameters:
feedback : list of float

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