Abstract
This package provides a wrapper of the COCO experiments libarary’s bbob-constrained test suite.
APIs
class Problem(function_id: int, dimension: int, instance_id: int = 1)
function_id
: ID of the bbob-constrained benchmark function to use. It must be in the range of[1, 54]
.dimension
: Dimension of the benchmark function. It must be in[2, 3, 5, 10, 20, 40]
.instance_id
: ID of the instance of the benchmark function. It must be in the range of[1, 15]
.
Methods and Properties
search_space
: Return the search space.- Returns:
dict[str, optuna.distributions.BaseDistribution]
- Returns:
directions
: Return the optimization directions.- Returns:
list[optuna.study.StudyDirection]
- Returns:
__call__(trial: optuna.Trial)
: Evaluate the objective function and return the objective value.- Args:
trial
: Optuna trial object.
- Returns:
float
- Args:
evaluate(params: dict[str, float])
: Evaluate the objective function and return the objective value.- Args:
params
: Decision variable like{"x0": x1_value, "x1": x1_value, ..., "xn": xn_value}
. The number of parameters must be equal todimension
.
- Returns:
float
- Args:
constraints_func(trial: optuna.Trial.FrozenTrial)
: Evaluate the constraint functions and return the list of constraint functions values.- Args:
trial
: Optuna trial object.
- Returns:
list[float]
- Args:
evaluate_constraints(params: dict[str, float])
: Evaluate the constraint functions and return the list of constraint functions values.- Args:
params
: Decision variable like{"x0": x1_value, "x1": x1_value, ..., "xn": xn_value}
. The number of parameters must be equal todimension
.
- Returns:
list[float]
- Args:
The properties defined by cocoex.Problem are also available such as number_of_objectives
.
Installation
Please install the coco-experiment package.
pip install -U coco-experiment
Example
import optuna
import optunahub
bbob_constrained = optunahub.load_module("benchmarks/bbob_constrained")
constrained_sphere2d = bbob_constrained.Problem(function_id=1, dimension=2, instance_id=1)
study = optuna.create_study(
sampler=optuna.samplers.TPESampler(
constraints_func=constrained_sphere2d.constraints_func
),
directions=constrained_sphere2d.directions
)
study.optimize(constrained_sphere2d, n_trials=20)
try:
print(study.best_trial.params, study.best_trial.value)
except Exception as e:
print(e)
Details of Benchmark Functions
Please refer to the paper for details about each benchmark function.
Reference
Paul Dufossé, Nikolaus Hansen, Dimo Brockhoff, Phillipe R. Sampaio, Asma Atamna, and Anne Auger. Building scalable test problems for benchmarking constrained optimizers. 2022. To be submitted to the SIAM Journal of Optimization.
- Package
- benchmarks/bbob_constrained
- Author
- Optuna team
- License
- MIT License
- Verified Optuna version
- 4.1.0
- Last update
- 2025-01-21