Genetic Algo.
GA
• It is evolutionary algorithm Adaprive heuristic
search algobased on genetics and natural
selection
GA- Example
• F=x^2
• X=0- 31
• Prob=f/sum f
• Expected count= f/avg F
Basic steps
• Select encoding technique: binary
• slelect initla population
• Fitness function max and min
• Reproduction: useprob of selection
• Cross over . One point , two point. Random number
• Mutation, seprate random numbers
Repear steps
Fitness function and function
• If problem I Max(f(x))
• Then fitness function F(x)=f(x)
• If problem I Minf(x))
• Then fitness function F(x)=1/[1+f(x)]
• prob. Of selection Pi / Ʃfi
• Expected count = Fi /Avg(Fi) or N * Pi
• Random no. for
• Initial population
• Mating pool
• Cross over
• Mutation
Expected count
Fitnes Cum.
Rand. Binary s Func Prob. Prob Exp.
4 00100 16 0.013 0.013 0
21 10101 441 Random number
4 00100
Fitness
Func
16
0.355
Prob.
0.013
Cum.
Prob
0.013
0.368 1
16 10000 256 0.206 0.574 1
21 10101 441 0.355 0.368
16 10000 256 0.206 0.574
23 10111 529 0.426 1
23 10111 529 0.426 1 2
1242 1
1242 Avg=310.5
Mating pool and cross over (0.84)
Cum. Matubg Cross
Prob Range Rand no. pool Rand No. over Next Gen
0.013 0-0.012 897 10111 94 Y 10100
0.013-
0.368 0.387 416 10000 10011
0.388-
0.574 0.5743 942 10111 45 N 10111
0.574-
1 0.999 168 10101 10101
Next Generation
Off springs Variable Fitness fun
10100 20 400
10011 19 361
10111 23 529
10101 21 441
Sum 1731
Avg 432.75
Coding formula
• Variable=L+ (U-L/(2N-1)) (decimal equivalent)
• 0-31
• 10100=(20)
• =0+ ((31-0)/(32-1)) * 20