Skip to content

Commit a956077

Browse files
SebastianAmentfacebook-github-bot
authored andcommitted
Removing soft_eval_constraints
Summary: `soft_eval_constraints` has been deprecated for 7 months. This commit removed the function before the next BoTorch release. Reviewed By: Balandat Differential Revision: D54207128 fbshipit-source-id: 07f1bef38990ddf97058a564dec6d7e0d64e46f4
1 parent 02e8014 commit a956077

File tree

2 files changed

+0
-38
lines changed

2 files changed

+0
-38
lines changed

botorch/utils/objective.py

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010

1111
from __future__ import annotations
1212

13-
import warnings
14-
1513
from typing import Callable, List, Optional, Union
1614

1715
import torch
@@ -182,32 +180,6 @@ def compute_smoothed_feasibility_indicator(
182180
return is_feasible if log else is_feasible.exp()
183181

184182

185-
# TODO: deprecate this function
186-
def soft_eval_constraint(lhs: Tensor, eta: float = 1e-3) -> Tensor:
187-
r"""Element-wise evaluation of a constraint in a 'soft' fashion
188-
189-
`value(x) = 1 / (1 + exp(x / eta))`
190-
191-
Args:
192-
lhs: The left hand side of the constraint `lhs <= 0`.
193-
eta: The temperature parameter of the softmax function. As eta
194-
decreases, this approximates the Heaviside step function.
195-
196-
Returns:
197-
Element-wise 'soft' feasibility indicator of the same shape as `lhs`.
198-
For each element `x`, `value(x) -> 0` as `x` becomes positive, and
199-
`value(x) -> 1` as x becomes negative.
200-
"""
201-
warnings.warn(
202-
"`soft_eval_constraint` is deprecated. Please consider `torch.utils.sigmoid` "
203-
+ "with its `fat` and `log` options to compute feasibility indicators.",
204-
DeprecationWarning,
205-
)
206-
if eta <= 0:
207-
raise ValueError("eta must be positive.")
208-
return torch.sigmoid(-lhs / eta)
209-
210-
211183
def apply_constraints(
212184
obj: Tensor,
213185
constraints: List[Callable[[Tensor], Tensor]],

test/utils/test_objective.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
from botorch.utils.objective import (
1111
compute_feasibility_indicator,
1212
compute_smoothed_feasibility_indicator,
13-
soft_eval_constraint,
1413
)
1514
from botorch.utils.testing import BotorchTestCase
1615
from torch import Tensor
@@ -75,15 +74,6 @@ def test_apply_constraints(self):
7574
eta=0.0,
7675
)
7776

78-
# soft_eval_constraint is not in the path of apply_constraints, adding this test
79-
# for coverage.
80-
with self.assertRaisesRegex(ValueError, "eta must be positive."):
81-
soft_eval_constraint(lhs=obj, eta=0.0)
82-
ind = soft_eval_constraint(lhs=ones_f(samples), eta=1e-6)
83-
self.assertAllClose(ind, torch.zeros_like(ind))
84-
ind = soft_eval_constraint(lhs=-ones_f(samples), eta=1e-6)
85-
self.assertAllClose(ind, torch.ones_like(ind))
86-
8777
def test_apply_constraints_multi_output(self):
8878
# nonnegative objective, one constraint
8979
tkwargs = {"device": self.device}

0 commit comments

Comments
 (0)