BTech 2024 ML Genetic Algorithms
BTech 2024 ML Genetic Algorithms
Contents
1. Introduction
2. Examples
3. Genetic Algorithms & Applications
4. Conclusion
1. Introduction
What is GA
The search space (design space) may be so large that global optimum cannot be found in a reasonable time.
The existing linear or nonlinear methods may not be efficient or computationally expensive for solving such
problems.
Various stochastic search methods like Simulated annealing, Evolutionary Algorithms (EA) or Hill Climbing can
be used in such situations.
EAs have the advantage of being applicable to any combination of complexities (multi-objective, non-linearity
etc) and also can be combined with any existing local search or other methods.
To understand
The adaptive processes of natural systems
To design artificial systems software that retains
The robustness of natural systems
5
Classes of Search Techniques
Search
Techniques
Calculations Enumerative
BasedTechniqes Guided random search Techniqes
techniques
6
Basic Terminology
Search Space
All possible solutions to the problem
Population
It is a subset of all the possible (encoded) solutions to the given problem.
Chromosomes
A chromosome is one such solution to the given problem.
Gene
A gene is one element position of a chromosome.
Genome
Collection of all chromosomes for an individual
Allele
It is the value a gene takes for a particular chromosome.
Individual
Any possible solution
Trait
Possible aspect (features) of an individual
Locus
The position of a gene on the chromosome
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.
1. Initialization
1. Initially many individual solutions are randomly generated to form an initial population. The
population size depends on the nature of the problem, but typically contains several hundreds or
thousands of possible solutions.
2. Selection
1. A proportion of the existing population is selected to breed a new generation.
2. Individual solutions are selected through a fitness-based process, where fitter solutions (as measured
by a fitness function) are typically more likely to be selected. (Ex: Roulette wheel selection)
3. Reproduction
1. Generate a second generation population of solutions from those selected through genetic
operators:
1. Crossover (also called recombination)
2. Mutation
4. Termination
1. This generational process is repeated until a termination condition has been
reached.
Common terminating conditions are:
A solution is found that satisfies minimum criteria
Cross Over and Mutation
Cross Over
In single point crossover, you choose a locus at which you swap the remaining alleles from
one parent to the other. This is complex and is best understood visually.
Example: As you can see, the children take one section of the chromosome from each
parent.
The probability of crossover occurring is usually 60% to 70%.
Mutation
Mutation is fairly simple. You just change the selected alleles based on what you feel is
necessary and move on.
Mutation is, however, vital to ensuring genetic diversity within the population.
Psudo Code of basic Genetic Algorithm
Algorithm
Initialize population;
Evaluate population;
while Termination_Criteria_Not_Satisfied
Evaluate population;
}
Genetic Algorithm (GA) Functioning
Generation Generation
0 1
Individuals Fitness Offspring
011 $3 111
001 $1 010
110 $6 110
010 $2 010
Detailed Explanation: Steps in GA
Step 1:
Represent the problem variable domain as a chromosome of a fixed length,
choose the size of a chromosome population N, the crossover probability pc and
the mutation probability pm.
Step 2:
Define a fitness function to measure the performance, or fitness, of an individual
chromosome in the problem domain. The fitness function establishes the basis
for selecting chromosomes that will be mated during reproduction.
Step 3:
Randomly generate an initial population of chromosomes of size N:
x 1, x 2 , . . . , x N
Step 4:
Calculate the fitness of each individual chromosome:
f (x1), f (x2), . . . , f (xN)
Step 5:
Select a pair of chromosomes for mating from the current population.
Parent chromosomes are selected with a probability
related to their fitness.
Selection of a pair of Parents
Starting city may not be same as ending city (one example problem)
Starting city and ending city are the same (another example problem)
17
Representation
Representation is an ordered list of city [numbers known as an order-based
GA]
1) London 3) Dunedin 5) Beijing 7) Tokyo
2) Venice 4) Singapore 6) Phoenix 8) Victoria
-------------------------------------------------------
City List 1 (3 5 7 2 1 6 4 8)
City List 2 (2 5 7 6 8 1 3 4)
18
Crossover
Crossover combines inversion and recombination (locus
points from 3 to 6 have been selected for cross-over)
City List-1 (3 5 7 2 1 6 4 8)
City List-2 (2 5 7 6 8 1 3 4)
City List- New1 (2 5 7 8 1 6 3 4)
City List- New2 (3 5 7 6 2 1 4 8)
This operator is called order-based crossover.
After the cross-over, a minor correction is required to fulfil
the condition of uniqueness of indices. Changed indices are
shown in red color
19
Mutation
Mutation applied on first off-spring [City List- New1]. Here as
part of mutations, swapping is performed (we need to define
mutation, contextually). 2nd and 7th locations have been
swapped.
Before: (2 5 7 8 1 6 3 4)
After: (2 3 7 8 1 6 5 4)
20
New Population after cross-over and mutation
(8 cities case)
1. City List-1 (3 5 7 2 1 6 4 8)
2. City List-2 (2 5 7 6 8 1 3 4)
3. City List-3 (2 3 7 8 1 6 5 4) child-1
4. City List-4 (3 5 7 6 2 1 4 8) child-2
Fitness value of each list is computed:
Definition of Fitness function vary problem to problem
Fitness function for TSP problem?
Retain the lists with fitness values more than the pre-defined
threshold
21
TSP Example: 30 Cities
22
Solution i (Distance = 941)
23
Solution j (Distance = 800)
24
Solution k (Distance = 652)
25
Best Solution (Distance = 420)
26
Overview of Performance
27
Example: f(x)=x2
1.Selection
A.E Eiben and J.E Smith, Introduction to Evolutionary Computing :Genetic Algorithms
Considering the GA Technology
Termination Criteria
Performance, scalability
Cons
Randomized – not optimal or even complete.
Can get stuck on local maxima, though crossover / mutation can
help mitigate this.
It can be hard to work out how best to represent a candidate as a
bit string (or otherwise).
35
Local Minima Problem
Benefits of Genetic Algorithms
Concept is easy to understand
3. E. Anderson. The Irises of the Gaspe Peninsula. Bull. Amer. Iris Soc., 59:2-5, 1935.
4. Bäck and H.-P. Schwefel. An overview of evolutionary algorithms for par greeter
optimization. Evolutionary Computation, 1(1):1-23, 1993.