Skip to main content

BoCoDe

BOCoDe: Benchmarks for Optimization and Computational Design

Python tests code style: Ruff

BOCoDe is a Python/PyTorch library of optimization benchmark problems for benchmarking optimization algorithms, with a first-class BoTorch/Ax interface for Bayesian optimization research. It collects 307 benchmark problems — 159 engineering, 80 hyperparameter-optimization (HPO), and 68 synthetic — spanning five optimization classes (single-/multi-objective, unconstrained/constrained, and mixed-variable), with an emphasis on real-world engineering, control, materials-science, and HPO problems drawn from the literature and cited to their sources.

[!IMPORTANT] Output objective values are meant to be maximized (the library was designed for Bayesian optimization). For minimization algorithms, negate the objective. Constraints are inequality constraints: gx <= 0 is feasible.

[!NOTE] The library is still under construction. Please open a pull request or an issue to let us know if you run into problems. Thanks!

💡 What is in BOCoDe?

Every problem carries per-problem JSON metadata and a cited source, and is accessed by name through a central registry. The benchmark set covers 307 problems across three domains:

Domain Examples Count
Engineering trusses, pressure vessel, speed reducer, Mazda car design, CEC2020 real-world constrained suite, RE/CRE multi-objective suite, MODAct actuators, MuJoCo control, materials-science datasets (AgNP, CrossedBarrel, P3HT, Perovskite, AutoAM) 159
HPO Bayesmark, HPO-B, LCBench, LassoBench real datasets (DNA, Leukemia, …) 80
Synthetic Ackley, Rosenbrock, ZDT, DTLZ, MW, mixed-variable variants 68

By optimization class: SO-Unconstrained (150), SO-Constrained (48), MO-Unconstrained (26), MO-Constrained (26), SO-Mixed-Variable (57). The registry also ships additional problems beyond this benchmark set (e.g. combinatorial TSP and EPFL logic-synthesis tasks).

See CATEGORIZATION.md for the full per-problem table (dimensions, objectives, constraints, variable types, convexity, NP-hardness) and the NP-hardness assessment methodology.

💻 Installation

Core install (enough to import bocode and run most problems):

pip install bocode

Some problems need heavy or native dependencies, shipped as optional extras. Install only what you need:

pip install "bocode[mujoco]"     # MuJoCo control problems
pip install "bocode[truss]"      # Truss10D..Truss200D
pip install "bocode[box2d]"      # RobotPush
pip install "bocode[modact]"     # MODAct suite
pip install "bocode[hpo]"        # SVM
pip install "bocode[mazda]"      # Mazda car design
pip install "bocode[neorl]"      # QPowerModel surrogate
pip install "bocode[tabicl]"     # TabICL foundation-model surrogate (tabicl_* methods)
pip install "bocode[tabpfn]"     # TabPFN foundation-model surrogate (tfm_* / pfn_cei methods)
pip install "bocode[hebo]"       # HEBO optimizer (hebo method)
pip install "bocode[all]"        # everything available on PyPI
# bounce (bounce method) is not on PyPI: install from the official source tree with
#   pip install --no-deps --no-build-isolation <bounce repo> && pip install gin-config
# Known-good upstream versions (pinned in requirements-lock.txt):
#   HEBO  : github.com/huawei-noah/HEBO @ ee6112d (v0.3.6, `#subdirectory=HEBO`)
#   bounce: github.com/LeoIV/bounce      @ 738b9bd (v0.1.0) + gin-config
Extra Enables Backing dependency
mujoco MuJoCo locomotion problems gymnasium[mujoco]
control CartPole / Acrobot gymnasium
truss Truss10D…Truss200D slientruss3d
box2d RobotPush Box2D, pygame, joblib
modact MODAct CS/CT/CTS/CTSE/CTSEI modact
hpo SVM and the weighted-Lasso (LassoBench) problems scikit-learn
mazda Mazda openpyxl
neorl QPowerModel onnxruntime
viz function visualization dash, plotly, matplotlib

The Lasso problems are a clean-room weighted-Lasso reimplementation that needs only scikit-learn (the hpo extra); their datasets are fetched from OpenML on first use (network required). See bocode/opt_problems/hpo/_lasso_base.py for how it differs from upstream LassoBench.

Accessing a problem without its extra installed raises a clear error telling you which extra to install.

Large data files

A few problems use large data (the SVM dataset, the MOPTA08 and Mazda binaries). These are not shipped in the package; they are downloaded on first use to ~/.cache/bocode (override with BOCODE_CACHE_DIR) and verified by checksum. Set BOCODE_DATA_BASE_URL to point at a mirror if needed.

🔍 Example Usage

Problems are accessed by name (flat API) or via the registry:

import bocode
import torch

# List and filter problems by metadata
bocode.list_problems(application="Engineering")
bocode.list_problems(num_objectives=2, constrained=True)

# Instantiate by name (both forms are equivalent)
problem = bocode.Car()
problem = bocode.get_problem("Car")()

# Inspect metadata
meta = bocode.get_metadata("Car")  # dim, #obj, #constraints, bounds, source, ...

# Evaluate
x = torch.rand(5, problem.dim)
x = problem.scale(x)  # map [0, 1] samples into the problem bounds
values, constraints = problem.evaluate(x)
print("feasible:", (constraints <= 0).all(dim=1))

Convenience selectors for algorithm benchmarking:

bocode.get_single_objective_unconstrained()
bocode.get_single_objective_constrained()
bocode.get_multi_objective_unconstrained()
bocode.get_multi_objective_constrained()

Materials problems are discrete dataset-lookup problems — optimize over the measured candidate set:

p = bocode.AgNP()
values, _ = p.evaluate(p.candidates[:10])  # measured objective of those candidates

The old bocode.Engineering.Car namespace still works but emits a DeprecationWarning; prefer bocode.Car / bocode.get_problem("Car").

🧮 Algorithms

algorithms/ holds 31 single-file, CleanRL-style optimization baselines (27 Bayesian-optimization algorithms and 4 evolutionary baselines) organized by optimization class: GP-UCB, GP-LogEI, TuRBO, BAxUS, Vanilla-HD-BO, Standard-GP, CEI, SCBO, Penalty, CLF-CBO, qNEHVI, qNParEGO, MESMO, DGEMO, NSGA-II, SPEA2 and their constrained counterparts, mixed-variable methods (PR, Bounce, Casmopolitan, HEBO, BODi), and surrogate-swapped variants (RF, TabPFN, TabICL) of the UCB/TuRBO/SCBO families. This is research code, separate from the installable package. See algorithms/README.md.

🛠️ Development

mamba create -n bocode python=3.12 -y
mamba run -n bocode pip install -e ".[all]" pytest pytest-cov ruff
mamba run -n bocode pytest tests/        # smoke test skips problems whose extra is absent

Regenerate the registry, metadata, and categorization table after adding a problem:

python tools/generate_registry.py
python tools/generate_metadata.py
python tools/render_categorization.py

We welcome contributions! New problems should be real-world problems with a cited source, one file per problem, following the existing """Sources: ...""" docstring convention.

Citing

@misc{yu2025bocode,
    author={Rosen Ting-Ying Yu, Christophe Hatterer, Advaith Narayanan, Cyril Picard, Faez Ahmed},
    title = {{BOCoDe}: Benchmarks for Optimization and Computational Design},
    year={2025},
    url={https://github.com/rosenyu304/BOCoDe}
}

If you use a BOCoDe problem derived from another library or paper (BoTorch, MODAct, LassoBench, the PV-Lab materials datasets, the CEC2020 / RE suites, …), please also cite that source — each problem records its citation in its docstring and metadata.

License

BOCoDe is MIT licensed, as found in LICENSE.

Metadata

Release files for bocode 1.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for bocode 1.0.1
File Size Uploaded Provenance Actions
bocode-1.0.1.tar.gz 47.4 MB With provenance Details for bocode-1.0.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for bocode 1.0.1
File Interpreter ABI Platform Actions
bocode-1.0.1-py3-none-any.whl Python 3 none any Details for bocode-1.0.1-py3-none-any.whl

Total release size: 92.8 MB

Release files / bocode-1.0.1.tar.gz

Download URL bocode-1.0.1.tar.gz
Size 47.4 MB
Tags Source
SHA-256 checksum
How to use checksums
fbaf948fccacaf4d453fdde0add2693a7caa78531b12f494e993feb4d1bb6853
BLAKE2b-256 checksum
How to use checksums
66a34e6f5500b92a282c1d21c3b09a32b33e84cfb9776d3f7ab1c5ef70e882ad
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 15, 2026.

Transparency log

Release files / bocode-1.0.1-py3-none-any.whl

Download URL bocode-1.0.1-py3-none-any.whl
Size 45.4 MB
Tags Python 3
SHA-256 checksum
How to use checksums
4d911ebc0f5bc11a64523e83780e3d658b39310d53f3cb0f63dc7da303d14eb7
BLAKE2b-256 checksum
How to use checksums
065b5c335e871f70bf173d0ea4485d03fe43d300288375d82eccf970c80d1f34
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 15, 2026.

Transparency log

Security for bocode 1.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.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for bocode-1.0.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 15, 2026.

Transparency log

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page