Bayesian optimisation of elites =============================== Use :class:`qdpy.algorithms.BOPElites` to decide where to spend the next expensive evaluation. The example uses a cheap stand-in, a two-variable quadratic cost with a product descriptor. Its archive keeps the best genuine evaluation per descriptor cell. Run from the repository root after installing the :ref:`base package `. .. code-block:: sh python examples/bop_elites.py .. literalinclude:: ../examples/bop_elites.py :language: python The first eight proposals here come from a scrambled Sobol sequence. The default warm-up is ten proposals per decision variable, so set ``initial_samples`` below the budget when you want a shorter run to reach the modelled phase. Once the search has enough observations, it fits separate fixed Matérn Gaussian processes for the objective and each descriptor. Acquisition combines the expected improvement in each cell with the predicted probability of landing there. The runner evaluates one proposal at a time and updates the models with its result. Use the printed cell entries to check the measured descriptor and cost of each elite. ``n_observations`` counts finite measurements, including points with descriptors outside the grid. A failed call spends one attempt and the search remembers that genome. Set ``quality_floor`` in signed units. For a declared raw minimisation range of ``[0, 2]``, use ``-2`` as the empty-cell floor. For a second descriptor, return two descriptor values from the evaluator and give the grid a two-axis shape and one interval per axis. ``candidate_pool`` and ``restarts`` control the amount of work spent searching each acquisition function. Compare both attempted evaluations and wall time when tuning these settings. See :doc:`specialized_qd_benchmarks` for a comparison with Sobol and MAP-Elites. .. _known-feasibility-and-shared-descriptor-inputs: Known feasibility and shared descriptor inputs ---------------------------------------------- Set ``model_feasibility=True`` if the evaluator can tell that a design is infeasible. Return ``(None, None, {"bop_valid": False})`` for that outcome. An evaluator error spends an attempt and leaves the feasibility data unchanged. After at least three outcomes in each class, a three-fold sigmoid-calibrated SVM weights the acquisition by the probability of feasibility. Successful measurements outside the grid still provide positive feasibility labels. Inspect ``n_invalid_observations`` for the explicit negative count. The ``descriptor_transform`` option is useful when several descriptors share a measured quantity and you know how to compute each descriptor from it. Fit Gaussian processes to the source quantities and pass the same draws to every descriptor that uses them. This estimates a joint cell probability. A sample outside the grid contributes to no cell. The following transform receives rows of raw genomes and source values. .. code-block:: python import numpy as np from qdpy.algorithms import BOPElites from qdpy.containers import Grid def descriptors(genomes, latents): flow = latents[:, 0] return np.column_stack((flow, flow + 0.1 * genomes[:, 0])) grid = Grid(shape=(8, 8), fitness_domain=((0.0, 3.0),), features_domain=((0.0, 1.0), (0.0, 1.0))) search = BOPElites( grid, budget=32, dimension=2, ind_domain=(0.0, 1.0), quality_floor=0.0, optimisation_task="maximisation", initial_samples=8, candidate_pool=16, restarts=1, seed=11, model_feasibility=True, descriptor_transform=descriptors, latent_size=1, posterior_samples=128, ) def evaluate(genome): x, y = genome if x + y > 1.2: return None, None, {"bop_valid": False} flow = 0.1 + 0.75 * y quality = 3 - (x - 0.6)**2 - (y - 0.4)**2 return (quality,), None, {"bop_latents": (flow,)} for _ in range(search.budget): (candidate,) = search.ask_batch() search.tell_batch([evaluate(candidate)]) print(search.n_observations, search.n_invalid_observations) Use ordinary grid features and a deterministic, vectorized transform. The transform sets the archived descriptor from the original measurement. The source GPs and the objective GP remain independent. The transform accounts for dependence introduced by reusing the sources. Joint cell sampling is a QDpy extension. Its draw count is a power of two and controls acquisition cost and resolution. :doc:`additional_qd_benchmarks` compares the four combinations on a constrained analytic task. See `Kent et al. (2025) `__.