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.
Metadata
Release files for bboptpy 0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| bboptpy-0.1.tar.gz | 141.5 kB | Without provenance | Details for bboptpy-0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| bboptpy-0.1-cp312-cp312-win_amd64.whl | CPython 3.12 | CPython 3.12 | Windows x86-64 | Details for bboptpy-0.1-cp312-cp312-win_amd64.whl |
Total release size: 867.1 kB
Release files / bboptpy-0.1.tar.gz
| Download URL | bboptpy-0.1.tar.gz |
|---|---|
| Size | 141.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
fb8242f3fcd1c47a81d29d5326f9cfd79217ed9907180393245bb89e82285163
|
|
BLAKE2b-256 checksum How to use checksums |
6ca8eaf39101fc4683701a325bd16ec6774bc82bfad5882778e7eaf932fb8153
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.12.7
|
Release files / bboptpy-0.1-cp312-cp312-win_amd64.whl
| Download URL | bboptpy-0.1-cp312-cp312-win_amd64.whl |
|---|---|
| Size | 725.5 kB |
| Tags | CPython 3.12 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
fc070b480570383d8445dbf10643f4d0f91d8cb3504e227f494cae48da07257b
|
|
BLAKE2b-256 checksum How to use checksums |
81367039c17958c8c6202c6aaaf4f0d7d275c06f9925f26a9bc515ab62c79e04
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.12.7
|
Security for bboptpy 0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.