简体   繁体   中英

Scipy basinhopping not respecting stepsize?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM