function [pop]=initializega(num,bounds,eevalFN,eevalOps,options)
Output parameters:
Initial population generated pop
Input parameters:
The number of individuals in the population num
Upper and lower bounds of bounds on behalf of the variable matrix
eevalFN fitness function
eevalOps parameters passed to the fitness function
Select options encoded form (floating point code or binary coding)
When the specified variable binary coding precision accuracy
function [x,endPop,bPop,traceInfo] = ga(bounds,evalFN,evalOps,startPop,opts,... termFN,termOps,selectFN,selectOps,xOverFNs,xOverOps,mutFNs,mutOps)
Output parameters:
The optimal solution x obtained
endPop resulting population
A search for the optimal trajectory of population bPop
Input parameters:
bounds on behalf of the matrix variable bounds
evalFN fitness function
evalOps parameters passed to the fitness function
startPop initial population
opts [epsilon prob_ops display] opts (1: 2) options equivalent to initializega parameter, the third parameter to control whether to output, typically 0.
The [1e-6 1 0]
termFN termination of the function name
termOps transfer function parameters termination
Select the name of the function selectFN
selectOps transfer parameter selection function
CROSS function name table xOverFNs
xOverOps parameters passed to the function table cross
mutFNs variogram table
1. seeking f (x) = x + 10 * sin (5x) + * cos (4x) the maximum value of 7, where 0 <= X <=. 9
10, both binary and binary code length, the number of individuals in the population as 20, crossover probability 0.95, 0.08 mutation probability
function[sol,eval]=fitness(sol,options) x=sol(1); eval=x+10*sin(5*x)+7*cos(4*x); end
>> initPop=initializega(10,[0 10],'fitness'); [x endPop,bPop,trace]=ga([0 10],'fitness',[],initPop,... [1e-6 1 1],'maxGenTerm',25,'normGeomSelect',... [0.08],['arithXover'],[2],'nonUnifMutation',[2 25 3]);
BPop >>
bPop =
1.0000 9.3320 20.3311
4.0000 7.8404 24.8068
9.0000 7.8448 24.8296
11.0000 7.8467 24.8373
13.0000 7.8565 24.8554
25.0000 7.8565 24.8554
>> x
x =
7.8565 24.8554
when x is 7.8565, f (x) takes the maximum value 24.8554