Академический Документы
Профессиональный Документы
Культура Документы
GA Solver
X = GA(FITNESSFCN,NVARS) finds the minimum of FITNESSFCN using GA. NVARS is the dimension (number of design variables) of the FITNESSFCN. FITNESSFCN accepts a vector X of size 1-by-NAVRS, and returns a scalar evaluated at X. X = GA(FITNESSFCN,NAVRS,OPTIONS) finds the minimum for FITNESSFCN with the default optimization parameters replaced by values in the structure OPTIONS. OPTIONS can be created with the GAOPTIMSET function. X = GA(PROBLEM) finds the minimum for PROBLEM. PROBLEM is a structure that has the following fields: fitnessfcn: <Fitness Function> nvars: <Number of design variables> options: <Options structure created with GAOPTIMSET> randstate: <Optional field to reset rand state> randnstate: <Optional field to reset randn state>
GA Solver
[X, FVAL] = GA(FITNESSFCN, ...) returns FVAL, the value of the fitness function FITNESSFCN at the solution X. [X,FVAL,REASON] = GA(FITNESSFCN, ...) returns the REASON for stopping. [X,FVAL,REASON,OUTPUT] = GA(FITNESSFCN, ...) returns a structure OUTPUT with the following information: randstate: <State of the function RAND used before GA started> randnstate: <State of the function RANDN used before GA started> generations: <Total generations, excluding HybridFcn iterations> funccount: <Total function evaluations> message: <GA termination message> [X,FVAL,REASON,OUTPUT,POPULATION] = GA(FITNESSFCN, ...) returns the final POPULATION at termination. [X,FVAL,REASON,OUTPUT,POPULATION,SCORES] = GA(FITNESSFCN, ...) returns the SCORES of the final POPULATION.
GA Solver
There are several steps to the GA: population generation scoring loop fitness scaling selection crossover mutation scoring migration output termination testing end loop Each of these steps can be controlled by the options structure created by GAOPTIMSET.
GA Solver
Example: Minimize 'rastriginsfcn' fitness function of numberOfVariables = 2 x = ga(@rastriginsfcn,2) Display plotting functions while GA minimizes options = gaoptimset('PlotFcns',... {@gaplotbestf,@gaplotbestindiv,@gaplotexpect ation,@gaplotstopping}); [x,fval,reason,output] = ga(@rastriginsfcn,2,options)
TimeLimit
- The total time (in seconds) allowed for simulation [ positive scalar | {INF} ] FitnessLimit - The lowest allowed score [ scalar | {-Inf} ] StallGenLimit - If after this number of generations there is no improvement, the simulation will end [ positive scalar | {50} ] StallTimeLimit - If after this many seconds there is no improvement, the simulation will end [ positive scalar | {20} ] InitialPopulation - The initial population used in seeding the GA algorithm [ Matrix | {[]} ] InitialScores - The initial scores used to determine fitness; used in seeding the GA algorithm [ column vector | {[]} ] [ positive scalar | {1} ] CreationFcn - Function used to generate initial population [ {@gacreationuniform} ] FitnessScalingFcn - Function used to scale fitness scores. [ @fitscalingshiftlinear | @fitscalingprop | @fitscalingtop | {@fitscalingrank} ]
SelectionFcn
- Function used in selecting parents for next generation [ @selectionremainder | @selectionrandom | @selectionroulette | @selectiontournament | {@selectionstochunif} ] CrossoverFcn - Function used to do crossover [ @crossoverheuristic | @crossoverintermediate | @crossoversinglepoint | @crossovertwopoint | {@crossoverscattered} ] MutationFcn - Function used in mutating genes [ @mutationuniform | {@mutationgaussian} ] HybridFcn - Another optimization function to be used once GA has normally terminated (for whatever reason) [ @fminsearch | @patternsearch | @fminunc | {[]} ] Display - Level of display [ 'off' | 'iter' | 'diagnose' | {'final'} ] OutputFcns - Function(s) called in every generation. This is more general than PlotFcns. [ @gaoutputgen | {[]} ] PlotFcns - Function(s) used in plotting various quantities during simulation [ @gaplotbestf | @gaplotbestindiv | @gaplotdistance | @gaplotexpectation | @gaplotgeneology | @gaplotselection | @gaplotrange | @gaplotscorediversity | @gaplotscores | @gaplotstopping | {[]} ] PlotInterval - The number of generations between plotting results [ positive scalar | {1} ] Vectorized - Objective function is vectorized and it can evaluate more than one point in one call [ 'on' | {'off'} ]