Optimization Toolbox | ![]() ![]() |
Changing the Default Settings
The function optimset
creates or updates an options
variable to pass to the various optimization functions. The arguments to the optimset
function are parameter name and parameter value pairs, such as TolX
and 1e-4
. Any unspecified properties have default values. You need to type only enough leading characters to define the parameter name uniquely. Case is ignored for parameter names. For parameter values that are strings, however, case and the exact string are necessary.
help optimset
provides information that defines the different parameters and describes how to use them.
Here are some examples of the use of optimset
.
Returning All Parameters
optimset
returns all the parameters that can be set with typical values and default values.
Determining Parameters Used by a Function
The options
structure defines the parameters that can be used by the functions provided by the toolbox. Because functions do not use all the parameters, it may be useful to find which parameters are used by a particular function.
To determine which options
structure fields are used by a function, pass the name of the function (in this example, fmincon
) to optimset
optimset('fmincon')
optimset fmincon
This statement returns a structure. Fields not used by the function have empty values ([]
); fields used by the function are set to their default values for the given function.
Displaying Output
To display output at each iteration, enter
options = optimset('Display', 'iter');
This command sets the options.Display
field value to 'iter'
, which causes the toolbox to display output at each iteration. You can also turn off any output display ('off'
), display output only at termination ('final'
), or display output only if the problem fails to converge ('notify'
).
Running Medium-Scale Optimization
For functions that support medium- and large-scale optimization problems, the default is for the function to use the large-scale algorithm. To use the medium-scale algorithm, enter
options = optimset('LargeScale', 'off');
Setting More Than One Parameter
You can specify multiple parameters with one call to optimset
. For example, to reset the output option and the tolerance on x, enter
options = optimset('Display', 'iter', 'TolX', 1e-6);
Updating an options Structure
To update an existing options
structure, call optimset
and pass options
as the first argument.
options = optimset(options, 'Display', 'iter', 'TolX', 1e-6);
Retrieving Parameter Values
Use the optimget
function to get parameter values from an options
structure. For example, to get the current display option, enter
verbosity = optimget(options, 'Display');
![]() | Default Parameter Settings | Displaying Iterative Output | ![]() |