Skip to content

Commit 58b651d

Browse files
Bug fix in estimating feasible volume
Summary: Added a special case when outcome constraints are None. Reviewed By: Balandat Differential Revision: D21477628 fbshipit-source-id: 05b1de471cd3ef1beaa64e4a87446530d893f372
1 parent 6f3d599 commit 58b651d

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

botorch/utils/feasible_volume.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ def get_feasible_samples(
4747
feasible = torch.ones(nsamples, device=samples.device, dtype=torch.bool)
4848

4949
for (indices, coefficients, rhs) in inequality_constraints:
50-
feasible &= samples.index_select(1, indices) @ coefficients >= rhs
50+
lhs = samples.index_select(1, indices) @ coefficients.to(dtype=samples.dtype)
51+
feasible &= lhs >= rhs
5152

5253
feasible_samples = samples[feasible]
5354

@@ -82,6 +83,9 @@ def get_outcome_feasibility_probability(
8283
given outcome constraints with probability above or equal to
8384
the given threshold.
8485
"""
86+
if outcome_constraints is None:
87+
return 1.0
88+
8589
from botorch.sampling import SobolQMCNormalSampler
8690

8791
seed = seed if seed is not None else torch.randint(0, 1000000, (1,)).item()

test/utils/test_feasible_volume.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,19 @@ def test_estimate_feasible_volume(self):
6767
outcome_constraints=outcome_constraints,
6868
nsample_feature=2,
6969
nsample_outcome=1,
70+
dtype=dtype,
7071
)
7172

7273
self.assertEqual(p_linear, 1.0)
7374
self.assertEqual(p_outcome, 1.0 - samples[0, 0].item())
75+
76+
p_linear, p_outcome = estimate_feasible_volume(
77+
bounds=bounds,
78+
model=mm,
79+
outcome_constraints=None,
80+
nsample_feature=2,
81+
nsample_outcome=1,
82+
dtype=dtype,
83+
)
84+
self.assertEqual(p_linear, 1.0)
85+
self.assertEqual(p_outcome, 1.0)

0 commit comments

Comments
 (0)