GAOTV5 core function: (1) Function [POP] = Initializega (Num, Bounds, EEVALFN, EEVALOPS, OPTIONS) - The generated function of the initial population [output parameter] POP - generated initial group [input parameter] NUM - population Individual number of individuals Bounds - matrix EEVALFN - Adaptive function EEVALOPS - Parameters passing to the adaptivity function (floating point encoding or binary code) [precision f_or_b], select coding form (floating point encoding or binary code) [precision f_or_b], If the precision-variable specifies the accuracy f_or_b - to 1, select the floating point encoding, otherwise it is binary encoded, specified by precision) (2) Function [x, endpop, bpop, traceinfo] = Ga (Bounds , Evalfn, Evalops, StartPOP, OPTS, ... Termfn, Termops, SELECTFN, SELECTOPS, XOVERFNS, XOVEROPS, MUTFNS, MUTOPS A Search Track of the Best Group BPOP - Optical Bounds - Bound of Bounds - Matrix Eval EvalFN - Adaptive Function Evalops - Parameters Parameters Parameters Parameters of the Adaptive Function STARTPOP - Initial Population OPTS [EPSILON PROB_OPS Display] - OPTS (1: 2) is equivalent to the Options parameters of Initializega, the third parameter controls whether it is output, typically 0.
Such as the name of [1e-6 1 0] Termfn - Termination function, such as ['maxGEnterm'] Termops - Parameters passing a termination function, such as the [100] selectfn - Select the name of the function, such as ['NormGeomselect'] Selectops - Parameters passing a selection function, such as the [0.08] XOVERFNS - cross function name table, separated by space, such as ['ArithxOver HeuristicXover SimplexOver "] XOVEROPS - Parameter table passed to the cross-stroke, such as [2 0; 2 3; 2 0] MUTFNS - Variation Function Table, such as ['BoundaryMutation Multinoniumutation Nonunifmutation Unifmutation'] mutops - Parameter table passed to the cross function, such as [4 0 0; 6 100 3; 4 100 3; 4 0 0 ] Note] MATLAB toolbox function must be placed under the working directory [Question] F (x) = x 10 * sin (5x) 7 * COS (4X) maximum, where 0 <= x <= 9 [ Analysis】 Select binary code, the number of individuals in the population is 10, the binary coding length is 20, the cross probability is 0.95, the mutation probability is 0.08 [program list]% write target function function [SOL, EVAL] = Fitness (Sol, Options) X = SOL (1); Eval = x 10 * sin (5 * x) 7 * COS (4 * x);% stores the above function as fitness.m file and put initpop = Initializega in the working directory (10 [0 9], 'FITNESS');% Generates initial group, size is 10 [x endpop, bpop, trace] = Ga ([0 9], 'Fitness', [], initpop, [1e-6 1 1 ], 'MaxGenterm', 25, 'NormGeomselect', ... [0.08], ['ArithxOver'], [2], 'Nonunifmutation', [2 25 3])% 25 Iterative operations Learning: x = 7.8562 24.8553 (when X is 7.8562, F (x) takes the maximum value 24.8553) Note: genetic calculation The method is generally used to achieve approximate optimal solutions, not the optimal solution. In addition, the convergence of the genetic algorithm is related to its initial value. If you run the above command, you may have different or different from me. However, multiple times the above command (with different initial groups) must be obtained by approximately optimal solutions. Genetic Algorithm Example 2 [Problem] In -5 <= xi <= 5, I = 1, 2 interval, solve F (x1, x2) = - 20 * Exp (-0.2 * sqrt (0.5 * (x1. ^ 2 x2. ^ 2))) - EXP (0.5 * (COS (2 * pi * x1) COS (2 * pi * x2))) 22.71282 minimum.