Skip to content

[JMLR (CCF-A)] PyPop7: A Pure-Python Library for POPulation-based Black-Box Optimization (BBO), especially *Large-Scale* variants (including evolutionary algorithms, swarm-based randomized optimizers, pattern search, and random search). [https://jmlr.org/papers/v25/23-0386.html] (Its Planned Extensions: PyCoPop7, PyNoPop7, PyDPop77, and PyMePop7)

License

Notifications You must be signed in to change notification settings

Evolutionary-Intelligence/pypop

Repository files navigation

PyPop7: A Pure-PYthon library of POPulation-based continuous OPtimization in black-box cases [CCF-A]

[News!] PyPop7 has been used and cited in one Nature paper [Veenstra et al., Nature, 2025] and etc. For recently popular Meta-Black-Box Optimization, please refer to e.g., MetaBox from the research team of Prof. Gong (South China University of Technology).

Pub arXiv PyPI Docs Downloads Downloads visitors Python Linux Apple Windows CircleCI GitHub Actions Codecov PyCharm Sphinx WeChat EvoI

PyPop7 is a Python library of population-based randomized optimization for single-objective, real-parameter, unconstrained black-box problems. Its main goal is to provide a unified interface and a large set of elegant implementations (e.g., evolutionary algorithms, swarm-based optimizers, and pattern search) for Black-Box Optimization, particularly various population-based optimizers, in order to facilitate research repeatability, wide benchmarking, and especially their real-world applications.

Specifically, for alleviating the notorious curse-of-dimensionality issue, PyPop7's focus is to cover their State Of The Art (SOTA) for Large-Scale Optimization (LSO), though many of their small- and medium-scaled versions or variants are also included here (for e.g., theoretical or benchmarking or educational or practical purposes). For a growing list of its diverse use and/or citation cases, please refer to this online website. Although we have chosen GPL-3.0 license initially, anyone could use, modify, and improve it entirely freely for any (no matter open-source or closed-source) positive purposes.

How to Quickly Use

"In our opinion, the main fact, which should be known to any person dealing with optimization models, is that in general, optimization problems are unsolvable. This statement, which is usually missing in standard optimization courses, is very important for understanding optimization theory and the logic of its development in the past and in the future."---From Prof. Yurii Nesterov

The following 3 simple steps are enough to utilize the black-box optimization power of PyPop7:

  • Recommend using pip to install pypop7 on the Python3-based virtual environment via venv or conda [but not mandatory]:
$ pip install pypop7

For PyPop7, the number 7 was added just because pypop has been registered by other in PyPI. The icon butterfly for PyPop7 is used to respect/allude to the book (butterflies in its cover) of Fisher ("the greatest of Darwin's successors"): The Genetical Theory of Natural Selection, which directly inspired Prof. Holland's proposal of Genetic Algorithms (GA).

  • Define the objective / cost / loss / error / fitness function to be minimized for the optimization problem at hand (here the term fitness function is used, in order to follow the established terminology tradition of evolutionary computation):
import numpy as np  # for numerical computation (as the computing engine of pypop7)

# Rosenbrock (one notorious test function from the continuous optimization community)
def rosenbrock(x):
    return 100.0 * np.sum(np.square(x[1:] - np.square(x[:-1]))) + np.sum(np.square(x[:-1] - 1.0))

# to define the fitness function to be *minimized* and also its problem settings
ndim_problem = 1000
problem = {'fitness_function': rosenbrock,
           'ndim_problem': ndim_problem,  # dimension
           'lower_boundary': -5.0 * np.ones((ndim_problem,)),  # lower search boundary
           'upper_boundary': 5.0 * np.ones((ndim_problem,))}  # upper search boundary

Without loss of generality, only the minimization process is considered here, since maximization can be easily transferred to minimization just by negating (-) it. Note that this well-known test function is used only for the benchmarking purpose.

  • Run one black-box optimizer or more on the above optimization problem. Owing to its low computational complexity and well metric-learning ability, choose LM-MA-ES as an example. Please refer to https://pypop.readthedocs.io/en/latest/es/lmmaes.html for its algorithmic procedure.
# LMMAES: Limited Memory Matrix Adaptation Evolution Strategy
from pypop7.optimizers.es.lmmaes import LMMAES
# to define algorithm options (which differ in details among different optimizers)
options = {'fitness_threshold': 1e-10,  # to stop if best-so-far fitness <= 1e-10
           'max_runtime': 3600.0,  # to stop if runtime >= 1 hours (3600 seconds)
           'seed_rng': 0,  # random seed (which should be set for repeatability)
           'x': 4.0 * np.ones((ndim_problem,)),  # mean of search distribution
           'sigma': 3.0,  # global step-size (but not necessarily optimal)
           'verbose': 500}
lmmaes = LMMAES(problem, options)  # to initialize (under a unified API)
results = lmmaes.optimize()  # to run its (time-consuming) evolution process
print(results)

Clearly, to obtain the nearly optimal rate of convergence for LMMAES, the key hyper-parameter sigma may need to be well fine-tuned for this test function rosenbrock. In practice, Hyper-Paramter Optimization (HPO) is one very common strategy to approximate the possibly best solution for the complex optimization problem at hand. Please refer to e.g., the following books and papers as reference:

Online Documentations, Online Tutorials, and Future Extensions

Please refer to https://pypop.rtfd.io/ for online documentations and tutorials of this well-designed ("self-boasted" by ourselves) Python library for Black-Box Optimization (e.g., online praises from others). A total of 4 extended versions of PyPop7 (as PP7) are ongoing or planned for further development:

  • For Constrained Black-Box Optimization (PyCoPop7 as PCP7),
  • For Noisy Black-Box Optimization (PyNoPop7 as PNP7),
  • Enhancement via Parallel and Distributed Optimization (PyDPop7 as DP7),
  • Enhancement via Meta-evolution based Optimization (PyMePop7 as PMP7).

A (Still Growing) Number of Black-Box Optimizers (BBO)


The below classification based on only the dimensionality of objective function, is just a roughly empirical estimation for the basic algorithm selection task. In practice, perhaps the simplest way to algorithm selection is trial-and-error. More advanced automated algorithm selection techniques can be also considered here in principle.

  • lso: indicates the specific version for Large-Scale Optimization (LSO), e.g., dimension >> 1000 (but this is not an absolutely deterministic number depending upon the concrete problem.
  • c: indicates the competitive or de facto BBO version for low- or medium-dimensional problems (though it may also work well under some certain LSO circumstances).
  • b: indicates the baseline BBO version mainly for theoretical and/or educational interest, owing to its algorithmic simplicity (relative ease for mathematical analysis).

This is an algorithm-centric rather than benchmarking-centric Python library (though undoubtedly proper benchmarking is crucial for BBO).

For new/missed BBO, we have provided a unified API to freely add them if they can well satisfy the design philosophy widely recognized in the scientific research community. Note that currently both Ant Colony Optimization (ACO) and Tabu Search (TS) are not covered in this library, since they work well mainly in discrete or combinatorial search spaces in many cases. Furthermore, both brute-force (exhaustive) search and grid search are also excluded here, since it works only for very low (typically < 10) dimensions. In the near-future version, we will consider to add others (e.g., Simultaneous Perturbation Stochastic Approximation (SPSA)) into this open-source library. Please refer to development guide for more details.

Computational Efficiency

For large-scale optimization (LSO), computational efficiency is an indispensable performance criterion of BBO/DFO/ZOO in the post-Moore era. To obtain high-performance computation as much as possible, NumPy is heavily used in this library as the base of numerical computation along with SciPy and scikit-learn. Sometimes Numba is also utilized, in order to further accelerate the wall-clock time.

Folder Structure

The first-level folder structure of this library PyPop7 is presented below:

  • .circleci: for automatic testing based on pytest.
    • config.yml: configuration file in CircleCI.
  • .github: all configuration files for GitHub.
  • docs: for online documentations.
  • pypop7: all Python source code of BBO.
  • tutorials: a set of tutorials.
  • .gitignore: for GitHub.
  • .readthedocs.yaml: for readthedocs.
  • CODE_OF_CONDUCT.md: code of conduct.
  • LICENSE: open-source license.
  • README.md: basic information of this library.
  • pyproject.toml: for PyPI (used by setup.cfg as build-system).
  • requirements.txt: only for development.
  • setup.cfg: only for PyPI (used via pyproject.toml).

References

For each population-based algorithm family, we are providing several representative applications published on some (rather all) top-tier journals/conferences (such as, Nature, Science, PNAS, PRL, JACS, JACM, PIEEE, JMLR, ICML, NeurIPS, ICLR, CVPR, ICCV, RSS, just to name a few), reported in the (actively-updated) paper list called DistributedEvolutionaryComputation.

Sponsor

Now it is supported by National Natural Science Foundation of China under Grant No. 72401122, Guangdong Basic and Applied Basic Research Foundation under Grant No. 2024A1515012241 and 2021A1515110024. From 2021 to 2023, this open-source Python library was supported by Shenzhen Fundamental Research Program (a total of 2 000 000 Yuan).

Citation and Activities

If this open-source Python library is used in your paper or project, it is highly welcomed but NOT mandatory to cite the following arXiv preprint paper (First Edition: 12 Dec 2022): Duan, Q., Zhou, G., Shao, C., Wang, Z., Feng, M., Huang, Y., Tan, Y., Yang, Y., Zhao, Q. and Shi, Y., 2024. PyPop7: A Pure-Python Library for Population-Based Black-Box Optimization. arXiv preprint arXiv:2212.05652. (Now it has been submitted to JMLR, after 3-round reviews from 28 Mar 2023 to 01 Nov 2023 to 05 Jul 2024, and finally accepted in 11 Oct 2024.)

2026

  • A tutorial on Open-Source Software for Swarm Intelligence is planning for e.g., [ICSI 2026] or [ANTS 2026] etc.
  • A tutorial on Open-Source Software for Evolutionary Algorithms is planning for e.g., [IEEE-CEC 2026] or [IEEE-SSCI 2026] etc.

2025

  • A batch-updated version of PyPop7 is ongoing.
  • An account called PyPop7 on the Wechat Public Platform has been registered in 16 Apr 2025. (Chinese: 微信公众号 PyPop7)
  • An oral presentation will be given by one author in IEEE-CEC 2025 and its PPT file will be released.
  • An one-page paper has been submitted to IEEE-CEC 2025 as one Journal-to-Conference (J2C) paper. (Accepted in 18 Mar 2025)

BibTeX

@article{JMLR-2024-Duan, title={{PyPop7}: A {pure-Python} library for population-based black-box optimization}, author={Duan, Qiqi and Zhou, Guochen and Shao, Chang and Others}, journal={Journal of Machine Learning Research}, volume={25}, number={296}, pages={1--28}, year={2024} }

Visitors

visitors

Star