PyPop7’s Documentations for Continuous Black-Box Optimization

[NEWS] Recently, PyPop7 has been used and/or cited in one Nature paper ([Nature, 2025]), etc.

https://img.shields.io/badge/GitHub-PyPop7-red.svg https://img.shields.io/badge/PyPI-pypop7-yellowgreen.svg https://img.shields.io/badge/license-GNU%20GPL--v3.0-green.svg https://img.shields.io/badge/OS-Linux%20%7C%20Windows%20%7C%20MacOS%20X-orange.svg https://static.pepy.tech/badge/pypop7 https://visitor-badge.laobi.icu/badge?page_id=Evolutionary-Intelligence.pypop https://img.shields.io/badge/arxiv-2212.05652-red https://img.shields.io/badge/JMLR-2024-red https://readthedocs.org/projects/pypop/badge/?version=latest

“Responsible for adaptation, optimization, and innovation in the living world, evolution executes a simple algorithm of diversifcation and natural selection, an algorithm that works at all levels of complexity from single protein molecules to whole ecosystems.”— From Nobel Lecture of Frances H. Arnold (California Institute of Technology)

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

Specifically, for alleviating the well-known (‘notorious’) curse of dimensionality, the main focus of PyPop7 is to cover State-Of-The-Art (SOTA) implementations on Large-Scale BBO, though many of medium- or small-scale versions (variants) are also included.

Note

This open-source Python library for continuous BBO is still under active maintenance. In the future, we plan adding some NEW BBO algorithms and some SOTA versions of existing BBO families, in order to make this library as fresh as possible. Any suggestions, extensions, improvements, usages, and tests (even criticisms) to this open-source Python library are highly welcomed!

Now this arXiv paper (arXiv:2212.05652) has been submitted to JMLR, accepted in Fri, 11 Oct 2024 after 3-round reviews from Tue, 28 Mar 2023 to Wed, 01 Nov 2023 to Fri, 05 Jul 2024.)

Quick Start

Three basic steps are often enough to utilize the potential of PyPop7 for many (though not all) black-box optimization cases:

  1. Use pip to automatically install pypop7 via PyPI:

    $ pip install pypop7
    

Please refer to this online documentation for details about installation ways.

  1. Define your own objective (aka cost or fitness) function to be minimized for the complex optimization problem at hand:

    1>>> import numpy as np  # for numerical computation (PyPop7's computing engine)
    2>>> def rosenbrock(x):  # one notorious function in the optimization community
    3...     return 100.0*np.sum(np.square(x[1:] - np.square(x[:-1]))) + np.sum(np.square(x[:-1] - 1.0))
    4>>> ndim_problem = 1000  # problem dimension
    5>>> problem = {'fitness_function': rosenbrock,  # fitness function to be minimized
    6...            'ndim_problem': ndim_problem,  # problem dimension
    7...            'lower_boundary': -5.0*np.ones((ndim_problem,)),  # lower search boundary
    8...            'upper_boundary': 5.0*np.ones((ndim_problem,))}  # upper search boundary
    

Please refer to this online documentation for details about problem definition. Note that any maximization problem can be transformed into the minimization problem simply via negating it.

  1. Run one black-box optimizer or more from PyPop7 on the above problem:

     1>>> from pypop7.optimizers.es.lmmaes import LMMAES  # choose any optimizer which you prefer
     2>>> options = {'fitness_threshold': 1e-10,  # terminate when the best-so-far fitness < 1e-10
     3...            'max_runtime': 3600,  # terminate when the runtime exceeds 1 hour
     4...            'seed_rng': 0,  # seed of random number generation (for repeatability)
     5...            'x': 4.0*np.ones((ndim_problem,)),  # initial mean of search distribution
     6...            'sigma': 3.0,  # initial global step-size (to be fine-tuned for optimality)
     7...            'verbose': 500}
     8>>> lmmaes = LMMAES(problem, options)  # initialize the optimizer (a unified interface)
     9>>> results = lmmaes.optimize()  # run its (time-consuming) optimization (evolution) process
    10>>> # print best-so-far fitness and used function evaluations returned by the optimizer
    11>>> print(results['best_so_far_y'], results['n_function_evaluations'])
    129.948e-11 2973386 (# different NumPy versions may result in different results #)
    

Please refer to this online documentation for details about optimizer settings.

Note

If this open-source Python library is used in your project or paper, please cite the following JMLR paper (BibTeX):

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

Contents of PyPop7: