Targeted search, balanced designs, and adversarial tournaments

The three workflows on this page use the base QDpy installation. Run examples/targeted_qd.py from a checkout to compare them with matched baselines.

JEDi for finding high-fitness solutions

qdpy.algorithms.JEDi models the fitness of occupied descriptor cells. A Matérn Gaussian process predicts fitness and uncertainty for every cell. Its observation variance decreases as more valid evaluations visit a cell, including evaluations that never replace an elite. JEDi selects from the Pareto front of the predicted means and standard deviations. It starts a limited-memory evolution strategy at the elite closest to each target behavior. See Templier et al. (GECCO 2024).

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

grid = Grid(shape=(8, 8), features_domain=((0., 1.), (0., 1.)),
            fitness_domain=((0., 2.),))
search = JEDi(grid, budget=240, dimension=12, batch_size=8, warmup=24,
              targets_per_cycle=2, generations_per_target=3,
              sigma0=.12, seed=11, optimisation_task="max")

def evaluate(individual):
    genome = np.asarray(individual)
    score = 1. - np.square(genome - .65).mean()
    return (float(score),), genome[:2]

best = search.optimise(evaluate)
print(best.fitness.values, search.target_history[-1])
print(sum(search.cell_visits.values()))

The target strategies take turns issuing complete evaluator batches. The surrogate is fitted once per cycle, then revisited after the strategies spend their assigned generations. The last partial batch can still update the result grid. A larger proximity_weight directs the strategies more strongly toward their assigned targets. The GP length scale is fixed and measured in normalized descriptor units. Use a modest grid resolution for the dense GP fit.

The method supports fixed Grid and CVTGrid archives. To drive it yourself, use ask_batch() and submit results to tell_batch() in proposal order. Use None for a failed evaluation.

T-DominO for one balanced design per cell

qdpy.containers.TDominOGrid compares the challenger and incumbent against the same anchors. The anchors are the challenger, the current elites in the neighborhood, and the displaced elites remembered there. Each objective contributes a count of anchors the design matches or beats. The product of those counts decides the tournament, with ties keeping the incumbent. See Gaier et al. (PPSN 2022).

from qdpy.algorithms import IsoLineMAPElites
from qdpy.containers import TDominOGrid
import random

random.seed(11)
np.random.seed(11)

grid = TDominOGrid(shape=(10,), features_domain=((0., 1.),),
                   fitness_domain=((0., 1.), (0., 10.), (0., 100.)),
                   anchor_capacity=10, neighbor_radius=2)
search = IsoLineMAPElites(grid, budget=240, dimension=3, batch_size=8,
                          optimisation_task="max")

def evaluate(individual):
    position, balance, strength = individual
    quality = .5 + .5 * strength
    scores = (1. - 1.4 * np.abs(balance - np.array([.15, .5, .85]))) * quality
    return tuple(np.maximum(0., scores) * [1., 10., 100.]), (position,)

best = search.optimise(evaluate)
cell = grid.index_grid(best)
print(best.fitness.values, len(grid.anchors(cell)))

Set optimisation_task to a tuple such as (1., -1., 1.) to maximize the first and third objectives and minimize the second. The reported fitness remains in its original units. Tournament scores are local and change as the reference points change. Compare the retained raw objectives across cells. An export_grid JSON snapshot supports plots and analysis. The live archive retains its displaced-elite history.

Tournament-informed GAME

Call qdpy.algorithms.game_search() with task_selection="ranking" or task_selection="pareto". Ranking clusters strategies by their relative strengths across a panel of former opponents. It selects the best mean payoff in each cluster. Pareto treats the payoff against each opponent as a distinct objective and uses NSGA-III to select the next tasks. Both reuse the selected strategies’ tournament measurements to seed the next round. See Anne et al. (GECCO 2026).

from qdpy.algorithms import game_cross_play, game_search
from examples.targeted_qd import cycle_game

search = game_search(cycle_game, dimensions=(2, 2), rounds=4,
                     matches_per_round=80, task_count=3, cells_per_task=3,
                     task_selection="ranking", match_budget=480, seed=11)
latest = {round_.side: [elite.genome for elite in round_.representatives]
          for round_ in search.rounds}
panel = game_cross_play(cycle_game, latest["red"], latest["blue"])
print(search.total_attempts, panel.attempts, panel.metrics("red"))

The cap covers the search and the task-selection tournaments. Check stopped_for_budget when a complete tournament or search round does not fit. Cross-play is a separate evaluation cost. To compare several variants, concatenate their Red strategies and concatenate their Blue strategies, run one cross-play tournament, and pass each variant’s side-specific indices to panel.metrics. This reports best win rate, best worst-case payoff, collective counterplay expertise, and the fraction of shared matchup-profile clusters occupied.

python examples/targeted_qd.py all --budget 480

See Targeted search and policy population benchmarks for the seeded comparisons.