-
-
Notifications
You must be signed in to change notification settings - Fork 5.1k
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
ENH: optimize: add optional parameters of adaptive step size adjustment in bashinhopping
.
#14941
Conversation
…nt in `bashinhopping`.
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 @AtsushiSakai. Seems like it was missing, but maybe there was a reason behind this 🤷♂️. @andyfaff is this ok to add these? Or should we just fix these as constants?
I can see there are no tests for these 2 parameters in general.
Co-authored-by: Pamphile ROY <roy.pamphile@gmail.com>
Co-authored-by: Pamphile ROY <roy.pamphile@gmail.com>
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.
It looks good to me. Are there sensible ranges for the newly added keywords? If so, then they should be outlined, otherwise how is the user supposed to know how to change them for different performance?
scipy/optimize/_basinhopping.py
Outdated
|
||
.. versionadded:: 1.8.0 | ||
|
||
factor : float, optional |
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.
What is the sensible value range for factor??
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.
0 and < 1.
It might make sense to raise an exception if it is out of that range.
scipy/optimize/_basinhopping.py
Outdated
@@ -437,6 +437,19 @@ def basinhopping(func, x0, niter=100, T=1.0, stepsize=0.5, | |||
`take_step` and `accept_test`, and these functions use random | |||
number generation, then those functions are responsible for the state | |||
of their random number generator. | |||
accept_rate : float, optional |
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.
What is the sensible value range for accept_rate?
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.
> 0 and < 1. It would probably make sense to raise an exception otherwise.
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 and good point about the validation since this is going to be exposed. Same for factor.
In my original PR there was some discussion about how many parameters to expose, i.e. the tension between simplicity for the new user and flexibility for the power user. It's been some time since I was immersed in this topic, but if I recall correctly, both of these are adjustable parameters, i.e. there is no theory saying what the right value is. If there is demand for exposing them as publicly adjustable parameters then have no reason to oppose it. |
scipy/optimize/_basinhopping.py
Outdated
|
||
.. versionadded:: 1.8.0 | ||
|
||
factor : float, optional |
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.
0 and < 1.
It might make sense to raise an exception if it is out of that range.
scipy/optimize/_basinhopping.py
Outdated
@@ -437,6 +437,19 @@ def basinhopping(func, x0, niter=100, T=1.0, stepsize=0.5, | |||
`take_step` and `accept_test`, and these functions use random | |||
number generation, then those functions are responsible for the state | |||
of their random number generator. | |||
accept_rate : float, optional |
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.
> 0 and < 1. It would probably make sense to raise an exception otherwise.
scipy/optimize/_basinhopping.py
Outdated
|
||
.. versionadded:: 1.8.0 | ||
|
||
factor : float, optional |
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.
You might consider giving it a more self-explanatory name. e.g. stepsize_adjustment_factor. But then that is quite long, so I will leave it up to you.
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.
At most I would go with stepsize_factor
or it would be long as you said.
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.
I think stepsize_factor
works here.
scipy/optimize/_basinhopping.py
Outdated
@@ -437,6 +437,19 @@ def basinhopping(func, x0, niter=100, T=1.0, stepsize=0.5, | |||
`take_step` and `accept_test`, and these functions use random | |||
number generation, then those functions are responsible for the state | |||
of their random number generator. | |||
accept_rate : float, optional |
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.
target_accept_rate would be more self-explanatory, but it is also longer, so whatever you feel is better is fine.
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.
Isn't target
already implied?
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.
I think target_accept_rate
would be preferred here.
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.
It's been some time since I was immersed in this topic, but if I recall correctly, both of these are adjustable parameters, i.e. there is no theory saying what the right value is.
Thanks @js850 for the information and review. It's fine if we don't have more knowledge on these for now. Interested people might ask to improve the doc once this has been used or if some already know.
scipy/optimize/_basinhopping.py
Outdated
@@ -437,6 +437,19 @@ def basinhopping(func, x0, niter=100, T=1.0, stepsize=0.5, | |||
`take_step` and `accept_test`, and these functions use random | |||
number generation, then those functions are responsible for the state | |||
of their random number generator. | |||
accept_rate : float, optional |
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 and good point about the validation since this is going to be exposed. Same for factor.
scipy/optimize/_basinhopping.py
Outdated
|
||
.. versionadded:: 1.8.0 | ||
|
||
factor : float, optional |
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.
At most I would go with stepsize_factor
or it would be long as you said.
scipy/optimize/_basinhopping.py
Outdated
@@ -437,6 +437,19 @@ def basinhopping(func, x0, niter=100, T=1.0, stepsize=0.5, | |||
`take_step` and `accept_test`, and these functions use random | |||
number generation, then those functions are responsible for the state | |||
of their random number generator. | |||
accept_rate : float, optional |
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.
Isn't target
already implied?
To summarise:
|
|
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.
LGTM, thanks @AtsushiSakai and everyone for the help reviewing.
Reference issue
Fix #8774
What does this implement/fix?
optimize.bashinhopping
has adaptive step size adjustment using this class.scipy/scipy/optimize/_basinhopping.py
Lines 181 to 205 in 0f91f0f
The
AdaptiveStepsize
class has optional parametersaccept_rate
andfactor
to configure the behavior of adaptive step size adjustment.However, scipy users cannot configure these parameters because
bashinhopping
does not have arguments to set these.bashinhopping
only provides an argument to setintervel
.So, I added the optional parameters
accept_rate
andfactor
forbashinhopping
.