Complete the code to import the dual_annealing function from scipy.optimize.
from scipy.optimize import [1]
The dual_annealing function is imported from scipy.optimize to perform simulated annealing optimization.
Complete the code to define the objective function that returns the sum of squares of x.
def objective(x): return [1]
The objective function returns the sum of squares of the input array x, which is a common test function for optimization.
Fix the error in the bounds definition to correctly specify bounds for two variables between -5 and 5.
bounds = [[1], [1]]
Bounds must be tuples specifying (min, max) for each variable. Using (-5, 5) is correct.
Fill both blanks to run dual_annealing with the objective function and bounds, storing the result in 'result'.
result = [1](objective, [2])
The dual_annealing function is called with the objective function and bounds to perform optimization.
Fill all three blanks to print the minimum value found and the corresponding variables from the result.
print('Minimum value:', result.[1]) print('At variables:', result.[2]) print('Number of function evaluations:', result.[3])
The result.fun gives the minimum value, result.x the variables, and result.nfev the number of function evaluations.