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
DOC: dual_annealing optimizer does not pass bounds to minimizer when minimizer_kwargs is partially given #20614
Comments
Thanks for the report @SterlingYM . I understand that the API might be counter intuitive but passing bounds automatically to the local optimizer would break backwards compatibility. Another issue is that not all local optimizers support bounds. I suggest that we add this behavior to the docstring explicitly. What do you think? |
@dschmitz89 I understand changing the implementation comes with some difficulties. At least I think adding docstrings is worth it, since I spent many hours debugging this issue and I am sure someone else would do that in the future. A few alternative ideas:
self.kwargs = minimizer_kwargs
self.kwargs_extra = minimizer_kwargs_extra
if not self.kwargs:
# define kwargs, same as the original implementation, and add the following
self.kwargs.update(self.kwargs_extra)
else:
self.kwargs.update(self.kwargs_extra) # this is not necessary but just in case
# (or we can have the kwargs.updateI() line outside the if statement) I am suggesting this because the current workaround to specify bounds twice in a single function call of |
I fully agree that the current API seems silly. In fact, Adding one more option makes this already complex API even harder to grasp though in my opinion. Slightly related question: did you encounter the same issue with |
Issue with current documentation:
Regarding the documentation of
dual_annealing
:The current implementation of
dual_annealing
only generates the newkwargs
dict for the local minimizer when there is NOminimizer_kwargs
provided.https://github.com/scipy/scipy/blob/4ee0de31b758f81be85435a0ad72d315a840441d/scipy/optimize/_dual_annealing.py#L403C1-L413C70
This causes issues during local search, such as below:
The only kwargs items passed to the minimizer is
{'eps': 1e-5}
, where users like myself might expect{'eps': 1e-5, 'bounds': bounds}
to be passed.This results in an extremely inefficient local search, since the local minimizer finds some coordinates outside the bounds only to get rejected by the sanity check code (below).
https://github.com/scipy/scipy/blob/4ee0de31b758f81be85435a0ad72d315a840441d/scipy/optimize/_dual_annealing.py#L428C1-L431C43
To avoid this, current workaround is to add
bounds
tominimizer_kwargs
:Idea or request for content:
It will be a great help for users to explicitly mention in the document (or change the implementation so that default kwargs get updated by user kwargs: see below) that minimizer_kwargs will be the ONLY kwargs that get passed to the minimizer.
Current description of
minimizer_kwargs
option isand this is misleading, since it gives an impression that only the modification to the default values (such as
eps
parameter in the example above) are needed, in which case users may thinkbounds
is not necessary.Alternatively, changing the implementation (of the kwargs generator code I linked above) to something like this
might match the expected behavior.
Additional context (e.g. screenshots, GIFs)
No response
The text was updated successfully, but these errors were encountered: