Documentation

This is machine translation

Translated by Microsoft
Mouse over text to see original. Click the button below to return to the English verison of the page.

gaoptimset

Create genetic algorithm options structure

Syntax

gaoptimset
options = gaoptimset
options = gaoptimset(@ga)
options = gaoptimset(@gamultiobj)
options = gaoptimset('param1',value1,'param2',value2,...)
options = gaoptimset(oldopts,'param1',value1,...)
options = gaoptimset(oldopts,newopts)

Description

gaoptimset with no input or output arguments displays a complete list of parameters with their valid values.

options = gaoptimset (with no input arguments) creates a structure called options that contains the options, or parameters, for the genetic algorithm and sets parameters to [], indicating default values will be used.

options = gaoptimset(@ga) creates a structure called options that contains the default options for the genetic algorithm.

options = gaoptimset(@gamultiobj) creates a structure called options that contains the default options for gamultiobj.

options = gaoptimset('param1',value1,'param2',value2,...) creates a structure called options and sets the value of 'param1' to value1, 'param2' to value2, and so on. Any unspecified parameters are set to their default values. It is sufficient to type only enough leading characters to define the parameter name uniquely. Case is ignored for parameter names.

options = gaoptimset(oldopts,'param1',value1,...) creates a copy of oldopts, modifying the specified parameters with the specified values.

options = gaoptimset(oldopts,newopts) combines an existing options structure, oldopts, with a new options structure, newopts. Any parameters in newopts with nonempty values overwrite the corresponding old parameters in oldopts.

Options

The following table lists the options you can set with gaoptimset. See Genetic Algorithm Options for a complete description of these options and their values. Values in {} denote the default value. {}* means the default when there are linear constraints, and for MutationFcn also when there are bounds. You can also view the optimization parameters and defaults by typing gaoptimset at the command line. I* indicates that ga ignores or overwrites the option for mixed integer optimization problems.

optimoptions hides the options listed in italics, but gaoptimset does not. See Options that optimoptions Hides.

OptionDescriptionValues
ConstraintTolerance

Positive scalar. ConstraintTolerance is used to determine the feasibility with respect to nonlinear constraints. Also, max(sqrt(eps),ConstraintTolerance) determines feasibility with respect to linear constraints.

For gaoptimset, use TolCon.

Positive scalar | {1e-3}

CreationFcn

I* Handle to the function that creates the initial population. See Population Options.

{@gacreationuniform} | {@gacreationlinearfeasible}* | Custom creation function

CrossoverFcn

I* Handle to the function that the algorithm uses to create crossover children. See Crossover Options.

{@crossoverscattered} for ga, {@crossoverintermediate}* for gamultiobj | @crossoverheuristic | @crossoversinglepoint | @crossovertwopoint | @crossoverarithmetic | Custom crossover function

CrossoverFraction

The fraction of the population at the next generation, not including elite children, that is created by the crossover function

Positive scalar | {0.8}

Display

Level of display

'off' | 'iter' | 'diagnose' | {'final'}

DistanceMeasureFcn

I* Handle to the function that computes distance measure of individuals, computed in decision variable or design space (genotype) or in function space (phenotype), for gamultiobj only

{@distancecrowding,'phenotype'}

EliteCount

Positive integer specifying how many individuals in the current generation are guaranteed to survive to the next generation. Not used in gamultiobj.

Positive integer | {ceil(0.05*PopulationSize)} | {0.05*(default PopulationSize)} for mixed-integer problems

FitnessLimit

Scalar. If the fitness function attains the value of FitnessLimit, the algorithm halts.

Scalar | {-Inf}

FitnessScalingFcn

Handle to the function that scales the values of the fitness function

Option unavailable for gamultiobj

{@fitscalingrank} | @fitscalingshiftlinear | @fitscalingprop | @fitscalingtop | Custom fitness scaling function

FunctionTolerance

Positive scalar. The algorithm stops if the average relative change in the best fitness function value over MaxStallGenerations generations is less than or equal to FunctionTolerance. If StallTest is 'geometricWeighted', then the algorithm stops if the weighted average relative change is less than or equal to FunctionTolerance.

For gaoptimset, use TolFun.

Positive scalar | {1e-6} for ga, {1e-4} for gamultiobj

HybridFcn

I* Handle to a function that continues the optimization after ga terminates

or

Cell array specifying the hybrid function and its options structure. See ga Hybrid Function.

For gamultiobj, the only hybrid function is @fgoalattain. See gamultiobj Hybrid Function.

Function handle | @fminsearch | @patternsearch | @fminunc | @fmincon | {[]}

or

1-by-2 cell array | {@solver, hybridoptions}, where solver = fminsearch, patternsearch, fminunc, or fmincon {[]}

InitialPenalty

I* Initial value of penalty parameter

Positive scalar | {10}

InitialPopulationMatrix

Initial population used to seed the genetic algorithm; can be partial — see Population Options

For gaoptimset, use InitialPopulation.

Matrix | {[]}

InitialPopulationRange

Matrix or vector specifying the range of the individuals in the initial population. Applies to gacreationuniform creation function. ga shifts and scales the default initial range to match any finite bounds.

For gaoptimset, use PopInitRange.

Matrix or vector | {[-10;10]} for unbounded components, {[-1e4+1;1e4+1]} for unbounded components of integer-constrained problems, {[lb;ub]} for bounded components, with the default range modified to match one-sided bounds.

InitialScoreMatrix

I* Initial scores used to determine fitness; can be partial

For gaoptimset, use InitialScores.

Column vector | {[]}

MaxGenerations

Positive integer specifying the maximum number of iterations before the algorithm halts

For gaoptimset, use Generations.

Positive integer |{100*numberOfVariables} for ga, {200*numberOfVariables} for gamultiobj

MaxStallGenerations

Positive integer. The algorithm stops if the average relative change in the best fitness function value over MaxStallGenerations generations is less than or equal to FunctionTolerance. If StallTest is 'geometricWeighted', then the algorithm stops if the weighted average relative change is less than or equal to FunctionTolerance.

For gaoptimset, use StallGenLimit.

Positive integer | {50} for ga, {100} for gamultiobj

MaxStallTime

Positive scalar. The algorithm stops if there is no improvement in the objective function for MaxStallTime seconds, as measured by tic and toc.

Option unavailable for gamultiobj

For gaoptimset, use StallTimeLimit.

Positive scalar | {Inf}

MaxTime

Positive scalar. The algorithm stops after running after MaxTime seconds, as measured by tic and toc. This limit is enforced after each iteration, so ga can exceed the limit when an iteration takes substantial time.

For gaoptimset, use TimeLimit.

Positive scalar | {Inf}

MigrationDirection

Direction of migration — see Migration Options

'both' | {'forward'}

MigrationFraction

Scalar between 0 and 1 specifying the fraction of individuals in each subpopulation that migrates to a different subpopulation — see Migration Options

Scalar | {0.2}

MigrationInterval

Positive integer specifying the number of generations that take place between migrations of individuals between subpopulations — see Migration Options

Positive integer | {20}

MutationFcn

I* Handle to the function that produces mutation children. See Mutation Options.

{@mutationgaussian} for ga, {@mutationadaptfeasible}* for gamultiobj | @mutationuniform | Custom mutation function

NonlinearConstraintAlgorithm

Nonlinear constraint algorithm. See Nonlinear Constraint Solver Algorithms.

Option unchangeable for gamultiobj.

For gaoptimset, use NonlinConAlgorithm.

{'auglag'} for ga, {'penalty'} for gamultiobj

OutputFcn

Functions that ga calls at each iteration. See Output Function Options.

For gaoptimset, use OutputFcns.

Function handle or cell array of function handles | {[]}

ParetoFraction

I* Scalar between 0 and 1 specifying the fraction of individuals to keep on the first Pareto front while the solver selects individuals from higher fronts, for gamultiobj only

Scalar | {0.35}

PenaltyFactor

I* Penalty update parameter

Positive scalar | {100}

PlotFcn

Array of handles to functions that plot data computed by the algorithm. See Plot Options.

For gaoptimset, use PlotFcns.

{[]} | @gaplotbestf | @gaplotbestindiv | @gaplotdistance | @gaplotexpectation | @gaplotgenealogy | @gaplotmaxconstr | @gaplotrange | @gaplotselection | @gaplotscorediversity | @gaplotscores | @gaplotstopping | Custom plot function

For gamultiobj there are additional choices: @gaplotpareto | @gaplotparetodistance | @gaplotrankhist | @gaplotspread

PlotInterval

Positive integer specifying the number of generations between consecutive calls to the plot functions

Positive integer | {1}

PopulationSize

Size of the population

Positive integer | {50} when numberOfVariables <= 5, {200} otherwise | {min(max(10*nvars,40),100)} for mixed-integer problems

PopulationType

Data type of the population — must be 'doubleVector' for mixed integer problems

'bitstring' | 'custom' | {'doubleVector'}

ga ignores all constraints when PopulationType is set to 'bitString' or 'custom'. See Population Options.

SelectionFcn

I* Handle to the function that selects parents of crossover and mutation children.

gamultiobj uses only @selectiontournament.

{@selectionstochunif} for ga, {@selectiontournament} for gamultiobj | @selectionremainder | @selectionuniform | @selectionroulette | Custom selection function

StallTest

Stopping test type

'geometricWeighted' | {'averageChange'}

UseParallel

Compute fitness and nonlinear constraint functions in parallel, see Vectorize and Parallel Options (User Function Evaluation) and How to Use Parallel Processing.

true | {false}

UseVectorized

Specifies whether functions are vectorized, see Vectorize and Parallel Options (User Function Evaluation) and Vectorize the Fitness Function.

For gaoptimset, use Vectorized with the values 'on' or 'off'.

true | {false}

Introduced before R2006a

Was this topic helpful?