|On this page…|
To call the simulated annealing function at the command line, use the syntax
[x fval] = simulannealbnd(@objfun,x0,lb,ub,options)
@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 a file.
Command Line Simulated Annealing Optimization provides a detailed description of using the function simulannealbnd and creating the options structure.
To open the Optimization app, enter
at the command line, or enter optimtool and then choose simulannealbnd from the Solver menu.
You can also start the tool from the MATLAB Apps tab.
To use the Optimization app, 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 a file that computes the objective function. Compute Objective Functions explains how write this 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 Compute Objective Functions, 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,