Powerful and scalable black-box optimization algorithms for Python and C++.
Project description
bboptpy
bboptpy is a large suite of efficient algorithms written in C++ for the optimization of black-box functions.
Main advantages:
- single unified interface for Python with a user-friendly API
- variety of classical and modern algorithms with state-of-the-art improvements that are robust and very fast
- transparent implementation that makes it easy to build upon.
Full documentation and list of supported algorithms and functions is found here.
Installation
To use this library in a Python project, you will need a C++ compiler for Python and git (e.g. conda install git).
Then install directly:
pip install git+https://github.com/mike-gimelfarb/bboptpy
Algorithms Supported
The following algorithms are currently fully supported with Python wrappers:
- Univariate:
- Multivariate:
- Unconstrained:
- Adaptive Coordinate Descent (ACD)
- AMaLGaM IDEA
- Basin Hopping
- Controlled Random Search (CRS)
- Covariance Matrix Adaptation Evolutionary Strategy (CMA-ES):
- Differential Evolution (DE):
- Differential Search (DSA)
- Exponential Natural Evolution Strategy (xNES)
- Novel Self-Adaptive Harmony Search (NSHS)
- Hessian Evolutionary Strategy (HE-ES)
- Self-Adaptive Multi-Population JAYA
- Adaptive Nelder-Mead Method
- Particle Swarm Optimization (PSO):
- Powell's Methods:
- PRAXIS
- Rosenbrock Method
- Unconstrained:
Usage
Simple example to optimize a univariate function:
import numpy as np
from bboptpy import Brent
# function to optimize
def fx(x):
return np.sin(x) + np.sin(10 * x / 3)
alg = Brent(mfev=20000, atol=1e-6)
sol = alg.optimize(fx, lower=2.7, upper=7.5, guess=np.random.uniform(2.7, 7.5))
print(sol)
This will print the following output:
x*: 5.1457349293974861
calls to f: 10
converged: 1
Simple example to optimize a multivariate function:
import numpy as np
from bboptpy import ActiveCMAES
# function to optimize
def fx(x):
total = 0.0
for x1, x2 in zip(x[:-1], x[1:]):
total += 100 * (x2 - x1 ** 2) ** 2 + (1 - x1) ** 2
return total
n = 10 # dimension of problem
alg = ActiveCMAES(mfev=10000, tol=1e-4, np=20)
sol = alg.optimize(fx, lower=-10 * np.ones(n), upper=10 * np.ones(n), guess=np.random.uniform(-10, 10, size=n))
print(sol)
This will print the following output:
x*: 0.999989 0.999999 1.000001 1.000007 1.000020 1.000029 1.000102 1.000183 1.000357 1.000689
objective calls: 6980
constraint calls: 0
B/B constraint calls: 0
converged: yes
Citation
To cite this repository, either use the link in the sidebar, or the following bibtext entry:
@software{gimelfarb2024bboptpy,
author = {Gimelfarb, Michael},
license = {LGPL-2.1+},
title = {{bboptpy: Powerful and scalable black-box optimization algorithms for Python and C++.}},
url = {https://github.com/mike-gimelfarb/bboptpy},
year = {2024}
}
To cite the authors of the individual algorithms, please see the references in the comments heads of the respective C++ source files.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file bboptpy-0.1.tar.gz.
File metadata
- Download URL: bboptpy-0.1.tar.gz
- Upload date:
- Size: 141.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fb8242f3fcd1c47a81d29d5326f9cfd79217ed9907180393245bb89e82285163
|
|
| MD5 |
2b2777d35d6fcc62cd91a5a38c799d0e
|
|
| BLAKE2b-256 |
6ca8eaf39101fc4683701a325bd16ec6774bc82bfad5882778e7eaf932fb8153
|
File details
Details for the file bboptpy-0.1-cp312-cp312-win_amd64.whl.
File metadata
- Download URL: bboptpy-0.1-cp312-cp312-win_amd64.whl
- Upload date:
- Size: 725.5 kB
- Tags: CPython 3.12, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fc070b480570383d8445dbf10643f4d0f91d8cb3504e227f494cae48da07257b
|
|
| MD5 |
99623a54fbaabe4e549d57ee1b5535ab
|
|
| BLAKE2b-256 |
81367039c17958c8c6202c6aaaf4f0d7d275c06f9925f26a9bc515ab62c79e04
|