简体   繁体   中英

scipy.optimize.basinhopping interval and accept test syntaces

I am trying to find the global minimum of an objective function using basinhopping , but for a majority of the time it is stuck at a local minimum. I read through the document for basinhopping , and found the interval and accept_test might be helpful, but now the question is what values to give them, eg I want my objective function to go as close to 0 as possible (1e-5 close) without spending too much time at very large values like 4 or 5. As for interval how does one know how often a stepsize is being updated?

Here is how i'm looking for a "global" minimum:

np.random.seed(555)   # Seeded to allow replication.
minimizer_kwargs = {"method": "L-BFGS-B", "bounds": bnds,, tol=1e-4}
ret = basinhopping(merit_function, abcdex, minimizer_kwargs=minimizer_kwargs, niter=10)
zoom = ret['x']

res = minimize(merit_function, zoom, method = 'L-BFGS-B', bounds=bnds, tol=1e-9)
print res

If you're stuck in a local minimum then that likely means you need a bigger stepsize. You can set the stepsize with the keyword "stepsize".

An appropriate stepsize depends on the problem, but luckily basinhopping will adjust the stepsize automatically. How often it does this depends on the "interval" keyword. Every interval iterations the stepsize will be increased or decreased by a factor of 0.9. If the initial guess for the stepsize is way off this can still take some time. If you decrease the interval to 10 (or so) this should be much faster.

I don't think accept_test will help you here. That can be used to, for example, enforce forbidden regions of configuration space.

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