I declared a function, I want to find its minimum method of differential evolution.
import math DEF F (X): Return Math.Sin (X / 5.0) * Math.exp (X / 10.0) + 5 * Math.EXP (-X / 2.0) from scipy import optimize Bounds = [1, 30] Result = Optimize.Differential_evolution (F, Bounds)
But after starting the script, I get such a mistake:
# Population is Scaled to Between [0, 1]. Indexerror: TUPLE INDEX OUT OF RANGE
What is the problem?
Answer 1, Authority 100%
Bounds is not just a pair (min, max), but a list of such pairs. Correction on
Bounds = [(1, 30)] Must fix everything.
Please note that the boundaries of the values of the function arguments are a list of tuples (List, in which Tuple objects are placed). Even if you have a function of one argument, take the boundaries of its values into square brackets to transmit a list of one cap in this parameter. In the implementation of scipy.optimize.differential_evolution The length of this list is used to determine the number of arguments of the function