Trying to solve a simple non linear minimization problem with one variable.
from scipy.optimize import minimize
import math
alpha = 0.05
waiting = 50
mean_period = 50
neighborhood_size = 5
def my_func(w):
return -(2/(w+1) + alpha*math.floor(waiting/mean_period))*(1-(2/(w+1) + alpha*math.floor(waiting/mean_period)))**(neighborhood_size-1)
print minimize(my_func, mean_period, bounds=(2,200))
which gives me
ValueError: length of x0 != length of bounds
Do I input it wrong? How should I format it?
And if I remove the bounds, I get:
status: 2
success: False
njev: 19
nfev: 69
hess_inv: array([[1]])
fun: array([-0.04072531])
x: array([50])
message: 'Desired error not necessarily achieved due to precision loss.'
jac: array([-1386838.30676792])
The function looks like that and therefore I need the bounds to limit the solution in the local maximum that I am interested in.