Quality thresholds, measured surrogates, and comparable policies

Use NOAH to produce a shortlist above a quality barrier, DSA-ME to allocate expensive evaluations, and MOME-X to preserve different performance and reproducibility trade-offs. QSD-PBT trains a population of policies with different behaviors at comparable returns. See Quality thresholds, measured surrogates, and comparable policies for commands and seeded controls.

NOAH

A shortlist of eight good schedules can be more useful than a large archive when each alternative needs a manual review. Give NOAH a quality barrier, a distance describing structural differences, and operators for drawing and varying a genome. The implementation alternates quality selection, tighter bounds, and diversity selection.

from examples.quality_thresholds import design, hamming, mutate, propose
from qdpy.algorithms import NOAH

search = NOAH(population_size=8, barrier=29., maximize=True,
              diversity_scale=.35, seed=11)
result = search.run(lambda genome: design(genome)[0][0],
                    budget=320, propose=propose, mutate=mutate, distance=hamming)
for candidate in result.acceptable:
    print(candidate.fitness, candidate.genome)

acceptable contains measured solutions that meet the requested barrier. When the budget runs out early, population still exposes the alternatives at the last working bound. Each attempted objective call consumes a slot, including repeated genomes and candidates that lose against the current bound. Genomes should be immutable and hashable.

NOAH uses the Solow–Polasky set diversity measure. Its exponential similarity matrix must be positive definite after a small diagonal regularization. Use a symmetric distance such as Hamming or Euclidean distance. Increasing diversity_scale makes shorter differences matter more. Keep the population modest, because evaluating diversity requires a dense pairwise matrix. This bounded variant uses fixed-size proposal attempt blocks and spends remaining calls improving diversity after reaching the requested barrier. Ulrich and Thiele, GECCO 2011.

Deep Surrogate-Assisted MAP-Elites

Supply proposal and mutation functions for the decision space. DSA-ME starts from a random set of measured candidates. Between exact batches it refits a model using all successful exact calls, clears the predicted archive, and illuminates it with new predictions. Then it evaluates the predicted elites on the actual task and archives them at their measured descriptors.

from examples.quality_thresholds import design, design_grid, mutate, propose
from qdpy.algorithms import DeepSurrogateMAPElites

archive = design_grid()
search = DeepSurrogateMAPElites(
    archive, budget=112, propose=propose, mutate=mutate,
    initial_samples=16, model_budget=192, seed=11,
)
search.optimise(design)
print(archive.filled_bins, search.nb_evaluations, search.model_evaluations)
print(search.cell_matches, search.verified_predictions)

The default model is a two-hidden-layer scikit-learn regressor trained on standardized inputs and outputs. Supply surrogate with fit(X, Y) and predict(X) to replace it. Each row of Y has scalar fitness followed by descriptors. Use encode(genome) to turn a numeric genome into model features without changing its evaluation representation. The evaluator supports QDpy’s ordinary return format. Pass seeded=True for evaluate(genome, seed) or pass an executor to parallelize exact calls.

container contains measured elites. predicted_archive shows the last search under the model, and can be empty if predictions fall outside the grid. A round with no usable prediction measures a fresh random proposal. The original paper applies the same inner and outer loops to collectible card deck search. Zhang et al., GECCO 2022.

MOME-X

Consider a controller whose faster settings make the final position less predictable. MOME-X uses repeated measurements to estimate typical fitness and score reproducibility. In each descriptor cell it keeps nondominated trade-offs between fitness and reproducibility.

from examples.quality_thresholds import noisy_design
from qdpy.algorithms import MOMEX
from qdpy.containers import ParetoGrid

fronts = ParetoGrid(
    shape=(8,), max_items_per_bin=6,
    fitness_domain=((0., 1.), (-1., 0.)), fitness_weights=(1., 1.),
    features_domain=((0., 1.),), truncation="crowding",
)
search = MOMEX(fronts, budget=512, dimension=2, samples=4, seed=11)
search.optimise(noisy_design, seeded=True)
fast = search.project(reproducibility_weight=0.)
stable = search.project(reproducibility_weight=16.)
print(fast.filled_bins, stable.filled_bins, search.nb_evaluations)

Each candidate costs a complete group of samples attempts. If a rollout fails, the group consumes its usual budget and yields no candidate. Fitness and niche coordinates use componentwise median or mean. Reproducibility is minus the mean of the coordinate standard deviations across repeats. If descriptor axes have incompatible units, put them on comparable scales in the evaluator. Use a fitness weight of -1. to minimize the first objective. The reproducibility objective always maximizes.

project(weight) chooses one elite per cell by signed raw fitness plus the given weight times reproducibility. This creates an independent scalar archive and costs no new evaluations. Use separate held-out rollouts to audit the resulting choices. The fixed-sampling Pareto method follows Flageat et al., Section IV-D.

Quality-Similar Diversity with Population-Based Training

Install qdpy[rl] to train categorical PPO actors with independent critics and adaptive diversity weights. A descriptor describes a full episode, so it can include features such as how often an agent changes direction or which order it visits landmarks. Each member fits a descriptor baseline and uses the resulting advantage to increase the population’s mean pairwise descriptor distance.

from examples.qsd_pbt import TwoStyles, describe
from qdpy.rl import PPOConfig, PolicyConfig, QSDPBT

search = QSDPBT(
    TwoStyles, descriptor=describe, descriptor_size=2, population_size=4,
    max_episode_steps=8, ppo=PPOConfig(rollout_steps=48, epochs=3, batch_size=24),
    policy=PolicyConfig((12,)), initial_weight=5., decay_steps=700, seed=11,
)
search.train(768)
audit = search.evaluate(episodes_per_policy=16, seed=511)
print(audit.returns, audit.diversity_by_quality((0., 6., 7., 8.000001)))
actor = search.policies()[0]
print(actor.act([0.], deterministic=True))

The diversity weight decays during training and decays faster for members with lower running returns. A quality_offset can shift the quality used by the weight schedule. Reports still use the raw returns. history(observation, past_actions, past_rewards) can provide a summary of the episode prefix to the descriptor critic. The default context is the observation and progress through the fixed horizon.

This synchronous PPO variant supports Discrete and MultiDiscrete. It trains the descriptor critic on completed episodes, using the final descriptor minus the critic baseline for the descriptor advantage. A partial episode at the end of a collection contributes a bootstrapped task update. Its descriptor is unused. Save each exported actor with actor.save(path) and load it with CategoricalPolicy.load(path). Take held-out measurements at training checkpoints to compare styles across several quality levels. Use the same return bins for each method you compare. Wu et al., ICLR 2023.