Solution for How to determine the xtol of scipy.optimize.fmin when the input of the function is a array?
is Given Below:
I want to get the value of an array that makes a function gets the min value. So I use scipy.optimize.fmin() to get the array. However, it iters for too many times. So, I want to set the value of xtol and ftol to reduce the number of iterations. However, I wonder how can I determine the value of xtol if the input of the function is an array. I have set the value of xtol to 5 and the value of ftol to 5 and I have printed the value of the delta x and delta y, but I discover that the y changes just for 0.005*e-6 and every point in the input array changes for 0.5. So, how does the xtol decide when the iteration calls an end when the x is exactly an array.
psg = np.arange(dur/(N-1), dur-dur/(N-1)+1, dur/(N-1)).T func = lambda psg_: mjCOST(psg_, pos, vel, acc, t0) psg = scipy.optimize.fmin(func = func, x0 = psg,xtol=5,ftol=5,maxiter=1000)