4
運行以下代碼,在第7次打印出正在評估的參數(x)時,儘管初始步長設置爲.1且間隔設置爲50,但參數將從大約100跳至.01。如何流域購物能夠跳過如此大幅度的跳躍?不尊重步驟的Scipy盆地?
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)