Skip to content

Commit

Permalink
Add test verifying output dimension in degenerate case
Browse files Browse the repository at this point in the history
  • Loading branch information
AdrianSosic committed Feb 12, 2025
1 parent d74a113 commit 8c73830
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions test/optim/test_optimize.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,12 @@

import numpy as np
import torch

from botorch.acquisition.acquisition import (
AcquisitionFunction,
OneShotAcquisitionFunction,
)
from botorch.acquisition.analytic import LogExpectedImprovement
from botorch.acquisition.knowledge_gradient import qKnowledgeGradient
from botorch.acquisition.monte_carlo import qExpectedImprovement
from botorch.acquisition.multi_objective.hypervolume_knowledge_gradient import (
Expand Down Expand Up @@ -1147,6 +1149,23 @@ def nlc(x):
),
)

def test_optimize_acqf_all_fixed_features(self):
train_X = torch.rand(3, 2)
train_Y = torch.rand(3, 1)
gp = SingleTaskGP(train_X=train_X, train_Y=train_Y)
gp.eval()
logEI = LogExpectedImprovement(model=gp, best_f=train_Y.max())
bounds = torch.stack([torch.zeros(2), torch.ones(2)])
_, acqf_value = optimize_acqf(
logEI,
bounds,
q=1,
num_restarts=1,
raw_samples=1,
fixed_features={0: 0, 1: 0},
)
self.assertEqual(acqf_value.ndim, 0)

def test_constraint_caching(self):
def nlc(x):
return 4 - x.sum(dim=-1)
Expand Down

0 comments on commit 8c73830

Please sign in to comment.