Skip to content
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

Guarantee weights_below to be finite in MOTPE #5435

Merged
merged 9 commits into from
May 27, 2024
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions optuna/samplers/_tpe/sampler.py
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,8 @@ def _build_parzen_estimator(
weights_below = _calculate_weights_below_for_multi_objective(
study, trials, self._constraints_func
)[param_mask_below]
if not np.isfinite(weights_below).all():
weights_below = np.clip(1.0 - np.isfinite(weights_below), EPS, 1.0)
mpe = self._parzen_estimator_cls(
observations, search_space, self._parzen_estimator_parameters, weights_below
)
Expand Down Expand Up @@ -814,8 +816,8 @@ def _calculate_weights_below_for_multi_objective(
contributions = np.asarray(
[hv - WFG().compute(lvals[indices_mat[i]], reference_point) for i in range(n_below)]
)
contributions += EPS
weights_below = np.clip(contributions / np.max(contributions), 0, 1)
contributions = np.clip(contributions, EPS, None)
weights_below = np.clip(contributions / np.max(contributions), EPS, 1.0)
eukaryo marked this conversation as resolved.
Show resolved Hide resolved

# For now, EPS weight is assigned to infeasible trials.
weights_below_all = np.full(len(below_trials), EPS)
Expand Down
Loading