Skip to main content

CBXpy

Project description

cbx

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.

Source Distribution

cbx-0.1.1.tar.gz (19.8 kB view hashes)

Uploaded Source

Built Distribution

cbx-0.1.1-py3-none-any.whl (24.0 kB view hashes)

Uploaded Python 3

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