Skip to main content

BBOBax: Accelerated Black-Box Optimization Benchmark.

Project description

BBOBax

Accelerated Black-Box Optimization Benchmark in JAX.

PyPI - Python Version PyPI - Version JAX

A high-performance reimplementation of the COCO (COmparing Continuous Optimizers) test suite in JAX. BBOBax allows for massive parallelization of function evaluations on hardware accelerators (GPUs/TPUs), enabling efficient benchmarking of black-box optimization algorithms.

Features

  • JAX-based: Fully differentiable (where applicable) and JIT-compilable.
  • Hardware Acceleration: Run benchmarks on GPUs and TPUs for massive speedups.
  • Standard BBOB: Includes standard single-objective BBOB functions (noiseless).
  • Noise Support: Configurable noise models (Gaussian, Uniform, Cauchy, etc.) for robust optimization benchmarking.
  • Quality-Diversity (QD): Support for Quality-Diversity benchmarks with customizable descriptor functions.
  • Flexible API: Easy integration with existing JAX-based evolutionary computation libraries (e.g., EvoJAX, evosax).

Installation

We recommend using uv for a fast and reliable installation, but standard pip is also supported.

Using uv (Recommended)

# Clone the repository
git clone https://github.com/maxencefaldor/bbobax.git
cd bbobax

# Create a virtual environment
uv venv
source .venv/bin/activate

# Install dependencies and the package in editable mode
uv pip install -e .

Using pip

pip install bbobax
# Or install from source
pip install -e .

Note on JAX: You may need to install the specific version of JAX compatible with your CUDA/cuDNN version. Please refer to the JAX installation guide for details.

Usage

Basic BBOB Example

Here is a minimal example of how to initialize a BBOB task, sample a problem instance, and evaluate a solution.

import jax
from bbobax import BBOB

# Initialize BBOB task with default functions
bbob = BBOB.create_default(min_num_dims=2, max_num_dims=10)

# Sample a task instance (function ID, dimensions, optimal values, etc.)
key = jax.random.key(0)
key_task, key_init, key_eval, key_x = jax.random.split(key, 4)
task_params = bbob.sample(key_task)

# Initialize internal state (e.g., rotation matrices)
state = bbob.init(key_init, task_params)

# Sample a random solution in the search space
x = bbob.sample_x(key_x)

# Evaluate the solution
# Returns updated state and evaluation metrics (fitness)
state, eval_metrics = bbob.evaluate(key_eval, x, state, task_params)

print(f"Function ID: {task_params.fn_id}")
print(f"Dimensions: {task_params.num_dims}")
print(f"Fitness: {eval_metrics.fitness}")

Quality-Diversity (QD) Example

BBOBax also supports Quality-Diversity optimization tasks where solutions are evaluated based on both fitness and a behavior descriptor.

import jax
from bbobax import QDBBOB, bbob_fns, get_random_projection_descriptor

# Define descriptor functions (e.g., random projection)
descriptor_fns = [get_random_projection_descriptor]

# Initialize QD-BBOB task
qd_bbob = QDBBOB(
    descriptor_fns=descriptor_fns,
    fitness_fns=bbob_fns,
    descriptor_size=2,
    min_num_dims=10, 
    max_num_dims=10
)

# Sample task
key = jax.random.key(42)
key_task, key_init, key_eval, key_x = jax.random.split(key, 4)
task_params = qd_bbob.sample(key_task)

# Initialize state
state = qd_bbob.init(key_init, task_params)

# Sample solution
x = qd_bbob.sample_x(key_x)

# Evaluate
state, eval_metrics = qd_bbob.evaluate(key_eval, x, state, task_params)

print(f"Fitness: {eval_metrics.fitness}")
print(f"Descriptor: {eval_metrics.descriptor}")

Documentation

Full documentation is available at https://maxencefaldor.github.io/bbobax/.

To build the documentation locally:

# Install documentation dependencies
uv pip install -e ".[docs]"

# Serve the documentation
mkdocs serve

Citation

If you use BBOBax in your research, please cite it using the following metadata:

title: "BBOBax"
abstract: "BBOBax: Accelerated Black-Box Optimization Benchmark in JAX."
authors:
  - family-names: "Faldor"
    given-names: "Maxence"
    orcid: "https://orcid.org/0000-0003-4743-9494"
repository-code: "https://github.com/maxencefaldor/bbobax"
type: software

References

This library is built upon the standard BBOB function definitions. Please verify the details in the provided documentation:

  • Noiseless Functions: Hansen, N., Finck, S., Ros, R., & Auger, A. (2009). Real-parameter black-box optimization benchmarking 2009: Noiseless functions definitions. PDF
  • Noisy Functions: Hansen, N., Finck, S., Ros, R., & Auger, A. (2009). Real-parameter black-box optimization benchmarking 2009: Noisy functions definitions. PDF

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

bbobax-0.1.0.tar.gz (32.3 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

bbobax-0.1.0-py3-none-any.whl (13.9 kB view details)

Uploaded Python 3

File details

Details for the file bbobax-0.1.0.tar.gz.

File metadata

  • Download URL: bbobax-0.1.0.tar.gz
  • Upload date:
  • Size: 32.3 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.8

File hashes

Hashes for bbobax-0.1.0.tar.gz
Algorithm Hash digest
SHA256 41b30749e493a1715cc95d24b1b024e5fd4344bcbdba1079379791dceb87c97c
MD5 f52c05c75e8f8adede78e301160eff57
BLAKE2b-256 31e3d2163df38081d57a81412065c1bfedd1fb764b49fa7c96678c5016134ebb

See more details on using hashes here.

File details

Details for the file bbobax-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: bbobax-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 13.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.8

File hashes

Hashes for bbobax-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a604a6318d35c5202bdb4b8dbbebb4002f21295c582eec37c2b05a32da28ed10
MD5 9e7950c5973729212f8b466a771d8ba4
BLAKE2b-256 5be34223651dec409e698a6b15a70ba08502c25dd25995ed75b2f3d32af6a90d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page