Documentation

Minimize Function with Many Local Minima

Description

This section presents an example that shows how to find a local minimum of a function using simulated annealing.

De Jong's fifth function is a two-dimensional function with many (25) local minima:

dejong5fcn Many standard optimization algorithms get stuck in local minima. Because the simulated annealing algorithm performs a wide random search, the chance of being trapped in local minima is decreased.

Note:

Because simulated annealing uses random number generators, each time you run this algorithm you can get different results. See Reproduce Your Results for more information.

Minimize at the Command Line

To run the simulated annealing algorithm without constraints, call simulannealbnd at the command line using the objective function in dejong5fcn.m, referenced by anonymous function pointer:

rng(10,'twister') % for reproducibility
fun = @dejong5fcn;
[x,fval] = simulannealbnd(fun,[0 0])

This returns

Optimization terminated: change in best function value less than options.FunctionTolerance.

x =
-16.1292  -15.8214

fval =
6.9034

where

• x is the final point returned by the algorithm.

• fval is the objective function value at the final point.

Minimize Using the Optimization App

To run the minimization using the Optimization app,

1. Set up your problem as pictured in the Optimization app 2. Click under Run solver and view results: Your results can differ from the pictured ones, because simulannealbnd uses a random number stream.