Genetic Algorithms 2018
Genetic Algorithms 2018
2
Definition of the genetic algorithm (GA)
y The genetic algorithm is a probabalistic search
algorithm that iteratively transforms a set (called a
population) of mathematical objects (typically fixed-
length binary character strings),
strings) each with an
associated fitness value, into a new population of
offspring objects using the Darwinian principle of
natural selection and using operations that are
patterned after naturally occurring genetic
operations, such as crossover (sexual recombination)
and mutation.
mutation
3
A genetic algorithm search characteristic ay (Goldberg)
5
Classes of Search Techniques
S
Search
hTTechniques
h i
Genetic Genetic
og a
Programmingg Algorithms
go t s
6
Genetic algorithm
y A genetic algorithm maintains a population of candidate
solutions for the pproblem at hand,, and makes it evolve byy
iteratively applying a set of stochastic operators
p
Stochastic operators
y Selection replicates the most successful solutions found in a
population at a rate proportional to their relative quality
y Recombination decomposes two distinct solutions and
then randomly mixes their parts to form novel solutions
y Mutation randomly perturbs a candidate solution
7
The Metaphor
Genetic Algorithm Nature
8
The Metaphor (cont)
9
10
11
Flowchart of GA
• all individuals in
population evaluated by
fitness function
• individuals allowed to
reproduce (selection),
crossover, mutate
12
How does a Genetic Algorithm work?
• The selected individuals reproduce to create the next
generation.
• The crossover operator recombines the individuals
selected for reproduction with a pre-specified
probabilit of crossover.
probability crosso er
• The mutation operator induces changes in the
chromosomes (individuals) by complementing each bit of
an individual with a pre-specified probability of
mutation.
• Binary representation is common in genetic algorithm and
potential solutions are represented in the form of binary
string.
string
13
14
Generating Initial population
y Population
l size is chosen
h (1-10 individuals/parameter
d d l
optimized for most applications)
y Parameters to be optimized
p are encoded.
y After we choose a population size and encoding method, we
must choose a maximum range for each parameter.
y Ranges for parameters should be determined based on what
would be physically reasonable (if you’re interested in solving a
physical problem).
y Generate initial population of individuals (chromosomes)
y The initial population can be generated by randomizing the
genes for each chromosome of the initial population
y You can set the parameters for a few individuals if you want.
This might speed up the process.
15
Simple Genetic Algorithm
1. produce
d an initiall population
l off individuals
d d l
2. evaluate the fitness of all individuals
3. while termination condition not met do
4. select fitter individuals for reproduction
p
5. recombine between individuals
6
6. mutate
t t iindividuals
di id l
7. evaluate the fitness of the modified individuals
8. generate a new population
9. End while
16
Simple Genetic algorithm
20
TSP: Statement of the problem
y The traveling salesman problem involves a salesman who must make a
tour of a number of cities using the shortest path available and visit
each cityy exactlyy once and onlyy once and return to the original
g startingg
point.
y For each number of cities n ,the number of paths which must be
explored
l d is n!, causing thish problem
bl to grow exponentially ll rather
h than
h
as a polynomial.
y This problem is known to be NP NP-hard,
hard, and cannot be solved exactly in
polynomial time.
y The exact algorithms are designed to find the optimal solution to the
TSP, that is, the tour of minimal length. They are computationally
expensive because they must (implicitly) consider all solutions in order
to identifyy the optimum.
p
21 Prof. B. D. Sahoo, Department of
CSE, NIT Rourkela, 2008
Example: TSP solutions
25
Exercises
27