Guided variation, reward coverage, and offline priors¶
The examples use the base package for symbolic regression, tabular
policy transfer, and offline search. Learning operator choices with
DMOME uses qdpy[rl].
Mix linked slots in expression trees¶
Use variation="template-linkage" in
qdpy.symbolic.symbolic_regression() with structural or semantic
MAP-Elites. The mixer clusters homologous slots by their distance
through the expression-tree template. The learned-linkage control
uses categorical mutual information with a distinct symbol for
inactive slots. Both use the existing expression grammar and fitter.
import numpy as np
from qdpy.symbolic import symbolic_regression
X = np.linspace(-1., 1., 32)[:, None]
y = np.sin(X[:, 0]) + X[:, 0] ** 2
result = symbolic_regression(
X, y, variation="template-linkage", operators=("add", "mul", "square", "sin"),
budget=500, max_fit_evaluations=200, seed=11,
)
print(result.best.formula, result.stats.fit_evaluations, result.stats.block_proposals)
Each chain draws a snapshot of archive donors. Active slot changes
that preserve or improve fitted training error become the new
incumbent. Every valid measured intermediate enters archive
competition. Duplicate active trees reuse their fitted models.
Pass variation="learned-linkage" to estimate dependencies or
variation="subtree" to use the original variation. The total fit
cap includes numerical coefficient fitting calls and is independent
of the tree-proposal cap. This adapts the template and masked-intron
measures of Koch et al., GECCO 2026.
Build a repertoire for future reward weights¶
qdpy.algorithms.tabular_sfols() takes a finite transition model,
expected immediate features, and a start-state distribution. It solves
each unit reward first. Later, it uses a linear program to rank corners
of the current value envelope by optimistic improvement.
import numpy as np
from qdpy.algorithms import tabular_sfols
continuation = np.zeros((2, 3, 2))
continuation[0, :, 1] = 1.
features = np.array([[[0., 0.]] * 3, [[1., 0.], [0., 1.], [.7, .7]]])
result = tabular_sfols(continuation, features, [1., 0.], max_policy_solves=8)
print(result.policy_solves, result.upper_gap, result.repertoire.action_table([.5, .5]))
Use a nonnegative weight vector that sums to one for the same coverage
scope as the search. The reported gap refers to the supplied start
distribution and includes numerical solver tolerances. None
means the budget ended before all unit weights were solved. GPI
chooses actions using the stored successor features. The number of
corners grows with reward dimension, so start with two or three
features. See Alegre et al., ICML 2022.
Learn when to apply a variation operator¶
qdpy.rl.DMOME chooses among user-defined operators using a
DQN. The state includes occupancy, the recent admission rate, and
the selected parent’s fitness and descriptors. The learning signal is
the child’s admission outcome. ParetoGrid(truncation="hypervolume")
uses the worst signed domain corner as the reference and removes the
smallest contributor when a two-objective front exceeds capacity.
from qdpy.containers import ParetoGrid
from qdpy.rl import DMOME, DMOMEConfig
archive = ParetoGrid(shape=5, max_items_per_bin=2, truncation="hypervolume",
fitness_domain=((0., 4.),) * 2, features_domain=((-0.5, 4.5),))
search = DMOME(
archive, initializer=lambda rng: (int(rng.integers(5)),),
operators={"next": lambda p, d, rng: ((p[0] + 1) % 5,),
"reset": lambda p, d, rng: (int(rng.integers(5)),)},
config=DMOMEConfig(batch_size=8), seed=11,
)
stats = search.run(lambda point, seed: ((point[0], 4 - point[0]), point), 50)
print(stats.operator_attempts, stats.optimizer_steps)
Use qdpy.algorithms.OperatorMOME with controller="uniform"
or "bandit" for base-package controls. Each operator receives a
parent and a donor. Each evaluator call counts once, and DQN optimizer
steps and target updates are counted separately. This variant exposes
the scheduling operators as callbacks and uses archive summaries for
the DQN state. See Zou et al., 2026.
Guide an offline search with a categorical prior¶
qdpy.algorithms.PriorGuidedOfflineMAPElites uses a fixed log
of evaluated designs. Supply the number of categories at each locus
and a plausibility score from zero to one. The prior helps choose
edits, and its influence on elite selection increases with the frozen
model’s uncertainty. You can audit the predicted elites later with
an independent measurement budget.
from qdpy.algorithms import PriorGuidedOfflineMAPElites
from qdpy.containers import Grid
geometry = Grid(shape=3, fitness_domain=((0., 4.),),
features_domain=((-0.5, 2.5),), fitness_weights=(1.,))
search = PriorGuidedOfflineMAPElites(
geometry, [(0, 0), (0, 1), (1, 1)], [1., 2., 3.], [(0.,), (1.,), (2.,)],
nvec=(2, 2), prior=lambda point: float(point[0] == point[1]), seed=11,
)
predicted = search.run(40)
verified = search.verify(predicted, lambda point, seed: ((1. + sum(point),), (sum(point),)), 3)
print(predicted.predictions, predicted.prior_queries, verified.evaluations)
The archive retains predicted quality in the original units and the
acquisition score separately. Use prior_weight=0 for the prior-free
control and set uncertainty_penalty for a fixed deviation penalty.
This categorical POME variant uses one-hot inputs, a frozen Matérn
surrogate, and a callable prior. See the POME preprint and CPU pilots for guided search
for pilot settings and results.