ribs.emitters.EmitterBase

class ribs.emitters.EmitterBase(archive, *, solution_dim, bounds)[source]

Base class for emitters.

Every emitter has an ask() method that generates a batch of solutions, and a tell() method that inserts solutions into the emitter’s archive. Child classes are only required to override ask().

DQD emitters should override ask_dqd() and tell_dqd() methods.

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

  • solution_dim (int) – The dimension of solutions produced by this emitter.

  • bounds (None or array-like) –

    Bounds of the solution space. 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.

    Unbounded upper bounds are set to +inf, and unbounded lower bounds are set to -inf.

Methods

ask()

Generates a (batch_size, solution_dim) array of solutions.

ask_dqd()

Generates a (batch_size, solution_dim) array of solutions for which gradient information must be computed.

tell(solution, objective, measures, ...)

Gives the emitter results from evaluating solutions.

tell_dqd(solution, objective, measures, ...)

Gives the emitter results from evaluating the gradient of the solutions, only used for DQD emitters.

Attributes

archive

The archive which stores solutions generated by this emitter.

lower_bounds

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

solution_dim

The dimension of solutions produced by this emitter.

upper_bounds

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

ask()[source]

Generates a (batch_size, solution_dim) array of solutions.

Returns an empty array by default.

ask_dqd()[source]

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, objective, measures, add_info, **fields)[source]

Gives the emitter results from evaluating solutions.

This base class implementation (in EmitterBase) needs to be overriden.

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

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

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

  • add_info (dict) – Data returned from the archive add() method.

  • fields (keyword arguments) – Additional data for each solution. Each argument should be an array with batch_size as the first dimension.

tell_dqd(solution, objective, measures, jacobian, add_info, **fields)[source]

Gives the emitter results from evaluating the gradient of the solutions, only used for DQD emitters.

Parameters
  • solution (numpy.ndarray) – (batch_size, :attr:`solution_dim`) array of solutions generated by this emitter’s ask() method.

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

  • measures (numpy.ndarray) – (batch_size, measure space dimension) array with the measure space coordinates of each solution.

  • jacobian (numpy.ndarray) – (batch_size, 1 + measure_dim, solution_dim) array consisting of Jacobian matrices of the solutions obtained from ask_dqd(). Each matrix should consist of the objective gradient of the solution followed by the measure gradients.

  • add_info (dict) – Data returned from the archive add() method.

  • fields (keyword arguments) – Additional data for each solution. Each argument should be an array with batch_size as the first dimension.

property archive

The archive which stores solutions generated by this emitter.

Type

ribs.archives.ArchiveBase

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