Skip to content

Commit e68efb5

Browse files
Balandatfacebook-github-bot
authored andcommitted
Fix non-None constraint noise levels in some constrained test problems (#2241)
Summary: This was inadvertently overridden / nnot properly set in some constructors. We currently don't properly test that this attribute is correctly assigned upon instantiation. It's not straightforward to figure out how to easily do this in the current test setup; we can figure that out in a follow-up. Pull Request resolved: #2241 Reviewed By: SebastianAment Differential Revision: D54669269 Pulled By: Balandat fbshipit-source-id: 18248c3851b1235a98f08389215e8e5cc5ffbe74
1 parent 520468e commit e68efb5

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

botorch/test_functions/synthetic.py

+9-5
Original file line numberDiff line numberDiff line change
@@ -848,12 +848,12 @@ def __init__(
848848
negate: If True, negate the function.
849849
bounds: Custom bounds for the function specified as (lower, upper) pairs.
850850
"""
851-
self.constraint_noise_std = self._validate_constraint_noise(
852-
constraint_noise_std
853-
)
854851
SyntheticTestFunction.__init__(
855852
self, noise_std=noise_std, negate=negate, bounds=bounds
856853
)
854+
self.constraint_noise_std = self._validate_constraint_noise(
855+
constraint_noise_std
856+
)
857857

858858
def _validate_constraint_noise(
859859
self, constraint_noise_std
@@ -939,10 +939,12 @@ def __init__(
939939
negate: If True, negate the function.
940940
bounds: Custom bounds for the function specified as (lower, upper) pairs.
941941
"""
942-
self._validate_constraint_noise(constraint_noise_std)
943942
Hartmann.__init__(
944943
self, dim=dim, noise_std=noise_std, negate=negate, bounds=bounds
945944
)
945+
self.constraint_noise_std = self._validate_constraint_noise(
946+
constraint_noise_std
947+
)
946948

947949
def evaluate_slack_true(self, X: Tensor) -> Tensor:
948950
return -X.norm(dim=-1, keepdim=True) + 1
@@ -975,10 +977,12 @@ def __init__(
975977
negate: If True, negate the function.
976978
bounds: Custom bounds for the function specified as (lower, upper) pairs.
977979
"""
978-
self._validate_constraint_noise(constraint_noise_std)
979980
Hartmann.__init__(
980981
self, dim=dim, noise_std=noise_std, negate=negate, bounds=bounds
981982
)
983+
self.constraint_noise_std = self._validate_constraint_noise(
984+
constraint_noise_std
985+
)
982986

983987
def evaluate_slack_true(self, X: Tensor) -> Tensor:
984988
return -X.pow(2).sum(dim=-1, keepdim=True) + 1

0 commit comments

Comments
 (0)