File tree Expand file tree Collapse file tree 2 files changed +0
-38
lines changed Expand file tree Collapse file tree 2 files changed +0
-38
lines changed Original file line number Diff line number Diff line change 1010
1111from __future__ import annotations
1212
13- import warnings
14-
1513from typing import Callable , List , Optional , Union
1614
1715import 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-
211183def apply_constraints (
212184 obj : Tensor ,
213185 constraints : List [Callable [[Tensor ], Tensor ]],
Original file line number Diff line number Diff line change 1010from botorch .utils .objective import (
1111 compute_feasibility_indicator ,
1212 compute_smoothed_feasibility_indicator ,
13- soft_eval_constraint ,
1413)
1514from botorch .utils .testing import BotorchTestCase
1615from 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 }
You can’t perform that action at this time.
0 commit comments