Experiments and integrations ============================ YAML configuration ------------------ Use one factory for containers and algorithms so an algorithm can refer to its archive by name. A container that keeps a parent history also references that parent by name. Define each dependency before the object that uses it. Top-level domain definitions can use one name per objective or descriptor, with bounds named by appending ``Domain`` to the name. The following configuration minimises a score named ``error`` and uses ``x`` and ``y`` as descriptors. Save it as ``search.yaml``. .. code-block:: yaml seed: 42 logger_type: basic fitness_list: [error] errorDomain: [0.0, 2.0] features_list: [x, y] xDomain: [0.0, 1.0] yDomain: [0.0, 1.0] main_algorithm_name: search containers: archive: type: Grid shape: [4, 4] algorithms: search: type: RandomUniform container: archive budget: 12 batch_size: 4 dimension: 2 ind_domain: [0.0, 1.0] optimisation_task: minimisation Run a small experiment with an evaluator that produces those named scores. The logger writes the effective YAML configuration and seed with the result. .. code-block:: python from qdpy.experiment import QDExperiment class Example(QDExperiment): def eval_fn(self, ind): x, y = ind error = x**2 + y**2 return (error,), (x, y), {"error": error, "x": x, "y": y} if __name__ == "__main__": experiment = Example("search.yaml", parallelism_type="none") experiment.run() .. autoclass:: qdpy.experiment.QDExperiment :members: reinit, run, eval_fn, several_eval_fn .. autoclass:: qdpy.base.Factory :members: build .. autoclass:: qdpy.base.Registry Executors --------- Choose a sequential executor to debug evaluation code in the controlling process. Thread evaluators share application memory. Process evaluators receive serialized arguments and return serialized results. Keep the candidate's returned measurements in the result so the controller can update its own archive. Use the ``ray`` extra for the Ray executor and install SCOOP separately. SCOOP scripts start under ``python -m scoop``. See :doc:`tutorial_ray` to run Ray with a local or distributed runtime. .. autoclass:: qdpy.base.SequentialExecutor Snapshots and plots ------------------- Use :class:`~qdpy.algorithms.AlgorithmLogger` for native result files. Evaluation tables record incumbent values, and iteration tables summarize the archive after completed batches. Read a trusted pickle using :func:`~qdpy.tools.open_pickle_file`. To include the immediate parents of a container in saved results, set ``disable_parents_pickling=False``. Current snapshots can supply genomes for a warm start with :class:`~qdpy.algorithms.FromArchive`. .. autoclass:: qdpy.base.Saveable :members: save .. autoclass:: qdpy.bundles.RunBundleOptions .. autoclass:: qdpy.bundles.RunBundle .. autofunction:: qdpy.bundles.open_run_bundle .. autofunction:: qdpy.plots.default_plots_grid .. autofunction:: qdpy.plots.plotGrid .. autofunction:: qdpy.plots.plotGridSubplots .. autofunction:: qdpy.plots.plot_evals .. autofunction:: qdpy.plots.plot_iterations Archive visualization --------------------- .. autofunction:: qdpy.plots.plot_archive .. autofunction:: qdpy.plots.plot_archives .. py:class:: qdpy.reporting.ArchiveCellComparison Result of :func:`qdpy.reporting.compare_archive_cells`. The count arrays ``reference_only``, ``contender_only``, and ``both`` have the reporting grid's shape. ``median_difference`` has the same shape and holds NaN where no seed reached the cell with both methods. ``paired_seeds``, ``unmatched_reference``, and ``unmatched_contender`` identify seed support. .. autofunction:: qdpy.reporting.compare_archive_cells .. autofunction:: qdpy.plots.plot_archive_difference .. autoclass:: qdpy.lineage.LineageRecorder :members: attach, close, id_for, mark_failed .. autofunction:: qdpy.lineage.read_lineage .. autofunction:: qdpy.plots.plot_lineage .. autoclass:: qdpy.plots.ArchiveRecorder :members: attach, capture .. autoclass:: qdpy.plots.ArchiveFrame .. autofunction:: qdpy.plots.read_archive_history .. autofunction:: qdpy.plots.align_archive_histories .. autofunction:: qdpy.plots.render_archive_frames .. autofunction:: qdpy.plots.assemble_gif .. autofunction:: qdpy.plots.assemble_mp4 .. autofunction:: qdpy.plots.animate_archives Genealogy and stepping stones ----------------------------- See :doc:`tutorial_genealogy` for measured examples. .. autoclass:: qdpy.lineage.LineageNode .. autofunction:: qdpy.genealogy.ancestry .. autofunction:: qdpy.genealogy.ancestor_archive .. autofunction:: qdpy.genealogy.plot_ancestry_archive .. autoclass:: qdpy.genealogy.GoalSwitch .. autofunction:: qdpy.genealogy.goal_switches .. autofunction:: qdpy.genealogy.search_trajectory_network .. autofunction:: qdpy.genealogy.lineage_trajectory_network .. autoclass:: qdpy.genealogy.SearchTrajectoryNetwork :members: betweenness, stepping_stones, worsening_fraction .. autoclass:: qdpy.genealogy.SteppingStoneAnalysis .. autofunction:: qdpy.genealogy.plot_stepping_stones .. autoclass:: qdpy.algorithms.innovation_engine.ClassChampion .. autoclass:: qdpy.algorithms.innovation_engine.ClassifierIlluminationResult .. autofunction:: qdpy.algorithms.classifier_illumination .. autoclass:: qdpy.phylogeny.CaseEstimates .. autofunction:: qdpy.phylogeny.case_cohorts .. autofunction:: qdpy.phylogeny.estimate_case_errors DEAP and learned descriptors ---------------------------- Install the ``deap`` extra for ``qdpy.algorithms.deap.DEAPQDAlgorithm``. Its default ``qdSimple`` routine takes a DEAP toolbox, evaluates the invalid individuals, and updates a QDpy container after the initial batch and each generation. It accepts a pre-evaluated initial batch and reports the evaluated final batch through its iteration callback. See the DEAP examples for toolbox operators and the Doxygen reference for the signatures. Install PyTorch separately to use ``qdpy.containers.TorchFeatureExtractionContainerDecorator``. The wrapped archive uses the model's latent vector as its descriptor. Choose consistent numeric named scores and keep training records in a parent or training container if retraining needs historical observations. The feature extraction example combines the decorator with an autoscaling grid. For fixed unit bounds, enable ``quantile_transform=True``. Use ``observation_score`` to pass a fixed-shape array instead of scalar named scores. For multiple jointly trained grids, see :doc:`tutorial_mc_aurora`. Legacy API ---------- Original scripts can call ``qdpy.legacy.MapElites``, ``qdpy.legacy.CVTMapElites``, or ``qdpy.legacy.SAIL``. Their evaluators and result dictionaries use the legacy conventions. For a new search, the native API separates the optimiser, evaluator, and archive as described in :doc:`architecture`.