ribs.emitters.rankers.TwoStageRandomDirectionRanker¶
-
class ribs.emitters.rankers.TwoStageRandomDirectionRanker(seed: int | integer | None =
None)[source]¶ Ranks solutions based on status and on projection onto a direction in measure space.
This ranker differs from
ribs.emitters.rankers.RandomDirectionRankerin that solutions are ranked in two stages: first by whether they are added, then by their projection onto a random direction in the archive space.This ranker originates from the random direction emitter in Fontaine 2020.
Note that archives used with this ranker must have
lower_boundsandupper_boundsattributes.Methods
rank(emitter, archive, data, add_info)Ranks solutions first by whether they are added, then by their projection onto a random direction in the archive.
reset(emitter, archive)Generates a random direction in the archive's measure space.
Attributes
(measure_dim,)array with the target measure direction vector.- rank(emitter: EmitterBase, archive: ArchiveBase, data: dict[str, ndarray], add_info: dict[str, ndarray]) tuple[ndarray, ndarray][source]¶
Ranks solutions first by whether they are added, then by their projection onto a random direction in the archive.
- Parameters:¶
- emitter: EmitterBase¶
Emitter that this
rankerobject belongs to.- archive: ArchiveBase¶
Archive used by
emitterwhen creating and inserting solutions.- data: dict[str, ndarray]¶
Dict mapping from field names like
solutionandobjectiveto arrays with data for the solutions.- add_info: dict[str, ndarray]¶
Information returned by an archive’s
add()method.
- Returns:¶
The first array (shape
(batch_size,)) is an array of indices representing a ranking of the solutions and the second array (shape(batch_size,)or(batch_size, n_values)) is an array of values that this ranker used to rank the solutions.batch_sizeis the number of solutions andn_valuesis the number of values that the rank function used.
- reset(emitter: EmitterBase, archive: ArchiveBase) None[source]¶
Generates a random direction in the archive’s measure space.
A random direction is sampled from a standard Gaussian – since the standard Gaussian is isotropic, there is equal probability for any direction. The direction is then scaled to the archive bounds so that it is a random archive direction.
- Parameters:¶
- emitter: EmitterBase¶
Emitter that this
rankerobject belongs to.- archive: ArchiveBase¶
Archive used by
emitterwhen creating and inserting solutions.