advanced search -...
TRANSCRIPT
![Page 1: Advanced Search - pages.cs.wisc.edupages.cs.wisc.edu/~yliang/cs540_1_spring18/slides/hillclimbing_part3.pdfslide 1 Advanced Search Genetic algorithm Yingyu Liang yliang@cs.wisc.edu](https://reader031.vdocuments.us/reader031/viewer/2022020206/5d61730088c993f1688b5291/html5/thumbnails/1.jpg)
slide 1
Advanced SearchGenetic algorithm
Yingyu Liang
Computer Sciences Department
University of Wisconsin, Madison
[Based on slides from Jerry Zhu, Andrew Moore http://www.cs.cmu.edu/~awm/tutorials ]
![Page 2: Advanced Search - pages.cs.wisc.edupages.cs.wisc.edu/~yliang/cs540_1_spring18/slides/hillclimbing_part3.pdfslide 1 Advanced Search Genetic algorithm Yingyu Liang yliang@cs.wisc.edu](https://reader031.vdocuments.us/reader031/viewer/2022020206/5d61730088c993f1688b5291/html5/thumbnails/2.jpg)
slide 2
GENETIC ALGORITHM
http://www.genetic-programming.org/
![Page 3: Advanced Search - pages.cs.wisc.edupages.cs.wisc.edu/~yliang/cs540_1_spring18/slides/hillclimbing_part3.pdfslide 1 Advanced Search Genetic algorithm Yingyu Liang yliang@cs.wisc.edu](https://reader031.vdocuments.us/reader031/viewer/2022020206/5d61730088c993f1688b5291/html5/thumbnails/3.jpg)
slide 3
Evolution
• Survival of the fittest, a.k.a. natural selection
• Genes encoded as DNA (deoxyribonucleic acid), sequence of
bases: A (Adenine), C (Cytosine), T (Thymine) and G (Guanine)
![Page 4: Advanced Search - pages.cs.wisc.edupages.cs.wisc.edu/~yliang/cs540_1_spring18/slides/hillclimbing_part3.pdfslide 1 Advanced Search Genetic algorithm Yingyu Liang yliang@cs.wisc.edu](https://reader031.vdocuments.us/reader031/viewer/2022020206/5d61730088c993f1688b5291/html5/thumbnails/4.jpg)
slide 4
Evolution
• Survival of the fittest, a.k.a. natural selection
• Genes encoded as DNA (deoxyribonucleic acid), sequence of
bases: A (Adenine), C (Cytosine), T (Thymine) and G (Guanine)
• The chromosomes from the parents exchange randomly by a
process called crossover. Therefore, the offspring exhibit some
traits of the father and some traits of the mother.
▪ Requires genetic diversity among the parents to ensure
sufficiently varied offspring
![Page 5: Advanced Search - pages.cs.wisc.edupages.cs.wisc.edu/~yliang/cs540_1_spring18/slides/hillclimbing_part3.pdfslide 1 Advanced Search Genetic algorithm Yingyu Liang yliang@cs.wisc.edu](https://reader031.vdocuments.us/reader031/viewer/2022020206/5d61730088c993f1688b5291/html5/thumbnails/5.jpg)
slide 5
Evolution
• Survival of the fittest, a.k.a. natural selection
• Genes encoded as DNA (deoxyribonucleic acid), sequence of
bases: A (Adenine), C (Cytosine), T (Thymine) and G (Guanine)
• The chromosomes from the parents exchange randomly by a
process called crossover. Therefore, the offspring exhibit some
traits of the father and some traits of the mother.
▪ Requires genetic diversity among the parents to ensure
sufficiently varied offspring
• A rarer process called mutation also changes the genes (e.g.
from cosmic ray).
▪ Nonsensical/deadly mutated organisms die.
▪ Beneficial mutations produce “stronger” organisms
▪ Neither: organisms aren’t improved.
![Page 6: Advanced Search - pages.cs.wisc.edupages.cs.wisc.edu/~yliang/cs540_1_spring18/slides/hillclimbing_part3.pdfslide 1 Advanced Search Genetic algorithm Yingyu Liang yliang@cs.wisc.edu](https://reader031.vdocuments.us/reader031/viewer/2022020206/5d61730088c993f1688b5291/html5/thumbnails/6.jpg)
slide 6
Natural selection
• Individuals compete for resources
• Individuals with better genes have a larger chance to
produce offspring, and vice versa
![Page 7: Advanced Search - pages.cs.wisc.edupages.cs.wisc.edu/~yliang/cs540_1_spring18/slides/hillclimbing_part3.pdfslide 1 Advanced Search Genetic algorithm Yingyu Liang yliang@cs.wisc.edu](https://reader031.vdocuments.us/reader031/viewer/2022020206/5d61730088c993f1688b5291/html5/thumbnails/7.jpg)
slide 7
Natural selection
• Individuals compete for resources
• Individuals with better genes have a larger chance to
produce offspring, and vice versa
• After many generations, the population consists of
lots of genes from the superior individuals, and less
from the inferior individuals
• Superiority defined by fitness to the environment
![Page 8: Advanced Search - pages.cs.wisc.edupages.cs.wisc.edu/~yliang/cs540_1_spring18/slides/hillclimbing_part3.pdfslide 1 Advanced Search Genetic algorithm Yingyu Liang yliang@cs.wisc.edu](https://reader031.vdocuments.us/reader031/viewer/2022020206/5d61730088c993f1688b5291/html5/thumbnails/8.jpg)
slide 8
Evolution and Natural Selection
• Popularized by Darwin
• Mistake of Lamarck: environment does not force an individual to
change its genes
![Page 9: Advanced Search - pages.cs.wisc.edupages.cs.wisc.edu/~yliang/cs540_1_spring18/slides/hillclimbing_part3.pdfslide 1 Advanced Search Genetic algorithm Yingyu Liang yliang@cs.wisc.edu](https://reader031.vdocuments.us/reader031/viewer/2022020206/5d61730088c993f1688b5291/html5/thumbnails/9.jpg)
slide 9
Genetic algorithm
• Yet another AI algorithm based on real-world analogy
• Yet another heuristic stochastic search algorithm
![Page 10: Advanced Search - pages.cs.wisc.edupages.cs.wisc.edu/~yliang/cs540_1_spring18/slides/hillclimbing_part3.pdfslide 1 Advanced Search Genetic algorithm Yingyu Liang yliang@cs.wisc.edu](https://reader031.vdocuments.us/reader031/viewer/2022020206/5d61730088c993f1688b5291/html5/thumbnails/10.jpg)
slide 10
Genetic algorithm
• Yet another AI algorithm based on real-world analogy
• Yet another heuristic stochastic search algorithm
• Each state s is called an individual. Often (carefully)
coded up as a string.
• The score f(s) is called the fitness of s. Our goal is to
find the global optimum (fittest) state.
• At any time we keep a fixed number of states. They
are called the population. Similar to beam search.
(3 2 7 5 2 4 1 1)
![Page 11: Advanced Search - pages.cs.wisc.edupages.cs.wisc.edu/~yliang/cs540_1_spring18/slides/hillclimbing_part3.pdfslide 1 Advanced Search Genetic algorithm Yingyu Liang yliang@cs.wisc.edu](https://reader031.vdocuments.us/reader031/viewer/2022020206/5d61730088c993f1688b5291/html5/thumbnails/11.jpg)
slide 11
Individual encoding
• The “DNA”
• Satisfiability problem A B C
A C D
B D E
C D E
A C E
What is the individual encoding scheme?
![Page 12: Advanced Search - pages.cs.wisc.edupages.cs.wisc.edu/~yliang/cs540_1_spring18/slides/hillclimbing_part3.pdfslide 1 Advanced Search Genetic algorithm Yingyu Liang yliang@cs.wisc.edu](https://reader031.vdocuments.us/reader031/viewer/2022020206/5d61730088c993f1688b5291/html5/thumbnails/12.jpg)
slide 12
Individual encoding
• The “DNA”
• Satisfiability problem
(A B C D E) = (T F T T T)
A B C
A C D
B D E
C D E
A C E
![Page 13: Advanced Search - pages.cs.wisc.edupages.cs.wisc.edu/~yliang/cs540_1_spring18/slides/hillclimbing_part3.pdfslide 1 Advanced Search Genetic algorithm Yingyu Liang yliang@cs.wisc.edu](https://reader031.vdocuments.us/reader031/viewer/2022020206/5d61730088c993f1688b5291/html5/thumbnails/13.jpg)
slide 13
Individual encoding
• The “DNA”
• TSP
What is the individual encoding scheme?
![Page 14: Advanced Search - pages.cs.wisc.edupages.cs.wisc.edu/~yliang/cs540_1_spring18/slides/hillclimbing_part3.pdfslide 1 Advanced Search Genetic algorithm Yingyu Liang yliang@cs.wisc.edu](https://reader031.vdocuments.us/reader031/viewer/2022020206/5d61730088c993f1688b5291/html5/thumbnails/14.jpg)
slide 14
Individual encoding
• The “DNA”
• TSP
A-E-D-C-B-F-G-H-A
![Page 15: Advanced Search - pages.cs.wisc.edupages.cs.wisc.edu/~yliang/cs540_1_spring18/slides/hillclimbing_part3.pdfslide 1 Advanced Search Genetic algorithm Yingyu Liang yliang@cs.wisc.edu](https://reader031.vdocuments.us/reader031/viewer/2022020206/5d61730088c993f1688b5291/html5/thumbnails/15.jpg)
slide 15
Genetic algorithm
• Genetic algorithm: a special way to generate neighbors, using the analogy of cross-over, mutation, and natural selection.
![Page 16: Advanced Search - pages.cs.wisc.edupages.cs.wisc.edu/~yliang/cs540_1_spring18/slides/hillclimbing_part3.pdfslide 1 Advanced Search Genetic algorithm Yingyu Liang yliang@cs.wisc.edu](https://reader031.vdocuments.us/reader031/viewer/2022020206/5d61730088c993f1688b5291/html5/thumbnails/16.jpg)
slide 16
Genetic algorithm
• Genetic algorithm: a special way to generate neighbors, using the analogy of cross-over, mutation, and natural selection.
Number of non-attacking pairs
prob. reproduction
fitness
![Page 17: Advanced Search - pages.cs.wisc.edupages.cs.wisc.edu/~yliang/cs540_1_spring18/slides/hillclimbing_part3.pdfslide 1 Advanced Search Genetic algorithm Yingyu Liang yliang@cs.wisc.edu](https://reader031.vdocuments.us/reader031/viewer/2022020206/5d61730088c993f1688b5291/html5/thumbnails/17.jpg)
slide 17
Genetic algorithm
• Genetic algorithm: a special way to generate neighbors, using the analogy of cross-over, mutation, and natural selection.
Number of non-attacking pairs
prob. reproduction
fitness
Next generation
![Page 18: Advanced Search - pages.cs.wisc.edupages.cs.wisc.edu/~yliang/cs540_1_spring18/slides/hillclimbing_part3.pdfslide 1 Advanced Search Genetic algorithm Yingyu Liang yliang@cs.wisc.edu](https://reader031.vdocuments.us/reader031/viewer/2022020206/5d61730088c993f1688b5291/html5/thumbnails/18.jpg)
slide 18
Genetic algorithm
• Genetic algorithm: a special way to generate neighbors, using the analogy of cross-over, mutation, and natural selection.
Number of non-attacking pairs
prob. reproduction
fitness
Next generation
![Page 19: Advanced Search - pages.cs.wisc.edupages.cs.wisc.edu/~yliang/cs540_1_spring18/slides/hillclimbing_part3.pdfslide 1 Advanced Search Genetic algorithm Yingyu Liang yliang@cs.wisc.edu](https://reader031.vdocuments.us/reader031/viewer/2022020206/5d61730088c993f1688b5291/html5/thumbnails/19.jpg)
slide 19
Genetic algorithm
• Genetic algorithm: a special way to generate neighbors, using the analogy of cross-over, mutation, and natural selection.
Number of non-attacking pairs
prob. reproduction
fitness
Next generation
How about for the SAT and TSP problems?
![Page 20: Advanced Search - pages.cs.wisc.edupages.cs.wisc.edu/~yliang/cs540_1_spring18/slides/hillclimbing_part3.pdfslide 1 Advanced Search Genetic algorithm Yingyu Liang yliang@cs.wisc.edu](https://reader031.vdocuments.us/reader031/viewer/2022020206/5d61730088c993f1688b5291/html5/thumbnails/20.jpg)
slide 20
Genetic algorithm (one variety)
1. Let s1, …, sN be the current population
2. Let pi = f(si) / j f(sj) be the reproduction probability
3. FOR k = 1; k<N; k+=2
• parent1 = randomly pick according to p
• parent2 = randomly pick another
• randomly select a crossover point, swap strings
of parents 1, 2 to generate children t[k], t[k+1]
4. FOR k = 1; k<=N; k++
• Randomly mutate each position in t[k] with a
small probability (mutation rate)
5. The new generation replaces the old: { s }{ t }.
Repeat.
![Page 21: Advanced Search - pages.cs.wisc.edupages.cs.wisc.edu/~yliang/cs540_1_spring18/slides/hillclimbing_part3.pdfslide 1 Advanced Search Genetic algorithm Yingyu Liang yliang@cs.wisc.edu](https://reader031.vdocuments.us/reader031/viewer/2022020206/5d61730088c993f1688b5291/html5/thumbnails/21.jpg)
slide 21
Proportional selection
• pi = f(si) / j f(sj)
• j f(sj) = 5+20+11+8+6=50
• p1=5/50=10%
![Page 22: Advanced Search - pages.cs.wisc.edupages.cs.wisc.edu/~yliang/cs540_1_spring18/slides/hillclimbing_part3.pdfslide 1 Advanced Search Genetic algorithm Yingyu Liang yliang@cs.wisc.edu](https://reader031.vdocuments.us/reader031/viewer/2022020206/5d61730088c993f1688b5291/html5/thumbnails/22.jpg)
slide 22
Variations of genetic algorithm
• Parents may survive into the next generation
• Use ranking instead of f(s) in computing the
reproduction probabilities.
• Cross over random bits instead of chunks.
• Optimize over sentences from a programming
language. Genetic programming.
• …
![Page 23: Advanced Search - pages.cs.wisc.edupages.cs.wisc.edu/~yliang/cs540_1_spring18/slides/hillclimbing_part3.pdfslide 1 Advanced Search Genetic algorithm Yingyu Liang yliang@cs.wisc.edu](https://reader031.vdocuments.us/reader031/viewer/2022020206/5d61730088c993f1688b5291/html5/thumbnails/23.jpg)
slide 23
Genetic algorithm issues
• State encoding is the real ingenuity, not the decision to use genetic algorithm.
• Lack of diversity can lead to premature convergence and non-optimal solution
• Not much to say theoretically
▪ Cross over (sexual reproduction) much more
efficient than mutation (asexual reproduction).
• Easy to implement.
• Try hill-climbing with random restarts first!