Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
y0z committed Dec 16, 2024
1 parent 165cc97 commit 3eee04e
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions package/benchmarks/bbob_constrained/_bbob_constrained.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from __future__ import annotations

from typing import Any
from typing import Sequence

import cocoex as ex
import optuna
Expand Down Expand Up @@ -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]

Expand All @@ -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:
Expand All @@ -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)
Expand Down

0 comments on commit 3eee04e

Please sign in to comment.