0% found this document useful (0 votes)
54 views

Introduction To Genetic Algorithms (GA)

Genetic algorithms are a type of optimization technique based on principles of natural selection and genetics. They work by simulating the natural evolution process of populations. The genetic algorithm begins with a population of chromosomes that encode potential solutions. It then applies genetic operators like crossover and mutation to produce a new generation. Fitness functions evaluate the population and the most fit individuals are selected to pass their genes on to the next generation. This process is repeated until an optimal or near-optimal solution emerges.

Uploaded by

Saksham Rawat
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
54 views

Introduction To Genetic Algorithms (GA)

Genetic algorithms are a type of optimization technique based on principles of natural selection and genetics. They work by simulating the natural evolution process of populations. The genetic algorithm begins with a population of chromosomes that encode potential solutions. It then applies genetic operators like crossover and mutation to produce a new generation. Fitness functions evaluate the population and the most fit individuals are selected to pass their genes on to the next generation. This process is repeated until an optimal or near-optimal solution emerges.

Uploaded by

Saksham Rawat
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 46

Genetic

algorithms(GA)
Module 4
Introduction to genetic
Algorithms(GA)
• Genetic Algorithm (GA) is a search-based optimization technique
based on the principles of Genetics and Natural Selection.
• It is frequently used to find optimal or near-optimal solutions to
difficult problems which otherwise would take a lifetime to solve.
• It is frequently used to solve optimization problems, in research,
and in machine learning.
Optimisatio
n• Optimization is the process of making something better.
• In any process, we have a set of inputs and a set of outputs as shown
in the following figure.

Optimization refers to finding the values of inputs in such a way that we get the “best” output values.
“best” varies from problem to problem, but in mathematical terms, it refers to maximizing or
minimizing one or more objective functions, by varying the input parameters.
Genetic
algorithms(GAs)
• Genetic Algorithms (GAs) are search based algorithms based on the
concepts of natural selection and genetics.
• GAs are a subset of a much larger branch of computation known
as Evolutionary Computation.
• Genetic Algorithms are the heuristic search and optimization
techniques that mimic the process of natural evolution.
• GAs were developed by John Holland and his students and colleagues
at the University of Michigan, most notably David E. Goldberg and has
since been tried on various optimization problems with a high degree
of success.
Survival of the fittest- Charles
Darwin
• Many people assume that "the fittest" refers to the strongest, biggest, or
smartest and most cunning individuals.
• The fittest individuals are simply the ones who have the combination
of traits that allow them to survive and produce more offspring in
their particular environment.
• What makes an individual fit all depends on the environment at the
time and the combination of traits that are most suited to flourishing in
it.
• He believed that evolution was a random process, that it was just
chance that an organism was born into just the right environment with
just the right combination of genes to allow it to survive in that
particular environment.
Theory of natural selection-
Example
• Giraffes have long necks
• Giraffes with slightly longer necks could feed on leaves of higher
branches when all lower ones had been eaten off.
• They had a better chance of survival.
• Favorable characteristic propagated through generations of
giraffes.
• Now, evolved species has long necks.
Exampl
e
• This longer necks may have due to the effect of mutation initially.
However as it was favourable, this was propagated over the
generations
•Thus genetic algorithms implement the
optimization strategies by simulating evolution
of species through natural selection
Advantages of
GAs
• Does not require any derivative information (which may not be available
for many real-world problems).
• Is faster and more efficient as compared to the traditional methods.
• Has very good parallel capabilities.
• Optimizes both continuous and discrete functions and also multi-objective
problems.
• Provides a list of “good” solutions and not just a single solution.
• Always gets an answer to the problem, which gets better over the time.
• Useful when the search space is very large and there are a large number
of parameters involved.
Limitations of
GAs
• GAs are not suited for all problems, especially problems which are
simple and for which derivative information is available.
• Fitness value is calculated repeatedly which might be computationally
expensive for some problems.
• Being stochastic, there are no guarantees on the optimality or the
quality of the solution.
• If not implemented properly, the GA may not converge to the optimal
solution.
Reasons for
GAs
• The reasons why GAs are needed are as follows −
• Solving difficult problems
• Failure of gradient based methods
• Getting a good solutions fast
Failure of gradient based methods
Traditional calculus based methods work
by starting at a random point and by
moving in the direction of the gradient, till
we reach the top of the hill. This
technique is efficient and works very well
for single-peaked objective functions like
the cost function in linear regression.
But, in most real-world situations, we
have a very complex problem called as
landscapes, which are made of many
peaks and many valleys, which causes
such methods to fail, as they suffer from
an inherent tendency of getting stuck at
the local optima as shown in the following
figure.
Simple genetic
algorithms
Simple genetic
algorithm
GA basic
terminology
• Population − It is a subset of all the possible (encoded) solutions to
the given problem. The population for a GA is analogous to the
population for human beings except that instead of human beings,
we have Candidate Solutions representing human beings.
• Chromosomes − A chromosome is one such solution to the given
problem.
• Gene − A gene is one element position of a chromosome.
• Allele − It is the value a gene takes for a particular chromosome.
GA basic
terminology…
• Genotype − Genotype is the population in the computation space. In the
computation space, the solutions are represented in a way which can
be easily understood and manipulated using a computing system.
• Phenotype − Phenotype is the population in the actual real world
solution
space in which solutions are represented in a way they are represented
in real world situations.
• Decoding and Encoding − For simple problems, the phenotype and
genotype spaces are the same. However, in most of the cases,
the phenotype and genotype spaces are different.
• Decoding is a process of transforming a solution from the genotype to the
phenotype space,
• while encoding is a process of transforming from the phenotype to
genotype space.
GA basic
terminology
• Fitness Function − A fitness function simply defined is a function
which takes the solution as input and produces the suitability of the
solution as the output. In some cases, the fitness function and the
objective function may be the same, while in others it might be
different based on the problem.
• Genetic Operators − These alter the genetic composition of the
offspring. These include crossover, mutation, selection, etc.
Basic structure of
GA
GA parameters
• Crossover
• Mutation
• Selection
CROSS OVER
Crossove
r
• Crossover takes two individuals, and cuts their chromosome strings at
some randomly chosen position, to produce two “head" segments,
and two “tail" segments.
• The tail segments are then swapped over to produce two new full
length chromosomes.
crossover
Types of crossover-4
types
• There are 4 types of crossover: single point, two-point, uniform and
arithmetic crossover.
• Single point crossover - one crossover point is selected, binary string
from beginning of chromosome to the crossover point is copied from
one parent, the rest is copied from the second parent

11001011+11011111 =
11001111
Two-point
•crossover
Two point crossover - two crossover point are selected, binary string
from beginning of chromosome to the first crossover point is copied
from one parent, the part from the first to the second crossover point
is copied from the second parent and the rest is copied from the first
parent.

11001011 + 11011111 =
11011111
Uniform Crossover and arithmetic
crossover
Uniform crossover - bits are randomly copied from the first or from the second
parent

11001011 + 11011101 = 11011111

Arithmetic crossover - some arithmetic operation is performed to make a new offspring

11001011 + 11011111 = 11001001 (AND)


SELECTION
selection
• The process that determines which solutions are to be preserved and
allowed to reproduce and which ones deserve to die out.
• The primary objective of the selection operator is to emphasize the
good solutions and eliminate the bad solutions in a population while
keeping the population size constant.

“Selects the best, discards the rest”


Functions of selection operator
• Step 1: Identify the good solutions in a population
• Step 2: Make multiple copies of the good solutions
• Step 3: Eliminate bad solutions from the population so that multiple
copies of good solutions can be placed in the population
Now how to identify the good solutions?
Selection operator
• There are different techniques to implement selection in Genetic
Algorithms.
• They are:
• Tournament selection
• Roulette wheel selection
• Proportionate selection
• Rank selection
• Steady state selection, etc
Tournament
selection
• In tournament selection several tournaments are played among a few
individuals. The individuals are chosen at random from the
population.
• The winner of each tournament is selected for next generation.
• Selection pressure can be adjusted by changing the tournament size.
• Weak individuals have a smaller chance to be selected if tournament
size is large.
Algorithm for tournament selection
Roulette wheel selection
• Parents are selected according to their fitness values
• The better chromosomes have more chances to be selected
Rank
selection
Steady state selection
MUTATION
Mutation
• Mutation is the occasional introduction of new features in to the
solution strings of the population pool to maintain diversity in the
population.
• Though crossover has the main responsibility to search for the
optimal solution, mutation is also used for this purpose.
Binary
mutation
• Mutation operator changes a 1 to 0 or vice versa, with a mutation
probability of .
• The mutation probability is generally kept low for steady
convergence.
• A high value of mutation probability would search here and there like
a random search technique.
Selection, crossover and mutation
ELITIS
M
• Crossover and mutation may destroy the best solution of
the population pool
• Elitism is the preservation of few best solutions of the population
pool
• Elitism is defined in percentage or in number
Traveling Salesman Problem using
• https://www.youtube.com/watch?v=3GAfjE_ChRI
GA

You might also like