From 3eee04ecbd8bde4fa0c42c5f942452f950311598 Mon Sep 17 00:00:00 2001 From: y0z Date: Mon, 16 Dec 2024 20:24:00 +0900 Subject: [PATCH] Update --- .../benchmarks/bbob_constrained/_bbob_constrained.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/package/benchmarks/bbob_constrained/_bbob_constrained.py b/package/benchmarks/bbob_constrained/_bbob_constrained.py index cee5429..e29c10a 100644 --- a/package/benchmarks/bbob_constrained/_bbob_constrained.py +++ b/package/benchmarks/bbob_constrained/_bbob_constrained.py @@ -1,7 +1,6 @@ from __future__ import annotations from typing import Any -from typing import Sequence import cocoex as ex import optuna @@ -49,10 +48,10 @@ def __init__(self, function_id: int, dimension: int, instance_id: int = 1): @property def search_space(self) -> dict[str, optuna.distributions.BaseDistribution]: """Return the search space.""" - return self._search_space + return self._search_space.copy() @property - def directions(self) -> Sequence[optuna.study.StudyDirection]: + def directions(self) -> list[optuna.study.StudyDirection]: """Return the optimization directions.""" return [optuna.study.StudyDirection.MINIMIZE] @@ -66,9 +65,9 @@ def evaluate(self, params: dict[str, float]) -> float: The objective value. """ - return self._problem(list(params.values())) + return self._problem([params[name] for name in self._search_space]) - def evaluate_constraints(self, params: dict[str, float]) -> Sequence[float]: + def evaluate_constraints(self, params: dict[str, float]) -> list[float]: """Evaluate the constraint functions. Args: params: @@ -78,7 +77,7 @@ def evaluate_constraints(self, params: dict[str, float]) -> Sequence[float]: The constraint functions values. """ - return self._problem.constraint(list(params.values())).tolist() + return self._problem.constraint([params[name] for name in self._search_space]) def __getattr__(self, name: str) -> Any: return getattr(self._problem, name)