Specify options for the genetic algorithm.


options = optimset('option1', value1, 'option2', value2, ...)


The name of option N.
The value of option N.


A struct containing the options.
The available options are:
  • Display: An 'iter'/'off' flag to indicate whether the objective function results will be displayed for each generation. For more extensive iteration information, see the output return argument of the ga function.
  • Generations: The maximum number of generations allowed.
  • InitialPopulation: The population to initialize the algorithm.
  • MaxFail: The maximum number of failed sample evaluations.
  • PopInitialRange: A range from which the initial population is randomly selected.
  • PopulationSize: The size of the population.
  • Seed: The seed for the random number generator.
  • TolCon: The constraint violation allowance, as a percent.


Set the number of generations:

options = gaoptimset('Generations', 200)
options = struct [
Generations: 200

Set the population size:

options = gaoptimset('PopulationSize', 200)
options = struct [
PopulationSize: 200


The default value for Display is 'off'.

The default for Generations is 100 times the number of variables, up to a maxmimum of 1000.

The default for InitialPopulation is uniformly random on the interval (-10,10) for each variable.

The default value for MaxFail is 20000.

PopInitialRange can be specified as a two-element vector applied to each design variable, or as a 2-by-N matrix, where N is the number of design variables.

The default for PopulationSize is 100, which allows the algorithm to choose.

The default value for Seed is 0 (unrepeatable).

TolCon only applies when ga cannot find a feasible solution. In such cases, the function returns the best infeasible solution found within the allowed violation, along with a warning. The algorithm does not attempt to minimize the utilized violation. The TolCon value is applied as a percent of the constraint bound, with an absolute minimum of 1.0e-4, applied when the bound is zero or near zero.

An elite count of 10% of the population is advanced to the next generation. This option is not yet available for modification.