Skip to content

Calculate hypervolume in HSSP using sum of contributions#6130

Merged
nabenabe0928 merged 3 commits intooptuna:masterfrom
not522:hypervolume-contribs
Jun 20, 2025
Merged

Calculate hypervolume in HSSP using sum of contributions#6130
nabenabe0928 merged 3 commits intooptuna:masterfrom
not522:hypervolume-contribs

Conversation

@not522
Copy link
Copy Markdown
Member

@not522 not522 commented Jun 5, 2025

Motivation

The hypervolume determined by the selected points can be calculated as the sum of their contributions. This allows skipping the initial hypervolume calculation for each iteration in HSSP.

Description of the changes

  • Change to calculate hypervolume in HSSP using sum of contributions

Benchmark

  • master: 26.196007 sec
  • PR: 25.605701 sec
import optuna


def objective(trial: optuna.Trial) -> tuple[float, float, 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


sampler = optuna.samplers.TPESampler(seed=42)
study = optuna.create_study(sampler=sampler, directions=["minimize"]*3)
study.optimize(objective, n_trials=1000)
trials = study.trials
print((trials[-1].datetime_complete - trials[0].datetime_start).total_seconds())

@not522 not522 added the enhancement Change that does not break compatibility and not affect public interfaces, but improves performance. label Jun 5, 2025
Copy link
Copy Markdown
Contributor

@nabenabe0928 nabenabe0928 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you change here to np.maximum(0.0, contribs) so that any contribs will not be lower than max_contrib and add an inline note about this?
Such a situation can happen due to numerical instability.

return contribs

@nabenabe0928
Copy link
Copy Markdown
Contributor

@sawa3030 Could you check this PR?

@not522
Copy link
Copy Markdown
Member Author

not522 commented Jun 6, 2025

Could you change here to np.maximum(0.0, contribs) so that any contribs will not be lower than max_contrib and add an inline note about this? Such a situation can happen due to numerical instability.

return contribs

It's OK, but does that situation cause any errors?

@nabenabe0928
Copy link
Copy Markdown
Contributor

Could you change here to np.maximum(0.0, contribs) so that any contribs will not be lower than max_contrib and add an inline note about this? Such a situation can happen due to numerical instability.

return contribs

It's OK, but does that situation cause any errors?

I am not sure how likely it is, but it may trigger some unwanted behavior.
For example, if all(contribs < 0) becomes True at some point, contribs will not be updated anymore due to the check if contribs[i] < max_contrib: continue.
Yet, there should (or can) still be rankings among contribs.
By removing np.maximum, we may lose such information, resulting in picking up indices based on the contribs right before all(contribs < 0) holds.

@not522
Copy link
Copy Markdown
Member Author

not522 commented Jun 12, 2025

In such cases, all contributions become almost zero, so doesn't it matter which one we choose?
By the way, starting max_contrib from negative infinity rather than 0 seems like a simple solution to me.

@nabenabe0928
Copy link
Copy Markdown
Contributor

nabenabe0928 commented Jun 13, 2025

@not522
Let me leave this comment as a sidenote.

all contributions become almost zero, so doesn't it matter which one we choose?

It depends on the scale of each objective, but the exact reason why we use the logarithm in the single-objective optimization is to capture such a nuanced difference.
However, I am open to the change:)

The detailed discussion is available in this paper.

@nabenabe0928
Copy link
Copy Markdown
Contributor

@sawa3030
Could you please review this PR?
Once you think this PR looks sound, we can merge this PR:D

Copy link
Copy Markdown
Collaborator

@sawa3030 sawa3030 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm sorry to keep you waiting long. LGTM

@nabenabe0928 nabenabe0928 added this to the v4.5.0 milestone Jun 20, 2025
Copy link
Copy Markdown
Contributor

@nabenabe0928 nabenabe0928 left a 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, LGTM!

@nabenabe0928 nabenabe0928 merged commit f80e720 into optuna:master Jun 20, 2025
14 checks passed
@not522 not522 deleted the hypervolume-contribs branch June 20, 2025 02:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement Change that does not break compatibility and not affect public interfaces, but improves performance.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants