Use hypervolume difference as upperbound of contribs in HSSP#6131
Use hypervolume difference as upperbound of contribs in HSSP#6131nabenabe0928 merged 6 commits intooptuna:masterfrom
Conversation
nabenabe0928
left a comment
There was a problem hiding this comment.
Thank you for the PR, I left some comments:)
optuna/_hypervolume/hssp.py
Outdated
| # Note: H(T v {j}) - H(T) <= H({t} v {j}) - H({t}) = H({j}) - H({t} ^ {j}). | ||
| # Here, t is the last selected point and j is the candidate. The inequality comes from | ||
| # submodularity and the equality comes from the inclusion-exclusion principle. | ||
| single_volume = np.abs(np.prod(pareto_loss_values - reference_point[np.newaxis, :], axis=1)) |
There was a problem hiding this comment.
We could precompute single_volume if necessary.
It is an implicit assumption, but the compute_hypervolume function internally checks np.all(pareto_loss_values <= reference_point[np.newaxis, :]), so np.prod(reference_point[np.newaxis, :] - pareto_loss_values, axis=1) is equivalent.
Note
r - a is quicker than r[np.newaxis, :] - a.
In [1]: import numpy as np
...:
...:
...: a = np.random.random((30, 3))
...: r = np.ones(3)
...: %timeit r - a
...: %timeit r[np.newaxis, :] - a
...: assert np.allclose(r - a, r[np.newaxis, :] - a)
708 ns ± 8.28 ns per loop (mean ± std. dev. of 7 runs, 1,000,000 loops each)
887 ns ± 10.7 ns per loop (mean ± std. dev. of 7 runs, 1,000,000 loops each)|
I confirmed the reproducibility with the following! contribs = np.minimum(
contribs,
(
np.prod(reference_point - pareto_loss_values, axis=1)
- np.prod(reference_point - np.maximum(selected_vecs[-2], pareto_loss_values), axis=1)
),
) |
Co-authored-by: Shuhei Watanabe <47781922+nabenabe0928@users.noreply.github.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #6131 +/- ##
==========================================
+ Coverage 88.39% 88.42% +0.03%
==========================================
Files 207 207
Lines 14036 14043 +7
==========================================
+ Hits 12407 12418 +11
+ Misses 1629 1625 -4 ☔ View full report in Codecov by Sentry. |
Co-authored-by: Shuhei Watanabe <47781922+nabenabe0928@users.noreply.github.com>
Co-authored-by: Shuhei Watanabe <47781922+nabenabe0928@users.noreply.github.com>
Motivation
Since
contribsin HSSP manages the upper bound of contribution for each point, it can be updated by the difference HV with the last selected point and the next candidate. This reduces the number of points that actually require hypervolume calculation.Description of the changes
Benchmark