diff --git a/botorch/optim/homotopy.py b/botorch/optim/homotopy.py index c6b5534f50..20f8f52735 100644 --- a/botorch/optim/homotopy.py +++ b/botorch/optim/homotopy.py @@ -20,29 +20,24 @@ class HomotopySchedule(ABC): @abstractmethod def num_steps(self) -> int: """Number of steps in the schedule.""" - pass @property @abstractmethod def value(self) -> Any: """Current value in the schedule.""" - pass @property @abstractmethod def should_stop(self) -> bool: """Return true if we have incremented past the end of the schedule.""" - pass @abstractmethod def restart(self) -> None: """Restart the schedule to start from the beginning.""" - pass @abstractmethod def step(self) -> None: """Move to solving the next problem.""" - pass class FixedHomotopySchedule(HomotopySchedule): diff --git a/test/optim/test_homotopy.py b/test/optim/test_homotopy.py index cebcb68ea3..ac3cd6142a 100644 --- a/test/optim/test_homotopy.py +++ b/test/optim/test_homotopy.py @@ -7,6 +7,7 @@ import torch from botorch.acquisition import PosteriorMean +from botorch.acquisition.monte_carlo import qExpectedImprovement from botorch.models import GenericDeterministicModel from botorch.optim.homotopy import ( FixedHomotopySchedule, @@ -142,6 +143,20 @@ def test_optimize_acqf_homotopy(self): ) self.assertEqual(candidate[0, 0], torch.tensor(1, **tkwargs)) + # With q > 1. + acqf = qExpectedImprovement(model=model, best_f=0.0) + candidate, acqf_val = optimize_acqf_homotopy( + q=3, + acq_function=acqf, + bounds=torch.tensor([[-10, -10], [5, 5]]).to(**tkwargs), + homotopy=Homotopy(homotopy_parameters=[hp]), + num_restarts=2, + raw_samples=16, + fixed_features=fixed_features, + ) + self.assertEqual(candidate.shape, torch.Size([3, 2])) + self.assertEqual(acqf_val.shape, torch.Size([3])) + def test_prune_candidates(self): tkwargs = {"device": self.device, "dtype": torch.double} # no pruning