Optimization Toolbox    

Changing the Default Settings

The function optimset creates or updates an options structure 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 can 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.

or

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

This command sets the value of the Display parameter 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 all functions that support medium- and large-scale optimization problems except fsolve, the default is for the function to use the large-scale algorithm. To use the medium-scale algorithm, enter

For fsolve, the default is the medium-scale algorithm. To use the large-scale algorithm, enter

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

Updating an options Structure

To update an existing options structure, call optimset and pass options as the first argument:

Retrieving Parameter Values

Use the optimget function to get parameter values from an options structure. For example, to get the current display option, enter


  Default Parameter Settings Displaying Iterative Output