This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

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