Interactive search, scheduling rules, and repertoire reuse

Bayesian Optimization with Interactive Illumination

BOIL spends a shared evaluation budget in stages. It first builds a surrogate map of quality and descriptors. It multiplies expected joint improvement by a factor that grows with the entropy of descriptor cell membership. After inspecting the predictions, select cells to refine or choose a descriptor to target. See Kent and Branke (GECCO 2023).

from qdpy.algorithms import BOIL
from qdpy.containers import Grid
from examples.repertoire_workflows import landscape

def evaluate(genome):
    fitness, descriptor = landscape(genome)
    return (fitness,), (descriptor,)

grid = Grid(shape=(5,), features_domain=((0., 1.),), fitness_domain=((0., 1.),))
search = BOIL(grid, budget=36, dimension=2, ind_domain=(0., 1.),
              quality_floor=0., initial_samples=6, candidate_pool=24,
              restarts=2, optimisation_task="max", seed=11)

search.optimise(evaluate, budget=12)
preview = search.prediction_map(samples=128)
print([(row.cell, row.fitness_mean, row.probability) for row in preview])

search.focus([(3,), (4,)])
search.optimise(evaluate, budget=6)

search.set_target((.83,), distance_weight=3.)
search.optimise(evaluate)
print(search.best_target(), search.remaining_evaluations)

The prediction map is a read-only model view with estimated cell membership probabilities. The live grid contains evaluated designs. In the target phase, Monte Carlo expected improvement searches for high weighted fitness minus the distance penalty. best_target() returns the strongest measured utility among all observations, including designs that the grid rejected. This implementation uses fixed grid geometry and caller-chosen phase lengths.

QD Genetic Programming for scheduling

QD-GP evolves two expression trees. The sequencing tree chooses the next operation in a queue. The routing tree chooses a machine. Each descriptor records the reference rank of the option chosen by the tree at a fixed decision probe. The resulting rank vectors are encoded as integer coordinates. See Xu et al. (GECCO 2025).

Install the deap extra with pip install '.[deap]' from a checkout. The example uses the paper’s fixed-instance variant, QDGPf. It compares all rules on the same training cases and audits the training winner on separate cases.

import numpy as np
from examples.qdgp_schedule import evaluate_jobs, instance, make_search

rng = np.random.default_rng(677)
training = [instance(rng) for _ in range(5)]
held_out = [instance(rng) for _ in range(8)]
search = make_search(seed=11)

def cost(sequencing, routing):
    return np.mean([evaluate_jobs(case, sequencing, routing) for case in training])

best = search.run(cost, budget=144)
print(best.cell, best.rules)
seq, route = search.compile(best.rules)
print(np.mean([evaluate_jobs(case, seq, route) for case in held_out]))

To use your own scheduling simulator, supply two untyped DEAP primitive sets and your probe candidates and reference rankings. DecisionProbe takes a sequence of feature rows and a permutation of candidate indices in best-first order. Smaller rule outputs win. Use deterministic primitives and fixed terminals. Compile rule text with the same trusted primitive sets used to train the rules.

Reset-free Trial-and-Error

Use a repertoire as a library of actions the planner can chain. The initial transition model uses nominal displacements. Gaussian-process residuals learn how actual transitions differ from those displacements. Monte Carlo tree search plans the next action from the current state. See Chatzilygeroudis et al..

from qdpy.algorithms import RTESkill, ResetFreeTrialAndError

moves = ((1., 0.), (-1., 0.), (0., 1.), (0., -1.))
skills = tuple(RTESkill(move, move) for move in moves)
planner = ResetFreeTrialAndError(skills, simulations=96, seed=11)

def execute(state, genome):
    east, north = genome
    return (state[0] + .5 * east, state[1] + north + .5 * east)

path = planner.run((0., 0.), (3., 2.), execute, max_trials=14)
print(path.states[-1], path.goal_reached, planner.stats)

Pass a live numeric grid or its exported JSON in place of explicit RTESkill records if its descriptors are nominal displacements. The current model assumes additive motion in fixed coordinates. Use plan() and observe() independently when your simulator already owns the interaction loop. The optional traversable(before, after) callback rejects simulated transitions. Set model_capacity to limit the observations carried into the next GP fit.

QD Meta-Evolution

QD-Meta searches over feature maps. An outer limited-memory evolution strategy proposes a population of linear maps. Each map rebuilds a grid from the same snapshot of measured raw features, runs MAP-Elites, and receives a score from a caller-defined archive metric. See Bossens and Tarapore.

import numpy as np
from qdpy.algorithms import QDMeta

def evaluate(genome):
    values = np.asarray(genome)
    return 1. - np.square(values - .5).mean(), values

def meta_fitness(archive):
    elites = np.asarray([list(elite) for elite in archive])
    return -np.mean([np.square(elites[:, 1] - target).min() for target in (.2, .5, .8)])

search = QDMeta(2, ((0., 1.), (0., 1.)), (6,), initial_samples=24,
                population_size=4, inner_evaluations=12, seed=11)
result = search.run(evaluate, meta_fitness, generations=3)
print(result.projection.weights, result.evaluations, result.meta_evaluations)

The measurement counter includes warm-up and all inner proposals. Building a new archive from the shared database uses existing measurements. Meta-objective calls have their own count. Track simulator trials performed inside that callback when comparing budgets. Use separate held-out tasks to assess the chosen feature map. The first implementation uses a fixed inner evaluation count per map and generation.

python examples/repertoire_workflows.py all
python examples/qdgp_schedule.py

See Interactive and repertoire workflow benchmarks for the seed budgets and comparisons.