I'm writing a code in Python for optimization. I'm using the differential_evolution
algorithm available in scipy
library. I wrote the following code with the help of internet resources:
from scipy.optimize import differential_evolution
from numpy import exp
from numpy import sqrt
from numpy import cos
from numpy import e
from numpy import pi
import math
def objective(v):
x, y = v
return -20.0 * exp(-0.2 * sqrt(0.5 * (x**2 + y**2))) - exp(0.5 * (cos(2 * pi * x) + cos(2 * pi * y))) + e + 20
result = differential_evolution(objective)
and I'm getting the error:
Exception has occurred: TypeError
differential_evolution() missing 1 required positional argument: 'bounds'
When I try the same code with bounds it works:
result = differential_evolution(objective,[[-5.0,5.0],[-5.0,5.0]])
But according to the documentation, the 'bounds' argument is optional. (Also screenshot below) And also I really don't see the point of requiring that argument. I really don't want to supply that argument because in most cases I don't really know a bound.
Am I missing something here? Am I doing something wrong?