ribs.schedulers.BayesianOptimizationScheduler

class ribs.schedulers.BayesianOptimizationScheduler(archive: GridArchive, emitters: Sequence[BayesianOptimizationEmitter], result_archive: ArchiveBase | None = None, *, add_mode: 'batch' | 'single' = 'batch')[source]

Similar to Scheduler but with support for upscaling archives.

This scheduler should only be used in conjunction with BayesianOptimizationEmitter and GridArchive.

Parameters:
archive: GridArchive

An archive object.

emitters: Sequence[BayesianOptimizationEmitter]

A list of emitters.

result_archive: ArchiveBase | None = None

An additional archive where all solutions are added.

add_mode: 'batch' | 'single' = 'batch'

Indicates how solutions should be added to the archive. The default is “batch”, which adds all solutions with one call to add(). Alternatively, use “single” to add the solutions one at a time with add_single(). “single” mode is included since implementing batch addition on an archive is sometimes non-trivial. We highly recommend “batch” mode since it is significantly faster.

Raises:
  • TypeError – Some emitters are not BayesianOptimizationEmitter.

  • ValueError – Not all emitters have the same upscale schedule.

Methods

ask()

Generates a batch of solutions by calling ask on all emitters.

ask_dqd()

Generates a batch of solutions by calling ask_dqd on all DQD emitters.

tell(objective, measures, **fields)

Updates emitters and the archive with new data.

tell_dqd(objective, measures, jacobian, **fields)

Returns info for solutions from ask_dqd().

Attributes

archive

Archive for storing solutions found in this scheduler.

emitters

Emitters for generating solutions in this scheduler.

result_archive

An additional archive for storing solutions found in this scheduler.

upscale_schedule

The upscale schedules for all the Bayesian optimization emitters.

ask() ndarray

Generates a batch of solutions by calling ask on all emitters.

Note

The order of the solutions returned from this method is important, so do not rearrange them.

Returns:

A (batch_size, dim) array of solutions to evaluate. Each row contains a single solution.

Raises:

RuntimeError – This method was called immediately after calling an ask method.

ask_dqd() None[source]

Generates a batch of solutions by calling ask_dqd on all DQD emitters.

Note

The order of the solutions returned from this method is important, so do not rearrange them.

Returns:

A (batch_size, dim) array of solutions to evaluate. Each row contains a single solution.

Raises:

RuntimeError – This method was called immediately after calling an ask method.

tell(objective: ArrayLike | None, measures: ArrayLike, **fields: ArrayLike | None) None[source]

Updates emitters and the archive with new data.

When ALL emitters are ready to upscale, calls retessellate() to upscale the archive. Otherwise same as tell().

tell_dqd(objective: ArrayLike | None, measures: ArrayLike, jacobian: ArrayLike, **fields: ArrayLike | None) None[source]

Returns info for solutions from ask_dqd().

Note

The objective, measures, and jacobian arrays must be in the same order as the solutions created by ask_dqd(); i.e. objective[i], measures[i], and jacobian[i] should be the objective, measures, and jacobian for solution[i].

Parameters:
objective: ArrayLike | None

(batch_size,) array where each entry contains the objective function evaluation of a solution. This can also be None to indicate there is no objective, which would be the case in diversity optimization problems.

measures: ArrayLike

(batch_size, measure_dim) array where each row contains a solution’s coordinates in measure space.

jacobian: ArrayLike

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

**fields: ArrayLike | None

Additional data for each solution. Each argument should be an array with batch_size as the first dimension.

Raises:
property archive : ArchiveBase

Archive for storing solutions found in this scheduler.

property emitters : Sequence[EmitterBase]

Emitters for generating solutions in this scheduler.

property result_archive : ArchiveBase

An additional archive for storing solutions found in this scheduler.

If result_archive was not passed to the constructor, this property is the same as archive.

property upscale_schedule : ndarray | None

The upscale schedules for all the Bayesian optimization emitters.

None if emitters do not undergo archive upscaling.