Dual Annealing API

The Dual Annealing global optimization algorithm is available in Python via the dual_annealing() SciPy function.

The function takes the name of the objective function and the bounds of each input variable as minimum arguments for the search. There are a number of additional hyperparameters for the search that have default values, although you can configure them to customize the search.

The “ maxiter ” argument specifies the total number of iterations of the algorithm (not the total number of function evaluations) and defaults to 1,000 iterations. The “ maxfun ” can be specified if desired to limit the total number of function evaluations and defaults to 10 million.

The initial temperature of the search is specified by the “ initial_temp ” argument, which defaults to 5,230. The annealing process will be restarted once the temperature reaches a value equal to or less than ( initial_temp * restart_temp_ratio ). The ratio defaults to a very small number 2e-05 (i.e. 0.00002), so the default trigger for re-annealing is a temperature of (5230 * 0.00002) or 0.1046.

The algorithm also provides control over hyperparameters specific to the generalized simulated annealing on which it is based. This includes how far jumps can be made during the search via the “ visit ” argument, which defaults to 2.62 (values less than 3 are preferred), and the “ accept ” argument that controls the likelihood of accepting new solutions, which defaults to -5. The minimize() function is called for the local search with default hyperparameters. The local search can be configured by providing a dictionary of hyperparameter names and values to the “ local_search_options ” argument.

The local search component of the search can be disabled by setting the “ no_local_search ” argument to True.

The result of the search is an OptimizeResult object where properties can be accessed like a dictionary. The success (or not) of the search can be accessed via the ‘ success ‘ or ‘message’ key.

The total number of function evaluations can be accessed via ‘ nfev ‘ and the optimal input found for the search is accessible via the ‘ x ‘ key.