Skip to content

Commit

Permalink
Improve seq greedy error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
Scienfitz committed Apr 28, 2024
1 parent 81b422a commit 6b4be22
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions baybe/recommenders/pure/bayesian/sequential_greedy.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,19 +68,20 @@ def _recommend_discrete(
) -> pd.Index:
# See base class.

# For batch size > 1, this optimizer need a MC acquisition function
if batch_size > 1 and not self.acquisition_function.is_mc:
raise NoMCAcquisitionFunctionError(
f"The '{self.__class__.__name__}' only works with Monte Carlo "
f"acquisition functions for batch sizes > 1."
)

from botorch.optim import optimize_acqf_discrete

# determine the next set of points to be tested
candidates_tensor = to_tensor(candidates_comp)
try:
points, _ = optimize_acqf_discrete(
self._botorch_acqf, batch_size, candidates_tensor
)
except AttributeError as ex:
raise NoMCAcquisitionFunctionError(
f"The '{self.__class__.__name__}' only works with Monte Carlo "
f"acquisition functions for batch sizes > 1."
) from ex
points, _ = optimize_acqf_discrete(
self._botorch_acqf, batch_size, candidates_tensor
)

# retrieve the index of the points from the input dataframe
# IMPROVE: The merging procedure is conceptually similar to what
Expand Down

0 comments on commit 6b4be22

Please sign in to comment.