Use Exported Options and Problems

As an alternative to creating an options structure using gaoptimset, you can set the values of options in the Optimization app and then export the options to a structure in the MATLAB® workspace, as described in the Importing and Exporting Your Work section of the Optimization Toolbox™ documentation. If you export the default options in the Optimization app, the resulting structure options has the same settings as the default structure returned by the command

options = gaoptimset(@ga)

except that the option 'Display' defaults to 'off' in an exported structure, and is 'final' in the default at the command line.

If you export a problem structure, ga_problem, from the Optimization app, you can apply ga to it using the syntax

[x,fval] = ga(ga_problem)

The problem structure contains the following fields:

  • fitnessfcn — Fitness function

  • nvars — Number of variables for the problem

  • Aineq — Matrix for inequality constraints

  • Bineq — Vector for inequality constraints

  • Aeq — Matrix for equality constraints

  • Beq — Vector for equality constraints

  • LB — Lower bound on x

  • UB — Upper bound on x

  • nonlcon — Nonlinear constraint function

  • options — Options structure

Was this topic helpful?