Adapt a repertoire with M-BOA ============================= Use map-based Bayesian optimization (M-BOA) when you have a repertoire of controllers or designs and only a few trials to find one that works in a changed setting. For example, a controller with strong nominal performance can perform poorly with reduced traction. M-BOA uses the measured difference from nominal performance to update predictions for entries with nearby descriptors. The example builds a nominal map of scalar designs. The deployment optimum shifts from 0.2 to 0.7, and the search can test up to six entries. .. code-block:: python from qdpy.algorithms import MBOA from qdpy.containers import Grid from qdpy.phenotype import Features, Fitness, Individual grid = Grid(shape=21, fitness_domain=((-2, 1),), features_domain=((0, 1),), fitness_weights=(1.0,)) for i in range(21): setting = i / 20 nominal = 1 - 3 * (setting - 0.2)**2 grid.add(Individual([setting], fitness=Fitness((nominal,)), features=Features((setting,)))) search = MBOA(grid, budget=6, length_scale=0.45, kappa=0.35) best = search.run(lambda genome: 1 - 3 * (genome[0] - 0.7)**2) print(best.candidate.genome, best.fitness) You can also export a native Grid or CVTGrid with :func:`qdpy.results.export_grid` and pass the JSON file path to ``MBOA``. The source needs fixed-length numeric genomes, finite descriptors, and one objective with a consistent direction. The optimizer copies the source measurements when constructed. For physical experiments, use ``candidate = search.ask()`` and ``search.tell(measured_fitness)`` after each trial. Pass ``None`` for a failed trial. It spends one trial and contributes no observation to the model. Each entry is tried at most once by default. Enable ``allow_repeats`` and set ``noise_variance`` in squared fitness units if re-testing an entry is useful. ``search.best`` describes one measured trial, while ``search.posterior()`` returns an estimated mean and standard deviation for every candidate in source order. The residual model assumes that nearby descriptors experience similar changes. A map whose descriptors are unrelated to the deployment change can give misleading predictions. ``length_scale`` uses normalized coordinates on axes with finite, nondegenerate bounds. See :doc:`repertoire_qd_benchmarks` for a small shifted-objective comparison. `Cully et al., Robots that can adapt like animals, Nature 2015 `_.