-
Notifications
You must be signed in to change notification settings - Fork 45
Add optimizer from bayesian-optimization #602
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
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportAttention: Patch coverage is
... and 1 file with indirect coverage changes 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @spline2hg, thanks for the great PR.
The PR is quite good already but I have made many small comments about the code style.
I'm happy to talk if there are questions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks very nice. Just two very small comments.
@spline2hg I had a brief look at the mypy errors.
|
Hey again! Thanks for the changes. I had a deeper look into the mypy issues, some of which were unrelated to this PR, and fixed them in #601, which was just merged into main. You should be able to update this branch with main to resolve the issues. For now, we will stick with mypy version 1.14.1. Please ping me if there are remaining errors! |
@timmens, the pre-commit mypy check is passing, but the mypy in environment is raising an error about assigning to Any.Adding ignore to it is causing pre-commit mypy to complain. |
Have you tried to re-create your local conda environment to get the same version of mypy as in the CI runs? |
@janosg yes i have updated the environment, current mypy version in my environment is 1.14.1 |
I've had a look at the situation and have a proposal. I did not, however, find out why this is a problem here and not with the Proposal:
Example: 1.def _solve_internal_problem(
self, problem: InternalOptimizationProblem, x0: NDArray[np.float64]
) -> InternalOptimizeResult:
if not IS_BAYESOPT_INSTALLED:
raise NotInstalledError(
"To use the 'bayes_opt' optimizer you need to install bayes_opt. "
"Use 'pip install bayesian-optimization'. "
"Check the documentation for more details: "
"https://bayesian-optimization.github.io/BayesianOptimization/index.html"
)
from bayes_opt import BayesianOptimization, SequentialDomainReductionTransformer 2.if TYPE_CHECKING:
from bayes_opt import BayesianOptimization
from bayes_opt.acquisition import AcquisitionFunction Since we import the runtime dependencies inside the function, we only need these objects for the type checking, and therefore also only if 3.def _process_bayes_opt_result(
optimizer: "BayesianOptimization",
x0: NDArray[np.float64],
problem: InternalOptimizationProblem,
) -> InternalOptimizeResult: Implications: If we decide to follow this route, then we should do the same for iminuit! Additionally: We should remove |
@timmens Thanks for the detailed proposal! I had missed that bayes_opt is actually typed ,and that was causing the issue, thanks for pointing it out. I’ve added the following changes:
Happy to mirror the same fix for iminuit in the same PR. |
Thanks! This looks good to me, also the |
Thanks @timmens and @spline2hg. This looks good!
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. This is ready to merge!
This PR adds the optimizer from
bayesian-optimization
library.Implemented Features
Remaining Work
constraint handling is currently skipped. Some changes are required in the way constraints are processed, before this can be properly implemented.