Skip to content

Commit

Permalink
Limit surrogate access to single untransformed targets
Browse files Browse the repository at this point in the history
  • Loading branch information
AdrianSosic committed Sep 4, 2024
1 parent 68ec6b9 commit 29e16cb
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions baybe/campaign.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

from baybe.exceptions import IncompatibilityError
from baybe.objectives.base import Objective, to_objective
from baybe.objectives.single import SingleTargetObjective
from baybe.parameters.base import Parameter
from baybe.recommenders.base import RecommenderProtocol
from baybe.recommenders.meta.base import MetaRecommender
Expand All @@ -27,6 +28,7 @@
from baybe.serialization import SerialMixin, converter
from baybe.surrogates.base import SurrogateProtocol
from baybe.targets.base import Target
from baybe.targets.numerical import NumericalTarget
from baybe.telemetry import (
TELEM_LABELS,
telemetry_record_recommended_measurement_percentage,
Expand Down Expand Up @@ -308,6 +310,18 @@ def get_surrogate(self) -> SurrogateProtocol:
Returns:
Surrogate: The surrogate of the current recommender.
"""
# TODO: remove temporary restriction when target transformations can be handled
match self.objective:
case SingleTargetObjective(
_target=NumericalTarget(bounds=b)
) if not b.is_bounded:
pass
case _:
raise NotImplementedError(
"Surrogate model access is currently only supported for a single "
"untransformed target."
)

if self.objective is None:
raise IncompatibilityError(
f"No surrogate is available since no '{Objective.__name__}' is defined."
Expand Down

0 comments on commit 29e16cb

Please sign in to comment.