CBXpy
Project description
What is CBXPy?
CBXPy
is a python package for consensus-based particle dynamics, focusing on optimization and sampling. Minimizing a function using CBXPy can be done as follows
from cbx.dynamics import CBO
f = lambda x: x[0]**2 + x[1]**2
dyn = CBO(f, d=2)
x = dyn.optimize()
A Documentation is available at https://pdips.github.io/CBXpy
Installation
What is CBX?
Originally designed for optimization problems
$$ \min_{x \in \mathbb{R}^n} f(x), $$
the scheme was introduced as CBO (Consensus Based Optimization). Given an ensemble of points $x = (x_1, \ldots, x_N)$, the update reads
$$ x_i \gets x_i - \lambda\ dt\ (x_i - c(x)) + \sigma\ \sqrt{dt} |x_i - c(x)| \xi_i $$
where $\xi_i$ are i.i.d. standard normal random variables. The core element is the consensus point
$$ \begin{align*} c(x) = \left(\sum_{i=1}^{N} x_i\ \exp(-\alpha\ f(x_i))\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.
Usage examples
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.