<a href=https://experimental-design.github.io/bofire/>
<img width="350" src="https://raw.githubusercontent.com/experimental-design/bofire/main/graphics/logos/bofire-long.png" alt="BoFire Logo" />
</a>
<hr/>
[![Test](https://github.com/experimental-design/bofire/workflows/Tests/badge.svg)](https://github.com/experimental-design/bofire/actions?query=workflow%3ATests)
[![Lint](https://github.com/experimental-design/bofire/workflows/Lint/badge.svg)](https://github.com/experimental-design/bofire/actions?query=workflow%3ALint)
[![Docs](https://github.com/experimental-design/bofire/workflows/Docs/badge.svg)](https://github.com/experimental-design/bofire/actions?query=workflow%3ADocs)
[![PyPI](https://img.shields.io/pypi/v/bofire.svg)](https://pypi.org/project/bofire)
BoFire is a **B**ayesian **O**ptimization **F**ramework **I**ntended for **R**eal **E**xperiments.
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](https://experimental-design.github.io/bofire/install/),
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](https://botorch.org/) that depends on
[PyTorch](https://pytorch.org/). To use the DoE package, you need to install
[Cyipopt](https://cyipopt.readthedocs.io/en/stable/)
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](https://experimental-design.github.io/bofire/getting_started/).
We first must define the domain of the optimization problem.
```python
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.
```python
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](https://arxiv.org/abs/2408.05040):
@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](https://botorch.org/). For BoTorch, please cite also the [botorch paper](https://proceedings.neurips.cc/paper_files/paper/2020/hash/f5b1b89d98b7286673128a5fb112cb9a-Abstract.html):
@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](https://github.com/leojklarner/gauche). If you use the molecular kernels in BoFire please cite also the [gauche paper](https://proceedings.neurips.cc/paper_files/paper/2023/hash/f2b1b2e974fa5ea622dd87f22815f423-Abstract-Conference.html):
@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](./CONTRIBUTING.md) 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](./LICENSE).
Raw data
{
"_id": null,
"home_page": "https://github.com/experimental-design/bofire",
"name": "bofire",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.9.0",
"maintainer_email": null,
"keywords": "Bayesian optimization, Multi-objective optimization, Experimental design",
"author": null,
"author_email": null,
"download_url": "https://files.pythonhosted.org/packages/cc/62/95ed6f3566ebf8572caef168ae44c505363ef864b69e3a381112686f2288/bofire-0.0.15.tar.gz",
"platform": null,
"description": "<a href=https://experimental-design.github.io/bofire/>\n <img width=\"350\" src=\"https://raw.githubusercontent.com/experimental-design/bofire/main/graphics/logos/bofire-long.png\" alt=\"BoFire Logo\" />\n</a>\n\n<hr/>\n\n[![Test](https://github.com/experimental-design/bofire/workflows/Tests/badge.svg)](https://github.com/experimental-design/bofire/actions?query=workflow%3ATests)\n[![Lint](https://github.com/experimental-design/bofire/workflows/Lint/badge.svg)](https://github.com/experimental-design/bofire/actions?query=workflow%3ALint)\n[![Docs](https://github.com/experimental-design/bofire/workflows/Docs/badge.svg)](https://github.com/experimental-design/bofire/actions?query=workflow%3ADocs)\n[![PyPI](https://img.shields.io/pypi/v/bofire.svg)](https://pypi.org/project/bofire)\n\nBoFire is a **B**ayesian **O**ptimization **F**ramework **I**ntended for **R**eal **E**xperiments.\n\nWhy BoFire?\n\nBoFire ...\n\n- supports mixed continuous, discrete and categorical parameter spaces for system inputs and outputs,\n- separates objectives (minimize, maximize, close-to-target) from the outputs on which they operate,\n- supports different specific and generic constraints as well as black-box output constraints,\n- can provide flexible DoEs that fulfill constraints,\n- provides sampling methods for constrained mixed variable spaces,\n- serializes problems for use in RESTful APIs and json/bson DBs,\n- allows easy out of the box usage of strategies for single and multi-objective Bayesian optimization, and\n- provides a high flexibility on the modelling side if needed.\n\n## Installation\n\nIn our [docs](https://experimental-design.github.io/bofire/install/),\nyou can find all different options for the BoFire installation.\nTo install all BoFire-features you need to run\n```\npip install bofire[optimization,cheminfo]\n```\nThis will also install [BoTorch](https://botorch.org/) that depends on\n[PyTorch](https://pytorch.org/). To use the DoE package, you need to install\n[Cyipopt](https://cyipopt.readthedocs.io/en/stable/)\nadditionally, e.g., via\n```\nconda install -c conda-forge cyipopt\n```\n\n## Getting Started\nFor a more complete introduction to BoFire, please look at the [Getting Started documentation](https://experimental-design.github.io/bofire/getting_started/).\n\nWe first must define the domain of the optimization problem.\n\n```python\nfrom bofire.data_models.features.api import ContinuousInput, ContinuousOutput\nfrom bofire.data_models.objectives.api import MaximizeObjective\nfrom bofire.data_models.constraints.api import NChooseKConstraint\nfrom bofire.data_models.domain.api import Domain, Inputs, Outputs, Constraints\n\ninput_features = Inputs(features=[\n ContinuousInput(key=\"x1\", bounds=(0,1)),\n ContinuousInput(key=\"x2\", bounds=(0,1)),\n ContinuousInput(key=\"x3\", bounds=(0,1)),\n])\n\noutput_features = Outputs(features=[\n ContinuousOutput(key=\"y\", objective=MaximizeObjective())\n])\n\nconstraints = Constraints(constraints=[\n NChooseKConstraint(\n features=[\"x1\", \"x2\", \"x3\"],\n min_count=1, max_count=2, none_also_valid=False)\n])\n\ndomain = Domain(\n inputs=input_features,\n outputs=output_features,\n constraints=constraints\n)\n```\n\nYou can also use one of the many benchmarks available in BoFire.\nHere, we use the Detergent benchmark to demonstrate the ask/tell interface for\nproposing new experiments with multi-objective Bayesian optimization.\n\n```python\nimport bofire.strategies.api as strategies\nfrom bofire.benchmarks.api import Detergent\nfrom bofire.data_models.strategies.api import QnehviStrategy, RandomStrategy\n\n# create benchmark\ndetergent = Detergent()\ndomain = detergent.domain\n\n# create initial data with the random strategy while satisfying constraints\nsampler = strategies.map(RandomStrategy(domain=domain))\ninitial_samples = sampler.ask(2)\nexperiments = detergent.f(initial_samples, return_complete=True)\n\n# Bayesian optimization\nmobo_strategy = strategies.map(QnehviStrategy(domain=domain))\nn_experiments = 4\nfor _ in range(n_experiments):\n mobo_strategy.tell(experiments=experiments)\n candidates = mobo_strategy.ask(candidate_count=1)\n experiments = detergent.f(candidates, return_complete=True)\n\n# Print all told experiments\nprint(mobo_strategy.experiments)\n```\n\n## Documentation\n\nDocumentation including a section on how to get started can be found under https://experimental-design.github.io/bofire/.\n\n## Reference\n\nWe would love for you to use BoFire in your work! If you do, please cite [our paper](https://arxiv.org/abs/2408.05040):\n\n @misc{durholt2024bofire,\n title={BoFire: Bayesian Optimization Framework Intended for Real Experiments},\n 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},\n year={2024},\n eprint={2408.05040},\n archivePrefix={arXiv},\n primaryClass={cs.LG},\n url={https://arxiv.org/abs/2408.05040},\n }\n\nBayesian optimization in BoFire is based on META's [BoTorch library](https://botorch.org/). For BoTorch, please cite also the [botorch paper](https://proceedings.neurips.cc/paper_files/paper/2020/hash/f5b1b89d98b7286673128a5fb112cb9a-Abstract.html):\n\n @inproceedings{NEURIPS2020_f5b1b89d,\n author = {Balandat, Maximilian and Karrer, Brian and Jiang, Daniel and Daulton, Samuel and Letham, Ben and Wilson, Andrew G and Bakshy, Eytan},\n booktitle = {Advances in Neural Information Processing Systems},\n editor = {H. Larochelle and M. Ranzato and R. Hadsell and M.F. Balcan and H. Lin},\n pages = {21524--21538},\n publisher = {Curran Associates, Inc.},\n title = {BoTorch: A Framework for Efficient Monte-Carlo Bayesian Optimization},\n url = {https://proceedings.neurips.cc/paper_files/paper/2020/file/f5b1b89d98b7286673128a5fb112cb9a-Paper.pdf},\n volume = {33},\n year = {2020}\n }\n\nFor molecular optimizations, BoFire uses the molecular kernels from the [Gauche library](https://github.com/leojklarner/gauche). If you use the molecular kernels in BoFire please cite also the [gauche paper](https://proceedings.neurips.cc/paper_files/paper/2023/hash/f2b1b2e974fa5ea622dd87f22815f423-Abstract-Conference.html):\n\n @inproceedings{NEURIPS2023_f2b1b2e9,\n 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},\n booktitle = {Advances in Neural Information Processing Systems},\n editor = {A. Oh and T. Naumann and A. Globerson and K. Saenko and M. Hardt and S. Levine},\n pages = {76923--76946},\n publisher = {Curran Associates, Inc.},\n title = {GAUCHE: A Library for Gaussian Processes in Chemistry},\n url = {https://proceedings.neurips.cc/paper_files/paper/2023/file/f2b1b2e974fa5ea622dd87f22815f423-Paper-Conference.pdf},\n volume = {36},\n year = {2023}\n }\n\n\n\n## Contributing\n\nSee our [Contributing](./CONTRIBUTING.md) guidelines. If you are not sure about something or find bugs, feel free to create an issue.\n\nBy contributing you agree that your contributions will be licensed under the same license as BoFire: [BSD 3-Clause License](./LICENSE).\n",
"bugtrack_url": null,
"license": "BSD-3",
"summary": null,
"version": "0.0.15",
"project_urls": {
"Homepage": "https://github.com/experimental-design/bofire"
},
"split_keywords": [
"bayesian optimization",
" multi-objective optimization",
" experimental design"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "fbe0e2cd26dccf0a8ad701c3d30825f13607ff3685a31988133912f5f4ff871e",
"md5": "b626e91f246c97d74c41fb2ff7f6ffdb",
"sha256": "b142059531f9458bdec6a293ad8e82f29e3ae5f778e069843c27192ac2391e1d"
},
"downloads": -1,
"filename": "bofire-0.0.15-py3-none-any.whl",
"has_sig": false,
"md5_digest": "b626e91f246c97d74c41fb2ff7f6ffdb",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.9.0",
"size": 461806,
"upload_time": "2024-11-13T16:00:51",
"upload_time_iso_8601": "2024-11-13T16:00:51.109826Z",
"url": "https://files.pythonhosted.org/packages/fb/e0/e2cd26dccf0a8ad701c3d30825f13607ff3685a31988133912f5f4ff871e/bofire-0.0.15-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "cc6295ed6f3566ebf8572caef168ae44c505363ef864b69e3a381112686f2288",
"md5": "809cb03ed14b6a3dcac83b14b84aed0a",
"sha256": "15bf807dd78e93d694933cbf0ed4ddfa1bffd365febd45429f63b7e2ccbd1fcb"
},
"downloads": -1,
"filename": "bofire-0.0.15.tar.gz",
"has_sig": false,
"md5_digest": "809cb03ed14b6a3dcac83b14b84aed0a",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.9.0",
"size": 590180,
"upload_time": "2024-11-13T16:00:53",
"upload_time_iso_8601": "2024-11-13T16:00:53.336275Z",
"url": "https://files.pythonhosted.org/packages/cc/62/95ed6f3566ebf8572caef168ae44c505363ef864b69e3a381112686f2288/bofire-0.0.15.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-11-13 16:00:53",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "experimental-design",
"github_project": "bofire",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "bofire"
}