Residual regression and focused QD search¶

This guide covers five ways to preserve or use diversity during search. The examples compare each method with a control using the same attempt budget. Coefficient optimization in residual symbolic regression uses the optional qdpy[cma] installation. The remaining examples use the base package.

Find equations for different parts of a dataset¶

Diversified Residual Symbolic Regression (DRSR) retains equations with different residual patterns. For each fitted equation, compute the mean absolute residual within every group and record the group with the largest mean. Along with raw tree size and the number of non-algebraic operators, that group determines the archive cell. The robust loss determines which equation survives within a cell. [Ikeda2026]

import numpy as np
from qdpy.symbolic import Expression, residual_symbolic_regression

x = np.tile(np.linspace(0.2, 1.5, 20), 2)[:, None]
y = np.concatenate((x[:20, 0], -0.8 * x[20:, 0]))
result = residual_symbolic_regression(
    x, y, groups=np.repeat((7, 12), 20), loss="medae",
    budget=32, fit_evaluations=23, max_fit_evaluations=700,
    initial_expressions=(Expression.variable(0),), seed=11,
)
for elite in result.elites[:6]:
    print(elite.model.formula, elite.outlier_cluster, elite.loss)
print(result.stats)

Pass integer training group labels, or use the default k-means partition of scaled input and target columns. Each tree gets one multiplicative coefficient per node. QDpy uses its existing tree variation and constant folding, then runs bounded CMA-ES. The initial coefficients and every finite trial can enter the archive. This keeps alternative fits of the same tree available. Undefined predictions consume a trial and are excluded from admission. Candidate models carry the training RMSE separately from the chosen robust loss.

Use layout="structural" for a control with the same coefficient search and only the two structural axes. Compare resulting models on fresh labeled data. The bundled demo reports the lowest held-out RMSE among retained models for each of two known relationships. It uses the training regime labels to construct the archive.

Trigger extinction in a Voronoi archive¶

Pass extinction_period and extinction_size to qdpy.algorithms.VoronoiElites. The period is measured in committed batches. In a scheduled batch, after offering each result, repeatedly remove the lower-quality member of the closest descriptor pair until the archive fits the reduced size. Ordinary batches can refill the archive to its usual capacity. A scheduled batch containing only failures still shrinks the archive. [Feiden2023]

from qdpy.algorithms import VoronoiElites
from qdpy.containers import VoronoiArchive

archive = VoronoiArchive(20, features_domain=((0., 1.),) * 2,
                         fitness_domain=((0., 1.),))
search = VoronoiElites(
    archive, 120, 2, batch_size=10,
    extinction_period=5, extinction_size=6, seed=11,
)
search.optimise(lambda x: ((1. - (x[0] - 0.8) ** 2,), tuple(x)))
print(search.extinctions, search.pruned, len(archive))

Choose the descriptor to reflect meaningful behavioral differences. The wall-maze comparison uses four measured positions along each route. It reports the first evaluator call to reach the goal region and maps survivors onto a common endpoint grid.

Use different descriptors for selection and admission¶

In qdpy.algorithms.MultiDescriptorMAPElites, the ordinary feature vector places evaluated offspring in an archive cell. Store a second numeric descriptor in the evaluator’s named scores. Parent selection uses these vectors for the current elites. A maze example uses endpoints for archive cells and sampled trajectories for parent selection. [Gravina2019]

from qdpy.algorithms import MultiDescriptorMAPElites
from qdpy.containers import Grid

archive = Grid(shape=(10,), features_domain=((0., 1.),),
               fitness_domain=((0., 1.),), fitness_weights=(1.,))
def evaluate(genome):
    u, v = genome
    return (1. - (u - .5) ** 2,), (u,), {"waypoints": (v, u * v)}

search = MultiDescriptorMAPElites(
    archive, 96, 2, selection_size=2, selection_score="waypoints",
    mode="blend", batch_size=8, seed=11,
)
search.optimise(evaluate)
print(archive.filled_bins, search.forecasts)

novelty measures nearest-neighbor distance in the selection space. surprise measures distance from forecasts obtained by extrapolating cluster-center movement over two archive snapshots. blend combines the two distances and pareto uses both as objectives in a rank-and-crowding tournament. The single-score modes draw parents in proportion to the scores, with uniform sampling when all scores are zero. Each method uses the same bounded Iso+LineDD variation and native grid admission. Supply the named selection vector on each elite when warm-starting.

Let a user direct local search¶

qdpy.algorithms.WindowedMAPElites implements User-Controlled MAP-Elites (UC-ME). After a short global search, show a small set of feasible elites near the current descriptor window. A user selection moves the window. Future batches breed from the elites inside it. Measured offspring can populate cells anywhere in the archive. [Sfikas2023]

from qdpy.algorithms import RealVariable, WindowedMAPElites
from qdpy.containers import Grid

grid = Grid(shape=(10, 10), features_domain=((0., 1.),) * 2,
            fitness_domain=((0., 1.),), fitness_weights=(1.,))
search = WindowedMAPElites(
    grid, 60, [RealVariable(0., 1.)] * 2, window_radius=.2,
    constraint_names="size", batch_size=10, seed=11,
)
def evaluate(genome):
    u, v = genome
    return (1. - .2 * abs(u - v),), (u, v), {"size": u + v - 1.2}

search.optimise(evaluate)
def choose_widest(panel):
    return max(range(len(panel)), key=lambda i: panel[i].features.values[0])

search.choose(choose_widest, count=4, sampling="medoids")
search.optimise(evaluate, budget=60)
print(search.window_center)

The chooser returns the zero-based index of one of its alternatives. Use alternatives() and focus(elite) if a notebook or UI needs time to collect a choice. focus(None) returns to global search. Medoids represent clusters of nearby designs. Corner sampling picks distinct elites nearest to evenly spaced corner indices, up to one elite per corner. In constrained runs, alternate between the eligible feasible and lowest-violation elites when both pools have entries. choose() only shows feasible alternatives.

Diversify ties within a binary Pareto front¶

qdpy.algorithms.GSEMOD samples a Pareto representative and flips each bit with probability 1 / dimension. A new nondominated objective vector can enter the population. If a candidate ties the objectives of a representative, the population’s bit balance decides whether the replacement is accepted. [Antipov2025]

from qdpy.algorithms import GSEMOD

search = GSEMOD(6, diversity="lexicographic", seed=11)
def evaluate(bits, seed):
    ones = sum(bits)
    return ones, len(bits) - ones

search.run(evaluate, 500)
print(search.stats.imbalance)
print(search.population)

The evaluator returns finite maximization objectives, or None to record a failed attempt. Negate objectives you want to minimize. total minimizes the sum of the per-bit imbalances. lexicographic first minimizes the largest imbalance, then compares the rest in descending order. none is ordinary GSEMO with replacement on ties. Call run() again to spend an additional budget.

Reproduce the CPU comparisons¶

Run the bundled example from a source checkout. Each command prints one JSON row per method and seed. The residual case requires qdpy[cma].

python examples/residual_window_qd.py residual --seeds 11 22 33 44 55
python examples/residual_window_qd.py voronoi --seeds 11 22 33 44 55
python examples/residual_window_qd.py descriptors --seeds 11 22 33 44 55
python examples/residual_window_qd.py window --seeds 11 22 33 44 55
python examples/residual_window_qd.py binary --seeds 11 22 33 44 55

Both symbolic layouts recovered both generating relationships in all five runs at 48 tree proposals and 1,104 coefficient trials per run. The residual layout retained eight equations on average, and the structural control retained four. Mean best held-out RMSE for the negative-slope regime was 0.0146 with residual descriptors and 0.0528 with structural descriptors. Both layouts had mean positive-regime RMSE below 0.011.

Both Voronoi variants reached the goal in every run at 704 calls. With extinction, the mean first discovery was at call 171.0, compared with 286.6 for ordinary Voronoi-Elites. Median discovery calls were 169 and 183. Both variants ended with 28 survivors after the final refill, with mean endpoint QD scores of 14.03 and 14.36.

On the endpoint grid after 480 maze evaluations, uniform, novelty, surprise, blend, and Pareto selection had mean QD scores of 57.83, 61.03, 59.67, 62.12, and 60.25. Blend also had the largest mean nearest-neighbor trajectory distance, 0.150 compared with 0.147 for uniform selection.

With six choices and 276 evaluations, the scripted target preference averaged 0.642 across the global archive, 0.764 with corner displays, and 0.767 with medoid displays. The local methods occupied about 39 cells each. The global run averaged 53.4 cells.

All GSEMO variants reached the 35-vector reference Pareto front of the ten-bit LOTZ-k problem at 1,800 evaluations. Ordinary GSEMO averaged total imbalance of 174.4. Sum and lexicographic tie-breaking averaged 146.0 and 146.4. The optimum total imbalance is 146 for this problem. These comparisons use small, controlled examples.

[Ikeda2026]

Diversified Residual Symbolic Regression.

[Feiden2023]

Overcoming Deceptive Rewards with Quality-Diversity.

[Gravina2019]

Blending Notions of Diversity for MAP-Elites.

[Sfikas2023]

Controllable Exploration of a Design Space via Interactive Quality Diversity.

[Antipov2025]

Runtime Analysis of Evolutionary Diversity Optimization on the Multi-objective (LeadingOnes, TrailingZeros) Problem.

qdpy

Navigation

Contents:

  • Choose your first QDpy search
  • Run your first searches from PyPI
  • Validation for recommended methods
  • Run a seeded MAP-Elites search
  • 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
    • Find equations for different parts of a dataset
    • Trigger extinction in a Voronoi archive
    • Use different descriptors for selection and admission
    • Let a user direct local search
    • Diversify ties within a binary Pareto front
    • Reproduce the CPU comparisons
  • 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: Adaptive exploration, operator selection, and phased diversity
    • Next: Learned density, design portfolios, and shared controllers
©2018, Leo Cazenille. | Powered by Sphinx 9.2.0 & Alabaster 1.0.0 | Page source