Improve performance of plot_hypervolume_history#6115
Merged
HideakiImamura merged 1 commit intooptuna:masterfrom Jun 4, 2025
Merged
Improve performance of plot_hypervolume_history#6115HideakiImamura merged 1 commit intooptuna:masterfrom
plot_hypervolume_history#6115HideakiImamura merged 1 commit intooptuna:masterfrom
Conversation
plot_hypervolume_history
Member
|
I misunderstood. I'm so sorry.
import optuna
import time
optuna.logging.set_verbosity(optuna.logging.WARNING)
def test_pr6115_with_constraints():
def objective(trial):
x = trial.suggest_float("x", 0, 1)
y = trial.suggest_float("y", 0, 1)
z = trial.suggest_float("z", 0, 1)
trial.set_user_attr("constraints", [x ** 2 + y ** 2 + z ** 2 - 1])
return x, y, z
def constraints_func(trial):
return trial.user_attrs["constraints"]
sampler = optuna.samplers.NSGAIISampler(seed=42, constraints_func=constraints_func)
study = optuna.create_study(directions=["maximize", "maximize", "maximize"], sampler=sampler)
study.optimize(objective, n_trials=10000)
reference_point=[0, 0, 0]
start = time.time()
fig = optuna.visualization.plot_hypervolume_history(study, reference_point)
end = time.time()
print(f"Time taken for hypervolume plot: {end - start} seconds")
if __name__ == "__main__":
test_pr6115_with_constraints()
|
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
Current implementation of
_get_hypervolume_history_infocalls_dominatesmany times. If we normalizevaluesfirst and perform checks equivalent to_dominatesonndarrays, its performance will be improvedDescription of the changes
_get_hypervolume_history_infono longer keepsbest_trials. Instead it maintainsbest_trials_values_normalizedasndarrray, for which checks like_dominatescan be efficiently performed.