Skip to content

Commit

Permalink
Clarify is_non_dominated behavior with NaN
Browse files Browse the repository at this point in the history
Summary: Since `<=` & `>=` always evaluate to False with NaN elements of tensors, this counts NaNs as dominated point, which is the desired behavior.

Differential Revision: D56945207
  • Loading branch information
saitcakmak authored and facebook-github-bot committed May 3, 2024
1 parent dd6ef71 commit 10a9348
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
2 changes: 2 additions & 0 deletions botorch/utils/multi_objective/pareto.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ def is_non_dominated(
Args:
Y: A `(batch_shape) x n x m`-dim tensor of outcomes.
If any element of `Y` is NaN, the corresponding point
will be treated as a dominated point (returning False).
maximize: If True, assume maximization (default).
deduplicate: A boolean indicating whether to only return
unique points on the pareto frontier.
Expand Down
7 changes: 7 additions & 0 deletions test/utils/multi_objective/test_pareto.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,13 @@ def test_is_non_dominated(self) -> None:
cargs = mock_is_non_dominated_loop.call_args[0]
self.assertTrue(torch.equal(cargs[0], y))

def test_is_non_dominated_with_nan(self) -> None:
# NaN should always evaluate to False.
Y = torch.rand(10, 2)
Y[3, 1] = float("nan")
Y[7, 0] = float("nan")
self.assertFalse(is_non_dominated(Y)[[3, 7]].any())

def test_is_non_dominated_loop(self):
n = 20
tkwargs = {"device": self.device}
Expand Down

0 comments on commit 10a9348

Please sign in to comment.