Skip to main content

No project description provided

Project description

BoFire Logo

Test Lint Docs PyPI

BoFire is a Bayesian Optimization Framework Intended for Real Experiments.

Why BoFire?

BoFire ...

  • supports mixed continuous, discrete and categorical parameter spaces for system inputs and outputs,
  • separates objectives (minimize, maximize, close-to-target) from the outputs on which they operate,
  • supports different specific and generic constraints as well as black-box output constraints,
  • can provide flexible DoEs that fulfill constraints,
  • provides sampling methods for constrained mixed variable spaces,
  • serializes problems for use in RESTful APIs and json/bson DBs,
  • allows easy out of the box usage of strategies for single and multi-objective Bayesian optimization, and
  • provides a high flexibility on the modelling side if needed.

Installation

In our docs, you can find all different options for the BoFire installation. To install all BoFire-features you need to run

pip install bofire[optimization,cheminfo]

This will also install BoTorch that depends on PyTorch. To use the DoE package, you need to install Cyipopt additionally, e.g., via

conda install -c conda-forge cyipopt

Getting Started

For a more complete introduction to BoFire, please look at the Getting Started documentation.

We first must define the domain of the optimization problem.

from bofire.data_models.features.api import ContinuousInput, ContinuousOutput
from bofire.data_models.objectives.api import MaximizeObjective
from bofire.data_models.constraints.api import NChooseKConstraint
from bofire.data_models.domain.api import Domain, Inputs, Outputs, Constraints

input_features = Inputs(features=[
    ContinuousInput(key="x1", bounds=(0,1)),
    ContinuousInput(key="x2", bounds=(0,1)),
    ContinuousInput(key="x3", bounds=(0,1)),
])

output_features = Outputs(features=[
    ContinuousOutput(key="y", objective=MaximizeObjective())
])

constraints = Constraints(constraints=[
    NChooseKConstraint(
        features=["x1", "x2", "x3"],
        min_count=1, max_count=2, none_also_valid=False)
])

domain = Domain(
    inputs=input_features,
    outputs=output_features,
    constraints=constraints
)

You can also use one of the many benchmarks available in BoFire. Here, we use the Detergent benchmark to demonstrate the ask/tell interface for proposing new experiments with multi-objective Bayesian optimization.

import bofire.strategies.api as strategies
from bofire.benchmarks.api import Detergent
from bofire.data_models.strategies.api import QnehviStrategy, RandomStrategy

# create benchmark
detergent = Detergent()
domain = detergent.domain

# create initial data with the random strategy while satisfying constraints
sampler = strategies.map(RandomStrategy(domain=domain))
initial_samples = sampler.ask(2)
experiments = detergent.f(initial_samples, return_complete=True)

# Bayesian optimization
mobo_strategy = strategies.map(QnehviStrategy(domain=domain))
n_experiments = 4
for _ in range(n_experiments):
    mobo_strategy.tell(experiments=experiments)
    candidates = mobo_strategy.ask(candidate_count=1)
    experiments = detergent.f(candidates, return_complete=True)

# Print all told experiments
print(mobo_strategy.experiments)

Documentation

Documentation including a section on how to get started can be found under https://experimental-design.github.io/bofire/.

Reference

We would love for you to use BoFire in your work! If you do, please cite our paper:

@misc{durholt2024bofire,
  title={BoFire: Bayesian Optimization Framework Intended for Real Experiments},
  author={Johannes P. D{\"{u}}rholt and Thomas S. Asche and Johanna Kleinekorte and Gabriel Mancino-Ball and Benjamin Schiller and Simon Sung and Julian Keupp and Aaron Osburg and Toby Boyne and Ruth Misener and Rosona Eldred and Wagner Steuer Costa and Chrysoula Kappatou and Robert M. Lee and Dominik Linzner and David Walz and Niklas Wulkow and Behrang Shafei},
  year={2024},
  eprint={2408.05040},
  archivePrefix={arXiv},
  primaryClass={cs.LG},
  url={https://arxiv.org/abs/2408.05040},
}

Bayesian optimization in BoFire is based on META's BoTorch library. For BoTorch, please cite also the botorch paper:

@inproceedings{NEURIPS2020_f5b1b89d,
    author = {Balandat, Maximilian and Karrer, Brian and Jiang, Daniel and Daulton, Samuel and Letham, Ben and Wilson, Andrew G and Bakshy, Eytan},
    booktitle = {Advances in Neural Information Processing Systems},
    editor = {H. Larochelle and M. Ranzato and R. Hadsell and M.F. Balcan and H. Lin},
    pages = {21524--21538},
    publisher = {Curran Associates, Inc.},
    title = {BoTorch: A Framework for Efficient Monte-Carlo Bayesian Optimization},
    url = {https://proceedings.neurips.cc/paper_files/paper/2020/file/f5b1b89d98b7286673128a5fb112cb9a-Paper.pdf},
    volume = {33},
    year = {2020}
}

For molecular optimizations, BoFire uses the molecular kernels from the Gauche library. If you use the molecular kernels in BoFire please cite also the gauche paper:

@inproceedings{NEURIPS2023_f2b1b2e9,
    author = {Griffiths, Ryan-Rhys and Klarner, Leo and Moss, Henry and Ravuri, Aditya and Truong, Sang and Du, Yuanqi and Stanton, Samuel and Tom, Gary and Rankovic, Bojana and Jamasb, Arian and Deshwal, Aryan and Schwartz, Julius and Tripp, Austin and Kell, Gregory and Frieder, Simon and Bourached, Anthony and Chan, Alex and Moss, Jacob and Guo, Chengzhi and D\"{u}rholt, Johannes Peter and Chaurasia, Saudamini and Park, Ji Won and Strieth-Kalthoff, Felix and Lee, Alpha and Cheng, Bingqing and Aspuru-Guzik, Alan and Schwaller, Philippe and Tang, Jian},
    booktitle = {Advances in Neural Information Processing Systems},
    editor = {A. Oh and T. Naumann and A. Globerson and K. Saenko and M. Hardt and S. Levine},
    pages = {76923--76946},
    publisher = {Curran Associates, Inc.},
    title = {GAUCHE: A Library for Gaussian Processes in Chemistry},
    url = {https://proceedings.neurips.cc/paper_files/paper/2023/file/f2b1b2e974fa5ea622dd87f22815f423-Paper-Conference.pdf},
    volume = {36},
    year = {2023}
}

Contributing

See our Contributing guidelines. If you are not sure about something or find bugs, feel free to create an issue.

By contributing you agree that your contributions will be licensed under the same license as BoFire: BSD 3-Clause License.

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

bofire-0.0.14.tar.gz (589.4 kB view details)

Uploaded Source

Built Distribution

bofire-0.0.14-py3-none-any.whl (460.8 kB view details)

Uploaded Python 3

File details

Details for the file bofire-0.0.14.tar.gz.

File metadata

  • Download URL: bofire-0.0.14.tar.gz
  • Upload date:
  • Size: 589.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.20

File hashes

Hashes for bofire-0.0.14.tar.gz
Algorithm Hash digest
SHA256 516c2aa06665f507e9ba96d60b66d66b6c5627e20e0f108828e7255764cb6999
MD5 6146754303c94b3ef925983fa38b018c
BLAKE2b-256 8efebcabcad5861db6de015c4502ff1dadf864363a20d7819cdcd0d7af3438be

See more details on using hashes here.

File details

Details for the file bofire-0.0.14-py3-none-any.whl.

File metadata

  • Download URL: bofire-0.0.14-py3-none-any.whl
  • Upload date:
  • Size: 460.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.20

File hashes

Hashes for bofire-0.0.14-py3-none-any.whl
Algorithm Hash digest
SHA256 712c10069a7952c1c27e7faf0e8eb03ea1137dfcee5a87412313361cffba2a7a
MD5 4ee549fbfe3708e3951124ff8314f51f
BLAKE2b-256 5d6c6fcbb6ca147a7d7931ce925efc84dcef8b84500021717fd0f90f7432034e

See more details on using hashes here.

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