What does this code?

Prompt novice how the code works in Python.
I tried to describe what I understand in every line.
Thanks in advance.
from scipy.optimize import rosen, differential_evolution #Import libraries
bounds = [(0,2), (0, 2), (0, 2), (0, 2), (0, 2)] #Specify the list of data
result = differential_evolution(rosen, bounds) #Assign a variable a value ? what?
result.x, result.fun # Not understood the meaning
from scipy.differential_evolution import optimize # import differential_evolution Again
import numpy as np # import numpy reducing np
def ackley(x): #defines function ackley from x
 arg1 = -0.2 * np.sqrt(0.5 * (x[0] ** 2 + x[1] ** 2))
 arg2 = 0.5 * (np.cos(2. * np.pi * x[0]) + np.cos(2. * np.pi * x[1]))
 return -20. * np.exp(arg1) - np.exp(arg2) + 20. + np.e
bounds = [(-5, 5), (-5, 5)] #Set a list of bounds
result = differential_evolution(ackley, bounds) # What is assigned?
result.x, result.fun # And then?
print(result.x, result.fun)
June 14th 19 at 18:49
1 answer
June 14th 19 at 18:51
1. learn the basics of python, and only then move on to more complex examples
2. open the documentation for scipy, read what parameters it uses, and which returns a function differential_evolution
And then there is do not understand, do you not understand how the python function is called, or how exactly to use the function differential_evolution

In addition:
just result.x, result.fun don't need, maybe it did in the console to check the result
the second time to import differential_evolution don't, it's likely you have collected from two different scripts
Thanks for the reply.
In General, from what I read I realized.
1)This library is essentially a single function
2)We are at the entrance serves some parameters and it returns us a value, right?
3) I just want to apply this function to iterate through sql queries with different parameters, and the fitness function will be the answer of this query, the higher the value, the better.
That's actually a question is it possible to use for such tasks? - Sophie.Gleas commented on June 14th 19 at 18:54
1. this library is a very large set of scientific functions
2. According to the description on her entry pass to a function, and the set of parameters and using the differential evolution method, she finds at least passed to the function.
3. The suitability of the method to your task, it is not a question of programming, and knowledge of the subject area and problem definition, I am not exactly help. - Garnett_Deckow commented on June 14th 19 at 18:57

Find more questions by tags Python