ribs.emitters.RandomDirectionEmitter

class ribs.emitters.RandomDirectionEmitter(archive, x0, sigma0, selection_rule='filter', restart_rule='no_improvement', weight_rule='truncation', bounds=None, batch_size=None, seed=None)[source]

Performs a random walk in behavior space by pursuing randomly chosen behavior space directions.

This emitter originates in Fontaine 2020. Initially, it starts at x0 and uses CMA-ES to search for solutions along a randomly chosen direction. Once CMA-ES restarts (see restart_rule), the emitter starts from a randomly chosen elite in the archive and pursues a new random direction.

Parameters
  • archive (ribs.archives.ArchiveBase) – An archive to use when creating and inserting solutions. For instance, this can be ribs.archives.GridArchive.

  • x0 (np.ndarray) – Initial solution.

  • sigma0 (float) – Initial step size.

  • selection_rule (“mu” or “filter”) – Method for selecting solutions in CMA-ES. With “mu” selection, the first half of the solutions will be selected, while in “filter”, any solutions that were added to the archive will be selected.

  • restart_rule (“no_improvement” or “basic”) – Method to use when checking for restart. With “basic”, only the default CMA-ES convergence rules will be used, while with “no_improvement”, the emitter will also restart when none of the proposed solutions were added to the archive.

  • weight_rule (“truncation” or “active”) – Method for generating weights in CMA-ES. Either “truncation” (positive weights only) or “active” (include negative weights).

  • bounds (None or array-like) – Bounds of the solution space. Solutions are clipped to these bounds. Pass None to indicate there are no bounds. Alternatively, pass an array-like to specify the bounds for each dim. Each element in this array-like can be None to indicate no bound, or a tuple of (lower_bound, upper_bound), where lower_bound or upper_bound may be None to indicate no bound.

  • batch_size (int) – Number of solutions to return in ask(). If not passed in, a batch size will automatically be calculated.

  • seed (int) – Value to seed the random number generator. Set to None to avoid a fixed seed.

Raises

ValueError – If any of selection_rule, restart_rule, or weight_rule is invalid.

Methods

ask()

Samples new solutions from a multivariate Gaussian.

tell(solutions, objective_values, …[, …])

Gives the emitter results from evaluating solutions.

Attributes

archive

The archive which stores solutions generated by this emitter.

batch_size

Number of solutions to return in ask().

lower_bounds

(solution_dim,) array with lower bounds of solution space.

sigma0

Initial step size for the CMA-ES optimizer.

solution_dim

The dimension of solutions produced by this emitter.

upper_bounds

(solution_dim,) array with upper bounds of solution space.

x0

Initial solution for the optimizer.

ask()[source]

Samples new solutions from a multivariate Gaussian.

The multivariate Gaussian is parameterized by the CMA-ES optimizer.

Returns

(batch_size, solution_dim) array – contains batch_size new solutions to evaluate.

tell(solutions, objective_values, behavior_values, metadata=None)[source]

Gives the emitter results from evaluating solutions.

As we insert solutions into the archive, we record the solutions’ projection onto the random direction in behavior space, as well as whether the solution was added to the archive. When using “filter” selection, we rank the solutions first by whether they were added, and second by the projection, and when using “mu” selection, we rank solely by projection. We then pass the ranked solutions to the underlying CMA-ES optimizer to update the search parameters.

Parameters
  • solutions (numpy.ndarray) – Array of solutions generated by this emitter’s ask() method.

  • objective_values (numpy.ndarray) – 1D array containing the objective function value of each solution.

  • behavior_values (numpy.ndarray) – (n, <behavior space dimension>) array with the behavior space coordinates of each solution.

  • metadata (numpy.ndarray) – 1D object array containing a metadata object for each solution.

property archive

The archive which stores solutions generated by this emitter.

Type

ribs.archives.ArchiveBase

property batch_size

Number of solutions to return in ask().

Type

int

property lower_bounds

(solution_dim,) array with lower bounds of solution space.

For instance, [-1, -1, -1] indicates that every dimension of the solution space has a lower bound of -1.

Type

numpy.ndarray

property sigma0

Initial step size for the CMA-ES optimizer.

Type

float

property solution_dim

The dimension of solutions produced by this emitter.

Type

int

property upper_bounds

(solution_dim,) array with upper bounds of solution space.

For instance, [1, 1, 1] indicates that every dimension of the solution space has an upper bound of 1.

Type

numpy.ndarray

property x0

Initial solution for the optimizer.

Type

numpy.ndarray