Multifidelity search, adaptive grids, and curricula

These workflows use QDpy’s base dependencies. The examples run on synthetic tasks with small budgets. See Multifidelity search, adaptive grids, and curricula benchmarks for reproduction commands and per-seed results.

Promote candidates across evaluation fidelities

Use qdHB when you can evaluate the same design at several costs, such as training for 1, 4, or 16 epochs. It runs successive-halving brackets. At each promotion, it samples a descriptor niche and takes its best remaining candidate. An exhausted niche falls back to a draw from the other candidates. Every call spends the full cost of its fidelity. The result grid admits only measurements from the highest fidelity.

from qdpy.algorithms import BOPElitesHyperband, QDHyperband
from qdpy.containers import Grid

archive = Grid(shape=8, features_domain=((0, 1),),
               fitness_domain=((0, 1),), fitness_weights=(1,))

def evaluate(genome, fidelity):
    location, setting = genome
    optimum = 0.15 + 0.7 * location + 0.04 / fidelity
    return 1 - (setting - optimum)**2, (location,)

search = QDHyperband(archive, dimension=2, fidelities=(1, 4, 16),
                     eta=4, seed=11)
search.run(evaluate, budget=320)
print(search.spent, archive.filled_bins)

For Bayesian proposals, construct a fresh grid and use BOPElitesHyperband(grid, 2, (1, 4, 16), eta=4, quality_floor=0, seed=11). Its random forests model the objective and descriptors across measured fidelities. At the start of a bracket, expected joint improvement ranks uniform and local candidates at that bracket’s starting fidelity. quality_floor gives the comparison value in raw units for unoccupied cells. Initially both methods sample uniformly.

Return None for a failed evaluation. The trial still spends its fidelity cost. Inspect the result with search.trials. A promotion can use a different cell if the descriptor changes after evaluation at a higher fidelity. An incomplete resource budget can be left over when it is too small for another full-fidelity call.

Schneider et al., Tackling Neural Architecture Search With Quality Diversity Optimization, AutoML 2022.

Choose parents with Monte Carlo Elites

Monte Carlo Elites applies an upper confidence bound to parent selection. A draw increases the attempt count of the selected arm. Its offspring adds one success if it enters the archive. The score combines the survival fraction with a bonus for arms drawn less often. Untried arms are selected first. Use individual arms to reset learning when an elite is replaced, or cell arms to keep the history across replacements.

from qdpy.algorithms import MonteCarloElites
from qdpy.containers import Grid

archive = Grid(shape=8, features_domain=((0, 1),),
               fitness_domain=((0, 1),), fitness_weights=(1,))
search = MonteCarloElites(archive, budget=128, dimension=2,
                          batch_size=1, arms="cell", seed=11)
search.optimise(lambda x: ((1 - (x[0] - .65)**2,), (x[1],)))
print(archive.filled_bins)

The native ask/tell interface accepts delayed or out-of-order results. Each pending offspring keeps the arm that generated it. Use a batch size of one to reproduce the steady-state schedule. For other mutation rules, provide mutate(parent, rng) and return a genome inside ind_domain.

Sfikas et al., Monte Carlo Elites, GECCO 2021.

Move grid boundaries as descriptors arrive

Regular grids can place nearly every candidate in a few cells when the descriptor distribution is skewed. A sliding grid recomputes its internal boundaries from marginal quantiles of recent evaluated descriptors. It retains the declared outer bounds. Every valid offer enters the rolling buffer, including candidates that lost local competition. At a remap, QDpy replays the old elites and the buffer.

from qdpy.containers import SlidingBoundariesGrid
from qdpy.phenotype import Features, Fitness, Individual

archive = SlidingBoundariesGrid(
    shape=4, features_domain=((0, 1),), fitness_domain=((0, 1),),
    fitness_weights=(1,), remap_frequency=4, buffer_capacity=8,
)
for i in range(1, 9):
    x = i / 100
    archive.add(Individual([x], fitness=Fitness((x,)), features=Features((x,))))
print(archive.bin_edges, archive.remaps)

Use qdpy.plots.plot_archive() to plot the nonuniform cells. qdpy.results.export_grid() and ArchiveRecorder save the edges for later plots. Tied quantiles can produce zero-width cells. Remaps start new per-cell activity histories. Use a common reporting grid with the same edges for both methods when comparing coverage or QD scores.

Fontaine et al., MAP-Elites with Sliding Boundaries, GECCO 2019.

Use evolution strategies for black-box variation

ME-ES samples antithetic perturbations around an elite and uses their ranked evaluations for an Adam update. It evaluates the updated center separately before archive admission. The perturbations spend evaluations and supply the update direction. Choose fitness, novelty, or alternating blocks with mode.

from qdpy.algorithms import MEES
from qdpy.containers import Grid

archive = Grid(shape=8, features_domain=((0, 1),),
               fitness_domain=((0, 1),), fitness_weights=(1,))

def evaluate(genome):
    return 1 - (genome[0] - .8)**2, (genome[1],)

search = MEES(archive, x0=[.4, .5], pairs=8, block_steps=4,
              mode="explore-exploit", ind_domain=(0, 1), seed=11)
search.run(evaluate, budget=171)
print(search.evaluations, search.center_evaluations, search.updates)

For parallel evaluations, pass a caller-owned executor with submit() and Future.result(). Feedback follows submission order. A failed rollout can return None. Both members of a perturbation pair must succeed before they contribute to its gradient. Use evaluations_per_center to spend multiple measurements on each center. A partial ES batch stays unstarted when it cannot fit the remaining budget.

Colas et al., Scaling MAP-Elites to Deep Neuroevolution, GECCO 2020.

Generate tasks with Enhanced POET

Start from an easy task and a policy that can improve on it. The task mutator proposes variants of tasks whose policies reach the reproduction threshold. A candidate must fall between the lower and upper score bounds under its parent’s policy. POET ranks candidates by how differently they order the current and archived policies. This is the paper’s performance-of-transferred-agents environment characterization (PATA-EC).

from qdpy.algorithms import EnhancedPOET

def score(task, genome, seed):
    return 1 - abs(task - genome[0])

def mutate_task(task, rng):
    return task + .25

def improve(task, genome, evaluate, rng):
    choices = (genome, (genome[0] + .1,), (genome[0] - .1,))
    return max(choices, key=evaluate)

search = EnhancedPOET(
    0., (0.,), mutate_task=mutate_task, improve=improve,
    minimal_criterion=(.5, .95), reproduction_threshold=.9,
    active_limit=3, mutate_every=1, transfer_every=2, seed=11,
)
stats = search.run(score, 120, rounds=30)
print(stats.evaluations, stats.admitted_tasks, stats.transfers)

Use the supplied evaluate(genome) callback inside the optimizer so its trials share the overall budget. A transfer must beat the incumbent’s best recent score both before and after fine-tuning. search.active and search.archived keep the task-policy pairs. The task encoding and within-task optimizer are caller-defined. Use an immutable hashable task encoding so the search can recognize previously evaluated tasks.

Wang et al., Enhanced POET, ICML 2020.