ribs.emitters.IsoLineEmitter¶
- class ribs.emitters.IsoLineEmitter(archive, *, iso_sigma=0.01, line_sigma=0.2, x0=None, initial_solutions=None, bounds=None, batch_size=64, seed=None)[source]¶
Emits solutions that are nudged towards other archive solutions.
If the archive is empty and
self._initial_solutions
is set, a call toask()
will returnself._initial_solutions
. Ifself._initial_solutions
is not set, we draw solutions from an isotropic Gaussian distribution centered atself.x0
with standard deviationself.iso_sigma
. Otherwise, to generate each new solution, the emitter selects a pair of elites \(x_i\) and \(x_j\) and samples from\[x_i + \sigma_{iso} \mathcal{N}(0,\mathcal{I}) + \sigma_{line}(x_j - x_i)\mathcal{N}(0,1)\]This emitter is based on the Iso+LineDD operator presented in Vassiliades 2018.
- Parameters
archive (ribs.archives.ArchiveBase) – An archive to use when creating and inserting solutions. For instance, this can be
ribs.archives.GridArchive
.iso_sigma (float) – Scale factor for the isotropic distribution used to generate solutions.
line_sigma (float) – Scale factor for the line distribution used when generating solutions.
x0 (array-like) – Center of the Gaussian distribution from which to sample solutions when the archive is empty. Must be 1-dimensional. This argument is ignored if
initial_solutions
is set.initial_solutions (array-like) – An (n, solution_dim) array of solutions to be used when the archive is empty. If this argument is None, then solutions will be sampled from a Gaussian distribution centered at
x0
with standard deviationiso_sigma
.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)
, wherelower_bound
orupper_bound
may be None to indicate no bound.seed (int) – Value to seed the random number generator. Set to None to avoid a fixed seed.
- Raises
ValueError – There is an error in x0 or initial_solutions.
ValueError – There is an error in the bounds configuration.
Methods
ask
()Generates
batch_size
solutions.ask_dqd
()Generates a
(batch_size, solution_dim)
array of solutions for which gradient information must be computed.tell
(solution_batch, objective_batch, ...[, ...])Gives the emitter results from evaluating solutions.
tell_dqd
(solution_batch, objective_batch, ...)Gives the emitter results from evaluating the gradient of the solutions, only used for DQD emitters.
Attributes
The archive which stores solutions generated by this emitter.
Number of solutions to return in
ask()
.The initial solutions which are returned when the archive is empty (if x0 is not set).
Scale factor for the isotropic distribution used to generate solutions when the archive is not empty.
Scale factor for the line distribution used when generating solutions.
(solution_dim,)
array with lower bounds of solution space.The dimension of solutions produced by this emitter.
(solution_dim,)
array with upper bounds of solution space.Center of the Gaussian distribution from which to sample solutions when the archive is empty (if initial_solutions is not set).
- ask()[source]¶
Generates
batch_size
solutions.If the archive is empty and
self._initial_solutions
is set, we returnself._initial_solutions
. Ifself._initial_solutions
is not set, we draw solutions from an isotropic Gaussian distribution centered atself.x0
with standard deviationself.iso_sigma
. Otherwise, each solution is drawn from a distribution centered at a randomly chosen elite with standard deviationself.iso_sigma
.- Returns
If the archive is not empty,
(batch_size, solution_dim)
array – containsbatch_size
new solutions to evaluate. If the archive is empty, we returnself._initial_solutions
, which might not havebatch_size
solutions.
- ask_dqd()¶
Generates a
(batch_size, solution_dim)
array of solutions for which gradient information must be computed.This method only needs to be implemented by emitters used in DQD. The method returns an empty array by default.
- tell(solution_batch, objective_batch, measures_batch, status_batch, value_batch, metadata_batch=None)¶
Gives the emitter results from evaluating solutions.
This base class implementation (in
EmitterBase
) needs to be overriden.- Parameters
solution_batch (numpy.ndarray) – Array of solutions generated by this emitter’s
ask()
method.objective_batch (numpy.ndarray) – 1D array containing the objective function value of each solution.
measures_batch (numpy.ndarray) –
(n, <measure space dimension>)
array with the measure space coordinates of each solution.status_batch (numpy.ndarray) – An array of integer statuses returned by a series of calls to archive’s
add_single()
method or by a single call to archive’sadd()
.value_batch (numpy.ndarray) – 1D array of floats returned by a series of calls to archive’s
add_single()
method or by a single call to archive’sadd()
. For what these floats represent, refer toribs.archives.add()
.metadata_batch (numpy.ndarray) – 1D object array containing a metadata object for each solution.
- tell_dqd(solution_batch, objective_batch, measures_batch, jacobian_batch, status_batch, value_batch, metadata_batch=None)¶
Gives the emitter results from evaluating the gradient of the solutions, only used for DQD emitters.
- Parameters
solution_batch (numpy.ndarray) –
(batch_size, :attr:`solution_dim`)
array of solutions generated by this emitter’sask()
method.objective_batch (numpy.ndarray) – 1-dimensional array containing the objective function value of each solution.
measures_batch (numpy.ndarray) –
(batch_size, measure space dimension)
array with the measure space coordinates of each solution.jacobian_batch (numpy.ndarray) –
(batch_size, 1 + measure_dim, solution_dim)
array consisting of Jacobian matrices of the solutions obtained fromask_dqd()
. Each matrix should consist of the objective gradient of the solution followed by the measure gradients.status_batch (numpy.ndarray) – 1d array of
ribs.archive.addstatus
returned by a series of calls to archive’sadd()
method.value_batch (numpy.ndarray) – 1d array of floats returned by a series of calls to archive’s
add()
method. for what these floats represent, refer toribs.archives.add()
.metadata_batch (numpy.ndarray) – 1d object array containing a metadata object for each solution.
- property archive¶
The archive which stores solutions generated by this emitter.
- property initial_solutions¶
The initial solutions which are returned when the archive is empty (if x0 is not set).
- Type
- property iso_sigma¶
Scale factor for the isotropic distribution used to generate solutions when the archive is not empty.
- Type
- property line_sigma¶
Scale factor for the line distribution used when generating solutions.
- Type
- 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¶
Center of the Gaussian distribution from which to sample solutions when the archive is empty (if initial_solutions is not set).
- Type