Running the following code, on the 7th print out of the parameter being evaluated (x), the parameter jumps from about 100 to .01 despite the initial stepsize being set to .1 and the interval being set to 50. How is basinhopping able to make a jump that exceeds the stepsize by such a large magnitude?
import multiprocessing as mp
from scipy.optimize import basinhopping
def runEnvironment(x):
return x**2
def func(x):
print "x:",x
pool = mp.Pool(processes=1)
results=pool.apply(runEnvironment,(x,))
pool.close()
return results
if __name__ == '__main__':
x0=100
ret=basinhopping(func, x0, niter=100, T=1.0, stepsize=.1, minimizer_kwargs=None, take_step=None, accept_test=None, callback=None, interval=50, disp=False, niter_success=None)
basinhopping is an iterative procedure where it uses local minimization, then takes a step in coordinate space (stepsize) then does local minimization again, hopefully to a different minimum.
The stepsize parameter only applies to the step in coordinate space.
In your example the default local minimizer (BFGS I think) finds the global minimum on the first iteration. The local minimizer uses 7 function evaluations to do that, but it's still within one basinhopping iteration. basinhopping doesn't know it's at the global minimum, so it continues to try to find a better one.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With