I'm trying to calculate minima of the six-hump camelback function using scipy.optimize.fmin_bfgs() function. Here is my code:
import numpy as np
import matplotlib.pyplot as plt
from scipy import optimize
def f(x,y):
return (4 - 2.1*x**2 + x**4/3)*x**2 + x*y + (4*y**2 - 4)*y**2
x0 = [0,0]
optimize.fmin_bfgs(f, x0)
Output:
TypeError: f() missing 1 required positional argument: 'y'
I guess there is something wrong with the way I pass x0?
Per this page there should be one array argument to f
: http://docs.scipy.org/doc/scipy/reference/generated/scipy.optimize.minimize.html
Do instead:
def f(x):
return (4 - 2.1*x[0]**2 + x[0]**4/3)*x[0]**2 + x[0]*x[1] + (4*x[1]**2 - 4)*x[1]**2
x0 = [0,0]
optimize.fmin_bfgs(f,x0)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With