CMA-MAEGA with analytic gradients ================================= Minimise ``x**2 + y**2`` while finding solutions at different values of the descriptor ``y``. :class:`qdpy.algorithms.CMAMAEGA` evaluates derivatives at its current centre and uses those directions to propose offspring. The ordinary evaluator measures the offspring. Install the :ref:`cma extra ` and run the script from the repository root. .. code-block:: sh python examples/cma_maega.py .. literalinclude:: ../examples/cma_maega.py :language: python Return a :class:`qdpy.algorithms.GradientEvaluation` with the raw objective, descriptors, and a Jacobian. The Jacobian has one column per genome coordinate. The first row contains the objective derivatives ``[2*x, 2*y]``, and the next row contains the derivatives of ``y``, ``[0, 1]``. Append one row per additional descriptor, in the same order as the descriptor values. CMA-MAEGA applies the objective sign and normalises nonzero rows before sampling coefficients. Each centre call counts as one evaluation, including failures. With this budget the script reports five centre evaluations and 19 offspring evaluations. The last offspring batch has three slots. It can update the archive and cell thresholds, and the centre move and covariance adaptation use full offspring batches. Manual scheduling ----------------- For one centre and offspring cycle, keep the constructor and replace the call to ``run()`` and the reporting block with this code. .. code-block:: python centre = search.ask_dqd() search.tell_dqd(evaluate_gradient(centre)) candidates = search.ask_batch() search.tell_batch([evaluate(ind) for ind in candidates]) print(search.nb_evaluations, search.gradient_evaluations) Report ``None`` through ``tell_dqd()`` if the centre evaluator fails. Request a new centre before asking for offspring. With the managed runner, a packed evaluator receives groups of offspring and the centre callback still receives one individual at a time. See `Fontaine and Nikolaidis (2023), Appendix D `__.