MAP-Elites with noisy evaluations ================================= When the same genome can return different fitnesses or descriptors, an archive can accumulate lucky measurements. Fitness noise can change which candidate wins a cell. Descriptor noise can move the same candidate across cell boundaries. A search can spend some of its rollout budget refining estimates before making either decision. Start with the Rastrigin demo ----------------------------- From the repository root with QDpy installed, try:: python examples/uncertain_rastrigin.py --policy map_elites --noise joint python examples/uncertain_rastrigin.py --policy fixed --noise joint python examples/uncertain_rastrigin.py --policy extract_me --noise joint The example uses a six-dimensional Rastrigin objective and the first two genome coordinates as descriptors, with bounded additive noise. Each run prints the search budget used, the number of reevaluations, the archive's observed scores, and the results of a separate audit. Try ``--noise none``, ``fitness``, or ``descriptor`` to isolate the two noise sources. Use your own evaluator ---------------------- Your evaluator can return ordinary QDpy measurements. An explicit rollout seed lets the evaluator construct its own random generator. The example below maximizes a noisy score using one descriptor. .. code-block:: python import random import numpy as np from qdpy.algorithms import UncertainMAPElites, reevaluate_archive from qdpy.containers import Grid def evaluate(individual, seed): rng = np.random.default_rng(seed) x, y = individual quality = 0.1 + 0.8 * (1.0 - abs(x - 0.7)) return (quality + rng.uniform(-0.04, 0.04),), (0.05 + 0.9 * y,) random.seed(42) np.random.seed(42) grid = Grid( shape=(12,), max_items_per_bin=8, fitness_domain=((0.0, 1.0),), features_domain=((0.0, 1.0),), ) search = UncertainMAPElites( grid, budget=512, dimension=2, policy="extract_me", sampling_size=64, optimisation_task="maximisation", seed=42, ) search.optimise(evaluate, seeded=True) audit = reevaluate_archive(grid, evaluate, samples=32, seed=42) print(search.nb_evaluations, audit.corrected_qd_score) ``UncertainMAPElites`` accepts standalone scalar-objective ``Grid`` and ``CVTGrid`` archives. ``sampling_size`` is the maximum number of raw rollouts in a generation. ``budget`` caps the run, including reevaluations and failed attempts. A run can finish with unused slots if the remaining budget cannot fit a complete scheduling unit. Supply a caller-owned executor to evaluate independent rollouts in parallel. Use a picklable evaluator with process pools. The local adaptive race uses sequential comparisons. The generation-based policies integrate worker results in submission order. A seed initializes deterministic per-rollout IDs and the extraction generator. Seed Python's ``random`` and NumPy's global RNG separately to reproduce the default emitter and grid replacement. For a custom emitter, pass ``base_alg=`` with the same grid. Its parent-selection rule applies in place of the policy's default selector. .. _choose-a-policy: Choose a policy --------------- .. list-table:: :header-rows: 1 :widths: 27 73 * - Policy - Rollout allocation and archive behavior * - MAP-Elites - One rollout per proposal. Use a regular QDpy emitter or ``FixedSamplingDecorator`` with ``nb_samples=1``. * - Fixed sampling - ``FixedSamplingDecorator`` requests a constant number of rollouts per proposal and uses their mean. * - Time-based sampling - ``TimeBasedSamplingDecorator`` increases the proposal target linearly from its minimum to its maximum, rounding down. * - ``adaptive`` - Promising challengers match the current elite's sample count. Losing challengers trigger one extra elite rollout. An updated elite can move to a new cell and resume the local race. A grid with depth retains backup elites when one drifts. * - ``deep_grid`` - Select a cell uniformly, then choose a parent in it with weights proportional to quality above the worst fitness bound. Overwrite a random old member when a cell overflows. * - ``deep_grid_sampling`` - Use the same deep grid with fixed repeats for each new proposal. The default is five repeats. * - ``archive_sampling`` - Give each stored solution one new rollout, rebuild the archive with their updated means, then generate offspring from it. * - ``parallel_adaptive`` - Reevaluate the archive as above. Give each offspring the integer median of the existing solutions' sample counts, measured before reevaluation. * - ``extract_me`` - Allocate a quarter of the generation by default to extracted elites. Give rank ``r`` within a cell weight ``exp(-r)`` and draw distinct elites across the archive. Generate offspring from the pre-extraction archive. Admit new and reevaluated solutions into the ranked depth using their measurement histories. * - Standard-error control - ``StandardErrorSamplingDecorator`` stops once the standard error of each fitness and descriptor coordinate meets its own absolute tolerance, subject to minimum and maximum sample counts. * - ``fill_then_refine`` control - Start with one rollout per proposal. After half the cells are filled, give new offspring five rollouts and use up to a quarter of each generation to bring surviving entries from the switch to five observations. For Archive-Sampling and Parallel-Adaptive-Sampling, pick a ``sampling_size`` larger than the maximum number of stored entries (``grid.capacity``). Leave room for at least one full offspring group. For Extract-ME, use a deeper grid during search and extract the best member of each occupied cell for reporting. See :doc:`tutorial_corrected_archive` for held-out reassignment and comparison. The benchmark config uses two initial rollouts for Extract-ME and a depth of ten for Adaptive Sampling. Its Rastrigin setup is shared across methods for implementation validation. The sampling decorators also support manual ``ask()`` and ``tell()``. Complete each issued object once. A single raw result can be reported as a fitness and descriptors pair, that pair plus named scores, or a returned individual in managed evaluation. Each completed offspring receives one feedback event in the wrapped emitter. Incomplete or failed offspring groups consume their attempted rollouts and are dropped. In managed execution a seeded sampling decorator also puts an ``evaluation_seed`` attribute on each input. See :doc:`api_algorithms` for the legacy ``AdaptiveSamplingDecorator`` and the explicit drifting-elite policy. Legacy YAML may specify ``container`` under the shared ``algorithms`` settings. The sampling wrapper and its base algorithm must resolve that setting to the same archive. Seeded results from older sampling schedules should be reproduced with the QDpy version used to run them. Try a stochastic simulator --------------------------- The optional Walker example evaluates each controller on independently seeded Gymnasium terrain. Each raw rollout is one episode with a step limit. The example uses a small 24–40–40–4 controller and two explicit motion descriptors. For comparison with published Walker numbers, use the original controller, descriptor geometry, and experimental protocol. To run the smoke example:: python -m pip install "gymnasium[box2d]" python examples/bipedal_walker/noisy_walker.py --budget 24 --sampling-size 8 --steps 30 --audit-samples 4 Source papers ------------- * Mouret and Clune (2015), the original MAP-Elites algorithm. `Illuminating search spaces by mapping elites `__. * Justesen, Risi and Mouret (2019), Adaptive Sampling and Drifting Elites. `MAP-Elites for noisy domains by adaptive sampling `__. * Flageat and Cully (2020), original Deep-Grid with random eviction. `Fast and stable MAP-Elites in noisy domains using deep grids `__. * Flageat and Cully (2024), Archive-Sampling, Parallel-Adaptive-Sampling, and Deep-Grid-Sampling. QDpy combines Deep-Grid-Sampling's fixed repeats with the original random-eviction Deep-Grid. `Uncertain Quality-Diversity `__. * Flageat et al. (2025), Extract-ME and the broader Extract-QD framework. The reference implementation specifies the exponential rank weights. `Extract-QD `__ and `author implementation `__.