Genetic Algorithms
description
Transcript of Genetic Algorithms
![Page 1: Genetic Algorithms](https://reader034.fdocuments.net/reader034/viewer/2022050806/56816016550346895dcf1803/html5/thumbnails/1.jpg)
Genetic AlgorithmsSolving by evolving
Pawel Drozdowski – November 2012
![Page 2: Genetic Algorithms](https://reader034.fdocuments.net/reader034/viewer/2022050806/56816016550346895dcf1803/html5/thumbnails/2.jpg)
IntroductionGA basics
Solving simple problemGA more advanced topicsSolving complex problem
Question and Answers
Agenda
![Page 3: Genetic Algorithms](https://reader034.fdocuments.net/reader034/viewer/2022050806/56816016550346895dcf1803/html5/thumbnails/3.jpg)
Evolution
Introduction
Charles Darwin 1809 -1882
Evolution is the change of inherited characteristics of populations over successive generations
what leads to greater diversity in this populations.
Greater diversity leads to greater chance of survivalin changing environment.
![Page 4: Genetic Algorithms](https://reader034.fdocuments.net/reader034/viewer/2022050806/56816016550346895dcf1803/html5/thumbnails/4.jpg)
Genetics
Introduction
DNA
Genetics is the science of genes.
Genes are a part of DNA molecule which carriesinformation how to build cells and pass traits to offspring.
![Page 5: Genetic Algorithms](https://reader034.fdocuments.net/reader034/viewer/2022050806/56816016550346895dcf1803/html5/thumbnails/5.jpg)
Assuming…
Introduction
Offspring genes keeps information of inherited characteristics.
Populations use genes diversity to survive in environment.
![Page 6: Genetic Algorithms](https://reader034.fdocuments.net/reader034/viewer/2022050806/56816016550346895dcf1803/html5/thumbnails/6.jpg)
…and that’s how creationists see it
Introduction
![Page 7: Genetic Algorithms](https://reader034.fdocuments.net/reader034/viewer/2022050806/56816016550346895dcf1803/html5/thumbnails/7.jpg)
Evolved, created… or neither?
Introduction
![Page 8: Genetic Algorithms](https://reader034.fdocuments.net/reader034/viewer/2022050806/56816016550346895dcf1803/html5/thumbnails/8.jpg)
Genetic Algorithm (GA)
1. Generate population2. Calculate fitness3. Make selection
4.Crossover5. MutateGo to 2Done
GA
![Page 9: Genetic Algorithms](https://reader034.fdocuments.net/reader034/viewer/2022050806/56816016550346895dcf1803/html5/thumbnails/9.jpg)
Parts of Genetic Algorithm
Chromosome and genesPopulation
Fitness functionSelection methodCrossover methodMutation methodStop conditions
GA
![Page 10: Genetic Algorithms](https://reader034.fdocuments.net/reader034/viewer/2022050806/56816016550346895dcf1803/html5/thumbnails/10.jpg)
GA – Chromosome and genes
![Page 11: Genetic Algorithms](https://reader034.fdocuments.net/reader034/viewer/2022050806/56816016550346895dcf1803/html5/thumbnails/11.jpg)
GA - Population
![Page 12: Genetic Algorithms](https://reader034.fdocuments.net/reader034/viewer/2022050806/56816016550346895dcf1803/html5/thumbnails/12.jpg)
GA - Fitness
DNA
Fitness function: Strength + Endurance
Score: 24 Score: 21 Score: 42
Score: 20 Score: 20 Score: 22
![Page 13: Genetic Algorithms](https://reader034.fdocuments.net/reader034/viewer/2022050806/56816016550346895dcf1803/html5/thumbnails/13.jpg)
GA - Selection
DNA
Fitness function: Strength + Endurance > 22
Score: 24 Score: 21 Score: 42
Score: 20 Score: 20 Score: 22
![Page 14: Genetic Algorithms](https://reader034.fdocuments.net/reader034/viewer/2022050806/56816016550346895dcf1803/html5/thumbnails/14.jpg)
GA - Selection
![Page 15: Genetic Algorithms](https://reader034.fdocuments.net/reader034/viewer/2022050806/56816016550346895dcf1803/html5/thumbnails/15.jpg)
GA - Selection
I have no sword so I won’t reproduce
![Page 16: Genetic Algorithms](https://reader034.fdocuments.net/reader034/viewer/2022050806/56816016550346895dcf1803/html5/thumbnails/16.jpg)
GA - Crossover
![Page 17: Genetic Algorithms](https://reader034.fdocuments.net/reader034/viewer/2022050806/56816016550346895dcf1803/html5/thumbnails/17.jpg)
GA - Crossover
![Page 18: Genetic Algorithms](https://reader034.fdocuments.net/reader034/viewer/2022050806/56816016550346895dcf1803/html5/thumbnails/18.jpg)
GA - Mutation
DNA
![Page 19: Genetic Algorithms](https://reader034.fdocuments.net/reader034/viewer/2022050806/56816016550346895dcf1803/html5/thumbnails/19.jpg)
GA - Mutation
DNA
![Page 20: Genetic Algorithms](https://reader034.fdocuments.net/reader034/viewer/2022050806/56816016550346895dcf1803/html5/thumbnails/20.jpg)
GA – Repeat all steps until dragon slain
DNA
Score: 32Score: 34Score: 64
![Page 21: Genetic Algorithms](https://reader034.fdocuments.net/reader034/viewer/2022050806/56816016550346895dcf1803/html5/thumbnails/21.jpg)
GA – Stop condition met
DNA
Score: 32Score: 34Score: 64
![Page 22: Genetic Algorithms](https://reader034.fdocuments.net/reader034/viewer/2022050806/56816016550346895dcf1803/html5/thumbnails/22.jpg)
DEMO1Flies vs Tomatoes
Solving simple problems
This demo uses AForge.Net library, check: www.aforgenet.com
![Page 23: Genetic Algorithms](https://reader034.fdocuments.net/reader034/viewer/2022050806/56816016550346895dcf1803/html5/thumbnails/23.jpg)
DefinitionThere are tomatoes and flies in the space.
Flies likes to eat tomatoes.
TaskDepending on different distribution of tomatoes
in space find out most likely place where flies would be.
Flies vs Tomatoes
![Page 24: Genetic Algorithms](https://reader034.fdocuments.net/reader034/viewer/2022050806/56816016550346895dcf1803/html5/thumbnails/24.jpg)
Chromosome
Array of 2 double values represented as sequence of bits { X Y }
Example: {0.41, 0.32}
X,Y pair defines location of a fly in the space
Flies vs Tomatoes
![Page 25: Genetic Algorithms](https://reader034.fdocuments.net/reader034/viewer/2022050806/56816016550346895dcf1803/html5/thumbnails/25.jpg)
CrossoverSingle cut
Flies vs TomatoesMutationGene value swap
X
X
X
Y
Y
Y
![Page 26: Genetic Algorithms](https://reader034.fdocuments.net/reader034/viewer/2022050806/56816016550346895dcf1803/html5/thumbnails/26.jpg)
Fitness function
Flies vs Tomatoes
0.95
0.75
0.5 0.4
0.2
![Page 27: Genetic Algorithms](https://reader034.fdocuments.net/reader034/viewer/2022050806/56816016550346895dcf1803/html5/thumbnails/27.jpg)
0.2
Selection - Roulette wheel
Flies vs Tomatoes
0.95
0.75
0.5
0.4
Take a note that every fly has a chance to propagate
its genes!
![Page 28: Genetic Algorithms](https://reader034.fdocuments.net/reader034/viewer/2022050806/56816016550346895dcf1803/html5/thumbnails/28.jpg)
FeaturesGA can find optimal solutions
GA can adjust solution in changing environment
IssuesMay stuck in local optimum
Chromosome construction and related operations can lead to distortions in GA
(for more search for schema theory, alleles)
Flies vs Tomatoes
![Page 29: Genetic Algorithms](https://reader034.fdocuments.net/reader034/viewer/2022050806/56816016550346895dcf1803/html5/thumbnails/29.jpg)
GA – Role of mutation over time
Mutation creates variation…
…favourable mutations gets selected…
…reproduction and mutation again…
…favourable mutations gets selected…
…reproduction and mutation again…
Changes done by mutation that are leading towards solution are propagating and cumulating over time.
![Page 30: Genetic Algorithms](https://reader034.fdocuments.net/reader034/viewer/2022050806/56816016550346895dcf1803/html5/thumbnails/30.jpg)
GA – Wide selection
By doing roulette wheel selection(giving chance to all guys proportionallyto their fitness) we can loose a lot of time doing exploration of too many possible solutions…
Who knows? Maybe only enduranceis important so why bother with the rest?
![Page 31: Genetic Algorithms](https://reader034.fdocuments.net/reader034/viewer/2022050806/56816016550346895dcf1803/html5/thumbnails/31.jpg)
GA – Narrow selection
By doing elite selection(picking up guys with highest score)we can loose opportunity of exploring for other possible solutions…
Who knows? Maybe high enoughagility, wisdom or intelligence can give usmuch better results?
![Page 32: Genetic Algorithms](https://reader034.fdocuments.net/reader034/viewer/2022050806/56816016550346895dcf1803/html5/thumbnails/32.jpg)
Know your enemy
Local optimum
Global optimum
Features of easily solvable search space:
Global optimum
Few local optimums
Hills to climb
Hill
Hill
Hill
Hill
![Page 33: Genetic Algorithms](https://reader034.fdocuments.net/reader034/viewer/2022050806/56816016550346895dcf1803/html5/thumbnails/33.jpg)
Know your enemy
Difficult search space lacks one or more features:
Where is global optimum?
Why there are so many local optimums separated in so rough way?!
Hey, there are no hills to climb!
![Page 34: Genetic Algorithms](https://reader034.fdocuments.net/reader034/viewer/2022050806/56816016550346895dcf1803/html5/thumbnails/34.jpg)
Co-evolution
Migrate successful chromosome fromone population to another.
Combine solutions that stuck in local optimumsand create even more fit individuals.
![Page 35: Genetic Algorithms](https://reader034.fdocuments.net/reader034/viewer/2022050806/56816016550346895dcf1803/html5/thumbnails/35.jpg)
DEMO2Traveling Salesman Problem
Solving complex problems
This demo uses AForge.Net library, check: www.aforgenet.comAnd TSP problems library from Heidelberg university: http://www.iwr.uni-heidelberg.de/groups/comopt/software/TSPLIB95
![Page 36: Genetic Algorithms](https://reader034.fdocuments.net/reader034/viewer/2022050806/56816016550346895dcf1803/html5/thumbnails/36.jpg)
DefinitionThere is a set of cities salesman needs to visit.
Each city must be visited once.
TaskWhat’s the shortest way through all the cities?
Traveling Salesman Problem
![Page 37: Genetic Algorithms](https://reader034.fdocuments.net/reader034/viewer/2022050806/56816016550346895dcf1803/html5/thumbnails/37.jpg)
Traveling Salesman Problem
Search space size for 48 cities problem is 1.24e+61(which stands in short for: 124139559253607267086228904373375038521586354677760000000000)
![Page 38: Genetic Algorithms](https://reader034.fdocuments.net/reader034/viewer/2022050806/56816016550346895dcf1803/html5/thumbnails/38.jpg)
Chromosome
Array of unique identifiers of cities { id1 id2 id3 id4 id5 }
Example: {1,3,2,4,5}
Permutation of identifiers defines city order in the route
Traveling Salesman Problem
![Page 39: Genetic Algorithms](https://reader034.fdocuments.net/reader034/viewer/2022050806/56816016550346895dcf1803/html5/thumbnails/39.jpg)
Crossover(as in AForge.Net implementation)
Traveling Salesman ProblemMutation
(as in AForge.Net implementation)
![Page 40: Genetic Algorithms](https://reader034.fdocuments.net/reader034/viewer/2022050806/56816016550346895dcf1803/html5/thumbnails/40.jpg)
Fitness function
Selection – Elite selection
Traveling Salesman Problem
![Page 41: Genetic Algorithms](https://reader034.fdocuments.net/reader034/viewer/2022050806/56816016550346895dcf1803/html5/thumbnails/41.jpg)
FeaturesGA can find optimal solutions… but what’s more important
it can find solution close to global optimum quite fast!
IssuesMay stuck in local optimum
The larger problem is, the longer we count (obvious)Vulnerable to chromosome construction
and used method of mutation, crossover and selection
Traveling Salesman Problem
![Page 42: Genetic Algorithms](https://reader034.fdocuments.net/reader034/viewer/2022050806/56816016550346895dcf1803/html5/thumbnails/42.jpg)
TSP applies to real world problems!
Traveling Salesman Problem
![Page 43: Genetic Algorithms](https://reader034.fdocuments.net/reader034/viewer/2022050806/56816016550346895dcf1803/html5/thumbnails/43.jpg)
GA applications
Source: http://www.talkorigins.org/faqs/genalg/genalg.html
AcousticsAerospace engineeringAstronomy and astrophysicsChemistryElectrical engineeringFinancial marketsGame playingGeophysicsMaterials engineeringMath and algorithmsMilitary and law enforcementMolecular biologyPattern recognition and data miningRoboticsRouting and schedulingSystems engineering
![Page 44: Genetic Algorithms](https://reader034.fdocuments.net/reader034/viewer/2022050806/56816016550346895dcf1803/html5/thumbnails/44.jpg)
GA applications
![Page 45: Genetic Algorithms](https://reader034.fdocuments.net/reader034/viewer/2022050806/56816016550346895dcf1803/html5/thumbnails/45.jpg)
GA applications
![Page 46: Genetic Algorithms](https://reader034.fdocuments.net/reader034/viewer/2022050806/56816016550346895dcf1803/html5/thumbnails/46.jpg)
GA applications
![Page 47: Genetic Algorithms](https://reader034.fdocuments.net/reader034/viewer/2022050806/56816016550346895dcf1803/html5/thumbnails/47.jpg)
GA applications
![Page 48: Genetic Algorithms](https://reader034.fdocuments.net/reader034/viewer/2022050806/56816016550346895dcf1803/html5/thumbnails/48.jpg)
Questionsand
Answers
![Page 49: Genetic Algorithms](https://reader034.fdocuments.net/reader034/viewer/2022050806/56816016550346895dcf1803/html5/thumbnails/49.jpg)
Genetic AlgorithmsThank you for your attention!