Skip to main content

pypop7 (Pure-PYthon library of POPulation-based OPtimization)

Project description

PyPop7: a Pure-PYthon open-source library of POPulation-based (evolution / swarm / pattern search) black-box OPtimization

GNU General Public License v3.0 PyPI for PyPop7 Documentation Status Coverage arxiv Downloads Downloads WeChat-Group

PyPop7 is a Pure-PYthon open-source library of POPulation-based OPtimization for single-objective, real-parameter, black-box problems (currently actively maintained). Its goal is to provide a unified interface and a set of elegant algorithmic implementations (e.g., evolutionary algorithms, swarm-based optimizers, pattern search, etc.) for Black-Box Optimization (BBO), particularly population-based optimizers, in order to facilitate research repeatability, benchmarking of BBO, and especially real-world applications.

More specifically, for alleviating their curse of dimensionality, the focus of PyPop7 is to cover their State Of The Art for Large-Scale Optimization (LSO), though many of their small/medium-scaled versions and variants are also included here (mainly for theoretical or benchmarking or educational purposes). For a list of public use cases of PyPop7, please refer to this online document for details. Although we have chosen GPL-3.0 license, anyone could use, modify, and improve this open-source Python library entirely freely for any (no matter open-source or closed-source) purpose.

How to Quickly Use

The following three steps are enough to utilize the black-box optimization power of this library PyPop7:

  1. Use pip to install pypop7 on the Python3-based virtual environment via venv or conda:
$ pip install pypop7
  1. Define the objective/cost/fitness function to be minimized for the optimization problem at hand,
import numpy as np  # for numerical computation, which is also the *computing engine* of pypop7

# the below example is Rosenbrock, one notorious test function from the 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))

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

Note that without loss of generality, only the minimization process is considered in this library, since maximization can be easily transferred to minimization by negating it.

  1. Run one or more black-box optimizers on this optimization problem:
# here we choose LM-MA-ES owing to its low complexity and metric-learning ability for LSO:
#     https://pypop.readthedocs.io/en/latest/es/lmmaes.html
from pypop7.optimizers.es.lmmaes import LMMAES
# define all the necessary algorithm options (which may differ among different optimizers)
options = {'fitness_threshold': 1e-10,  # terminate when the best-so-far fitness is lower than this threshold
           'max_runtime': 3600,  # 1 hours (terminate when the actual runtime exceeds it)
           'seed_rng': 0,  # seed of random number generation (which must be explicitly set for repeatability)
           'x': 4.0*np.ones((ndim_problem,)),  # initial mean of search (mutation/sampling) distribution
           'sigma': 3.0,  # initial global step-size of search distribution (not necessarily optimal)
           'verbose': 500}
lmmaes = LMMAES(problem, options)  # initialize the optimizer
results = lmmaes.optimize()  # run its (time-consuming) search process
print(results)

Note that for PyPop7, the number 7 is added just because pypop has been registered by other in PyPI. The icon butterfly for PyPop7 is used to respect to the book (a complete variorum edition) of Fisher, "the greatest of Darwin's successors": The Genetical Theory of Natural Selection (where four butterflies were drawn in its cover), which inspired the proposal of Genetic Algorithms (GA). Please refer to https://pypop.rtfd.io/ for the online documentation of this seemingly well-designed (self-boasted) pure-Python library (several praises from others).

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

For new/missed BBO, we provide a unified API to freely add them if they satisfy our design philosophy (see development-guide for details). Note that Ant Colony Optimization (ACO) and Tabu Search (TS) are not covered in this open-source Python library, since they work well mainly in discrete/combinatorial search spaces in many cases. Furthermore, brute-force search (exhaustive/grid search) is also excluded here, since it works only for very low (typically << 10) dimensions. In the future version, we will consider adding Simultaneous Perturbation Stochastic Approximation (SPSA) into this open-source Python library.


  • lso: indicates the specific BBO version for LSO (dimension >> 1000).
  • c: indicates the competitive (or de facto) BBO version for small/medium-dimensional problems (though it may work well under certain LSO circumstances).
  • b: indicates the baseline BBO version mainly for theoretical/educational interest, owing to its simplicity (relative ease to mathematical analysis).

Note that this classification based on only the dimension of objective function is just a rough estimation for algorithm selection. In practice, perhaps the simplest way to algorithm selection is trial-and-error or to try more advanced Automated Algorithm Selection techniques.


Computational Efficiency

For 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. Sometimes Numba is also utilized, in order to further accelerate the wall-clock time.

Folder Structure

The main folder structure of this open-source 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.
  • coverage-badge.svg: coverage rate of testing, calculated via Coverage.py and generated via https://smarie.github.io/python-genbadge/.
  • pyproject.toml: for PyPI.
  • requirements.txt: for development.
  • setup.cfg: for PyPI (used via pyproject.toml).

References

For each algorithm family, we try to provide several representative applications published on some top-tier journals and conferences (such as, Nature, Science, PNAS, PRL, JACS, JACM, PIEEE, JMLR, ICML, NeurIPS, ICLR, CVPR, ICCV, etc.), systematically reported in the (actively maintained) paper list called DistributedEvolutionaryComputation openly accessible via GitHub.

Sponsor

From 2021 to 2023, this open-source pure-Python library PyPop7 was supported by Shenzhen Fundamental Research Program under Grant No. JCYJ20200109141235597 (2,000,000 Yuan). Now it is supported by Guangdong Basic and Applied Basic Research Foundation under Grants No. 2024A1515012241 and 2021A1515110024. Furthermore, Qiqi Duan, one of its core developers, is also seeking new possible sponsors from enterprises.

Citation

If this open-source pure-Python library PyPop7 is used in your paper or project, it is highly welcomed but NOT mandatory to cite the following arXiv preprint paper: 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 submitted to JMLR, under review).

Star History

visitors

PyPop7-Star-Data

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

pypop7-0.0.82-py3-none-any.whl (560.3 kB view details)

Uploaded Python 3

File details

Details for the file pypop7-0.0.82-py3-none-any.whl.

File metadata

  • Download URL: pypop7-0.0.82-py3-none-any.whl
  • Upload date:
  • Size: 560.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.8.8

File hashes

Hashes for pypop7-0.0.82-py3-none-any.whl
Algorithm Hash digest
SHA256 91c93daa5d0fe231f8a4c9287248d9ecaf02f2361f1d7b3bb9c2d62b29139656
MD5 1ac9c1b98e9f83c21ea75e20b6569069
BLAKE2b-256 dc428f70ddc58fb852fa92bc66baaa5f95106ecdde7a43fc03a1f94f773624f0

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page