QDpy
Loading...
Searching...
No Matches
__init__.py
1# This file is part of qdpy.
2#
3# qdpy is free software: you can redistribute it and/or modify
4# it under the terms of the GNU Lesser General Public License as
5# published by the Free Software Foundation, either version 3 of
6# the License, or (at your option) any later version.
7#
8# qdpy is distributed in the hope that it will be useful,
9# but WITHOUT ANY WARRANTY; without even the implied warranty of
10# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11# GNU Lesser General Public License for more details.
12#
13# You should have received a copy of the GNU Lesser General Public
14# License along with qdpy. If not, see <http://www.gnu.org/licenses/>.
15
16"""Package `qdpy` implements recent Quality-Diversity algorithms: Map-Elites, CVT-Map-Elites, NSLC, SAIL, etc.
17QD algorithms can be accessed directly, but `qdpy` also includes building blocks that can be easily assembled together to build your own QD algorithms. It can be used with parallelism mechanisms and in distributed environments.
18
19This checkout requires Python 3.11 or newer.
20
21`qdpy` includes the following features:
22 * Generic support for diverse Containers: Grids, Novelty-Archives, Populations, etc
23 * Optimisation algorithms for QD: random search methods, quasi-random methods, evolutionary algorithms
24 * Support for multi-objective optimisation methods
25 * Possible to use optimisation methods not designed for QD, such as [CMA-ES](https://arxiv.org/pdf/1604.00772.pdf)
26 * Parallelisation of evaluations, using parallelism libraries, such as multiprocessing, concurrent.futures or [SCOOP](https://github.com/soravux/scoop)
27 * Easy integration with the popular [DEAP](https://github.com/DEAP/deap) evolutionary computation framework
28
29Install
30=======
31To install this checkout:
32 python -m pip install .
33
34`qdpy` includes optional features that need extra packages to be installed:
35 * `cma` for CMA-ES support
36 * `deap` to integrate with the DEAP library
37 * `tables` to output results files in the HDF5 format
38 * `tqdm` to display a progress bar showing optimisation progress
39 * `colorama` to add colours to pretty-printed outputs
40
41You can install `qdpy` and all of these optional dependencies with:
42 pip3 install qdpy[all]
43
44The development guide is in `docs/index.md` in the GitLab repository.
45
46Example
47=======
48From a python shell::
49
50 from qdpy import algorithms, containers, benchmarks, plots
51
52 # Create container and algorithm. Here we use MAP-Elites, by illuminating a Grid container by evolution.
53 grid = containers.Grid(shape=(64,64), max_items_per_bin=1, fitness_domain=((0., 1.),), features_domain=((0., 1.), (0., 1.)))
54 algo = algorithms.RandomSearchMutPolyBounded(grid, budget=60000, batch_size=500,
55 dimension=3, optimisation_task="maximisation")
56
57 # Create a logger to pretty-print everything and generate output data files
58 logger = algorithms.AlgorithmLogger(algo)
59
60 # Define evaluation function
61 eval_fn = algorithms.partial(benchmarks.illumination_rastrigin_normalised,
62 nb_features = len(grid.shape))
63
64 # Run illumination process !
65 best = algo.optimise(eval_fn)
66
67 # Print results info
68 print(algo.summary())
69
70 # Plot the results
71 plots.default_plots_grid(logger)
72
73 print("All results are available in the '%s' pickle file." % logger.final_filename)
74
75
76Usage, Documentation
77====================
78The source code is available at https://gitlab.com/leo.cazenille/qdpy.
79Read the documentation at https://qdpy-4d5382.gitlab.io/.
80
81
82:Author: Leo Cazenille, 2018-*
83
84:License: LGPLv3, see LICENSE file.
85
86"""
87
88
89__author__ = "qdpy Team"
90__license__ = "LGPLv3"
91__version__ = "0.4.0"
92__revision__ = __version__
93
94# MODELINE "{{{1
95# vim:expandtab:softtabstop=4:shiftwidth=4:fileencoding=utf-8
96# vim:foldmethod=marker