BONNI: Bayesian Optimization via Neural Network surrogates and Interior Point Optimization
Project description
BONNI: Bayesian Optimization via Neural Network surrogates and Interior Point Optimization
BONNI optimizes any black box function WITH gradient information. Especially in optimizations with many degree of freedom, gradient-information increases optimization speed. In the image, the surrogate fits the function almost perfectly with few observations.
Installation
You can install BONNI simply via
pip install bonni
We recommend installing also the GPU-acceleration from JAX, which will massively increase speed:
pip install jax[cuda]
Usage
BONNI provides a nice optimization wrapper similar to the scipy.minimize API:
from bonni import optimize_bonni
from pathlib import Path
import numpy as np
def fn(x: np.ndarray):
# Input function should return function value and gradient
value = x[0] ** 2 + x[1]
grad = np.asarray([2 * x[0], 1])
return value, grad
xs, ys, gs = optimize_bonni(
fn=fn,
bounds=np.asarray([[-1, 1], [0, 1]], dtype=float),
# BO requires some samples before iterations start. You can either explicitly provide
# previous fn evals via `xs=..., ys=..., gs=... or specify a number of random samples.
num_bonni_iterations=5,
num_random_samples=2,
direction="minimize",
save_path=Path.cwd(), # save data as npz here
seed=42,
)
Additionally, BONNI includes a convenient wrapper for IPOPT. The standard IPOPT package can be difficult to install/use, so we created a convenient wrapper shown below:
from bonni import optimize_ipopt
xs, ys, gs = optimize_ipopt(
fn=fn,
x0=np.asarray([0.5, 0.5]), # startpoint of optimization
bounds=np.asarray([[-1, 1], [0, 1]], dtype=float),
# IPOPT performs line search each iteration, such that the number
# of iterations and fn_eval may not be the same
max_fn_eval=5,
max_iterations=3,
direction="maximize",
save_path=Path.cwd(),
)
Documentation
You can find the full extensive documentation of BONNI here.
Citation
If you find this repository helpful for your research, please consider citing:
TODO insert citation as soon as paper online.
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 bonni-1.1.2.tar.gz.
File metadata
- Download URL: bonni-1.1.2.tar.gz
- Upload date:
- Size: 2.0 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
26d2946684710f61d2e59b6d500507f617d771f6e13a0b890926e972f9db2616
|
|
| MD5 |
5400a1923268e4b4cb4dd417263fb67b
|
|
| BLAKE2b-256 |
ac12de0b2e8287374dc7a893814497856eda55f16d87b427543ba9b104b02761
|
Provenance
The following attestation bundles were made for bonni-1.1.2.tar.gz:
Publisher:
publish.yml on ymahlau/bonni
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
bonni-1.1.2.tar.gz -
Subject digest:
26d2946684710f61d2e59b6d500507f617d771f6e13a0b890926e972f9db2616 - Sigstore transparency entry: 862840496
- Sigstore integration time:
-
Permalink:
ymahlau/bonni@81789e428325e549dc8b16023af91001912c8a15 -
Branch / Tag:
refs/tags/v1.1.2 - Owner: https://github.com/ymahlau
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@81789e428325e549dc8b16023af91001912c8a15 -
Trigger Event:
release
-
Statement type:
File details
Details for the file bonni-1.1.2-py3-none-any.whl.
File metadata
- Download URL: bonni-1.1.2-py3-none-any.whl
- Upload date:
- Size: 29.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ec47861d7e9d93f1352cdb865631c2258d5e2014b3e55aecf780bd7e6113a783
|
|
| MD5 |
cef7ee0555f202ac6f045572cc621f14
|
|
| BLAKE2b-256 |
512927f8d550bc0383205826bb38f5800f5f5ee0321dddaeb278a950a4a9ca95
|
Provenance
The following attestation bundles were made for bonni-1.1.2-py3-none-any.whl:
Publisher:
publish.yml on ymahlau/bonni
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
bonni-1.1.2-py3-none-any.whl -
Subject digest:
ec47861d7e9d93f1352cdb865631c2258d5e2014b3e55aecf780bd7e6113a783 - Sigstore transparency entry: 862840564
- Sigstore integration time:
-
Permalink:
ymahlau/bonni@81789e428325e549dc8b16023af91001912c8a15 -
Branch / Tag:
refs/tags/v1.1.2 - Owner: https://github.com/ymahlau
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@81789e428325e549dc8b16023af91001912c8a15 -
Trigger Event:
release
-
Statement type: