Run a seeded MAP-Elites search¶

In this example, each candidate is a vector of three values in [0, 1]. The evaluator minimises normalised Rastrigin fitness and uses the first two values as behaviour descriptors. A four-by-four grid stores the best candidate in each cell. Both the fitness and descriptor domains use the evaluator’s normalised range.

Use the search shortcut¶

Install QDpy from this checkout and run this example. It evaluates 24 candidates sequentially in batches of six.

from qdpy.benchmarks import illumination_rastrigin_normalised
from qdpy.simple import map_elites, run

search = map_elites(
    dimension=3, budget=24, batch_size=6, shape=(4, 4),
    fitness_domain=((0, 1),), features_domain=((0, 1), (0, 1)),
)
result = run(
    search, illumination_rastrigin_normalised, seed=42,
    output_dir="results.map_elites.simple",
)

print("Evaluations", result.evaluations)
print("Occupied cells", result.archive.filled_bins)
print("Best fitness", result.best.fitness.values)

qdpy.simple.map_elites() makes the grid and returns the optimiser. Use result.archive to inspect the same grid in memory. Passing output_dir writes run.json and a numeric archive snapshot. Choose a fresh directory for each saved run, or omit output_dir to run in memory.

The shortcut defaults to one candidate per batch so every proposal can use the previous evaluation. Increase batch_size to make more candidates available for parallel evaluation. See Control evaluation with ask and tell for evaluator formats and scheduling options.

Use a CVT archive¶

CVT-MAP-Elites assigns each behaviour descriptor to its nearest centroid. Choose the number of centroids independently of the number of descriptor dimensions. Pass a CVTGrid directly to the optimiser. Set NumPy’s seed before constructing the grid so that its fitted centroids repeat. The seed passed to run() controls the search.

import numpy as np

from qdpy.algorithms import RandomSearchMutPolyBounded
from qdpy.benchmarks import illumination_rastrigin_normalised
from qdpy.containers import CVTGrid
from qdpy.simple import run

np.random.seed(42)
archive = CVTGrid(
    shape=16, nb_sampled_points=512,
    fitness_domain=((0., 1.),), features_domain=((0., 1.), (0., 1.)),
)
search = RandomSearchMutPolyBounded(
    archive, budget=24, batch_size=6, dimension=3,
    ind_domain=(0., 1.), optimisation_task="minimisation",
)
result = run(search, illumination_rastrigin_normalised, seed=42)
print(result.evaluations, archive.filled_bins, archive.cluster_centers.shape)

To reuse the same tessellation across runs, pass the saved centroid array as centroids= when constructing another grid. See Plot archive geometry and evolution for a plot of the cells.

Build and log the search explicitly¶

Use the grid and optimiser directly to control their construction. This script saves the archive and logs in results.map_elites/.

import random
from functools import partial
from pathlib import Path

import numpy as np

from qdpy.algorithms import AlgorithmLogger, RandomSearchMutPolyBounded
from qdpy.benchmarks import illumination_rastrigin_normalised
from qdpy.containers import Grid
from qdpy.tools import open_pickle_file

seed = 42
random.seed(seed)
np.random.seed(seed)

grid = Grid(
    shape=(4, 4),
    max_items_per_bin=1,
    fitness_domain=((0.0, 1.0),),
    features_domain=((0.0, 1.0), (0.0, 1.0)),
)
search = RandomSearchMutPolyBounded(
    grid, budget=24, batch_size=6, dimension=3,
    optimisation_task="minimisation", name="map-elites",
)
evaluate = partial(illumination_rastrigin_normalised, nb_features=2)

output = Path("results.map_elites")
output.mkdir(exist_ok=True)
AlgorithmLogger(search, log_base_path=output, save_period=1,
                verbose=False, config={"seed": seed})
search.optimise(evaluate)

results = open_pickle_file(output / "final.p")
saved_grid = results["container"]
print("Evaluations:", results["nb_evaluations"])
print("Occupied cells:", saved_grid.filled_bins)
print("Best fitness:", saved_grid.best_fitness.values)
print("Best cell:", saved_grid.best_index)

saved_grid.quality_array[..., 0] holds the fitness surface for the first objective, with NaN in empty cells. The iteration result files let you inspect the grid after each batch. To repeat the run, keep the seed, script, and package versions and use a different output directory for each attempt.

See Run a seeded NSLC search for a search that uses neighbours to decide what to keep.

qdpy

Navigation

Contents:

  • Choose your first QDpy search
  • Run your first searches from PyPI
  • Validation for recommended methods
  • Run a seeded MAP-Elites search
    • Use the search shortcut
    • Use a CVT archive
    • Build and log the search explicitly
  • Run a seeded NSLC search
  • Choose a QD method
  • Choose a QD algorithm
  • Compare three QD baselines
  • Run reference QD benchmarks
  • Reference QD benchmark results
  • MAP-Elites with Iso+LineDD
  • CMA-MAE with a best-only result grid
  • Dominated Novelty Search
  • Multi-Objective MAP-Elites
  • CMA-MAEGA with analytic gradients
  • Bayesian optimisation of elites
  • Discount Model Search
  • Constrained MAP-Elites with mixed variables
  • Conditional design search with HiGeME
  • Generational Adversarial MAP-Elites
  • Multi-Task Multi-Behavior MAP-Elites
  • Parametric-Task MAP-Elites
  • Learn descriptors from trajectories with AutoQD
  • MOUR-QD for unbounded descriptors
  • Mix-ME for cooperative teams
  • Quality diversity through human feedback
  • Graph-path quality diversity
  • Dynamic MAP-Elites
  • Multiple descriptors and CMA-based search
  • Case-wise selection and policy repertoires
  • Case-wise search and policy repertoire benchmarks
  • Conditional designs and task repertoires
  • Conditional designs and task repertoire benchmarks
  • Offline search and diverse plans
  • Offline search and diverse planning benchmarks
  • Compact repertoires and skill composition
  • Compact repertoire benchmarks
  • Deep archives and scenario discovery
  • Deep archives and scenario discovery benchmarks
  • Adaptive exploration, operator selection, and phased diversity
  • Residual regression and focused QD search
  • Learned density, design portfolios, and shared controllers
  • Refine diverse starts and coevolve complementary solutions
  • Guide search with task feedback and local adaptation
  • Build repertoires for classifiers, schedules, and skills
  • Search across age layers, decoders, and learned behaviors
  • Dynamic mutation and learned novelty
  • Encodings, behavior spaces, and design prototypes
  • Editable archives, preference drift, and component credit
  • Composite designs, surrogate niching, and heuristics
  • Composite design and heuristic search benchmarks
  • Solver-backed archives, graph policies, and self-play
  • Solver-backed archives, graph controllers, and parent selection
  • Few-shot priors, basin search, and semantic trade-offs
  • Language models for context rewrites, ideas, and benchmark tasks
  • Changing constraints, structured niches, fidelity, and replay
  • Changing constraints, structured niches, fidelity, and replay
  • Hierarchical archives, counterfactuals, and generative QD
  • Hierarchical archives, counterfactuals, and generative QD
  • Constraint programming, safe exploration, and diffusion search
  • Constraint programming, safe exploration, and diffusion search
  • Sequence search, outcome distributions, and continuing control
  • Sequence search, outcome distributions, and continuing control
  • Counterexamples, design symmetries, and learned policy variation
  • Counterexamples, design symmetries, and learned policy variation
  • Few-shot priors, basin search, and semantic trade-offs
  • Feasible Pareto fronts, analytic gradients, and diverse breeding
  • Feasible fronts, gradients, and diverse breeding
  • Quality thresholds, measured surrogates, and comparable policies
  • Quality thresholds, measured surrogates, and comparable policies
  • Metric archives, peer exchange, and structured variation
  • Metric archives, peer exchange, and structured variation
  • Pareto fronts, noisy elites, and policy gradients
  • Pareto fronts, noisy elites, and policy gradients on CPU
  • Model merging, subset selection, and planning
  • CPU comparisons for model merging, subset selection, and planning
  • Binary swarms, geometric policies, and budgeted archives
  • CPU pilots for binary, geometric, and budgeted search
  • Reference niches, repertoire selection, and model-based skills
  • CPU pilots for reference repertoires and model-based skills
  • Case novelty, linked variation, and discovered skills
  • CPU pilots for case novelty, linked variation, and discovered skills
  • Near-optimal portfolios, novelty, and policy reuse
  • CPU pilots for portfolios, novelty–surprise search, and policy reuse
  • Guided variation, reward coverage, and offline priors
  • Objective voting, structural diversity, and transfer
  • CPU pilots for guided search
  • Batch acquisition, benchmark instances, feasibility, and scenario risk
  • CPU pilots for batch acquisition, benchmark instances, feasibility, and risk
  • Discrete policy search with PPO and MAP-Elites
  • Continuous control with PPO, TD3, and PGA-MAP-Elites
  • Batched neural MAP-Elites
  • Quality-diversity policy gradient
  • Descriptor-conditioned MAP-Elites
  • Quality-Diversity Actor-Critic
  • Discrete QDAC variants
  • Control evaluation with ask and tell
  • Run a QDpy seed sweep with Rundra
  • Evaluate a MAP-Elites search with Ray
  • Replay a saved search
  • Save and resume a portable run
  • Compare multi-seed runs
  • Plot archive geometry and evolution
  • Genealogy and stepping stones
  • MC-AURORA with learned descriptors
  • MAP-Elites with noisy evaluations
  • Audit a noisy archive
  • Shared noisy Rastrigin validation
  • How QDpy runs a search
  • Core Python API
  • QDpy source reference
  • QDpy release notes
  • Run the release preflight
  • Benchmark search throughput
  • QDpy parallelism benchmarks
  • Compare MAP-Elites, CVT-MAP-Elites, and CMA-MAE
  • Shared QD benchmark panels
  • Modern QD pilot results
  • Differentiable, Bayesian, and high-dimensional QD pilots
  • Constrained search and GAME pilots
  • Fixed-task and dynamic QD pilots
  • Local Pareto, team, feedback, graph, and Bayesian QD pilots
  • Joint population optimization with SQUAD
  • Segment crossover in MAP-Elites
  • Learned competition rules
  • Share policy representations with RefQD
  • Co-design bodies and controllers with Pollination
  • Population objectives, learned selection, and policy transfer
  • Adapt a repertoire with M-BOA
  • Two-objective MO-CMA-MAE
  • Gradient-informed search on categorical genomes
  • Behavior-regulated policy gradients
  • Return to promising states with Go-Explore
  • Repertoire adaptation, gradient search, and exploration benchmarks
  • Multifidelity search, adaptive grids, and curricula
  • Train controllers for objective trade-offs
  • Multifidelity search, adaptive grids, and curricula benchmarks
  • Scalable covariance search and learned genome variation
  • Gradient, imitation, and dynamics-aware policy search
  • Scalable emitters and continuous policy search benchmarks
  • Targeted search, balanced designs, and adversarial tournaments
  • SAC populations and search over frozen policy latents
  • Targeted search and policy population benchmarks
  • Interactive search, scheduling rules, and repertoire reuse
  • Distill a repertoire with the Quality-Diversity Transformer
  • Interactive and repertoire workflow benchmarks
  • Symbolic regression with MAP-Elites
  • Symbolic regression benchmark
  • Parent selection, surrogate search, and diverse skills
  • Parent selection, surrogate search, and skill pilots
  • Archive repair, ensembles, and policy reuse
  • Archive repair, ensembles, and policy reuse benchmarks
  • Differential evolution, mixed variables, and learned preferences
  • Differential evolution, mixed variables, and learned preferences
  • Solver repair, repertoire selection, and cross-component search
  • Solver repair, repertoire selection, and cross-component search
  • Offline search, learned niches, and cooperating policy parts
  • Offline search, learned niches, and cooperating policies benchmarks
  • Trace-Elites, MEMES, and asymmetric islands
  • Trace-Elites, MEMES, and AIM benchmarks
  • Deep QD, Voronoi-Elites, and occupancy CVT-MAP-Elites
  • Deep QD, Voronoi-Elites, and occupancy benchmarks
  • Sparse rewards, interpretable trees, and population diversity
  • Sparse rewards, decision trees, and determinant diversity
  • Ordered trajectories and model-guided variation
  • Ordered trajectories and model-guided variation

Related Topics

  • Documentation overview
    • Previous: Validation for recommended methods
    • Next: Run a seeded NSLC search
©2018, Leo Cazenille. | Powered by Sphinx 9.2.0 & Alabaster 1.0.0 | Page source