Skip to content

Commit f1fca01

Browse files
saitcakmakfacebook-github-bot
authored andcommitted
Clarify is_non_dominated behavior with NaN (#2332)
Summary: Pull Request resolved: #2332 Since `<=` & `>=` always evaluate to False with NaN elements of tensors, this counts NaNs as dominated point, which is the desired behavior. Reviewed By: Balandat Differential Revision: D56945207 fbshipit-source-id: c439ac75c762980bc0035f70cd925377d28157e2
1 parent dd6ef71 commit f1fca01

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

botorch/utils/multi_objective/pareto.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ def is_non_dominated(
3030
3131
Args:
3232
Y: A `(batch_shape) x n x m`-dim tensor of outcomes.
33+
If any element of `Y` is NaN, the corresponding point
34+
will be treated as a dominated point (returning False).
3335
maximize: If True, assume maximization (default).
3436
deduplicate: A boolean indicating whether to only return
3537
unique points on the pareto frontier.

test/utils/multi_objective/test_pareto.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,13 @@ def test_is_non_dominated(self) -> None:
158158
cargs = mock_is_non_dominated_loop.call_args[0]
159159
self.assertTrue(torch.equal(cargs[0], y))
160160

161+
def test_is_non_dominated_with_nan(self) -> None:
162+
# NaN should always evaluate to False.
163+
Y = torch.rand(10, 2)
164+
Y[3, 1] = float("nan")
165+
Y[7, 0] = float("nan")
166+
self.assertFalse(is_non_dominated(Y)[[3, 7]].any())
167+
161168
def test_is_non_dominated_loop(self):
162169
n = 20
163170
tkwargs = {"device": self.device}

0 commit comments

Comments
 (0)