-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Use hypervolume difference as upperbound of contribs in HSSP #6131
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 <[email protected]>
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #6131 +/- ##
==========================================
+ Coverage 88.29% 88.42% +0.13%
==========================================
Files 207 207
Lines 14034 14043 +9
==========================================
+ Hits 12391 12418 +27
+ Misses 1643 1625 -18 ☔ View full report in Codecov by Sentry. |
Co-authored-by: Shuhei Watanabe <[email protected]>
Co-authored-by: Shuhei Watanabe <[email protected]>
Motivation
Since
contribs
in 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