|
1 | | -from typing import Literal |
| 1 | +from typing import Literal, Optional, Type |
2 | 2 |
|
| 3 | +from pydantic import Field |
| 4 | + |
| 5 | +from bofire.data_models.features.api import AnyOutput |
| 6 | +from bofire.data_models.features.continuous import ContinuousOutput |
3 | 7 | from bofire.data_models.kernels.api import InfiniteWidthBNNKernel |
4 | | -from bofire.data_models.surrogates.single_task_gp import BaseSingleTaskGPSurrogate |
| 8 | +from bofire.data_models.priors.api import HVARFNER_NOISE_PRIOR, AnyPrior |
| 9 | +from bofire.data_models.surrogates.single_task_gp import TrainableBotorchSurrogate |
| 10 | +from bofire.data_models.surrogates.trainable import Hyperconfig |
5 | 11 |
|
6 | 12 |
|
7 | | -class SingleTaskIBNNSurrogate(BaseSingleTaskGPSurrogate[InfiniteWidthBNNKernel]): |
| 13 | +class SingleTaskIBNNSurrogate(TrainableBotorchSurrogate): |
8 | 14 | type: Literal["SingleTaskIBNNSurrogate"] = "SingleTaskIBNNSurrogate" |
| 15 | + kernel: InfiniteWidthBNNKernel = InfiniteWidthBNNKernel() |
| 16 | + hyperconfig: Optional[Hyperconfig] = None |
| 17 | + noise_prior: AnyPrior = Field(default_factory=lambda: HVARFNER_NOISE_PRIOR()) |
| 18 | + |
| 19 | + @classmethod |
| 20 | + def is_output_implemented(cls, my_type: Type[AnyOutput]) -> bool: |
| 21 | + """Abstract method to check output type for surrogate models |
| 22 | + Args: |
| 23 | + my_type: continuous or categorical output |
| 24 | + Returns: |
| 25 | + bool: True if the output type is valid for the surrogate chosen, False otherwise |
| 26 | + """ |
| 27 | + return isinstance(my_type, type(ContinuousOutput)) |
| 28 | + |
| 29 | + @property |
| 30 | + def hyperconfig_access(self) -> Optional[Hyperconfig]: |
| 31 | + return self.hyperconfig |
0 commit comments