GA Example - 2
GA Example - 2
---------------------------------------------------------------------***---------------------------------------------------------------------
Abstract - This paper explain genetic algorithm in brief used to solve the complex problems in the field of
with the help of flowchart and solve the simple searching and optimization problems. The process of
natural selection starts with the evolution selection is very
mathematical equality problem with the help of genetic
important step in this it selects the fittest individuals from
algorithm. Genetic algorithms are used to generate high a population and they produce offspring which inherit the
quality solutions for optimizations problems and search characteristics of the parents and will be added to the next
problems. Genetic Algorithm is a popular optimization tool generation the process is repeated till we found the
in the field of natural science, finance and economics, optimal answer to the problem. If parents have better
mathematics , earth science, industry, management , fitness, their offspring will be better than parents and have
a better chance at surviving, the whole genetic algorithm
biological science, earth science and computer science.
revolve around this only the fittest one will have more
Genetic Algorithms are based on the ideas of natural chance of surviving. This process keeps on repeating and at
selection and genetics. Genetic algorithms follow the process the end, a generation with the fittest individuals will be
of evolution and natural selection which means those found. This notion can be applied for a search problem and
species who can adapt to changes in their environment are also for optimization problem.
able to survive and reproduce and go to next generation and
those who are not able to adapt changes they will be 2. PHASES
discarded.
There are 5 phases in genetic algorithm which are as
Key Words: Genetic Algorithm, selection, population, follows:
fitness function.
1. Initial population
2. Fitness function
1. INTRODUCTION 3. Selection
4. Crossover
Genetic algorithm became famous because of the work of 5. Mutation
John Holland in the early 1970s, and with the help of his
book "Adaptation in Natural and Artificial Systems (1975)".
He was the founder of genetic algorithm. A genetic 2.1 Initial Population
algorithm is a search heuristic and optimization algorithm
which is inspired by Charles Darwin’s theory of natural This process starts with a set of individuals which is called
evolution. Darwin's concept of evolution is then applied to a Population. An individual have it’s own characteristics
computer science to solve computational problems which and theses individuals are known as Genes. Genes are
takes a lot of time if solved manually .This algorithm shows combined into a string to form a Chromosome.
the process of natural selection from the generation where
the fittest individuals are selected from the generation for 2.2 Fitness Function
the reproduction in order to produce offspring of the next
generation, the fittest ones will survive in the next The fitness function determines how fit an individual is it
generation. Genetic algorithms imitate the process of will survive in next generation or not. The fitness function
natural selection. In simple words, they choose the plays a vital role in genetic algorithm. The fitness function
individuals from the generation and then find their gives score to each individual. The probability that an
objective function and follow rest of the steps to find out individual will be selected for next generation is based on
the best solution. Genetic algorithms are based on an its fitness score. The fittest ones will survive in next
analogy with genetic structure and behaviour of generation.
chromosome of the population. Genetic algorithms are
© 2020, IRJET | Impact Factor value: 7.529 | ISO 9001:2008 Certified Journal | Page 7622
International Research Journal of Engineering and Technology (IRJET) e-ISSN: 2395-0056
Volume: 07 Issue: 05 | May 2020 www.irjet.net p-ISSN: 2395-0072
The idea of selection phase is to select the fittest individuals Flowchart of genetic algorithm is as follows:
from the population and give approval to them for the next
generation. Individuals are selected based on their fitness
scores. Individuals with high fitness score have more chance
to be selected for reproduction.
2.4 Crossover
2.5 Mutation
2.6 Termination
3. GENETIC ALGORITHM
© 2020, IRJET | Impact Factor value: 7.529 | ISO 9001:2008 Certified Journal | Page 7623
International Research Journal of Engineering and Technology (IRJET) e-ISSN: 2395-0056
Volume: 07 Issue: 05 | May 2020 www.irjet.net p-ISSN: 2395-0072
F_obj[1] = Abs(( 11 + 2*5 + 3*4 + 4*0 + 5*8 ) - 20) =53 From the probabilities above we find out that the
Chromosome 3 has the highest fitness, so Chromosome 3
F_obj[2] = Abs((9 + 2*15 + 3*3 + 4*1 + 5*3) - 20) = 47 has the highest probability to be selected for the next
generation. For the selection process we use roulette
F_obj[3] = Abs((4 + 2*0 + 3*1 + 4*8 + 5*2) - 20) = 29
wheel method, for that we should compute the cumulative
F_obj[4] = Abs((1 + 2*5 + 3*13 + 4*4 + 5*6) - 20) = 76 probability values and their sum should be equal to 1 if
their sum is not equal to 1 then there is some error in
F_obj[5] = Abs((2 + 2*9 + 3*12 + 4*9 + 5*2) - 20) = 82 above computations:
The chromosomes which higher fitness will have more C[3]= 0.0167 + 0.188 + 0.301=0.3518
probability to be selected for the next generation. To
C[4]= 0.0167 + 0.188 + 0.301+0.1173 =0.7167
calculate fitness probability we have to calculate the
fitness of each chromosome. To avoid the divide by zero C[5]= 0.0167 + 0.188 + 0.301+0.1173 + 0.1083 =0.7811
problem, the value of F_obj is added by 1 so that fitness
will be calculated. C[6]= 00.0167 + 0.188 + 0.301+0.1173 + 0.1083 +
0.1191=1.00
Fitness[1] = 1 / (1+F_obj[1]) = 1/(1+53) = 0.0185
This process is used to generate random number R in the
Fitness[2] = 1 / (1+F_obj[2]) = 1/(1+47) = 0.0208 range 0-1 as follows.
Fitness[3] = 1 / (1+F_obj[3]) = 1/(1+29)= 0.0333 R[1] = 0.209
Fitness[4] = 1 / (1+F_obj[4]) = 1/(1+76) = 0.013 R[2] = 0.482
Fitness[5] = 1 / (1+F_obj[5]) = 1/(1+82) = 0.0120 R[3] = 0.111
Fitness[6] = 1 / (1+F_obj[6]) = 1/(1+75) = 0.0132 R[4] = 0.842
Total=0.0185 + 0.0208 + 0.0333 + 0.013 + 0.0120+ R[5] = 0.589
0.0132
R[6] = 0.801
=0.1108
So here we do the comparison and on the basis of that new
chromosomes will be formed. If random number R[1] is
© 2020, IRJET | Impact Factor value: 7.529 | ISO 9001:2008 Certified Journal | Page 7624
International Research Journal of Engineering and Technology (IRJET) e-ISSN: 2395-0056
Volume: 07 Issue: 05 | May 2020 www.irjet.net p-ISSN: 2395-0072
greater than C[1] and smaller than C[2] then select end;
Chromosome[2] as a chromosome in the new population
for next generation[1][2]: end;s
In this example, we use one-cut point, i.e. we randomly Chromosome[4] >< Chromosome[1]
choose a position in the parent chromosome and then
After chromosome selection, the next step is to determine
exchange sub-chromosome till we reach the one cut point.
the position of the crossover point. This is accomplished
Parent chromosome which will mate is randomly choose
by generating random numbers between 1 to length of
and the number of mate Chromosomes is controlled using
Chromosome–1. Position of crossover point = length of
crossover rate (ρc) parameters. Pseudo-code for the
chromosome-1(5-1) = 4.
crossover process is as follows:
In this case, generated random numbers should be
Begin
between 1 and 4. When we get the crossover point,
k← 0; parents Chromosome will be cut at crossover point and
genes will be interchanged. For example we will generate
while(k<population)do 3 random number and we get:
© 2020, IRJET | Impact Factor value: 7.529 | ISO 9001:2008 Certified Journal | Page 7625
International Research Journal of Engineering and Technology (IRJET) e-ISSN: 2395-0056
Volume: 07 Issue: 05 | May 2020 www.irjet.net p-ISSN: 2395-0072
Chromosome[1] = Chromosome[1] >< Chromosome[3] of total gen in the population that will be mutated: number
of mutations = 0.1 * 30 = 1.8 ≈ 3 Suppose generation of
= [09;15;03;01;03] >< [11;05;04;00;08] random number yield 2, 14 and 28 then the chromosome
which have mutation are Chromosome number 1 gen
= [09;15;04;00;08]
number 2 , Chromosome 3 gen number 4 and chromosome
Chromosome[3] = Chromosome[3] >< Chromosome[4] number 6 gen number 3. The value of mutated gets at
mutation point is replaced by random number between 0-
= [11;05;04;00;08] >< [08;14;05;11;00] 20. Suppose generated random number are 2 , 0 and 5
then Chromosome composition after mutation are:
= [11;05;04;11;00]
Chromosome[1] = [09;02;04;00;08]
Chromosome[4] = Chromosome[4] >< Chromosome[5]
Chromosome[2] = [04;00;01;08;02]
= [08;14;05;11;00] >< [04;00;01;08;02]
Chromosome[3] = [11;05;04;00;00]
= [08;00;01;08;02]
Chromosome[4] = [08;00;01;08;02]
Thus Chromosome population after experiencing a
crossover process: Chromosome[5] = [04;00;01;08;02]
Chromosome[2] = [04;00;01;08;02] After finishing the mutation process then we have one
iteration or one generation of the genetic algorithm. Now,
Chromosome[3] = [11;05;04;11;00] we can evaluate the objective function after one
generation:
Chromosome[4] = [08;00;01;08;02]
Chromosome[1] = [09;02;04;00;08]
Chromosome[5] = [04;00;01;08;02]
F_obj[1] = Abs((9+ 2*2 + 3*4 + 4*0 + 5*8 )-20)
Chromosome[6] = [02;09;12;09;01]
= 45
4.5. Mutation
F_obj[2] = Abs((4+ 2*0 + 3*1 + 4*8 +5*2 )-20)
Mutation_rate parameter determines the number of
chromosomes that have mutations in a population. = 29
Mutation process is done by replacing the generation at
random position with a new value. The process is as F_obj[3] = Abs((11+ 2*5 + 3*4 + 4*0 +5*0 )-20)
follows:
= 13
So, first we have to calculate the total length of generation
in the population. The total length of the generation is F_obj[4] = Abs((8+ 2*0 + 3*1 + 4*8 +5*2 )-20)
total_generation = = 33
number_of_generation_in_Chromosome * number of
F_obj[5] = Abs((4+ 2*0 + 3*1 + 4*8 +5*2 )-20)
population
= 29
= 5 * 6 = 30
F_obj[6] = Abs((2+ 2*9 + 3*5 + 4*9 +5*1 )-20)
Mutation process is done by generating a random integer
between 1 and total gen (1 to 30). . If the generated = 56
random number is smaller than the mutation rate(ρm)
variable then marked the position of gen in chromosomes. So, these new Chromosomes will repeat the same process
Suppose we define ρm 10%, it is expected that 10% (0.1) of genetic algorithm such as evaluation, selection,
© 2020, IRJET | Impact Factor value: 7.529 | ISO 9001:2008 Certified Journal | Page 7626
International Research Journal of Engineering and Technology (IRJET) e-ISSN: 2395-0056
Volume: 07 Issue: 05 | May 2020 www.irjet.net p-ISSN: 2395-0072
1 1 3 2 0
2 6 4 0 0
1 0 2 2 1
1 1 0 3 1
2 0 1 0 3
6 0 3 0 1
4 4 0 2 0
0 3 2 2 0
3 2 2 0 1
4 4 0 2 0
© 2020, IRJET | Impact Factor value: 7.529 | ISO 9001:2008 Certified Journal | Page 7627