Skip to content

Commit

Permalink
Add edge case to 2d Pareto front algorithm.
Browse files Browse the repository at this point in the history
  • Loading branch information
parsiad committed Mar 23, 2021
1 parent 11b5187 commit 54c51a6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion optuna/_multi_objective.py
Expand Up @@ -34,7 +34,7 @@ def set_mask(width: int, hi: int) -> None:
if curr_x != x:
set_mask(width, hi=i)
width = 0
if y > best_y:
if y > best_y or (y == best_y and width == 0):
continue
if y < best_y:
width = 0
Expand Down
3 changes: 3 additions & 0 deletions tests/study_tests/test_study.py
Expand Up @@ -831,6 +831,9 @@ def _trial_to_values(t: FrozenTrial) -> Tuple[float, ...]:
study.optimize(lambda t: [3, 1], n_trials=1)
assert {_trial_to_values(t) for t in study.best_trials} == {(1, 1), (2, 2)}

study.optimize(lambda t: [3, 2], n_trials=1)
assert {_trial_to_values(t) for t in study.best_trials} == {(1, 1), (2, 2)}

study.optimize(lambda t: [1, 3], n_trials=1)
assert {_trial_to_values(t) for t in study.best_trials} == {(1, 3)}
assert len(study.best_trials) == 1
Expand Down

0 comments on commit 54c51a6

Please sign in to comment.