Dominated Novelty Search¶
Use qdpy.algorithms.DominatedNoveltySearch when you want a fixed
number of survivors and have yet to decide how to bin descriptors.
The example searches on normalised Rastrigin with two descriptors. It
maps the final population to a 4 × 4 grid for reporting.
Run from the repository root after installing the base package.
python examples/dominated_novelty.py
# SPDX-License-Identifier: LGPL-3.0-or-later
## @file
# @brief Run a grid-free Dominated Novelty Search on normalised Rastrigin.
"""Run a grid-free Dominated Novelty Search on normalised Rastrigin."""
from qdpy.algorithms import DominatedNoveltySearch
from qdpy.benchmarks import illumination_rastrigin_normalised
from qdpy.containers import Grid
from qdpy.simple import run
if __name__ == "__main__":
unit = (0.0, 1.0)
search = DominatedNoveltySearch(
budget=24, dimension=3, population_size=12, batch_size=4, k=3,
fitness_domain=(unit,),
)
result = run(search, illumination_rastrigin_normalised, seed=42)
# Bin the final population for comparison with a grid-based search.
reporting_grid = Grid(shape=(4, 4), fitness_domain=(unit,), features_domain=(unit, unit))
reporting_grid.update(result.archive, ignore_exceptions=False)
print(f"Evaluations: {result.evaluations}")
print(f"Survivors: {len(result.archive)}/{result.archive.capacity}")
print(f"Best raw fitness: {result.best.fitness.values[0]:.4f}")
print(f"Reported coverage: {reporting_grid.filled_bins}/{len(reporting_grid.solutions)} cells")
population_size caps the number of survivors. k caps the number of
strictly fitter neighbours used to score each candidate. The score is the
mean distance to those neighbours, or infinity when there are none.
Equal scores keep incumbents before offspring in proposal order, and
duplicate genomes share one entry. QDpy follows the paper’s strict
comparison. The authors’ reference code includes equally fit neighbours.
Report len(result.archive) as the survivor count and
reporting_grid.filled_bins as coverage. Several survivors can share a
cell. When comparing with MAP-Elites, use the same bins and descriptor
ranges for both reports. For your evaluator, return consistently sized,
finite descriptors. Rescale coordinates with unlike units before
returning them because the competition score uses Euclidean distance.
Manual generations¶
CMA-MAE, DNS, and MOME use batch_mode=True with the managed runner.
To run a single generation yourself, keep the constructor and replace
the call to run() and the reporting block with this code.
candidates = search.ask_batch()
search.tell_batch([illumination_rastrigin_normalised(ind) for ind in candidates])
print(search.nb_evaluations, len(search.container))
Pass results in proposal order and use None for a failed candidate.
Use ask_batch(size) if fewer than a full generation’s slots remain in
your budget. For a managed DNS run, output_dir saves the run manifest.
Use native logging to save the population itself. See Replay a saved search.
Bahlous-Boldi et al. (2025) · Authors’ reference implementation