Skip to content

Commit

Permalink
Adding sample_multiplier in EUBO's acqf_input_constructor (#1816)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #1816

Adding `sample_multiplier` in  EUBO's acqf_input_constructor

Reviewed By: Balandat

Differential Revision: D45628367

fbshipit-source-id: cac37ca3fecdb88e1b91caf93198d99c4b7df1dc
  • Loading branch information
ItsMrLin authored and facebook-github-bot committed May 7, 2023
1 parent e622ac4 commit 9746e34
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
8 changes: 6 additions & 2 deletions botorch/acquisition/input_constructors.py
Original file line number Diff line number Diff line change
Expand Up @@ -1041,21 +1041,25 @@ def construct_inputs_analytic_eubo(
model: Model,
pref_model: Model,
previous_winner: Optional[Tensor] = None,
sample_multiplier: Optional[float] = 1.0,
**kwargs: Any,
) -> Dict[str, Any]:
r"""Construct kwargs for the `AnalyticExpectedUtilityOfBestOption` constructor.
Args:
model: The outcome model to be used in the acquisition function.
pref_model: The preference model to be used in preference exploration
pref_model: The preference model to be used in preference exploration.
previous_winner: The previous winner of the best option.
sample_multiplier: The scale factor for the single-sample model.
Returns:
A dict mapping kwarg names of the constructor to values.
"""
# construct a deterministic fixed single sample model from `model`
# i.e., performing EUBO-zeta by default as described
# in https://arxiv.org/abs/2203.11382
one_sample_outcome_model = FixedSingleSampleModel(model=model)
w = torch.randn(model.num_outputs) * sample_multiplier
one_sample_outcome_model = FixedSingleSampleModel(model=model, w=w)

return {
"pref_model": pref_model,
Expand Down
13 changes: 13 additions & 0 deletions test/acquisition/test_input_constructors.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,11 +316,14 @@ def test_construct_inputs_constrained_analytic_eubo(self):
mock_model.num_outputs = 3
mock_model.train_inputs = [None]
mock_pref_model = mock.Mock()

# test basic construction
kwargs = c(model=mock_model, pref_model=mock_pref_model)
self.assertTrue(isinstance(kwargs["outcome_model"], FixedSingleSampleModel))
self.assertTrue(kwargs["pref_model"] is mock_pref_model)
self.assertTrue(kwargs["previous_winner"] is None)

# test previous_winner
previous_winner = torch.randn(3)
kwargs = c(
model=mock_model,
Expand All @@ -329,6 +332,16 @@ def test_construct_inputs_constrained_analytic_eubo(self):
)
self.assertTrue(torch.equal(kwargs["previous_winner"], previous_winner))

# test sample_multiplier
torch.manual_seed(123)
kwargs = c(
model=mock_model,
pref_model=mock_pref_model,
sample_multiplier=1e6,
)
# w by default is drawn from std normal and very unlikely to be > 10.0
self.assertTrue((kwargs["outcome_model"].w.abs() > 10.0).all())


class TestMCAcquisitionFunctionInputConstructors(
InputConstructorBaseTestCase, BotorchTestCase
Expand Down

0 comments on commit 9746e34

Please sign in to comment.