Trace-Elites, MEMES, and asymmetric islands¶
Use Trace-Elites when one evaluated solution can represent several cells. Use MEMES when you can batch many evaluations of real-valued solutions. Use the Asymmetric Island Model when team members have different roles and can be evaluated on both role-specific and team tasks. These methods use the base QDpy installation. The example script compares each method with an existing search. Benchmark settings and results
Trace-Elites¶
An evaluation returns a scalar fitness and an ordered sequence of descriptor points. In this example, a controller determines the endpoint and bend of a route. The same rollout can win cells along the route. The first and last points are ordinary descriptors and share the same coordinate bounds.
import numpy as np
from qdpy.algorithms import TraceElites
from qdpy.containers import Grid, TraceArchive
from qdpy.plots import plot_trace_archive
def evaluate(point):
x, y, bend = point
t = np.linspace(0., 1., 13)[:, None]
trace = (1. - t)**2 * np.array([.1, .15])
trace += 2 * t * (1. - t) * np.array([bend, .75])
trace += t**2 * np.array([x, y])
return 1.5 - (x - .8)**2 - .5 * (y - .75)**2, trace
geometry = Grid(shape=(8, 8), features_domain=((0., 1.), (0., 1.)),
fitness_domain=((0., 2.),), fitness_weights=(1.,))
archive = TraceArchive(geometry)
stats = TraceElites(archive, 3, seed=7).run(evaluate, budget=160)
print(stats.evaluations, archive.filled_bins, len(archive))
axes = plot_trace_archive(archive)
axes.figure.savefig("trace-elites.png")
Pass an empty best-only Grid or CVTGrid as geometry. The trace archive
copies the geometry and keeps one immutable record per retained
measurement. Several cells can point to that record. A repeated
visit to a cell competes once. An empty trace or a point outside the
descriptor bounds leaves those cells untouched. Use an empty trace
when an evaluation succeeds without visiting an eligible point, or
return None to record a failed evaluation.
filled_bins counts occupied cells and len(archive) counts
retained measurements. qd_score() credits quality per occupied
cell. By default, Trace-Elites samples occupied cells for parent
selection. An elite that wins several cells is sampled more often.
Use parent_selection="records" to choose uniformly from retained
measurements. Use archive.to_grid() to make a per-cell snapshot
for existing plotting or reporting tools. The snapshot materializes
one entry per occupied cell.
To compare against a single-point archive, report both methods’ retained traces in the same geometry and count the distinct genomes as well. The overlay draws a path for each retained measurement.
Ludwig, Espeseth, and Medvet, Trace-Elites, EvoApplications 2025.
MAP-Elites with Multiple Evolution Strategies¶
MEMES uses a shared elite archive and a separate FIFO of measured
center descriptors. Each emitter runs its own Adam update, with
fitness or novelty as the objective. Each round evaluates the
mirrored perturbations first and then measures the updated centers.
Only the measured centers compete for the elite archive. An emitter
whose center fails to survive for more than stale_budget rounds
restarts from a uniformly drawn elite.
This example passes an array of genomes to one evaluator. It returns one fitness and descriptor per input row, in the same order.
import numpy as np
from qdpy.algorithms import MEMES
from qdpy.containers import Grid
def evaluate_batch(points):
quality = 1.5 - ((points - .8)**2).mean(axis=1)
return list(zip(quality, points[:, :2]))
grid = Grid(shape=(8, 8), features_domain=((0., 1.), (0., 1.)),
fitness_domain=((0., 2.),), fitness_weights=(1.,))
starting_points = np.random.default_rng(7).uniform(.2, .8, (4, 16))
search = MEMES(grid, starting_points, pairs=4, novelty_capacity=128,
stale_budget=3, ind_domain=(0., 1.), seed=7)
search.run(None, 148, evaluate_batch=evaluate_batch)
print(search.stats.evaluations, search.stats.rounds, search.stats.emitter_resets)
With four centers and one measurement per center, initialization
costs four evaluations. Each round costs 36. A call can spend a
smaller budget than requested if the next complete round would
exceed the limit. You can resume by calling run() with an
additional budget. The default emitter split uses half for
fitness and the remainder for novelty.
For a scalar evaluator, pass run(evaluate, budget). Pass an
executor through executor= to run scalar evaluations concurrently.
The search applies feedback in submission order. A row of None
counts as a failure. Both perturbations in a mirror pair must
succeed for that pair to affect the update. With
evaluations_per_center > 1, every repeat must succeed before the
averaged measurement enters either archive.
Asymmetric Island Model¶
Each role has a native QD archive, called an island. Each team task has a population of evaluated teams, called a mainland. The roles can have different genome lengths, bounds, fitness functions, and descriptor spaces. This example uses one policy per class in each team.
from qdpy.algorithms import AIM
from qdpy.containers import Grid
def make_grid():
return Grid(shape=(8,), features_domain=((0., 1.),),
fitness_domain=((0., 2.),), fitness_weights=(1.,))
def evaluate_role(role, genome):
position = genome[0]
pace = genome[-1]
return 1.8 - (pace - .6)**2, (position,)
def evaluate_team(target, genomes):
(search_area,), (pickup_area, pace) = genomes
mismatch = .6 * (pickup_area - search_area)**2
search_score = 1. - (search_area - target)**2 - mismatch
pickup_score = 1. - (pace - .55)**2 - mismatch
return search_score + pickup_score, (search_score, pickup_score)
islands = {"searcher": make_grid(), "carrier": make_grid()}
search = AIM(islands, (.25, .75), role_sizes={"searcher": 1, "carrier": 2},
population_size=6, elite_size=2, island_offspring=2,
migration_period=2, seed=7)
stats = search.run(evaluate_role, evaluate_team, island_budget=40, team_budget=56)
print(stats.island_evaluations, stats.team_evaluations, stats.migration_rounds)
champion = search.team_populations[.25][0]
held_out_score, contributions = evaluate_team(.5, champion.genomes)
print(held_out_score)
Use the order of keys in islands for the team genome tuple and
the corresponding contribution tuple. Contributions guide migration
allocation. The scalar team fitness ranks teams on each task.
Each island uses its own signed objective.
To evolve a mainland, retain its best teams and generate the
remaining teams by crossing matching roles. On migration rounds,
the best team members are reevaluated on their islands. The resulting
local measurements compete in the role archive. Separately, each role’s
previous team contributions update a softmax over tasks, which allocates
island exports to offspring slots on the mainlands. The exported
roles are part of those measured teams. allocation_probabilities
reports the resulting role-by-task weights.
next_generation_cost gives the island and team call counts needed
for the next full generation. returning_evaluations is part of the
island count. Evaluation callbacks can return None to count a
failed attempt. This implementation uses caller-defined descriptors
and black-box variation in its islands. Evaluate selected champions
on held-out tasks outside run() to assess transfer independently.
Dixit and Tumer, Learning Inter-Agent Synergies in Asymmetric Multiagent Systems, AAMAS 2023.