Scalable covariance search and learned genome variation

Use qdpy.algorithms.LMMAMAE when covariance state is costly for long real-valued genomes. Use qdpy.algorithms.DDEElites when successful genomes may share structure that a learned representation can capture. Both accept the standard QDpy evaluator and use fixed one-elite Grid or CVTGrid archives.

LM-MA-MAE

LM-MA-MAE uses annealed cell thresholds from CMA-MAE and the limited-memory matrix adaptation evolution strategy. A small set of direction vectors replaces the square covariance matrix. The reporting archive continues to store the best measured candidate in each cell. See Scalable CMA-MAE and Limited-Memory Matrix Adaptation for Large Scale Black-box Optimization.

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

archive = Grid(shape=(10, 10), max_items_per_bin=1,
               fitness_domain=((0., 1.),),
               features_domain=((-1., 1.), (-1., 1.)))
search = LMMAMAE(archive, budget=384, x0=np.zeros(256), sigma0=.45,
                batch_size=16, threshold_min=0., learning_rate=.1,
                ind_domain=(-1., 1.), optimisation_task="max", seed=11)

def evaluate(individual):
    x = np.asarray(individual)
    return (float(np.exp(-np.mean(x ** 2))),), tuple(x[:2])

best = search.optimise(evaluate)
print(search.nb_evaluations, len(archive), best.fitness.values)

Set threshold_min in signed, weighted objective units. For example, use a negative threshold when maximizing negative scores. A final partial generation updates the archive without adapting the emitter. User-driven evaluation uses ask_batch() and tell_batch(), with results in proposal order and None for any failed slot. Use the native parallelism benchmarks for executor-driven evaluation.

DDE-Elites

DDE-Elites fits a variational autoencoder to the current archive’s bounded genomes. It combines reconstructive crossover, Iso+LineDD, and isotropic mutation using a sliding-window UCB1 bandit. Each generation rewards the selected mixture by the fraction of candidates that are still in the archive at the end of the batch. See Discovering Representations for Black-box Optimization.

Install PyTorch to construct the search. You can use the existing qdpy[rl] extra or install torch directly. Use a fresh archive with the same settings as above.

from qdpy.algorithms import DDEElites

archive = Grid(shape=(10, 10), max_items_per_bin=1,
               fitness_domain=((0., 1.),),
               features_domain=((-1., 1.), (-1., 1.)))
search = DDEElites(archive, budget=384, dimension=32, batch_size=16,
                   ind_domain=(-1., 1.), min_elites=4, fit_interval=2,
                   latent_size=4, optimisation_task="max", seed=11)

best = search.optimise(evaluate)
if search.model_fits:
    codes = search.encode([list(best)])
    new_genomes = search.decode(codes)
print(search.operator_counts)

Ensure that min_elites is reachable at your chosen resolution. Monitor model_fits and operator_counts to see whether reconstructive crossover ran. Increase fit_interval if model training dominates runtime. Mutation scales are in genome units and the VAE normalizes the genomes internally. Use encode and decode with arrays of rows after the first fit. The resulting reconstruction uses the most recently fitted model.

Run both examples and see the Scalable emitters and continuous policy search benchmarks for results.

python examples/scalable_qd.py lm-ma-mae
python examples/scalable_qd.py dde-elites iso-line