I'm working with scipy.optimize.minimize
, and I'm optimizing 3 parameters with a function like this
def foo(A, x, y, z):
test = my_function(A[0], A[1], A[2], x, y, z)
return test
In this answer I found some insight: How to display progress of scipy.optimize function? So I came up with this function:
def callbackF(Xi, x, y, z)
global Nfeval
print '{0:4d} {1: 3.6f} {2: 3.6f} {3: 3.6f} {4: 3.6f}'.format(Nfeval, Xi[0], Xi[1], Xi[2], foo(Xi, x, y, z))
Nfeval += 1
So my code will look like this
Optimal = minimize(fun=foo, x0=[fi, alfa, Ks], args=(x, y, z),
method='BFGS', callback=callbackF, tol=1e-2)
but I get this error :
TypeError: callbackF() takes exactly 4 arguments (1 given)
I understand the error, but how should I avoid it?