Constrained MAP-Elites with mixed variables =========================================== Find feasible designs across a grid when the input combines real values, integer counts, and categorical choices. The example varies size, layer count, and material. It reports one low-cost design per cell of the size and layer grid. Run from the repository root with the :ref:`base package `. .. code-block:: sh python examples/constrained_map_elites.py .. literalinclude:: ../examples/constrained_map_elites.py :language: python :class:`qdpy.algorithms.ConstrainedMAPElites` starts with an empty, best-only grid and one objective. Declare the variables in genome order. Candidates store integer category indices. Call ``search.decode(candidate)`` to recover the original labels. Return a fitness tuple, the descriptors, and a dictionary with one finite residual per configured constraint. Each residual must be at most zero for the candidate to enter the result grid. For a lower strength bound, subtract measured strength from required strength. Use separate score names for the objective and the residuals. The search keeps one near-feasible candidate per cell, ranked by the sum of positive residuals and then by weighted fitness. Scale residuals to comparable units if they should have similar influence. The default draws from either archive with equal probability when both have entries. Set ``infeasible_parent_probability=0`` to use feasible parents exclusively. With seed 7, the example reports seven feasible cells, three near-feasible cells, and a best raw cost of about 0.1603. Read ``search.infeasible_elites`` to inspect the near-feasible candidates. The feasible grid supplies coverage, QD score, and the best result. If that grid is empty after the budget is spent, ``run()`` raises ``RuntimeError``. The counters and near-feasible archive remain available on the search object. Use ``ask_batch()`` and ``tell_batch(results)`` for manual evaluation. Each batch draws parents from the archives at the start of that batch. Missing or nonfinite residuals consume an attempt and trigger a warning. The mixed-variable search follows `Brevault and Balesdent (2024) `__. For the two-archive strategy, see `Zammit et al. (2023) `__. See :doc:`constrained_coevolution_benchmarks` for the three-way comparison.