Skip to main content

BBOB torch

Implementation of BBOB functions (Real-Parameter Black-Box Optimization Benchmarking) as specified by https://coco.gforge.inria.fr/downloads/download16.00/bbobdocfunctions.pdf.

All the functions are vectorized and allow to pass potentional solutions in the same (num_of_solutions, problem_dimension).

Problem description

All the problems are represented by Problem class. This class allows to:

  • Evaluate your solutions by directly calling it problem(solutions).
  • Get problem dimension problem.dim.
  • Get optimal solution resp. optimal function value using problem.x_opt resp. problem.f_opt.
  • Get boundaries of solution using problem.min resp. problem.max for each dimension.
  • Change underlying type or device using problem.type(torch.float16) and problem.ty(torch.device('cuda:0')).

Problem creation

You can create new instance of each problem by calling corresponding create_fxx function. This function accepts problem dimension and can optionally accept device and seed.

import torch
import bbobtorch
problem = bbobtorch.create_f09(40, dev=torch.device('cuda:0'), seed=42)

Example

import matplotlib.pyplot as plt
import numpy as np
import torch
import bbobtorch

x = torch.arange(-5,5, 0.01, dtype=torch.float32)
grid = torch.stack(torch.meshgrid(x, x), -1)
flat_grid = torch.reshape(grid, (-1,2))
xgrid, ygrid = np.meshgrid(x.numpy(), x.numpy())

fn = bbobtorch.create_f22(2, seed=42)  # two dimension with seed 42
results = fn(flat_grid)
results_grid = torch.reshape(results, xgrid.shape) - fn.f_opt

plt.figure(figsize=(6,6))
plt.pcolormesh(xgrid, ygrid, results_grid, cmap='inferno', shading='nearest')
plt.scatter(*fn.x_opt.tolist()[::-1], marker='x', c='r')
plt.show()

BBOB f22 graph

You can view all the functions in attached PDF.


Author: Patrik Valkovič

License: MIT

Release files for BBOBtorch 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 BBOBtorch 1.0.1
File Size Uploaded
BBOBtorch-1.0.1.tar.gz 6.4 kB Details

Built distribution (wheel)

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

Total release size: 14.3 kB

Release files / BBOBtorch-1.0.1.tar.gz

Download URL BBOBtorch-1.0.1.tar.gz
Size 6.4 kB
Tags Source
SHA-256 checksum
How to use checksums
6718631a3d0fe6944b339610ce772a1235f4c83410e8005dec3f04a863fe2c6b
BLAKE2b-256 checksum
How to use checksums
75dfb963ca8d475c9ad6d191443b3804d4112e8d930e02c40ec1e39eac77ab3e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/54.0.0 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.8.8

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

Download URL BBOBtorch-1.0.1-py3-none-any.whl
Size 7.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3fe277d706546e2a8597f0443266841fc175b73a3191344f3feb8c78040a3bb4
BLAKE2b-256 checksum
How to use checksums
99322abfa0aa45e7858988070463bb9214aa84e47ff8d53fbee5ebade692aabc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/54.0.0 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.8.8

Release history Release notifications | RSS feed

This release

1.0.1 This release

2 release files

1.0.0

2 release files

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