of 71
8/8/2019 Genetic Algorithms (GA) Presentation
1/71
Genetic Algorithms (GA)Genetic Algorithms (GA)
Genetic Algorithms are good at taking large, potentially huge search spaces and navigating them, looking for optimal combinations of
things, solutions you might not otherwise find in a lifetime.
8/8/2019 Genetic Algorithms (GA) Presentation
2/71
8/8/2019 Genetic Algorithms (GA) Presentation
3/71
Introduction
Computing pioneers (especially in AI) lookedto natural systems as guiding metaphorsEvolutionary computation
Any biologically-motivated computing activitysimulating natural evolution
Genetic Algorithms are one form of thisactivity
Directed search algorithms based on the mechanicsof biological evolution
Original goalsFormal study of the phenomenon of adaptation
John HollandAn optimization tool for engineering problems
8/8/2019 Genetic Algorithms (GA) Presentation
4/71
Provide efficient, effectivetechniques for optimization and
machine learning applicationsWidely-used today in business,scientific and engineering circles
Introduction (cont..)
8/8/2019 Genetic Algorithms (GA) Presentation
5/71
Classes of Search Techniques
Finonacci Newton
Direct etho
s In
irect etho
s
Calculus-base t
echniques
Evolutionary strate
ies
Centralized Distributed
Parallel
Steady-state Generational
Sequential
Genetic algorithms
Evolutionary algorithms Si
ulate annealin
Guidedrandomsearchtechniques
Dyna
ic pro
ra
in
Enu
erativetechniques
Searchtechniques
8/8/2019 Genetic Algorithms (GA) Presentation
6/71
Wh e olution as a meta hor
o Ability to efficiently guide a search througha large solution spaceAbility to adapt solutions to changingenvironments
Emergent behavior is the goal The hoped-for emergent behavior isthe design of high-quality solutions todifficult problems and the ability toadapt these solutions in the face of achanging environment
Melanie Mitchell, An Introduction to GeneticAlgorithms
8/8/2019 Genetic Algorithms (GA) Presentation
7/71
Ev olutionar terminolog
Abstractions imported from biologyChromosomes, Genes, AllelesFitness, SelectionCrossover, Mutation
8/8/2019 Genetic Algorithms (GA) Presentation
8/71
Com onents of a GA
Encoding technique ( gene, chromosome )Initialization procedure ( creation)Evaluation function ( environment)Selection of parents ( reproduction)Genetic operators ( mutation, recombination)Parameter settings ( practice and art)( Parameters that affect GA are initial population, size of the
population, selection process and fitness function)
8/8/2019 Genetic Algorithms (GA) Presentation
9/71
GA terminolog
GA chromosomes are strings of genesEach gene has a number of alleles; i.e.,settings
Each chromosome is an encoding of asolution to a problem
A population of such chromosomes isoperated on by a GA
8/8/2019 Genetic Algorithms (GA) Presentation
10/71
Encoding
A data structure for representing candidatesolutions
Often takes the form of a bit string
Usually has internal structure; i.e., differentparts of the string represent differentaspects of the solution)
8/8/2019 Genetic Algorithms (GA) Presentation
11/71
Crosso ver
Mimics biological recombinationSome portion of genetic material is swappedbetween chromosomes
Typically the swapping produces an offspring
Mechanism for the dissemination of building blocks (schemas)
8/8/2019 Genetic Algorithms (GA) Presentation
12/71
Mutation
Selects a random locus gene location with some probability and alters the alleleat that locus
The intuitive mechanism for thepreservation of variety in the population
8/8/2019 Genetic Algorithms (GA) Presentation
13/71
8/8/2019 Genetic Algorithms (GA) Presentation
14/71
A Sim le GA
Generate initial population
doCalculate the fitness of each member
// simulate another generationdo
Select parents from current populationPerform crossover add offspring to the
new population while new population is not full
Merge new population into the current population
Mutate current population
while not converged
8/8/2019 Genetic Algorithms (GA) Presentation
15/71
Ho do GAs ork
The structure of a GA is relatively simpleto comprehend, but the dynamic behavioris complex
GAs work by discovering, emphasizing,and recombining good building blocks of solutions in a highly parallel fashion. Using formalism
Notion of a building block is formalized as aschemaSchemas are propagated or destroyedaccording to the laws of probability
8/8/2019 Genetic Algorithms (GA) Presentation
16/71
Schema
A template, much like a regularexpression, describing a set of stringsThe set of strings represented by a givenschema, characterizes a set of candidatesolutions sharing a propertyThis property is the encoded equivalent of a building block
8/8/2019 Genetic Algorithms (GA) Presentation
17/71
Ex am le
0 or 1 represents a fixed bit
Asterisk represents a dont care
11**** 00 is the set of all solutionsencoded in 8 bits, beginning with two onesand ending with two zeros
Solutions in this set all share the samevariants of the properties encoded at theseloci
8/8/2019 Genetic Algorithms (GA) Presentation
18/71
Schema qualifiers
LengthThe inclusive distance between the two bitsin a schema which are furthest apart
(the defining length of the previous example is 8)
OrderThe number of fixed bits in a schema
(the order of the previous example is 4)
8/8/2019 Genetic Algorithms (GA) Presentation
19/71
Not just sum of the arts
GAs explicitly evaluate and operate onwhole solutions
GAs implicitly evaluate and operate onbuilding blocks
Existing schemas may be destroyed orweakened by crossover
New schemas may be spliced together fromexisting schema
8/8/2019 Genetic Algorithms (GA) Presentation
20/71
Wh do the ork
Schemas can be destroyed or conserved
So how are good schemas propagatedthrough generations?
Conserved good schemas confer higherfitness on the offspring inheriting them
Fitter offspring are probabilistically morelikely to be chosen to reproduce
8/8/2019 Genetic Algorithms (GA) Presentation
21/71
A ro ximating schema d namics
Let H be a schema with at least one instancepresent in the population at time tLet m(H, t) be the number of instances of H at
time tLet x be an instance of H and f(x) be its fitnessThe expected number of offspring of x isf(x)/f(pop) (by fitness proportionate selection)
To know E(m(H, t +1)) (the expected numberof instances of schema H at the next timeunit), sum f(x)/f(pop) for all x in H
GA never explicitly calculates the averagefitness of a schema, but schema
proliferation depends on its value
8/8/2019 Genetic Algorithms (GA) Presentation
22/71
A ro ximating schema d namics
Approximation can be refined by takinginto account the operators
Schemas of long defining length are lesslikely to survive crossover
Offspring are less likely to be instances of such schemas
Schemas of higher order are less likely tosurvive mutation
8/8/2019 Genetic Algorithms (GA) Presentation
23/71
Im lications
Instances of short, low-order schemas whoseaverage fitness tends to stay above the meanwill increase exponentially
Changing the semantics of the operators canchange the selective pressures towarddifferent types of schemas
Lemmas t t e ema T eo r emSelection focuses the searchCrossover combines good schemasMutation is the insurance policy
8/8/2019 Genetic Algorithms (GA) Presentation
24/71
Sim le Genetic Algorithm{
initialize population;evaluate population;while TerminationCriteriaNotSatisfied{
select parents for reproduction;perform recombination and mutation;
evaluate population;}}
8/8/2019 Genetic Algorithms (GA) Presentation
25/71
The GA Cy cle of Re roduction
re roduction
o ulation e valuation
modification
discard
deleted
members
parents
children
modified
children
evaluated children
8/8/2019 Genetic Algorithms (GA) Presentation
26/71
P o ulation
Chromosomes could be:Bit strings ( 0 1 0 1 ... 11 00 )Real numbers (43.2 -33.1 ... 0 .0 89.2)Permutations of element (E11 E3 E7 ... E1 E15)Lists of rules (R1 R2 R3 ... R22 R23)Program elements (genetic programming)
... any data structure ...
population
8/8/2019 Genetic Algorithms (GA) Presentation
27/71
Re p roduction
re production
population
parents
children
P arents are selected at random ithselection chances iased in relation tochromosome e valuations.
8/8/2019 Genetic Algorithms (GA) Presentation
28/71
Chromosome Modification
modificationchildren
Modifications are stochastically triggeredOperator types are:
MutationCrossover (recombination)
modified children
8/8/2019 Genetic Algorithms (GA) Presentation
29/71
Mutation: Local Modification
Before: (1 0 1 1 0 1 1 0)
After: (0 1 1 0 0 1 1 0)
Before: (1.38 -69.4 326.44 0.1)
After: (1.38 -67.5 326.44 0.1)
Causes movement in the search space(local or global)Restores lost information to the population
8/8/2019 Genetic Algorithms (GA) Presentation
30/71
Crosso ver: Recom ination
P1 ( 0 1 1 0 1 0 0 0 ) ( 0 1 0 0 1 0 0 0 ) C1P2 (1 1 0 1 1 0 1 0 ) (1 1 1 1 1 0 1 0 ) C2
Crossover is a critical feature of geneticalgorithms:
It greatly accelerates search early inevolution of a populationIt leads to effective combination of schemata (sub solutions on differentchromosomes)
*
8/8/2019 Genetic Algorithms (GA) Presentation
31/71
Ev aluation
The evaluator decodes a chromosome and
assigns it a fitness measureThe evaluator is the only link between aclassical GA and the problem it is solving
e valuation
evaluated children
modified children
8/8/2019 Genetic Algorithms (GA) Presentation
32/71
Deletion
Generational GA:entire populations replaced with eachiterationS teady-state GA:a few members replaced each generation
population
discard
discarded members
8/8/2019 Genetic Algorithms (GA) Presentation
33/71
Generational GA
All parents reproduce at the same timeOffspring generation replaces parentgeneration
:: :
Current OffspringParent (temporary)
8/8/2019 Genetic Algorithms (GA) Presentation
34/71
8/8/2019 Genetic Algorithms (GA) Presentation
35/71
P opu la tion In itia liz a tion
Start ith a population of randoml y generated indi viduals, or use
- A p re viousl y sa ved population- A set of solutions p rovided y a human e xpert- A set of solutions p rovided y
another heuristic algorithm
8/8/2019 Genetic Algorithms (GA) Presentation
36/71
P a r en t e lec tion
Selection is a procedure of picking parent chromosome toproduce off-spring.Types of selection:
Random Selection Parents are selected randomly from thepopulation.Proportional Selection probabilities for picking eachchromosome is calculated
Rank Based Selection This method uses ranks instead of absolute fitness values.
o Purpose : to focus the search in promising regions of thespaceInspiration : Darwins survival of the fittest Trade-off between exploration and exploitation of the searchspace
8/8/2019 Genetic Algorithms (GA) Presentation
37/71
Ho to select these chromosomes
o Selection Methodso Fitness Proportionate Selection
o Roulette wheel selectiono Rank selection
o Steady state selectiono Tournament selectiono Others..
8/8/2019 Genetic Algorithms (GA) Presentation
38/71
F itness P roportionate Selection
A simple selection method is each individual,i , has the probabilityFitness ( i) / sum_over_all_individuals_j Fitness ( j)
where Fitness ( i) is the fitness function valuefor individual i .
8/8/2019 Genetic Algorithms (GA) Presentation
39/71
Roulette Wheel SelectionRoulette Wheel Selection
Chromosome Fitness % of total
1 6.82 31
2 1.11 5
3 8.48 38
4 2.57 12
5 3.08 14
Total 22.0 100
Imagine a roulette wheel where are placed allchromosomes in the population, every has its place bigaccordingly to its fitness function, like on the followingpicture.
8/8/2019 Genetic Algorithms (GA) Presentation
40/71
Roulette Wheel SelectionRoulette Wheel Selection ( cont..)( cont..)Let i = 1, where i denotes chromosome index;Calculate P( x i) using proportional selection;
Calculate sum of all chromosome fitness in population -sum S .Generate random number from interval (0, S) - r .
sum = P( x i);wh i le sum < r d o
i = i + 1; i.e. next chromosomesum = sum + P( x i);
en d
returnx
i as one of the selected parent;repeat unt i l all parents are selected
D rawback:If the best chromosome fitness is 9 0% of all the roulette
wheel then the other chromosomes will have very few
chances to be selected
8/8/2019 Genetic Algorithms (GA) Presentation
41/71
Rank SelectionRank Selection
Rank selection first ranks the population and thenevery chromosome receives fitness from thisranking. The worst will have fitness 1 , second worst2 etc. and the best will have fitness N (number of
chromosomes in population).
S ituation before ranking ( graph of fitnesses)
8/8/2019 Genetic Algorithms (GA) Presentation
42/71
Rank SelectionRank Selection ( cont..)( cont..)
S ituation after ranking ( graph of order numbers)
D rawback:This method can lead to slower convergence, because the best
chromosomes do not differ so much from other ones.
8/8/2019 Genetic Algorithms (GA) Presentation
43/71
S tea dy-S tate S elect i on
Main idea of this selection is that big part of chromosomes should survive to nextgeneration.
GA then works in a following way.In every generation are selected a few
(good - with high fitness) chromosomes forcreating a new offspring. Then some (bad -with low fitness) chromosomes areremoved and the new offspring is placed intheir place. The rest of population survivesto new generation.
8/8/2019 Genetic Algorithms (GA) Presentation
44/71
T ournament S elect i on
Binary tournamentTwo individuals are randomly chosen; thefitter of the two is selected as a parent
Probabilistic binary tournamentTwo individuals are randomly chosen; with achance p , 0 .5 < p < 1, the fitter of the two isselected as a parent
Larger tournamentsn individuals are randomly chosen; thefittest one is selected as a parent
By changing n and/or p , the GA can beadjusted dynamically
8/8/2019 Genetic Algorithms (GA) Presentation
45/71
Re p roduction
Reproduction operatorsCrossoverMutation
CrossoverTwo parents produce two offspringThere is a chance that the chromosomes of the twoparents are copied unmodified as offspringThere is a chance that the chromosomes of the twoparents are randomly recombined (crossover) to form
offspringGenerally the chance of crossover is between 0 .6 and1. 0
MutationThere is a chance that a gene of a child is changedrandomlyGenerally the chance of mutation is low (e.g. 0 .00 1)
8/8/2019 Genetic Algorithms (GA) Presentation
46/71
Crosso ver
Performed on two chromosomes asparentsThe probability of parents being crossed
over is given by crossover rateCrossover points are randomly selectedExchanges genetic code between parentsto create two new chromosomes asoffspringCommonly used crossover
One-point crossoverTwo-point crossoverUniform crossover
8/8/2019 Genetic Algorithms (GA) Presentation
47/71
One- P oint Crosso ver
Only one crossover point is selectedfor each parent
11011100
01100110
110 00110
011 11100Parent 1:
Parent 2:
Offspring 1
Offspring 2
Crossover point
8/8/2019 Genetic Algorithms (GA) Presentation
48/71
One- P oint Crosso ver
AdvantagesSimple to implement
Little disruption on evolved schemasWeakness
Cannot combine many schemas
1 * * * 1 1
* 0 0 * * *1 0 0 * 1 1
8/8/2019 Genetic Algorithms (GA) Presentation
49/71
T o- P oint Crosso ver
Two crossover points are selectedfor each parent
11011100
01100110
Parent 1
Parent 2
110 00 100
011 11 110
Offspring 1
Offspring 2
Crossover Points
8/8/2019 Genetic Algorithms (GA) Presentation
50/71
T o- P oint Crosso ver
AdvantageMore likely to combine schemas(downside: more likely to disruptexisting schemas)
1 * * * 1 1
* 0 0 * * *
1 0 0 * 1 1
8/8/2019 Genetic Algorithms (GA) Presentation
51/71
Uniform Crosso ver
Every gene can be swapped betweenthe parents independent of the other
genesThe probability of swapping genes isfixed at P0No need to select crossover points
11011100
01100110
Parent 1
Parent 2
1 1 0 0 11 10
0 1 1 1 01 00
Offspring 1
Offspring 2
8/8/2019 Genetic Algorithms (GA) Presentation
52/71
8/8/2019 Genetic Algorithms (GA) Presentation
53/71
Distri ution Bias
The number of genes to be swapped may bedistributed around a particular value instead of uniformly from 1 to L-1 ( L = individual length)
One-point crossover has no distribution biasCrossover point is selected randomly within thechromosome
Uniform crossover has high distribution biasThe number of genes to be swapped depends on
P0
8/8/2019 Genetic Algorithms (GA) Presentation
54/71
Mutation
Involves only one chromosomeApplies to each gene individuallyThe value of a mutated gene is flipped
The probability of a gene being mutatedis controlled by mutation rate M
The mutation rate per chromosome = M * LLow mutation rate: low exploration powerHigh mutation rate: too disruptive
11011 1 00 11011 0 00
8/8/2019 Genetic Algorithms (GA) Presentation
55/71
Imp lementation Variations
Varying rates of Crossover/MutationStart with low mutation rate and increase afterwardsStart with high crossover rate and decrease afterwards
Adaptive crossover and mutation ratesAdjust rates under certain conditions
Problem dependent variationsRandom crossover for variable length GAs
Crossover points can be selected separately forparentsCreates offspring with different lengths from theirparents
Parent 1
Parent 2
Offspring 1
Offspring 2
8/8/2019 Genetic Algorithms (GA) Presentation
56/71
Other Genetic Operators
Inversion
4 1 2 3 0 5
2 1 4 3 0 5
Transposition
4 1 2 3 0 5
3 0 5 4 1 2
8/8/2019 Genetic Algorithms (GA) Presentation
57/71
A Sim p le Exam p le
The Traveling Salesman Problem:
Find a tour of a given set of cities sothat
each city is visited only once
the total distance traveled is minimized
8/8/2019 Genetic Algorithms (GA) Presentation
58/71
Re p resentation
Representation is an ordered list of citynumbers known as an order-based GA.
2) London 3) Dunedin 5) Beijing4) Singapore 6) Phoenix
City List1 (3 5 2 6 4)
City List2 (2 5 6 3 4)
8/8/2019 Genetic Algorithms (GA) Presentation
59/71
Initial P opulation for TS P
(5,3,4,6,2) (2,4,6,3,5) (4,3,6,5,2)
(2,3,4,6,5) (4,3,6,2,5) (3,4,5,2,6)
(3,5,4,6,2) (4,5,3,6,2) (5,4,2,3,6)
(4,6,3,2,5) (3,4,2,6,5) (3,6,5,2,4)
8/8/2019 Genetic Algorithms (GA) Presentation
60/71
8/8/2019 Genetic Algorithms (GA) Presentation
61/71
Create Off-Sp ring 1 point
(5,3,4,6,2) (2,4,6,3,5) (4,3,6,5,2)
(2,3,4,6,5) (4,3,6,2,5) (3,4,5,2,6)
(3,5,4,6,2) (4,5,3,6,2) (5,4,2,3,6)
(4,6,3,2,5) (3,4,2,6,5) (3,6,5,2,4)
(3,4,5,6,2)
8/8/2019 Genetic Algorithms (GA) Presentation
62/71
(3,4,5,6,2)
Create More Offsp ring
(5,3,4,6,2) (2,4,6,3,5) (4,3,6,5,2)
(2,3,4,6,5) (4,3,6,2,5) (3,4,5,2,6)
(3,5,4,6,2) (4,5,3,6,2) (5,4,2,3,6)
(4,6,3,2,5) (3,4,2,6,5) (3,6,5,2,4)
(5,4,2,6,3)
8/8/2019 Genetic Algorithms (GA) Presentation
63/71
(3,4,5,6,2) (5,4,2,6,3)
Mutate
(5,3,4,6,2) (2,4,6,3,5) (4,3,6,5,2)
(2,3,4,6,5) (4,3,6,2,5) (3,4,5,2,6)
(3,5,4,6,2) (4,5,3,6,2) (5,4,2,3,6)
(4,6,3,2,5) (3,4,2,6,5) (3,6,5,2,4)
8/8/2019 Genetic Algorithms (GA) Presentation
64/71
Mutate
(5,3,4,6,2) (2,4,6,3,5) (4,3,6,5,2)
(2,3,4,6,5) (2,3,6, 4,5) (3,4,5,2,6)
(3,5,4,6,2) (4,5,3,6,2) (5,4,2,3,6)
(4,6,3,2,5) (3,4,2,6,5) (3,6,5,2,4)
(3,4,5,6,2) (5,4,2,6,3)
8/8/2019 Genetic Algorithms (GA) Presentation
65/71
Eliminate
(5,3,4,6,2) (2,4,6,3,5) (4,3,6,5,2)
(2,3,4,6,5) (2,3,6, 4,5) (3,4,5,2,6)
(3,5,4,6,2) (4,5,3,6,2) (5,4,2,3,6)
(4,6,3,2,5) (3,4,2,6,5) (3,6,5,2,4)
Tend to kill off the worst ones.
(3,4,5,6,2) (5,4,2,6,3)
8/8/2019 Genetic Algorithms (GA) Presentation
66/71
Integrate
(5,3,4,6,2) (2,4,6,3,5)
(2,3,6, 4,5) (3,4,5,2,6)
(3,5,4,6,2) (4,5,3,6,2) (5,4,2,3,6)
(4,6,3,2,5) (3,4,2,6,5) (3,6,5,2,4)
(3,4,5,6,2)
(5,4,2,6,3)
8/8/2019 Genetic Algorithms (GA) Presentation
67/71
Restart
(5,3,4,6,2) (2,4,6,3,5)
(2,3,6,4,5) (3,4,5,2,6)
(3,5,4,6,2) (4,5,3,6,2) (5,4,2,3,6)
(4,6,3,2,5) (3,4,2,6,5) (3,6,5,2,4)
(3,4,5,6,2)
(5,4,2,6,3)
8/8/2019 Genetic Algorithms (GA) Presentation
68/71
B enef i ts of Genet i c Algor i thms
Concept is easy to understandModular, separate from applicationSupports multi-objective optimization
Good for noisy environmentsAlways an answer; answer gets better withtimeInherently parallel; easily distributed
Many ways to speed up and improve a GA-based application as knowledge aboutproblem domain is gainedEasy to exploit previous or alternate
solutions
8/8/2019 Genetic Algorithms (GA) Presentation
69/71
When to Use a GA
Alternate solutions are too slow or overlycomplicatedNeed an exploratory tool to examine new
approachesProblem is similar to one that has already beensuccessfully solved by using a GAWant to hybridize with an existing solutionBenefits of the GA technology meet keyproblem requirements
8/8/2019 Genetic Algorithms (GA) Presentation
70/71
S ome A App lica tion T pes
Doma in App lica tion T pes
Con tr o l gas p ipeline pole alancing missile e vasion pu sui
Des i n semiconduc o la you ai c a design ke yboa dcon igu a ion communica ion ne o ks
S chedu ling manu ac u ing acili y scheduling r esou rce allo ca ion
Robo tics r aje ctory p lanning
Mach ine Lea r n ing designing neu r al ne twor ks imp r oving classi i ca tionalgo r ithms classi ie r s ys tems
S igna l Pr ocess ing ilte r design
Game Pl ay ing poke r, c he cke r s , p r isone rs dilemma
Comb ina to ria lOp tim iza tion
se t c ove r ing , tr a velling salesman , r ou ting , b in pa cking ,gr a ph colou r ing and pa rtitioning
8/8/2019 Genetic Algorithms (GA) Presentation
71/71
Gene tic Al o rit hms
FactsVery robust but slowIn the limit, optimal