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 CMAES to search for solutions along a randomly chosen direction. Once CMAES restarts (seerestart_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 CMAES. 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 CMAES 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 CMAES. Either “truncation” (positive weights only) or “active” (include negative weights).
bounds (None or arraylike) – Bounds of the solution space. Solutions are clipped to these bounds. Pass None to indicate there are no bounds. Alternatively, pass an arraylike to specify the bounds for each dim. Each element in this arraylike can be None to indicate no bound, or a tuple of
(lower_bound, upper_bound)
, wherelower_bound
orupper_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
, orweight_rule
is invalid.
Methods
ask
()Samples new solutions from a multivariate Gaussian.
tell
(solutions, objective_values, …[, …])Gives the emitter results from evaluating solutions.
Attributes
The archive which stores solutions generated by this emitter.
Number of solutions to return in
ask()
.(solution_dim,)
array with lower bounds of solution space.Initial step size for the CMAES optimizer.
The dimension of solutions produced by this emitter.
(solution_dim,)
array with upper bounds of solution space.Initial solution for the optimizer.

ask
()[source]¶ Samples new solutions from a multivariate Gaussian.
The multivariate Gaussian is parameterized by the CMAES optimizer.
 Returns
(batch_size, solution_dim)
array – containsbatch_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 CMAES 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.
 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
 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
 property
x0
¶ Initial solution for the optimizer.
 Type