| Products & Services | Solutions | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → Genetic Algorithm and Direct Search Toolbox |
| Contents | Index |
| Learn more about Genetic Algorithm and Direct Search Toolbox |
To call the simulated annealing function at the command line, use the syntax
[x fval] = simulannealbnd(@objfun,x0,lb,ub,options)
where
@objfun is a function handle to the objective function.
x0 is an initial guess for the optimizer.
lb and ub are lower and upper bound constraints, respectively, on x.
options is a structure containing options for the algorithm. If you do not pass in this argument, simulannealbnd uses its default options.
The results are given by:
x — Final point returned by the solver
fval — Value of the objective function at x
The command-line function simulannealbnd is convenient if you want to
Return results directly to the MATLAB workspace.
Run the simulated annealing algorithm multiple times with different options by calling simulannealbnd from an M-file.
Using Simulated Annealing from the Command Line provides a detailed description of using the function simulannealbnd and creating the options structure.
To open the Optimization Tool, enter
optimtool('simulannealbnd')
at the command line, or enter optimtool and then choose simulannealbnd from the Solver menu.

You can also start the tool from the MATLAB Start menu as pictured:

To use the Optimization Tool, you must first enter the following information:
Objective function — The objective function you want to minimize. Enter the fitness function in the form @fitnessfun, where fitnessfun.m is an M-file that computes the objective function. Writing Files for Functions You Want to Optimize explains how write this M-file. The @ sign creates a function handle to fitnessfun.
Number of variables — The length of the input vector to the fitness function. For the function my_fun described in Writing Files for Functions You Want to Optimize, you would enter 2.
You can enter bounds for the problem in the Constraints pane. If the problem is unconstrained, leave these fields blank.
To run the simulated annealing algorithm, click the Start button. The tool displays the results of the optimization in the Run solver and view results pane.
You can change the options for the simulated annealing algorithm in the Options pane. To view the options in one of the categories listed in the pane, click the + sign next to it.
For more information,
See the Optimization Tool chapter in the Optimization Toolbox User's Guide.
See Minimizing Using the Optimization Tool for an example of using the tool with the function simulannealbnd.
![]() | What Is Simulated Annealing? | Example — Minimizing De Jong's Fifth Function | ![]() |

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.
| © 1984-2009- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |