Metadata-Version: 2.1
Name: cbx
Version: 0.1.0
Summary: CBXpy
Author-email: Tim Roith <tim.roith@desy.de>
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Python: >3.5.2
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: numpy
Requires-Dist: scipy
Requires-Dist: scikit-learn
Requires-Dist: matplotlib
Provides-Extra: test
Requires-Dist: pytest ; extra == 'test'
Requires-Dist: torch ; extra == 'test'


![cbx](https://github.com/PdIPS/CBXpy/assets/44805883/65e7f1b2-e858-4b8d-af37-8eeaea15214c)

# 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

```python
   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](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
