Skip to content

Commit

Permalink
Fix non-None constraint noise levels in some constrained test problems (
Browse files Browse the repository at this point in the history
#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
  • Loading branch information
Balandat authored and facebook-github-bot committed Mar 8, 2024
1 parent 520468e commit e68efb5
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions botorch/test_functions/synthetic.py
Original file line number Diff line number Diff line change
Expand Up @@ -848,12 +848,12 @@ def __init__(
negate: If True, negate the function.
bounds: Custom bounds for the function specified as (lower, upper) pairs.
"""
self.constraint_noise_std = self._validate_constraint_noise(
constraint_noise_std
)
SyntheticTestFunction.__init__(
self, noise_std=noise_std, negate=negate, bounds=bounds
)
self.constraint_noise_std = self._validate_constraint_noise(
constraint_noise_std
)

def _validate_constraint_noise(
self, constraint_noise_std
Expand Down Expand Up @@ -939,10 +939,12 @@ def __init__(
negate: If True, negate the function.
bounds: Custom bounds for the function specified as (lower, upper) pairs.
"""
self._validate_constraint_noise(constraint_noise_std)
Hartmann.__init__(
self, dim=dim, noise_std=noise_std, negate=negate, bounds=bounds
)
self.constraint_noise_std = self._validate_constraint_noise(
constraint_noise_std
)

def evaluate_slack_true(self, X: Tensor) -> Tensor:
return -X.norm(dim=-1, keepdim=True) + 1
Expand Down Expand Up @@ -975,10 +977,12 @@ def __init__(
negate: If True, negate the function.
bounds: Custom bounds for the function specified as (lower, upper) pairs.
"""
self._validate_constraint_noise(constraint_noise_std)
Hartmann.__init__(
self, dim=dim, noise_std=noise_std, negate=negate, bounds=bounds
)
self.constraint_noise_std = self._validate_constraint_noise(
constraint_noise_std
)

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

0 comments on commit e68efb5

Please sign in to comment.