Genetic Algorithms: An Introduction - curaj.ac.in Algorithm Introduction.pdf · What are Genetic...
Transcript of Genetic Algorithms: An Introduction - curaj.ac.in Algorithm Introduction.pdf · What are Genetic...
![Page 1: Genetic Algorithms: An Introduction - curaj.ac.in Algorithm Introduction.pdf · What are Genetic Algorithms Inspired by Biological Evolution Search and Optimization Procedures Good](https://reader031.fdocuments.net/reader031/viewer/2022022014/5b3fb2ee7f8b9a5e528c7222/html5/thumbnails/1.jpg)
Genetic Algorithms: An Introduction
Rao Vemuri
UC Davis
![Page 2: Genetic Algorithms: An Introduction - curaj.ac.in Algorithm Introduction.pdf · What are Genetic Algorithms Inspired by Biological Evolution Search and Optimization Procedures Good](https://reader031.fdocuments.net/reader031/viewer/2022022014/5b3fb2ee7f8b9a5e528c7222/html5/thumbnails/2.jpg)
Outline
Motivation
Running Example
Examples from Dissertations
– DNA Sequencing
– Groundwater Remediation
– Atomic Stabilization
Genetic Programming
![Page 3: Genetic Algorithms: An Introduction - curaj.ac.in Algorithm Introduction.pdf · What are Genetic Algorithms Inspired by Biological Evolution Search and Optimization Procedures Good](https://reader031.fdocuments.net/reader031/viewer/2022022014/5b3fb2ee7f8b9a5e528c7222/html5/thumbnails/3.jpg)
What are Genetic Algorithms
Inspired by Biological Evolution
Search and Optimization Procedures
Good in Rugged Search Spaces
Good for Multimodal Environments
![Page 4: Genetic Algorithms: An Introduction - curaj.ac.in Algorithm Introduction.pdf · What are Genetic Algorithms Inspired by Biological Evolution Search and Optimization Procedures Good](https://reader031.fdocuments.net/reader031/viewer/2022022014/5b3fb2ee7f8b9a5e528c7222/html5/thumbnails/4.jpg)
Characteristics of GA’s
Can solve “hard” problems
Easy to interface with existing models
Rely on very little domain knowledge
![Page 5: Genetic Algorithms: An Introduction - curaj.ac.in Algorithm Introduction.pdf · What are Genetic Algorithms Inspired by Biological Evolution Search and Optimization Procedures Good](https://reader031.fdocuments.net/reader031/viewer/2022022014/5b3fb2ee7f8b9a5e528c7222/html5/thumbnails/5.jpg)
Adaptive Search Using GAs
Figure goes here
![Page 6: Genetic Algorithms: An Introduction - curaj.ac.in Algorithm Introduction.pdf · What are Genetic Algorithms Inspired by Biological Evolution Search and Optimization Procedures Good](https://reader031.fdocuments.net/reader031/viewer/2022022014/5b3fb2ee7f8b9a5e528c7222/html5/thumbnails/6.jpg)
The Central Idea
Start with a population of individual solutions
Represent individual solutions by bit strings
Call each bit string a chromosome
Evaluate each individual for fitness
Select those with high fitness
Mate them using Crossover (Exploitation)
Mutate (Exploration)
![Page 7: Genetic Algorithms: An Introduction - curaj.ac.in Algorithm Introduction.pdf · What are Genetic Algorithms Inspired by Biological Evolution Search and Optimization Procedures Good](https://reader031.fdocuments.net/reader031/viewer/2022022014/5b3fb2ee7f8b9a5e528c7222/html5/thumbnails/7.jpg)
Genetic Operators
Selection:
– Survival of the Fittest
Crossover:
– Unite individuals as parents to generate new
combinations of partial solutions
Mutation:
– Introduce new features not present in the parents
![Page 8: Genetic Algorithms: An Introduction - curaj.ac.in Algorithm Introduction.pdf · What are Genetic Algorithms Inspired by Biological Evolution Search and Optimization Procedures Good](https://reader031.fdocuments.net/reader031/viewer/2022022014/5b3fb2ee7f8b9a5e528c7222/html5/thumbnails/8.jpg)
Selection Operator
Calculate the fitness of all members
Select a subset with better fitness scores
– Roulette wheel selection (or FPR: fitness
proportionate reproduction)
– Tournament selection
– Etc.
![Page 9: Genetic Algorithms: An Introduction - curaj.ac.in Algorithm Introduction.pdf · What are Genetic Algorithms Inspired by Biological Evolution Search and Optimization Procedures Good](https://reader031.fdocuments.net/reader031/viewer/2022022014/5b3fb2ee7f8b9a5e528c7222/html5/thumbnails/9.jpg)
Crossover Operation
Parent 1: 100 111 00
Parent 2: 010 001 10
Child 1: 100 001 00
Child 2: 010 111 10
![Page 10: Genetic Algorithms: An Introduction - curaj.ac.in Algorithm Introduction.pdf · What are Genetic Algorithms Inspired by Biological Evolution Search and Optimization Procedures Good](https://reader031.fdocuments.net/reader031/viewer/2022022014/5b3fb2ee7f8b9a5e528c7222/html5/thumbnails/10.jpg)
Mutation Operation
Mutation is an important genetic operator.
It takes a single candidate and randomly
changes some aspect of it.
Parent: 100 111 00
Child: 100 011 00
![Page 11: Genetic Algorithms: An Introduction - curaj.ac.in Algorithm Introduction.pdf · What are Genetic Algorithms Inspired by Biological Evolution Search and Optimization Procedures Good](https://reader031.fdocuments.net/reader031/viewer/2022022014/5b3fb2ee7f8b9a5e528c7222/html5/thumbnails/11.jpg)
A Running Example
A Franchiser wants a profit-making strategy
in running a restaurant
Options are:
– Affordable Vs Fancy
– Hot Dogs Vs Crepes
– Soft Drinks Vs Wine
Data on costs and sales available to estimate
profits
![Page 12: Genetic Algorithms: An Introduction - curaj.ac.in Algorithm Introduction.pdf · What are Genetic Algorithms Inspired by Biological Evolution Search and Optimization Procedures Good](https://reader031.fdocuments.net/reader031/viewer/2022022014/5b3fb2ee7f8b9a5e528c7222/html5/thumbnails/12.jpg)
Encoding the Problem
Define 3-bit chromosome
Encode as follows
Bit 1: 0 Soft drink 1 Wine
Bit 2: 0 Hot dogs 1 Crepes
Bit 3: 0 Cheap 1 Expensive
Bit 1 Bit 2 Bit 3
![Page 13: Genetic Algorithms: An Introduction - curaj.ac.in Algorithm Introduction.pdf · What are Genetic Algorithms Inspired by Biological Evolution Search and Optimization Procedures Good](https://reader031.fdocuments.net/reader031/viewer/2022022014/5b3fb2ee7f8b9a5e528c7222/html5/thumbnails/13.jpg)
Fitness Evaluation
Each option is a 3-bit sequence
There are only 2^3 = 8 options
Assume that Profit =
Decimal value of the 3-bit sequence
A peek at the correct optimum by exhaustive
enumeration
– 000, 001, 010, 011, 100, 101, 110, 111
![Page 14: Genetic Algorithms: An Introduction - curaj.ac.in Algorithm Introduction.pdf · What are Genetic Algorithms Inspired by Biological Evolution Search and Optimization Procedures Good](https://reader031.fdocuments.net/reader031/viewer/2022022014/5b3fb2ee7f8b9a5e528c7222/html5/thumbnails/14.jpg)
Exhaustive Enumeration is Impractical
Consider a Travelling Salesman Problem
For N cities, there are (N-1)!/2 solutions
Assume
– A 20-city problem takes 1 hour
Then
– 21-city problem takes 20*1 hours = 20 hours
– 22-city problem takes 21*20*1 hours = 17.5 days
– 25-city problem takes ~ 6 Centuries !!!
![Page 15: Genetic Algorithms: An Introduction - curaj.ac.in Algorithm Introduction.pdf · What are Genetic Algorithms Inspired by Biological Evolution Search and Optimization Procedures Good](https://reader031.fdocuments.net/reader031/viewer/2022022014/5b3fb2ee7f8b9a5e528c7222/html5/thumbnails/15.jpg)
Let us Try a GA
Try, say, 4 randomly selected strategies at 4
different outlets
Compare their profits
Pick those that are doing well: Mating Pool
Using X-over and Mutation, generate
offspring strategies
Go back and repeat until a good strategy is
found
![Page 16: Genetic Algorithms: An Introduction - curaj.ac.in Algorithm Introduction.pdf · What are Genetic Algorithms Inspired by Biological Evolution Search and Optimization Procedures Good](https://reader031.fdocuments.net/reader031/viewer/2022022014/5b3fb2ee7f8b9a5e528c7222/html5/thumbnails/16.jpg)
One Simulation Run
X(i) F(i) MP F(i) X(i) F(i)
001 3 011 3 111 7
001 1 110 6 010 2
110 6 110 6 110 6
010 2 010 2 010 2
Total F 12 17 17
Worst 1 2 2
Ave 3 4.25 4.25
Best 6 6 7
![Page 17: Genetic Algorithms: An Introduction - curaj.ac.in Algorithm Introduction.pdf · What are Genetic Algorithms Inspired by Biological Evolution Search and Optimization Procedures Good](https://reader031.fdocuments.net/reader031/viewer/2022022014/5b3fb2ee7f8b9a5e528c7222/html5/thumbnails/17.jpg)
What Did the Franchiser Learn?
Lesson 1: $3 is an estimate of the average
profit (estimate based on 4 samples)
Lesson 2:
– 110 is 200% better than average strategy
– 010 is 2/3 as good as average strategy
– 001 is 1/3 as good as average strategy
![Page 18: Genetic Algorithms: An Introduction - curaj.ac.in Algorithm Introduction.pdf · What are Genetic Algorithms Inspired by Biological Evolution Search and Optimization Procedures Good](https://reader031.fdocuments.net/reader031/viewer/2022022014/5b3fb2ee7f8b9a5e528c7222/html5/thumbnails/18.jpg)
What Do We Do Next?
Option 1: Brute Force Method
– Continue Searching for better solutions
Option 2: Greedy Method
– Because 110 is 200% better than the average,
grab it. Do not worry about searching for better
solutions.
![Page 19: Genetic Algorithms: An Introduction - curaj.ac.in Algorithm Introduction.pdf · What are Genetic Algorithms Inspired by Biological Evolution Search and Optimization Procedures Good](https://reader031.fdocuments.net/reader031/viewer/2022022014/5b3fb2ee7f8b9a5e528c7222/html5/thumbnails/19.jpg)
Another Lesson Learned
Cost of exploring for a better solution
– Current profit – Average profit = $6 - $3 = $3
Cost of NOT exploring further
– Max. profit possible – Current profit + $7 - $6 = $1
This is Exploration Vs Exploitation
![Page 20: Genetic Algorithms: An Introduction - curaj.ac.in Algorithm Introduction.pdf · What are Genetic Algorithms Inspired by Biological Evolution Search and Optimization Procedures Good](https://reader031.fdocuments.net/reader031/viewer/2022022014/5b3fb2ee7f8b9a5e528c7222/html5/thumbnails/20.jpg)
A general form of the genetic algorithm:
![Page 21: Genetic Algorithms: An Introduction - curaj.ac.in Algorithm Introduction.pdf · What are Genetic Algorithms Inspired by Biological Evolution Search and Optimization Procedures Good](https://reader031.fdocuments.net/reader031/viewer/2022022014/5b3fb2ee7f8b9a5e528c7222/html5/thumbnails/21.jpg)
Useful References
• John Holland, Adaption in Natural and Artificial Systems, 1975.
• David E. Goldberg, Genetic Algorithms in Search, Optimization, and Machine Learning, Addison Wesley
• Zbigniew Michalewicz, Genetic Algorithms + Data Structures = Evolution Programs,Third Edition, Springer, 1996, ISBN: 3-540-60676-9,
• Evolutionary computing (EC) was introduced in the 1960s by I. Rechenberg in his work "Evolution strategies" (Evolutionsstrategie in original).
• In 1992 John Koza has used genetic algorithm to evolve programs to perform certain tasks. He called his method "genetic programming" (GP). LISP programs were used, because programs in this language can expressed in the form of a "parse tree", which is the object the GA works on.
![Page 22: Genetic Algorithms: An Introduction - curaj.ac.in Algorithm Introduction.pdf · What are Genetic Algorithms Inspired by Biological Evolution Search and Optimization Procedures Good](https://reader031.fdocuments.net/reader031/viewer/2022022014/5b3fb2ee7f8b9a5e528c7222/html5/thumbnails/22.jpg)
An Example
• Consider f(x)=100x2(1–x)2–x,
which has local minima x1 near 0 and x2
near 1:
Plot
![Page 23: Genetic Algorithms: An Introduction - curaj.ac.in Algorithm Introduction.pdf · What are Genetic Algorithms Inspired by Biological Evolution Search and Optimization Procedures Good](https://reader031.fdocuments.net/reader031/viewer/2022022014/5b3fb2ee7f8b9a5e528c7222/html5/thumbnails/23.jpg)
Code for Plotting
ezplot('100*x^2*(1-x)^2 - x',[-0.2,1.2])
ylabel('f(x)')
hold on
plot([0 0],[-1.7 0],'r--')
plot([1 1],[-1.7 -1],'r--')
annotation('textbox',[0.25 0.1 0.07 0.1],...
'String',{'x1'},'EdgeColor','none');
annotation('textbox',[0.8 0.1 0.07 0.1],...
'String',{'x2'},'EdgeColor','none');
hold off
![Page 24: Genetic Algorithms: An Introduction - curaj.ac.in Algorithm Introduction.pdf · What are Genetic Algorithms Inspired by Biological Evolution Search and Optimization Procedures Good](https://reader031.fdocuments.net/reader031/viewer/2022022014/5b3fb2ee7f8b9a5e528c7222/html5/thumbnails/24.jpg)
Output of Matlab
The minima are located at:
x1 = fminsearch(@(x)(100*x^2*(x - 1)^2 - x),0)
x1 =
0.0051
x2 = fminsearch(@(x)(100*x^2*(x - 1)^2 - x),1)
x2 =
1.0049
![Page 25: Genetic Algorithms: An Introduction - curaj.ac.in Algorithm Introduction.pdf · What are Genetic Algorithms Inspired by Biological Evolution Search and Optimization Procedures Good](https://reader031.fdocuments.net/reader031/viewer/2022022014/5b3fb2ee7f8b9a5e528c7222/html5/thumbnails/25.jpg)
Plot