python - Specifying the ranges in scipy.optimize.brute() -
when try minimize function scipy.minimize.brute() using following code:
import scipy scipy.optimize.brute(lambda x: x**2, ranges=(-2,3))
i following error:
typeerror: object of type 'int' has no len()
i suppose has specification of range, don't see why. documentation says
each component of ranges tuple must either “slice object” or range tuple of form (low, high).
where mistake?
as documentation says:
each component of ranges tuple must either “slice object” or range tuple of form (low, high).
so function expects tuple of tuples, 1 of form (low, high)
each dimension. have 1 dimension, correct call in case be
scipy.optimize.brute(lambda x: x**2, ranges=((-2,3),) )
Comments
Post a Comment