Blue Trail Software
Evolutionary Computing
Genetic Algorithms
An Introduction
Martín Pacheco
Overview of Topics
1. Biological inspiration
2. What is evolutionary computing (EC)
3. General outline of the evolutive algorithm (EA)
4. Genetic algorithm (GA) overview
5. SGA technical summary
6. SGA reproduction cycle
7. SGA operators
8. Practical Application Example:
“It is not the strongest of the
species that survives, nor the most
intelligent, but the one most
responsive to change.”
Biological Inspiration
● To understand biological processes
properly, we must first have an
understanding of the cell
● Human bodies are made up of
trillions of cells
● Each cell has a core structure
(nucleus) that contains your
chromosomes
● Additionally, each of our 23
chromosomes are made up of tightly
coiled strands of deoxyribonucleic
acid (DNA)
The Origin of
Species (1859)
Biological Inspiration
● Reproduction involves
recombination of genes
from parents and then small
amounts of mutation (errors)
in copying
● The fitness of an organism is
how much it can reproduce
before it dies
● Here is an example of the
passing of chromosomes
within human reproduction
What is evolutionary computing (EC)
● Evolution of species:
○ Natural selection
○ Genetic operators
● Biological sciences provide inspiration and
terminology
General Outline of EA
Population
Offspring
Parents
Parent selection
Recombination
Mutation
Survivor selection
Initialization
Termination
Genetic algorithm (GA) overview
● Originally developed by John Holland (1975).
● Genetic Algorithm’s have 2 essential components:
○ “Survival of the fittest”
○ Genetic Diversity
● The genetic algorithm (GA) is a search heuristic that
mimics the process of natural evolution.
● Attributed features:
○ Not too fast
Genetic algorithm (GA) overview
● Holland’s original GA is now known as the simple
genetic algorithm (SGA).
● Other GAs use different:
○ Representations
○ Mutations
○ Crossovers
○ Selections mechanisms
● Applications:
○ Optimization and Search Problems
The Simple GA
● Has been subject of many (early) studies
○ Still often used as benchmark for novel GAs
● Shows many shortcomings, e.g.
○ Representation is too restrictive
○ Mutation & crossovers only applicable for bit-string & integer
representations
○ Selection mechanism sensitive for converging populations with
close fitness values
○ Generational population model (step 5 in SGA repr. cycle) can be
improved with explicit survivor selection
SGA technical summary
Representation Binary strings
Recombination N-point or uniform
Mutation Bitwise bit-flipping with fixed
probability
Parent selection Fitness-Proportionate
Survivor selection All children replace parents
speciality Emphasis on crossover
SGA reproduction cycle
1. Select parents for the mating pool (size of mating pool
= population size)
2. Shuffle the mating pool
3. For each consecutive pair apply crossover with
probability pc , otherwise copy parents
4. For each offspring apply mutation (bit-flip with
probability pm independently for each bit)
5. Replace the whole population with the resulting
offspring
SGA operators: Point crossover
● Choose a random point on the two parents
● Split parents at this crossover point
● Create children by exchanging tails
● Pc typically in range (0.6, 0.9)0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0
Parents
Children
SGA operators: Mutation
● Alter each gene independently with a probability pm
● pm is called the mutation rate
○ Typically between 1/pop_size and 1/ chromosome_length
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
0 1 0 0 1 0 1 1 0 0 0 1 0 1 1 0 0 1
Child
Parent
SGA operators: Selection
● Main idea: better individuals get higher chance
○ Chances proportional to fitness
○ Implementation: roulette wheel technique
■ Assign to each individual a part of the roulette wheel
■ Spin the wheel n times to select n individuals
A
3/6 = 50%
B
1/6 =
17%
C
2/6 = 33%
fitness(A) = 3
fitness(B) = 1
fitness(C) = 2
N-Queen Problem
● N-Queen dates back to the 19th century (studied by
Gauss)
● Classical combinatorial problem, widely used as a
benchmark because of its simple and regular
structure.
● Problem involves placing N queen on a N x N
chessboard such that no queen can attack any other.
N-Queen Problem
This problem contains three constraints:
1. No two queens can share a same row.
2. No two queens can share a same column.
3. No two queens can share a same diameter.
N-Queen Problem: Cycle
Initialize Population
Parent Selection
Satisfy
Constraints
Children
Mutation
Insert Children
Select The Best
ThenElse
n + 1
generation
N-Queen Problem: Representation
1 4 2 3 3 1 4 2
N-Queen Problem: Representation
Genotypic space
Codification
Phenotypic space
Decodification
1 4 2 3
Chromosome
Gen
Alelo
N-Queen Problem: Fitness
[R1, R2, ..., Ri, Ri+1, ..., Rj, …, Rn]
i - Ri = j - Rj
o
i + Ri = j + Rj
|| Ri - Rj || = || i-j ||
N-Queen Problem: Parent Selection
1 2
3
5
6
7
10
9
8
4
10
1
4
5
6
9
7
3
9 4
4
9
1th
2th
N-Queen Problem: Crossover
1 4 2 3 3 1 4 2 1 4 4 2
Take a look at
● N-Queen report
● N-Queen source code at GitHub.
● Eiben, A. E. y Smith, J. E., (2015), Introduction to
Evolutionary Computing, Springer, 2da. Edición, ISBN:
978-3-540-40184-1
● Mitchell, M., (2014), An Introduction to Genetic
Algorithms, MIT Press
● Goldberg, D. E., (2007), Genetic Algorithms in Search,
Optimization, and Machine Learning, Addison-Wesley
Publishing Company, Inc., 2007, ISBN: 0201157675.
Fine, any question?

Evolutionary Computing - Genetic Algorithms - An Introduction

  • 1.
    Blue Trail Software EvolutionaryComputing Genetic Algorithms An Introduction Martín Pacheco
  • 2.
    Overview of Topics 1.Biological inspiration 2. What is evolutionary computing (EC) 3. General outline of the evolutive algorithm (EA) 4. Genetic algorithm (GA) overview 5. SGA technical summary 6. SGA reproduction cycle 7. SGA operators 8. Practical Application Example: “It is not the strongest of the species that survives, nor the most intelligent, but the one most responsive to change.”
  • 3.
    Biological Inspiration ● Tounderstand biological processes properly, we must first have an understanding of the cell ● Human bodies are made up of trillions of cells ● Each cell has a core structure (nucleus) that contains your chromosomes ● Additionally, each of our 23 chromosomes are made up of tightly coiled strands of deoxyribonucleic acid (DNA) The Origin of Species (1859)
  • 4.
    Biological Inspiration ● Reproductioninvolves recombination of genes from parents and then small amounts of mutation (errors) in copying ● The fitness of an organism is how much it can reproduce before it dies ● Here is an example of the passing of chromosomes within human reproduction
  • 5.
    What is evolutionarycomputing (EC) ● Evolution of species: ○ Natural selection ○ Genetic operators ● Biological sciences provide inspiration and terminology
  • 6.
    General Outline ofEA Population Offspring Parents Parent selection Recombination Mutation Survivor selection Initialization Termination
  • 7.
    Genetic algorithm (GA)overview ● Originally developed by John Holland (1975). ● Genetic Algorithm’s have 2 essential components: ○ “Survival of the fittest” ○ Genetic Diversity ● The genetic algorithm (GA) is a search heuristic that mimics the process of natural evolution. ● Attributed features: ○ Not too fast
  • 8.
    Genetic algorithm (GA)overview ● Holland’s original GA is now known as the simple genetic algorithm (SGA). ● Other GAs use different: ○ Representations ○ Mutations ○ Crossovers ○ Selections mechanisms ● Applications: ○ Optimization and Search Problems
  • 9.
    The Simple GA ●Has been subject of many (early) studies ○ Still often used as benchmark for novel GAs ● Shows many shortcomings, e.g. ○ Representation is too restrictive ○ Mutation & crossovers only applicable for bit-string & integer representations ○ Selection mechanism sensitive for converging populations with close fitness values ○ Generational population model (step 5 in SGA repr. cycle) can be improved with explicit survivor selection
  • 10.
    SGA technical summary RepresentationBinary strings Recombination N-point or uniform Mutation Bitwise bit-flipping with fixed probability Parent selection Fitness-Proportionate Survivor selection All children replace parents speciality Emphasis on crossover
  • 11.
    SGA reproduction cycle 1.Select parents for the mating pool (size of mating pool = population size) 2. Shuffle the mating pool 3. For each consecutive pair apply crossover with probability pc , otherwise copy parents 4. For each offspring apply mutation (bit-flip with probability pm independently for each bit) 5. Replace the whole population with the resulting offspring
  • 12.
    SGA operators: Pointcrossover ● Choose a random point on the two parents ● Split parents at this crossover point ● Create children by exchanging tails ● Pc typically in range (0.6, 0.9)0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 Parents Children
  • 13.
    SGA operators: Mutation ●Alter each gene independently with a probability pm ● pm is called the mutation rate ○ Typically between 1/pop_size and 1/ chromosome_length 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 0 0 1 0 1 1 0 0 0 1 0 1 1 0 0 1 Child Parent
  • 14.
    SGA operators: Selection ●Main idea: better individuals get higher chance ○ Chances proportional to fitness ○ Implementation: roulette wheel technique ■ Assign to each individual a part of the roulette wheel ■ Spin the wheel n times to select n individuals A 3/6 = 50% B 1/6 = 17% C 2/6 = 33% fitness(A) = 3 fitness(B) = 1 fitness(C) = 2
  • 15.
    N-Queen Problem ● N-Queendates back to the 19th century (studied by Gauss) ● Classical combinatorial problem, widely used as a benchmark because of its simple and regular structure. ● Problem involves placing N queen on a N x N chessboard such that no queen can attack any other.
  • 16.
    N-Queen Problem This problemcontains three constraints: 1. No two queens can share a same row. 2. No two queens can share a same column. 3. No two queens can share a same diameter.
  • 17.
    N-Queen Problem: Cycle InitializePopulation Parent Selection Satisfy Constraints Children Mutation Insert Children Select The Best ThenElse n + 1 generation
  • 18.
  • 19.
    N-Queen Problem: Representation Genotypicspace Codification Phenotypic space Decodification 1 4 2 3 Chromosome Gen Alelo
  • 20.
    N-Queen Problem: Fitness [R1,R2, ..., Ri, Ri+1, ..., Rj, …, Rn] i - Ri = j - Rj o i + Ri = j + Rj || Ri - Rj || = || i-j ||
  • 21.
    N-Queen Problem: ParentSelection 1 2 3 5 6 7 10 9 8 4 10 1 4 5 6 9 7 3 9 4 4 9 1th 2th
  • 22.
    N-Queen Problem: Crossover 14 2 3 3 1 4 2 1 4 4 2
  • 23.
    Take a lookat ● N-Queen report ● N-Queen source code at GitHub. ● Eiben, A. E. y Smith, J. E., (2015), Introduction to Evolutionary Computing, Springer, 2da. Edición, ISBN: 978-3-540-40184-1 ● Mitchell, M., (2014), An Introduction to Genetic Algorithms, MIT Press ● Goldberg, D. E., (2007), Genetic Algorithms in Search, Optimization, and Machine Learning, Addison-Wesley Publishing Company, Inc., 2007, ISBN: 0201157675.
  • 24.