cbxpy

A python package for consensus-based optimization

https://github.com/pdips/cbxpy

Science Score: 54.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
    Links to: joss.theoj.org
  • Academic email domains
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (13.4%) to scientific vocabulary
Last synced: 10 months ago · JSON representation ·

Repository

A python package for consensus-based optimization

Basic Info
Statistics
  • Stars: 23
  • Watchers: 5
  • Forks: 9
  • Open Issues: 0
  • Releases: 4
Created over 3 years ago · Last pushed 12 months ago
Metadata Files
Readme Contributing License Citation

README.md

cbx

status tests codecov License: MIT Doc

A Python package for consensus-based particle dynamics, focusing on optimization and sampling.

How to use CBXPy?

Minimizing a function using CBXPy can be done as follows:

```python from cbx.dynamics import CBO # import the CBO class

f = lambda x: x[0]2 + x[1]2 # define the function to minimize x = CBO(f, d=2).optimize() # run the optimization ```

A documentation together with more examples and usage instructions is available at https://pdips.github.io/CBXpy.

Installation

Currently CBXPy can only be installed from PyPI with pip.

bash pip install cbx

What is CBX?

Originally designed for optimization problems of the form

$$ \min_{x \in \mathbb{R}^n} f(x), $$

the scheme was introduced as CBO (Consensus-Based Optimization). Given an ensemble of points $x = (x1, \ldots, xN)$, the update reads

$$ xi \gets xi - \lambda\ dt\ (xi - c(x)) + \sigma\ \sqrt{dt} |xi - c(x)|\ \xi_i $$

where $\xi_i$ are i.i.d. standard normal random vectors. The core element is the consensus point

$$ \begin{align} c(x) = \left(\sum{i=1}^{N} xi\ \exp(-\alpha\ f(xi))\right)\bigg/\left(\sum{i=1}^N \exp(-\alpha\ f(x_i))\right) \end{align} $$

with a parameter $\alpha>0$. The scheme can be extended to sampling problems known as CBS, clustering problems and opinion dynamics, which motivates the acronym CBX, indicating the flexibility of the scheme.

Functionality

Among others, CBXPy currently implements

  • CBO (Consensus-Based Optimization) [1]
  • CBS (Consensus-Based Sampling) [2]
  • CBO with memory [3]
  • Batching schemes [4]
  • Polarized CBO [5]
  • Mirror CBO [6]
  • Adamized CBO [7]
  • Constrained CBO methods, including
    • Drift Correction [8]
    • Regularization [9]
    • Hypersurface CBO [10]

References

[1] A consensus-based model for global optimization and its mean-field limit, Pinnau, R., Totzeck, C., Tse, O. and Martin, S., Mathematical Models and Methods in Applied Sciences 2017

[2] Consensus-based sampling, Carrillo, J.A., Hoffmann, F., Stuart, A.M., and Vaes, U., Studies in Applied Mathematics 2022

[3] Leveraging Memory Effects and Gradient Information in Consensus-Based Optimization: On Global Convergence in Mean-Field Law, Riedl, K., 2022

[4] A consensus-based global optimization method for high dimensional machine learning problems, Carrillo, J.A., Jin, S., Li, L. and Zhu, Y., ESAIM: Control, Optimisation and Calculus of Variations 2021

[5] Bungert, L., Roith, T., & Wacker, P. (2024). Polarized consensus-based dynamics for optimization and sampling. Mathematical Programming, 1-31.

[6] Bungert, L., Hoffmann, F., Kim, D. Y., & Roith, T. (2025). MirrorCBO: A consensus-based optimization method in the spirit of mirror descent. arXiv preprint arXiv:2501.12189.

[7] Chen, J., Jin, S., & Lyu, L. (2020). A consensus-based global optimization method with adaptive momentum estimation. arXiv preprint arXiv:2012.04827.

[8] Carrillo, J. A., Jin, S., Zhang, H., & Zhu, Y. (2024). An interacting particle consensus method for constrained global optimization. arXiv preprint arXiv:2405.00891.

[9] Borghi, G., Herty, M., & Pareschi, L. (2023). Constrained consensus-based optimization. SIAM Journal on Optimization, 33(1), 211-236.

[10] Fornasier, M., Huang, H., Pareschi, L., & Sünnen, P. (2020). Consensus-based optimization on hypersurfaces: Well-posedness and mean-field limit. Mathematical Models and Methods in Applied Sciences, 30(14), 2725-2751.

Owner

  • Name: Purpose-driven particle systems
  • Login: PdIPS
  • Kind: organization

Citation (citation.cff)

cff-version: "1.2.0"
authors:
- family-names: Bailo
  given-names: Rafael
  orcid: "https://orcid.org/0000-0001-8018-3799"
- family-names: Barbaro
  given-names: Alethea
  orcid: "https://orcid.org/0000-0001-9856-2818"
- family-names: Gomes
  given-names: Susana N.
  orcid: "https://orcid.org/0000-0002-8731-367X"
- family-names: Riedl
  given-names: Konstantin
  orcid: "https://orcid.org/0000-0002-2206-4334"
- family-names: Roith
  given-names: Tim
  orcid: "https://orcid.org/0000-0001-8440-2928"
- family-names: Totzeck
  given-names: Claudia
  orcid: "https://orcid.org/0000-0001-6283-7154"
- family-names: Vaes
  given-names: Urbain
  orcid: "https://orcid.org/0000-0002-7629-7184"
doi: 10.5281/zenodo.12207224
message: If you use this software, please cite our article in the
  Journal of Open Source Software.
preferred-citation:
  authors:
  - family-names: Bailo
    given-names: Rafael
    orcid: "https://orcid.org/0000-0001-8018-3799"
  - family-names: Barbaro
    given-names: Alethea
    orcid: "https://orcid.org/0000-0001-9856-2818"
  - family-names: Gomes
    given-names: Susana N.
    orcid: "https://orcid.org/0000-0002-8731-367X"
  - family-names: Riedl
    given-names: Konstantin
    orcid: "https://orcid.org/0000-0002-2206-4334"
  - family-names: Roith
    given-names: Tim
    orcid: "https://orcid.org/0000-0001-8440-2928"
  - family-names: Totzeck
    given-names: Claudia
    orcid: "https://orcid.org/0000-0001-6283-7154"
  - family-names: Vaes
    given-names: Urbain
    orcid: "https://orcid.org/0000-0002-7629-7184"
  date-published: 2024-06-21
  doi: 10.21105/joss.06611
  issn: 2475-9066
  issue: 98
  journal: Journal of Open Source Software
  publisher:
    name: Open Journals
  start: 6611
  title: "CBX: Python and Julia Packages for Consensus-Based Interacting
    Particle Methods"
  type: article
  url: "https://joss.theoj.org/papers/10.21105/joss.06611"
  volume: 9
title: "CBX: Python and Julia Packages for Consensus-Based Interacting
  Particle Methods"

GitHub Events

Total
  • Release event: 1
  • Watch event: 4
  • Push event: 18
  • Fork event: 1
  • Create event: 1
Last Year
  • Release event: 1
  • Watch event: 4
  • Push event: 18
  • Fork event: 1
  • Create event: 1

Dependencies

.github/workflows/Sphinx.yml actions
  • actions/checkout v2 composite
  • actions/setup-python v2 composite
  • peaceiris/actions-gh-pages v3 composite
.github/workflows/Tests.yml actions
  • actions/checkout v3 composite
  • actions/setup-python v4 composite
pyproject.toml pypi
  • matplotlib *
  • numpy *
  • scikit-learn *
  • scipy *
requirements.txt pypi
  • matplotlib *
  • numpy *
  • scikit-learn *
  • scipy *