import typing as t
from pydantic import BaseModel
[docs]
class OptunaIntParamDC(BaseModel):
"""
Configuration for an integer parameter in Optuna.
Parameters
----------
type : int
Type identifier.
low : int
Lower bound of the range.
high : int
Upper bound of the range.
step : int, optional
Step size. Defaults to 1.
"""
type: int
low: int
high: int
step: int = 1
[docs]
class OptunaFloatParamDC(BaseModel):
"""
Configuration for a floating-point parameter in Optuna.
Parameters
----------
type : int
Type identifier.
low : float
Lower bound of the range.
high : float
Upper bound of the range.
"""
type: int
low: float
high: float
[docs]
class OptunaLogParamDC(BaseModel):
"""
Configuration for a logarithmic floating-point parameter in Optuna.
Parameters
----------
type : int
Type identifier.
low : float
Lower bound of the range.
high : float
Upper bound of the range.
"""
type: int
low: float
high: float
[docs]
class OptunaCatParamDC(BaseModel):
"""
Configuration for a categorical parameter in Optuna.
Parameters
----------
type : int
Type identifier.
vals : list
List of possible values.
"""
type: int
vals: t.List
OPTUNA_PARAM_DTYPE = t.Union[
None,
int,
float,
str,
OptunaIntParamDC,
OptunaFloatParamDC,
OptunaLogParamDC,
OptunaCatParamDC
]
[docs]
class OptunaConfigDC(BaseModel):
"""
Configuration for an Optuna study.
Parameters
----------
objectives : dict
Definition of objectives.
optimize : dict
Optimization settings.
parameters : dict
Dictionary of parameter configurations.
"""
objectives: t.Dict
optimize: t.Dict
parameters: t.Dict[str, OPTUNA_PARAM_DTYPE]