Offline search and diverse plans

GA-ME and DynAMO take a fixed log of design measurements. They propose designs that can be evaluated independently after search. DiveOff learns several policies in one latent-conditioned actor from a fixed transition log. The planning example uses a deterministic simulator and temporal rules to find several ways to finish the same task.

Gradient-Augmented MAP-Elites

Give GA-ME measured genomes, fitness, and descriptors. The method fits the same fixed Matérn-5/2 surrogate as Offline MAP-Elites, then differentiates its posterior means. Its targeting phase starts near Sobol targets in descriptor space. Each search cycle then alternates Iso+LineDD mutations and local quality ascent. Refinement accepts improving steps in the starting descriptor cell.

from examples.offline_planning import design_archive, design_fitness, design_log
from qdpy.algorithms import GradientAugmentedMAPElites

designs, fitness = design_log()
search = GradientAugmentedMAPElites(design_archive(), designs, fitness, designs, seed=11)
result = search.run(192, initial_samples=8, mutation_steps=14, dropout=.25)

def measure(genome, seed):
    return (design_fitness(genome),), tuple(genome)

verified = search.verify(result, measure, 16, seed=1011)
print(result.predictions, result.refinement_predictions, verified.archive.filled_bins)

Dropout removes some elites from the breeding archive between cycles. The reporting archive retains the best predictions from all phases. The budget counts each surrogate query, including the queries used to get gradients or reject an update. During verification, measured descriptors determine admission to a fresh archive. Use separate verification calls to see whether predicted quality and coverage hold.

The original GA-ME uses a region-penalized hill climber. QDpy uses bounded gradient steps with same-cell acceptance and backtracking, so local refinement works with rectangular and CVT cells. Kent’s GA-ME, Chapter 6.

DynAMO for offline design batches

DynAMO searches for a batch guided by both predicted fitness and the distribution of logged designs. It needs numeric designs and one measured fitness per design. The method works without descriptor bins. You can report audited proposals in a Grid after the search.

from examples.offline_planning import design_fitness, design_log
from qdpy.algorithms import DynAMO

designs, fitness = design_log()
search = DynAMO(designs, fitness, batch_size=16, reference_size=48,
                temperature=2., beta=1.5, transport_limit=.03, seed=11)
result = search.run(192, count=16)
measured = [design_fitness(row.genome) for row in result.designs]
print(result.predictions, result.transport_solves, max(measured))

QDpy’s finite-pool implementation fits a frozen reward GP and builds a softmax-weighted empirical reference from the logged fitness. The smoothed reference density supplies the KL term. Each proposal round solves a finite empirical Wasserstein problem and recovers a Lipschitz critic from its dual potentials. The scalar dual balances transport and the reference term. Sampling uses one probability per unique design in the accumulated pool. The reported source distance compares the most recent proposal batch with the reference. Treat it as a diagnostic of the last transport solve.

This implementation uses a bounded Euclidean design space, a categorical candidate distribution, and a finite transport solver. The paper’s source critic is neural and can be combined with several backbone optimizers. Verification counts are separate from surrogate queries. Transport work grows with reference size and batch size. Yao, Gee, and Bastani, ICML 2025.

DiveOff for offline continuous control

Install qdpy[rl] for this method. Prepare five aligned arrays for observations, physical actions, rewards, successor observations, and terminal flags. Keep the actual successor of a truncated rollout before a reset. Set the terminal flag only when the task terminates, since a time limit can still bootstrap. Training needs the Gymnasium space declarations and the recorded arrays.

from examples.diveoff import ForkNavigation, audit, transition_log
from qdpy.rl import DiveOff, DiveOffConfig, DiveOffPolicy, PolicyConfig

config = DiveOffConfig(latent_size=1, pretrain_updates=256, batch_size=64)
search = DiveOff(ForkNavigation.observation_space, ForkNavigation.action_space,
                 config=config, policy=PolicyConfig((32, 32)), seed=11, **transition_log())
stats = search.train(800)
actor = search.policy()
actor.save("diveoff-policy.npz")
loaded = DiveOffPolicy.load("diveoff-policy.npz")
print(stats.critic_updates, audit(loaded)["verified_routes"])

DiveOff first fits a Gaussian VAE on state-action pairs. The main loop updates twin critics with a sampled latent code shared across each Bellman target. Advantage-weighted actor likelihood and representation updates favor useful behaviors. A mutual-information objective trains the actor and encoder to make the latent codes recoverable from the generated actions. Set information_weight=0 to compare with the same update schedule and without that term.

The exported actor takes an observation and a finite latent vector. Hold the code fixed across an episode to test a particular policy. Choose a panel of codes before evaluating them and record both task returns and behavior descriptors on fresh episodes. The trainer has no simulator calls. The example counts its transition collection and evaluation separately. QDpy uses squashed Gaussian actions, clipped exponential weights, and slowly updated target critics. Osa and Harada, ICML 2024.

Feature-based planning with temporal rules

Supply a deterministic step function, a goal check, and atomic propositions associated with states. A monitor processes the initial state and every successor, retaining enough information to compute a Boolean result at the end of the plan.

from examples.offline_planning import (
    DESTINATION, MOVES, START, delivery_labels, delivery_step,
)
from qdpy.algorithms import always, feature_based_planning, ordered_visit

result = feature_based_planning(
    START, actions=lambda state: MOVES, simulate=delivery_step,
    goal=lambda state: state == DESTINATION, labels=delivery_labels,
    monitors={
        "charged_before_delivery": ordered_visit("charged", "delivered"),
        "kept_to_lanes": always("safe"),
    },
    max_plans=4, budget=1024,
)
for plan in result.plans:
    print(plan.profile, plan.actions)

eventually(p) accepts if proposition p is ever seen. always(p) accepts if it holds throughout the finite path. ordered_visit(p, q) requires q at a later state than p. For other finite-trace formulas, supply TemporalMonitor objects with an immutable memory, an update function, and an acceptance function. The API works with compiled monitors and predicate callbacks.

The default pass is breadth-first in the product of simulator and monitor states. This preserves paths with different histories to the same location, and the first plan for a profile minimizes action count in that pass. Add fact tuples through state_features to enable iterative-width pruning up to max_width. A pruned pass can miss profiles or return longer plans. All passes share the same budget. An attempted illegal move also counts as a simulator call. A plan ends at its first goal.

This implementation uses finite monitors with optional width pruning and collects distinct profiles during each pass. Abdelwahed et al., Feature-Based Iterative planning over simulators.

Run the examples

Run both commands from the repository root.

python -m examples.offline_planning --seeds 11 22 33
python -m examples.diveoff --seeds 11 22 33

See Offline search and diverse planning benchmarks for measured results.