Set and Change Options

For all Global Optimization Toolbox solvers except GlobalSearch and MultiStart, the recommended way to set options is to use the optimoptions function. Set GlobalSearch and MultiStart options using their name-value pairs; see Changing Global Options.

For example, to set the ga maximum time to 300 seconds and set iterative display:

options = optimoptions('ga','MaxTime',300,'Display','iter');

Change options as follows:

  • Dot notation. For example,

    options.MaxTime = 5e3;
  • optimoptions. For example,

    options = optimoptions(options,'MaxTime',5e3);

Ensure that you pass options in your solver call. For example,

[x,fval] = ga(@objfun,2,[],[],[],[],lb,ub,@nonlcon,options);

To see the options you can change, consult the solver function reference pages. For option details, see the options reference sections.

You can also set and change options using the Optimization App (Optimization Toolbox), although the Optimization app warns that it will be removed in a future release.

See Also

| | | | | |

Related Topics