Constraint programming, safe exploration, and diffusion search¶

The example covers a small job shop, a simulator with two separate safe regions, and two multimodal continuous problems. The Constraint programming, safe exploration, and diffusion search page shows the comparisons.

python -m pip install .
python -I examples/certified_safe_diffusion.py all
python -m pip install ".[cpsat]"
python -I examples/certified_safe_diffusion.py cpsat

CP-SAT archives¶

qdpy.algorithms.CPSATArchiveSearch solves one integer model per requested niche. Supply a native OR-Tools CpModel, an integral linear objective, and one integral linear expression for each descriptor. Auxiliary variables can represent nonlinear functions of the decision variables through CP-SAT constraints. For example, use add_max_equality to describe the latest completion time.

from ortools.sat.python import cp_model
from qdpy.algorithms import CPSATArchiveSearch
from qdpy.containers import Grid

model = cp_model.CpModel()
a = model.new_int_var(0, 4, "start_a")
b = model.new_int_var(0, 5, "start_b")
model.add_no_overlap([
    model.new_fixed_size_interval_var(a, 2, "job_a"),
    model.new_fixed_size_interval_var(b, 1, "job_b"),
])
archive = Grid(
    shape=(5,), features_domain=((-4., 5.),),
    fitness_domain=((0., 15.),), fitness_weights=(-1.,),
)
search = CPSATArchiveSearch(
    archive, model, objective=a + b + 3, descriptors=(b - a,),
)
for row in search.run():
    if row.genome is not None:
        print(row.cell, row.genome[a.index], row.fitness, row.objective_bound)

QDpy clones the supplied model and uses the grid’s objective direction and numeric domains. The grid converts each descriptor cell to the exact admissible integer interval, including the top endpoint in the last cell. Each stored genome contains the complete original model assignment in variable index order.

An optimal report includes the optimal incumbent and its objective bound. A feasible report also retains the incumbent and bound, with optimality still open. infeasible means the solver proved the model empty or the cell has an empty integer interval. unresolved means the solver supplied no incumbent or proof. Choose per-cell elapsed or deterministic work limits and retry selected cells with run(cells=...). The bounds and conclusions apply to the model as stated, including the archive’s domain constraints. Perron2023

Safe Bayesian illumination¶

qdpy.algorithms.SafeBayesianIllumination chooses which designs to evaluate from a finite candidate pool with known descriptors. Supply at least one trusted safe design. The evaluator measures both quality and one or more safety margins. Nonnegative margins indicate safety.

import numpy as np
from qdpy.algorithms import SafeBayesianIllumination
from qdpy.containers import Grid

points = np.arange(161, dtype=float)[:, None] / 160
archive = Grid(shape=(20,), features_domain=((0., 1.),),
               fitness_domain=((0., 1.),), fitness_weights=(1.,))
search = SafeBayesianIllumination(
    archive, points, points, safe_seeds=(36,), lipschitz=1.,
    expansion_budget=10,
)

def evaluate(genome):
    x, = genome
    return float(np.exp(-((x - .37) / .095)**2)), (.15 - abs(x - .29),)

search.run(evaluate, budget=32)
print(len(archive), len(search.trials), search.certified_indices())

The safety gate and the quality model use separate observations from the same evaluator call. By default the safety gate uses the lower confidence bound of a fixed-kernel GP for each margin. Its conclusions depend on calibration. When given Lipschitz constants, the gate uses measured margins and their error bounds to extend the safe set in raw Euclidean decision coordinates. The constants and observation error bounds must hold throughout the candidate space.

The first phase evaluates trusted seeds, then prioritizes safe points that might extend the safe set. Its GP mode scores uncertainty near the uncertified frontier. Its Lipschitz mode ranks possible expansions under optimistic GP predictions. After expansion, a separate GP ranks admissible points by expected improvement in their own descriptor niches. The gate still runs before each dispatch. Every attempted evaluation uses budget. A negative observed safety margin halts the search and stays in the trial log. The search may stop early when no untried candidate qualifies. Sui2018

Diffusion Evolution and MAP-Elites¶

qdpy.algorithms.DiffusionEvolution generates offspring by denoising a population of bounded real genomes. The update combines nearby measured genomes using Gaussian proximity and their signed fitness. A cosine schedule progressively reduces the noise. This is a numerical update over measured candidates and uses the base installation.

qdpy.algorithms.DiffusionMAPElites uses the same reverse update. It draws a reference pool from occupied niches and seeds its noisy particles near those elites. The population-only baseline uses the previous generation for both roles and reports into the same kind of archive. Both start a new Gaussian population after a complete schedule. The bounded implementation clips proposals and scales fitness weights within the reference pool.

from qdpy.algorithms import DiffusionMAPElites
from qdpy.containers import Grid

archive = Grid(shape=(12, 12), features_domain=((0., 1.),) * 2,
               fitness_domain=((0., 1.),), fitness_weights=(1.,))
search = DiffusionMAPElites(
    archive, budget=720, dimension=2, batch_size=24,
    diffusion_steps=30, seed=11,
)

def evaluate(genome):
    x, y = genome
    q = 1. / (1. + (x*x - .5)**2 + (y*y - .5)**2)
    return (q,), ((x + 1.) / 2., (y + 1.) / 2.)

search.optimise(evaluate)
print(archive.qd_score(), search.diffusion_proposals)

Use ask_batch() and tell_batch() when running an external evaluator. Provide feedback in proposal order. The Gaussian neighborhood calculation compares every particle with each reference, so max_elites bounds its work in the archive-guided variant. Zhang2025

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
  • 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
    • CP-SAT archives
    • Safe Bayesian illumination
    • Diffusion Evolution and MAP-Elites
  • 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: Hierarchical archives, counterfactuals, and generative QD
    • Next: Constraint programming, safe exploration, and diffusion search
©2018, Leo Cazenille. | Powered by Sphinx 9.2.0 & Alabaster 1.0.0 | Page source