Skip to content

Commit

Permalink
Clarify is_non_dominated behavior with NaN (#2332)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
saitcakmak authored and facebook-github-bot committed May 3, 2024
1 parent dd6ef71 commit f1fca01
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 f1fca01

Please sign in to comment.