Home python Error when using differential evolution in scipy

Error when using differential evolution in scipy




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].

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.

Description and example in official documentation .

Answer 2

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

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions