Skip to content

Fix a bug in constrained GPSampler#6181

Merged
y0z merged 3 commits intooptuna:masterfrom
nabenabe0928:bug-fix/fix-logic-of-best-params-in-constrained-gp
Jul 3, 2025
Merged

Fix a bug in constrained GPSampler#6181
y0z merged 3 commits intooptuna:masterfrom
nabenabe0928:bug-fix/fix-logic-of-best-params-in-constrained-gp

Conversation

@nabenabe0928
Copy link
Copy Markdown
Contributor

@nabenabe0928 nabenabe0928 commented Jun 27, 2025

Motivation

The original implementation takes best_params as the x fetched by argmax(Y[is_feasible]).
However, what we really want is x with the best feasible y.

See the example below,

X = [[1.0], [4.0], [2.0]]
Y = [2.0, 3.0, 5.0]
C = [1.0, -1.0, -1.0]

In this case, feasible = [False, True, True], meaning that Y_feasible = [3.0, 5.0] and X_feasible = [[4.0], [2.0]].
So X[argmax(Y_feasible)] becomes [4.0] instead of [2.0], which is the actual best feasible params.
I fixed this bug in this PR.

Note

Here, we aim to maximize Y.

Description of the changes

  • See the motivation

@nabenabe0928 nabenabe0928 added this to the v4.5.0 milestone Jun 27, 2025
@nabenabe0928 nabenabe0928 added the bug Issue/PR about behavior that is broken. Not for typos/examples/CI/test but for Optuna itself. label Jun 27, 2025
@nabenabe0928 nabenabe0928 marked this pull request as ready for review June 27, 2025 03:07
@nabenabe0928
Copy link
Copy Markdown
Contributor Author

@sawa3030 @kAIto47802
Could you review this PR?

Copy link
Copy Markdown
Collaborator

@kAIto47802 kAIto47802 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 changed the title Fix a bug in constrained GPSampler Fix a bug in constrained GPSampler Jul 2, 2025
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.

LGTM

Copy link
Copy Markdown
Member

@y0z y0z left a comment

Choose a reason for hiding this comment

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

LGTM

@y0z y0z merged commit 5c635d2 into optuna:master Jul 3, 2025
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Issue/PR about behavior that is broken. Not for typos/examples/CI/test but for Optuna itself.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants