Professional Documents
Culture Documents
Offspring 1 → 110101011
Offspring 2 → 100001101
Offspring 1 → 100001011
Offspring 2 → 110101101
Chromosome → 10010010111
Mutation → 10110010101
Chromosome → 10010010111
Mutation → 10110010011
Chromosome → 10010010111
Mutation → 10111000011
Dim fitness, prob, excount, roulette, minrange, maxrange, ofsv, ofsv1, ofsv2, ofsv3, ofsv4 As Double
rngclr.ClearContents
iterno = 0 'iteration count
minrange = Cells(6, 2)
maxrange = Cells(6, 3)
popsize = Cells(7, 3)
maxnumlen = Len(Application.WorksheetFunction.Dec2Bin(maxrange))
'initial population
For i = 1 To popsize
If i = 1 Then
GoTo 10
End If
For j = 1 To i - 1
GoTo 20
End If
Next j
10 Next i
'algorithm
Do While Cells(5, 9) = 0
iterno = iterno + 1
fitness = 0
For i = 1 To popsize
Next i
For i = 1 To popsize
popno = popno + 1
Cells(6 + i + popsize * (iterno - 1), 10) = Cells(6 + i + popsize * (iterno - 2), 20)
End If
'print chromosomes
'function evaluation
Cells(6 + i + popsize * (iterno - 1), 12) = Cells(6 + i + popsize * (iterno - 1), 10) ^ 2
'fitness sum
For i = 1 To popsize
Next i
For i = 1 To popsize
'print probability
Cells(6 + i + popsize * (iterno - 1), 14) = Cells(6 + i + popsize * (iterno - 1), 12) / Cells(6 + i +
popsize * (iterno - 1), 13)
Cells(6 + i + popsize * (iterno - 1), 15) = Cells(6 + i + popsize * (iterno - 1), 14) * popsize
Next i
'select range
Set rng = Range(Cells(7 + popsize * (iterno - 1), 15), Cells(6 + popsize + popsize * (iterno - 1), 15))
Set rngc = Range(Cells(7 + popsize * (iterno - 1), 11), Cells(6 + popsize + popsize * (iterno - 1), 11))
For i = 1 To (popsize + 2) / 2
'selecting parent
Next i
For i = 1 To ((popsize + 2) / 2) - 1
'generation of offspring
'offspring 1
ofs = ""
ofsv = 0
Next k
Next j
ofsv = Application.WorksheetFunction.Bin2Dec(ofs)
GoTo 30
End If
'offspring 2
ofs2 = ""
ofsv2 = 0
Next k
Next j
ofsv2 = Application.WorksheetFunction.Bin2Dec(ofs2)
GoTo 30
End If
Next i
'termination criteria
ofscount = 0
For i = 1 To 25
ofscount = ofscount + 1
End If
Next i
End If
Cells(5, 9) = 1
End If
Loop
Cells(5, 9) = 0
End Sub
2.2 Result:
3 Write algorithm for SASEGASA (Self Adaptive Segregate Genetic Algorithm
with Simulated Annealing aspects)
4 Genetic Algorithm
• Genetic algorithm is one of the techniques which is a subset of guided random search
techniques.
• Genetic algorithm is a bio inspired algorithm which is based on the success of evolution that
takes place in nature. In nature it is seen that an evolutionary process is a never-ending
ongoing process adapting constantly to changing environment and needs.
• This evolution in nature takes place with subtle changes in the DNA of the organism over a
long period of time.
• Each offspring in nature being a better than the previous one and improving little by little in
every generation.
• Genetic algorithm also works on the similar principles of evolving until the optimum solution
is reached.
• The initial population is represented in terms of binary or a form which can be termed as a
chromosome. The individual bit of the chromosomes is termed as genes.
• The initial population is primarily tested for its fitness and the fittest values are put in the
mating pool. These are termed as parents.
• The parents in mating pool are mated using the operation of cross over and the resulting
chromosomes are termed as the off springs. These off springs are expected to be fitter than
the parents and they are further used in the iteration process to check the fitness.
• These iterations are carried on till an optimum solution is reached.