From 4fdd6878d0559617f18f34f9b64ed22af43c14f3 Mon Sep 17 00:00:00 2001 From: AdrianSosic Date: Wed, 22 Jan 2025 14:19:30 +0100 Subject: [PATCH] Move inversion step to right context Not all MC acquisitions functions use best_f (e.g. qUCB), causing a KeyError in these cases --- baybe/acquisition/base.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/baybe/acquisition/base.py b/baybe/acquisition/base.py index 913a8e1a4..cec7c1d92 100644 --- a/baybe/acquisition/base.py +++ b/baybe/acquisition/base.py @@ -111,11 +111,12 @@ def to_botorch( additional_params["best_f"] = ( bo_surrogate.posterior(train_x).mean.min().item() ) + if self.is_mc: + additional_params["best_f"] *= -1.0 if issubclass(acqf_cls, bo_acqf.AnalyticAcquisitionFunction): additional_params["maximize"] = False - elif issubclass(acqf_cls, bo_acqf.MCAcquisitionFunction): - additional_params["best_f"] *= -1.0 + elif self.is_mc: additional_params["objective"] = LinearMCObjective( torch.tensor([-1.0]) )