ribs.emitters.rankers.NSLCRanker

class ribs.emitters.rankers.NSLCRanker(seed: int | integer | None = None, diversity_field: str | None = None)[source]

Ranks solutions with Novelty Search with Local Competition.

This ranker implements the selection strategy from Novelty Search with Local Competition (NSLC) in Lehman 2011b. The core idea is to rank solutions by non-dominated sorting on two objectives:

  1. Novelty (higher is better) – the average distance in measure space to the k-nearest neighbors in the archive.

  2. Local competition (higher is better) – the number of k-nearest neighbors that the solution outperforms on the objective.

NSLC is built on top of NSGA-II (Deb 2002), so this ranker runs NSGA-II’s fast non-dominated sort to partition solutions into Pareto fronts.

Tie-breaking within a front. Lehman & Stanley’s original NSLC replaces NSGA-II’s crowding distance with a third “genotypic diversity” objective on the grounds that two solutions with identical novelty and local competition scores may nevertheless differ substantially in other ways. The third objective is domain-specific (their ERO setup counts genotypes with the same number of outer graph nodes). This ranker supports both tie-breakers:

  • If diversity_field is None (the default), NSGA-II’s standard crowding distance in (novelty, local competition) space is used to order each front. This is the practical default used by modern NSLC implementations and does not require additional information from the emitter or archive.

  • If diversity_field is set to a string name, the ranker will look up name first in add_info and then in data and use those values as a third “higher is better” objective in the non-dominated sort, reproducing Lehman & Stanley’s 3-objective formulation. This is the paper-faithful mode and is intended for users who can provide a principled genotypic-diversity signal for their domain.

This ranker can only be used with archives that return both novelty and local_competition fields from their add method. Currently, this is ribs.archives.ProximityArchive.add() when the archive is constructed with local_competition=True.

Parameters:
seed: int | integer | None = None

Passed through to RankerBase; unused by this ranker but kept for API consistency with other rankers.

diversity_field: str | None = None

Optional name of an additional “higher is better” diversity objective to include in the non-dominated sort. When provided, the field is looked up first in add_info and then in data. When None, NSGA-II crowding distance is used as the within-front tiebreaker.

See also

NSLCClassicRanker: A variant that uses the standard genotypic_diversity field for the third objective, implementing the paper-faithful NSLC algorithm.

Methods

rank(emitter, archive, data, add_info)

Ranks solutions by fast non-dominated sort over (novelty, local_competition) -- plus an optional third diversity objective when diversity_field is set -- and breaks ties within each front with NSGA-II crowding distance.

reset(emitter, archive)

Resets the internal state of the ranker.

Attributes

diversity_field

Name of the optional third objective field, or None.

rank(emitter: EmitterBase, archive: ArchiveBase, data: dict[str, ndarray], add_info: dict[str, ndarray]) tuple[ndarray, ndarray][source]

Ranks solutions by fast non-dominated sort over (novelty, local_competition) – plus an optional third diversity objective when diversity_field is set – and breaks ties within each front with NSGA-II crowding distance.

Parameters:
emitter: EmitterBase

Emitter that this ranker object belongs to.

archive: ArchiveBase

Archive used by emitter when creating and inserting solutions.

data: dict[str, ndarray]

Dict mapping from field names like solution and objective to 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_size is the number of solutions and n_values is the number of values that the rank function used.

reset(emitter: EmitterBase, archive: ArchiveBase) None

Resets the internal state of the ranker.

Parameters:
emitter: EmitterBase

Emitter that this ranker object belongs to.

archive: ArchiveBase

Archive used by emitter when creating and inserting solutions.

property diversity_field : str | None

Name of the optional third objective field, or None.