Merged
Conversation
…sawa-yugo/lru_cache_for_hssp
nabenabe0928
reviewed
Aug 8, 2025
nabenabe0928
reviewed
Aug 8, 2025
y0z
reviewed
Aug 8, 2025
y0z
reviewed
Aug 8, 2025
Co-authored-by: Shuhei Watanabe <47781922+nabenabe0928@users.noreply.github.com>
Co-authored-by: Shuhei Watanabe <47781922+nabenabe0928@users.noreply.github.com>
Co-authored-by: Yoshihiko Ozaki <30489874+y0z@users.noreply.github.com>
Co-authored-by: Yoshihiko Ozaki <30489874+y0z@users.noreply.github.com>
Contributor
Author
Contributor
Author
(Approximate) Hit Rate
|
Contributor
|
I confirmed with @y0z that the cache hit rates here are reproducible. |
nabenabe0928
reviewed
Aug 8, 2025
Contributor
|
Benchmarking results with my funcs: from __future__ import annotations
import optuna
def multi_objective(trial: optuna.Trial) -> tuple[float, ...]:
x = trial.suggest_float("x", -5, 5)
y = trial.suggest_float("y", -5, 5)
return x**2 + y**2, (x - 2)**2 + (y - 2)**2, (x + 2)**2 + (y + 2)**2, (x + 2)**2 + (y - 2)**2
def objective(trial: optuna.Trial, n_objectives: int) -> tuple[float, ...]:
return multi_objective(trial)[:n_objectives]
if __name__ == "__main__":
n_objectives = 4
sampler = optuna.samplers.TPESampler(seed=0, multivariate=False)
study = optuna.create_study(sampler=sampler, directions=["minimize"]*n_objectives)
study.optimize(lambda t: objective(t, n_objectives), n_trials=1000)
print((study.trials[-1].datetime_complete - study.trials[0].datetime_start).total_seconds()) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.




Motivation
calculation of HSSP is unnecessarily repeated even when the results would be identical.
This PR aims to eliminate such redundant computations and improve efficiency.
related PR
TPESampler#6128Description of the changes
I introduced
lru_cacheto skip repeated calculations. To store the data in the cache,np.ndarrayobjects are converted intotupleand then reversed.