Evolutionary Algorithms In Ruby

  • 3,000 views
Uploaded on

This talk will introduce into programming with evolutionary algorithms. …

This talk will introduce into programming with evolutionary algorithms.
We'll build and/or discover a small framework for creating genetic
algorithms.

Genetic algorithms are good to solve certain kind of algorithmic
problems.
The talk will also give a rough picture about situations where
evolutionary programming might be the right solution.
Especially np hard problems like the traveling sales man problem (TSP) or
the rucksack problem are well known combinatoric problems (such as
distributing vservers across a number of vserver-hosts).

More in: Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
No Downloads

Views

Total Views
3,000
On Slideshare
0
From Embeds
0
Number of Embeds
4

Actions

Shares
Downloads
133
Comments
1
Likes
4

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide
  • 99,9% of all species(!) ever existed died out. The other 0,1% is about to do the same. But image if all those guys would still exist. Would be a fairly uncomfortable crowd, wouldn‘t it?
  • 99,9% of all species(!) ever existed died out. The other 0,1% is about to do the same. But image if all those guys would still exist. Would be a fairly uncomfortable crowd, wouldn‘t it?
  • 99,9% of all species(!) ever existed died out. The other 0,1% is about to do the same. But image if all those guys would still exist. Would be a fairly uncomfortable crowd, wouldn‘t it?
  • acceptable = certain fitness,
    boundary = n generations, best individual didnt improve for n generations
    steady improvement of the fittest individuals
  • acceptable = certain fitness,
    boundary = n generations, best individual didnt improve for n generations
    steady improvement of the fittest individuals
  • acceptable = certain fitness,
    boundary = n generations, best individual didnt improve for n generations
    steady improvement of the fittest individuals
  • What?
  • What?
  • What?
  • What?
  • You can‘t just try them all!
  • How to determine the fitness of a tsp individual?
  • How to determine the fitness of a tsp individual?
  • How to determine the fitness of a tsp individual?
  • How do we create individuals?
  • Problem should be visualized!!!
  • Problem should be visualized!!!
  • You can‘t just try them all!
  • You can‘t just try them all!

Transcript

  • 1. Evolutionary Algorithms in Ruby Julian Fischer fischer@enterprise-rails.de http://www.enterprise-rails.de
  • 2. Introduction
  • 3. Introduction About me
  • 4. About me Julian Fischer ‣Twitter: http://www.twitter.com/railshoster ‣E-Mail: fischer@enterprise-rails.de
  • 5. About me Julian Fischer ‣Twitter: http://www.twitter.com/railshoster ‣E-Mail: fischer@enterprise-rails.de ‣ CEO of Avarteq GmbH
  • 6. About me Julian Fischer ‣Twitter: http://www.twitter.com/railshoster ‣E-Mail: fischer@enterprise-rails.de ‣ CEO of Avarteq GmbH ‣ Lecturer „Ruby on Rails“ @ HTWdS
  • 7. About me Julian Fischer ‣Twitter: http://www.twitter.com/railshoster ‣E-Mail: fischer@enterprise-rails.de ‣ CEO of Avarteq GmbH ‣ Lecturer „Ruby on Rails“ @ HTWdS ‣ Ruby und Ruby on Rails programmer
  • 8. About me Julian Fischer ‣Twitter: http://www.twitter.com/railshoster ‣E-Mail: fischer@enterprise-rails.de ‣ CEO of Avarteq GmbH ‣ Lecturer „Ruby on Rails“ @ HTWdS ‣ Ruby und Ruby on Rails programmer ‣ Entperise-Rails.de - Head of Hosting
  • 9. Introduction About Avarteq GmbH
  • 10. About Avarteq GmbH
  • 11. About Avarteq GmbH ‣ Founded in Nov. 2008 from two existing companies.
  • 12. About Avarteq GmbH ‣ Founded in Nov. 2008 from two existing companies. ‣ Involvment of Key-Systems GmbH manages ~2,5 * 10^6 domains for customers of 200+ countries.
  • 13. About Avarteq GmbH ‣ Founded in Nov. 2008 from two existing companies. ‣ Involvment of Key-Systems GmbH manages ~2,5 * 10^6 domains for customers of 200+ countries. ‣ Team size: 14 people 8 full-time, 6 part-time/freelancer
  • 14. Introduction Portfolio
  • 15. About Avarteq GmbH
  • 16. About Avarteq GmbH ‣ Covers all stages of web development
  • 17. About Avarteq GmbH ‣ Covers all stages of web development ‣ Consulting
  • 18. About Avarteq GmbH ‣ Covers all stages of web development ‣ Consulting ‣ Conceptual ~ and screen design
  • 19. About Avarteq GmbH ‣ Covers all stages of web development ‣ Consulting ‣ Conceptual ~ and screen design ‣ Ruby&onplace. development. In house in Rails
  • 20. About Avarteq GmbH ‣ Covers all stages of web development ‣ Consulting ‣ Conceptual ~ and screen design ‣ Ruby&onplace. development. In house in Rails ‣ Ruby on Rails hosting/servers/clusters RailsHoster.de - Enterprise-Rails.de
  • 21. Evolution
  • 22. Evolution
  • 23. Evolution
  • 24. Evolution ‣ Population of individuals (organisms)
  • 25. Evolution ‣ Population of individuals (organisms) ‣ Genes are passed from generation to generation.
  • 26. Evolution ‣ Population of individuals (organisms) ‣ Genes are passed from generation to generation. ‣ Slightgeneration to thein genetic material from one changes next.
  • 27. Evolution ‣ Population of individuals (organisms) ‣ Genes are passed from generation to generation. ‣ Slightgeneration to thein genetic material from one changes next. ‣ Differences accumulate over time.
  • 28. Evolution ‣ Population of individuals (organisms) ‣ Genes are passed from generation to generation. ‣ Slightgeneration to thein genetic material from one changes next. ‣ Differences accumulate over time. ‣ New properties or even species emerge.
  • 29. Evolution Genetic Operations
  • 30. Evolution
  • 31. Evolution ‣ Basic genetic operations
  • 32. Evolution ‣ Basic genetic operations ‣ Mutation of genetic material. Random changes
  • 33. Evolution ‣ Basic genetic operations ‣ Mutation of genetic material. Random changes ‣ Recombination of two individuals. Recombine genetic material
  • 34. Evolution ‣ Basic genetic operations ‣ Mutation of genetic material. Random changes ‣ Recombination of two individuals. Recombine genetic material ‣ also known as sexual reproduction
  • 35. Evolution
  • 36. Evolution ‣ Selection
  • 37. Evolution ‣ Selection ‣ Who will survive and thus
  • 38. Evolution ‣ Selection ‣ Who will survive and thus ‣ is able to create the most offsprings?
  • 39. Evolution Challenges
  • 40. Evolution
  • 41. Evolution ‣ Changing environment and a lot of other changing temperature, energy resources, competitors and moving stuff, ...
  • 42. Evolution ‣ Changing environment and a lot of other changing temperature, energy resources, competitors and moving stuff, ... ‣ Huge search space countless possible individuals. vast amount of dna combinations,
  • 43. Evolution ‣ Changing environment and a lot of other changing temperature, energy resources, competitors and moving stuff, ... ‣ Huge search space countless possible individuals. vast amount of dna combinations, ‣ Restricted resources Death = release of allocated resources.
  • 44. Evolution
  • 45. Evolution ‣ Which combinations to create as an individual?
  • 46. Evolution ‣ Which combinations to create as an individual? ‣ Only validthey usually don‘t breed a banana plant but another If two dogs breed individuals dog, instead!
  • 47. Evolution ‣ Which combinations to create as an individual? ‣ Only validthey usually don‘t breed a banana plant but another If two dogs breed individuals dog, instead! ‣ Preserve good gene materialetc. have a lot of Maybe that‘s why rockstars, football champions, girlfriends?! Hey, I am a Ruby programmer, that‘s also awesome!
  • 48. Evolution ‣ Which combinations to create as an individual? ‣ Only validthey usually don‘t breed a banana plant but another If two dogs breed individuals dog, instead! ‣ Preserve good gene materialetc. have a lot of Maybe that‘s why rockstars, football champions, girlfriends?! Hey, I am a Ruby programmer, that‘s also awesome! ‣ Improve! but even improve what‘s good and make it better! Not only preserve
  • 49. How does that relate to computer science and Ruby?
  • 50. Evolution and Ruby?
  • 51. Evolution and Ruby? Given: Search or optimization problem with a huge search space
  • 52. Evolution and Ruby? Given: Search or optimization problem with a huge search space Wanted: A (heuristic) solution.
  • 53. Evolutionary Programming (EP) ...
  • 54. ...with Genetic Algorithms (GA)
  • 55. Genetic Algorithms Basic Idea
  • 56. Imitate the evolutionary process.
  • 57. Genetic Algorithms What we need
  • 58. Genetic Algorithms
  • 59. Genetic Algorithms ‣ Generation = Nr. of individuals
  • 60. Genetic Algorithms ‣ Generation = Nr. of individuals ‣ Individualbut a valid problem solution maybe a bad one = valid.
  • 61. Genetic Algorithms ‣ Generation = Nr. of individuals ‣ Individualbut a valid problem solution maybe a bad one = valid. ‣ Individuals constist of genes
  • 62. Genetic Algorithms ‣ Generation = Nr. of individuals ‣ Individualbut a valid problem solution maybe a bad one = valid. ‣ Individuals constist of genes ‣ Individuals havethe individual (good .. badfitness indicating the worthiness of a well known solution).
  • 63. Genetic Algorithms
  • 64. Genetic Algorithms ‣ Mutation operation
  • 65. Genetic Algorithms ‣ Mutation operation ‣ Recombination operation
  • 66. Genetic Algorithms ‣ Mutation operation ‣ Recombination operation ‣ Selection operation
  • 67. Genetic Algorithms Evolutionary Process
  • 68. Genetic Algorithms
  • 69. Genetic Algorithms ‣ Start with a first individual (genesis)
  • 70. Genetic Algorithms ‣ Start with a first individual (genesis) ‣ Create 2nd individual through mutation
  • 71. Genetic Algorithms ‣ Start with a first individual (genesis) ‣ Create 2nd individual through mutation ‣ Randomly/Statistically choose a genetic operation to create new individuals
  • 72. Genetic Algorithms
  • 73. Genetic Algorithms ‣ If a generation is full create a new one
  • 74. Genetic Algorithms ‣ If a generation is full create a new one ‣ Select fittest individuals to be passed in to the next generation.
  • 75. Genetic Algorithms ‣ If a generation is full create a new one ‣ Select fittest individuals to be passed in to the next generation. ‣ Repeat the process until we have an acceptable solution or hit a given boundary.
  • 76. Concrete?!
  • 77. Genetic Algorithms Example
  • 78. Travelling Salesman Problem (TSP)
  • 79. Traveling Salesman
  • 80. Traveling Salesman ‣ A salesman needs to travel to n cities
  • 81. Traveling Salesman ‣ A salesman needs to travel to n cities ‣ Each city needs to be visited once
  • 82. Traveling Salesman ‣ A salesman needs to travel to n cities ‣ Each city needs to be visited once ‣ The salesman wants to end where he started.
  • 83. Traveling Salesman ‣ A salesman needs to travel to n cities ‣ Each city needs to be visited once ‣ The salesman wants to end where he started. ‣ The route should be minimal.
  • 84. Why should we care about salesmen?
  • 85. Traveling Salesman
  • 86. Traveling Salesman ‣ TSP can be applied to many scenarios:
  • 87. Traveling Salesman ‣ TSP can be applied to many scenarios: ‣ (Flight) planning, logistics, ...
  • 88. Traveling Salesman ‣ TSP can be applied to many scenarios: ‣ (Flight) planning, logistics, ... ‣ Manufactoring of microchips
  • 89. Traveling Salesman ‣ TSP can be applied to many scenarios: ‣ (Flight) planning, logistics, ... ‣ Manufactoring of microchips ‣ Slightly modified in DNA sequencing
  • 90. Traveling Salesman ‣ TSP can be applied to many scenarios: ‣ (Flight) planning, logistics, ... ‣ Manufactoring of microchips ‣ Slightly modified in DNA sequencing ‣ ...
  • 91. Traveling Salesman
  • 92. Traveling Salesman ‣ What‘s the deal about it?
  • 93. Traveling Salesman ‣ What‘s the deal about it? ‣ Problem of combinatorical optimization
  • 94. Traveling Salesman ‣ What‘s the deal about it? ‣ Problem of combinatorical optimization ‣ Not a shortest path problem!
  • 95. Traveling Salesman ‣ What‘s the deal about it? ‣ Problem of combinatorical optimization ‣ Not a shortest path problem! ‣ Computational complexity: np complete nondeterministic polynomial time
  • 96. Too many possible combinations!
  • 97. Traveling Salesman
  • 98. Traveling Salesman ‣ Most direct solution: Check permutations
  • 99. Traveling Salesman ‣ Most direct solution: Check permutations ‣ O(n!)
  • 100. Traveling Salesman ‣ Most direct solution: Check permutations ‣ O(n!) ‣ 5! = 120 combinations
  • 101. Traveling Salesman ‣ Most direct solution: Check permutations ‣ O(n!) ‣ 5! = 120 combinations ‣ 10! = 3.628.800 combinations
  • 102. Traveling Salesman ‣ Most direct solution: Check permutations ‣ O(n!) ‣ 5! = 120 combinations ‣ 10! = 3.628.800 combinations ‣ 15! = 1.307.674.368.000 combinations
  • 103. Traveling Salesman ‣ Most direct solution: Check permutations ‣ O(n!) ‣ 5! = 120 combinations ‣ 10! = 3.628.800 combinations ‣ 15! = 1.307.674.368.000 combinations ‣ 20! ~ 2,43 * 10^18 combinations
  • 104. Genetic Algorithms TSP
  • 105. Use a genetic algorithm to find a heuristic solution
  • 106. TSP Individual
  • 107. TSP Individual
  • 108. TSP Individual ‣ Valid roundtrip- = cycle of -cities Saarbrücken. Saarbrücken - Amsterdam Madrid - Poznan Berlin -
  • 109. TSP Individual ‣ Valid roundtrip- = cycle of -cities Saarbrücken. Saarbrücken - Amsterdam Madrid - Poznan Berlin - ‣ Individual = valid roundtrip
  • 110. TSP Individual ‣ Valid roundtrip- = cycle of -cities Saarbrücken. Saarbrücken - Amsterdam Madrid - Poznan Berlin - ‣ Individual = valid roundtrip ‣ Genes = cities
  • 111. TSP Fitness
  • 112. TSP Fitness
  • 113. TSP Fitness ‣ Each city knows its geo coords (lat, lon)
  • 114. TSP Fitness ‣ Each city knows its geo coords (lat, lon) ‣ Calculate distance between two geo coords
  • 115. TSP Fitness ‣ Each city knows its geo coords (lat, lon) ‣ Calculate distance between two geo coords ‣ Fitness = sum of distances between cities
  • 116. TSP Genetic Operations
  • 117. Genetic Operations Mutation
  • 118. TSP Fitness
  • 119. TSP Fitness ‣ Shuffle mutation
  • 120. TSP Fitness ‣ Shuffle mutation ‣ Completely shuffle the order of cities in the roundtrip
  • 121. TSP Fitness ‣ Shuffle mutation ‣ Completely shuffle the order of cities in the roundtrip ‣ 1-3-5-4-2 → 3-5-1-2-4
  • 122. TSP Fitness ‣ Shuffle mutation ‣ Completely shuffle the order of cities in the roundtrip ‣ 1-3-5-4-2 → 3-5-1-2-4 ‣ (-) Doesn‘t rely on existing individuals
  • 123. TSP Fitness ‣ Shuffle mutation ‣ Completely shuffle the order of cities in the roundtrip ‣ 1-3-5-4-2 → 3-5-1-2-4 ‣ (-) Doesn‘t rely on existing individuals ‣ Not a slightly but a massive change
  • 124. TSP Fitness
  • 125. TSP Fitness ‣ Partly shuffle
  • 126. TSP Fitness ‣ Partly shuffle ‣ Exchange two randomly choosen cities
  • 127. TSP Fitness ‣ Partly shuffle ‣ Exchange two randomly choosen cities ‣ 1-3-5-4-2 → 1-3-4-5-2
  • 128. TSP Fitness ‣ Partly shuffle ‣ Exchange two randomly choosen cities ‣ 1-3-5-4-2 → 1-3-4-5-2 ‣ (+) Uses existing individuals
  • 129. TSP Fitness ‣ Partly shuffle ‣ Exchange two randomly choosen cities ‣ 1-3-5-4-2 → 1-3-4-5-2 ‣ (+) Uses existing individuals ‣ Many more mutation operations imaginable.
  • 130. Genetic Operations Recombination
  • 131. TSP Recombination
  • 132. TSP Recombination ‣ Recombination challenge:
  • 133. TSP Recombination ‣ Recombination challenge: ‣ How to combine parts of individuals in a way that a valid roundtrip will be produced?
  • 134. Recombination Cycle Crossover
  • 135. Cycle Crossover
  • 136. Cycle Crossover ‣ Pass randomly choosen parts from the the parents to the offsprings
  • 137. Cycle Crossover ‣ Pass randomly choosen parts from the the parents to the offsprings ‣ Creates two offsprings
  • 138. Cycle Crossover ‣ Pass randomly choosen parts from the the parents to the offsprings ‣ Creates two offsprings ‣ Example
  • 139. Cycle Crossover ‣ Pass randomly choosen parts from the the parents to the offsprings ‣ Creates two offsprings ‣ Example ‣ mom = [2, 3, 5, 7, 1, 6, 4]
  • 140. Cycle Crossover ‣ Pass randomly choosen parts from the the parents to the offsprings ‣ Creates two offsprings ‣ Example ‣ mom = [2, 3, 5, 7, 1, 6, 4] ‣ dad = [4, 5, 6, 3, 2, 7, 1]
  • 141. Cycle Crossover mom = [2, 3, 5, 7, 1, 6, 4] dad = [4, 5, 6, 3, 2, 7, 1]
  • 142. Cycle Crossover mom = [2, 3, 5, 7, 1, 6, 4] dad = [4, 5, 6, 3, 2, 7, 1] ‣ Choose a gene from the first parent (e.g. gene=3, index=1).
  • 143. Cycle Crossover mom = [2, 3, 5, 7, 1, 6, 4] dad = [4, 5, 6, 3, 2, 7, 1] ‣ Choose a gene from the first parent (e.g. gene=3, index=1). ‣ Add it to the cycle.
  • 144. Cycle Crossover mom = [2, 3, 5, 7, 1, 6, 4] dad = [4, 5, 6, 3, 2, 7, 1] ‣ Choose a gene from the first parent (e.g. gene=3, index=1). ‣ Add it to the cycle. ‣ Cycle: [3]
  • 145. Cycle Crossover mom = [2, 3, 5, 7, 1, 6, 4] dad = [4, 5, 6, 3, 2, 7, 1]
  • 146. Cycle Crossover mom = [2, 3, 5, 7, 1, 6, 4] dad = [4, 5, 6, 3, 2, 7, 1] ‣ Search for gene with the same index (1) in Dad's genes (gene=5, index=1).
  • 147. Cycle Crossover mom = [2, 3, 5, 7, 1, 6, 4] dad = [4, 5, 6, 3, 2, 7, 1] ‣ Search for gene with the same index (1) in Dad's genes (gene=5, index=1). ‣ Add it to the cycle.
  • 148. Cycle Crossover mom = [2, 3, 5, 7, 1, 6, 4] dad = [4, 5, 6, 3, 2, 7, 1] ‣ Search for gene with the same index (1) in Dad's genes (gene=5, index=1). ‣ Add it to the cycle. ‣ Cycle: [3, 5]
  • 149. Cycle Crossover mom = [2, 3, 5, 7, 1, 6, 4] dad = [4, 5, 6, 3, 2, 7, 1]
  • 150. Cycle Crossover mom = [2, 3, 5, 7, 1, 6, 4] dad = [4, 5, 6, 3, 2, 7, 1] ‣ Search for the corresponding gene (gene=5, index=2) in Mom's genes.
  • 151. Cycle Crossover mom = [2, 3, 5, 7, 1, 6, 4] dad = [4, 5, 6, 3, 2, 7, 1] ‣ Search for the corresponding gene (gene=5, index=2) in Mom's genes. ‣ Look for the gene at index 2 at Dad's genes (gene=6, index=2).
  • 152. Cycle Crossover mom = [2, 3, 5, 7, 1, 6, 4] dad = [4, 5, 6, 3, 2, 7, 1] ‣ Search for the corresponding gene (gene=5, index=2) in Mom's genes. ‣ Look for the gene at index 2 at Dad's genes (gene=6, index=2). ‣ Add it to the cycle.
  • 153. Cycle Crossover mom = [2, 3, 5, 7, 1, 6, 4] dad = [4, 5, 6, 3, 2, 7, 1] ‣ Search for the corresponding gene (gene=5, index=2) in Mom's genes. ‣ Look for the gene at index 2 at Dad's genes (gene=6, index=2). ‣ Add it to the cycle. ‣ Cycle: [3, 5, 6]
  • 154. Cycle Crossover mom = [2, 3, 5, 7, 1, 6, 4] dad = [4, 5, 6, 3, 2, 7, 1]
  • 155. Cycle Crossover mom = [2, 3, 5, 7, 1, 6, 4] dad = [4, 5, 6, 3, 2, 7, 1] ‣ Search for the corresponding gene in Dad's genes (gene=6, index=5).
  • 156. Cycle Crossover mom = [2, 3, 5, 7, 1, 6, 4] dad = [4, 5, 6, 3, 2, 7, 1] ‣ Search for the corresponding gene in Dad's genes (gene=6, index=5). ‣ Look for the gene at index 5 (gene=7, index=5) in Mom‘s genes.
  • 157. Cycle Crossover mom = [2, 3, 5, 7, 1, 6, 4] dad = [4, 5, 6, 3, 2, 7, 1] ‣ Search for the corresponding gene in Dad's genes (gene=6, index=5). ‣ Look for the gene at index 5 (gene=7, index=5) in Mom‘s genes. ‣ Add it to the cycle.
  • 158. Cycle Crossover mom = [2, 3, 5, 7, 1, 6, 4] dad = [4, 5, 6, 3, 2, 7, 1] ‣ Search for the corresponding gene in Dad's genes (gene=6, index=5). ‣ Look for the gene at index 5 (gene=7, index=5) in Mom‘s genes. ‣ Add it to the cycle. ‣ Cycle: [3, 5, 6, 7]
  • 159. Cycle Crossover mom = [2, 3, 5, 7, 1, 6, 4] dad = [4, 5, 6, 3, 2, 7, 1]
  • 160. Cycle Crossover mom = [2, 3, 5, 7, 1, 6, 4] dad = [4, 5, 6, 3, 2, 7, 1] ‣ Search for the corresponding gene in Moms's genes (gene=7, index=3).
  • 161. Cycle Crossover mom = [2, 3, 5, 7, 1, 6, 4] dad = [4, 5, 6, 3, 2, 7, 1] ‣ Search for the corresponding gene in Moms's genes (gene=7, index=3). ‣ Look for the gene at index 3 (gene=3, index=3).
  • 162. Cycle Crossover mom = [2, 3, 5, 7, 1, 6, 4] dad = [4, 5, 6, 3, 2, 7, 1] ‣ Search for the corresponding gene in Moms's genes (gene=7, index=3). ‣ Look for the gene at index 3 (gene=3, index=3). ‣ Add it to the cycle.
  • 163. Cycle Crossover mom = [2, 3, 5, 7, 1, 6, 4] dad = [4, 5, 6, 3, 2, 7, 1] ‣ Search for the corresponding gene in Moms's genes (gene=7, index=3). ‣ Look for the gene at index 3 (gene=3, index=3). ‣ Add it to the cycle. ‣ Cycle: [3, 5, 6, 7, 3]
  • 164. Cycle Crossover cycle = [3, 5, 6, 7, 3]
  • 165. Cycle Crossover cycle = [3, 5, 6, 7, 3] ‣ Now the cycle is complete!
  • 166. Cycle Crossover cycle = [3, 5, 6, 7, 3] ‣ Now the cycle is complete! ‣ We can create the offsprings.
  • 167. Cycle Crossover cycle = [3, 5, 6, 7, 3] ‣ Now the cycle is complete! ‣ We can create the offsprings. ‣ Genes which are in the cycle will be taken from their parents preserving their original positions
  • 168. Cycle Crossover cycle = [3, 5, 6, 7, 3] ‣ Now the cycle is complete! ‣ We can create the offsprings. ‣ Genes which are in the cycle will be taken from their parents preserving their original positions moms_child = [x, 3, 5, 7, x, 6, x] dads_child = [x, 5, 6, 3, x, 7, x]
  • 169. Cycle Crossover mom = [2, 3, 5, 7, 1, 6, 4] dad = [4, 5, 6, 3, 2, 7, 1] moms_child = [x, 3, 5, 7, x, 6, x] dads_child = [x, 5, 6, 3, x, 7, x]
  • 170. Cycle Crossover mom = [2, 3, 5, 7, 1, 6, 4] dad = [4, 5, 6, 3, 2, 7, 1] moms_child = [x, 3, 5, 7, x, 6, x] dads_child = [x, 5, 6, 3, x, 7, x] ‣ Missing genes will be taken from the other parent.
  • 171. Cycle Crossover mom = [2, 3, 5, 7, 1, 6, 4] dad = [4, 5, 6, 3, 2, 7, 1] moms_child = [x, 3, 5, 7, x, 6, x] dads_child = [x, 5, 6, 3, x, 7, x] ‣ Missing genes will be taken from the other parent. mom = [2, 3, 5, 7, 1, 6, 4] dads_child = [2, 5, 6, 3, 1, 7, 4]
  • 172. Cycle Crossover mom = [2, 3, 5, 7, 1, 6, 4] dad = [4, 5, 6, 3, 2, 7, 1] moms_child = [x, 3, 5, 7, x, 6, x] dads_child = [x, 5, 6, 3, x, 7, x] ‣ Missing genes will be taken from the other parent. mom = [2, 3, 5, 7, 1, 6, 4] dads_child = [2, 5, 6, 3, 1, 7, 4]
  • 173. Cycle Crossover mom = [2, 3, 5, 7, 1, 6, 4] dad = [4, 5, 6, 3, 2, 7, 1] moms_child = [x, 3, 5, 7, x, 6, x] dads_child = [x, 5, 6, 3, x, 7, x] ‣ Missing genes will be taken from the other parent. mom = [2, 3, 5, 7, 1, 6, 4] dads_child = [2, 5, 6, 3, 1, 7, 4]
  • 174. Cycle Crossover mom = [2, 3, 5, 7, 1, 6, 4] dad = [4, 5, 6, 3, 2, 7, 1] moms_child = [x, 3, 5, 7, x, 6, x] dads_child = [x, 5, 6, 3, x, 7, x] ‣ Missing genes will be taken from the other parent. mom = [2, 3, 5, 7, 1, 6, 4] dads_child = [2, 5, 6, 3, 1, 7, 4]
  • 175. Cycle Crossover mom = [2, 3, 5, 7, 1, 6, 4] dad = [4, 5, 6, 3, 2, 7, 1] moms_child = [x, 3, 5, 7, x, 6, x] dads_child = [x, 5, 6, 3, x, 7, x] ‣ Missing genes will be taken from the other parent. mom = [2, 3, 5, 7, 1, 6, 4] dads_child = [2, 5, 6, 3, 1, 7, 4] dad = [4, 5, 6, 3, 2, 7, 1] moms_child = [4, 3, 5, 7, 2, 6, 1]
  • 176. Cycle Crossover mom = [2, 3, 5, 7, 1, 6, 4] dad = [4, 5, 6, 3, 2, 7, 1] moms_child = [x, 3, 5, 7, x, 6, x] dads_child = [x, 5, 6, 3, x, 7, x] ‣ Missing genes will be taken from the other parent. mom = [2, 3, 5, 7, 1, 6, 4] dads_child = [2, 5, 6, 3, 1, 7, 4] dad = [4, 5, 6, 3, 2, 7, 1] moms_child = [4, 3, 5, 7, 2, 6, 1]
  • 177. Cycle Crossover mom = [2, 3, 5, 7, 1, 6, 4] dad = [4, 5, 6, 3, 2, 7, 1] moms_child = [x, 3, 5, 7, x, 6, x] dads_child = [x, 5, 6, 3, x, 7, x] ‣ Missing genes will be taken from the other parent. mom = [2, 3, 5, 7, 1, 6, 4] dads_child = [2, 5, 6, 3, 1, 7, 4] dad = [4, 5, 6, 3, 2, 7, 1] moms_child = [4, 3, 5, 7, 2, 6, 1]
  • 178. Cycle Crossover mom = [2, 3, 5, 7, 1, 6, 4] dad = [4, 5, 6, 3, 2, 7, 1] moms_child = [x, 3, 5, 7, x, 6, x] dads_child = [x, 5, 6, 3, x, 7, x] ‣ Missing genes will be taken from the other parent. mom = [2, 3, 5, 7, 1, 6, 4] dads_child = [2, 5, 6, 3, 1, 7, 4] dad = [4, 5, 6, 3, 2, 7, 1] moms_child = [4, 3, 5, 7, 2, 6, 1]
  • 179. TSP Evolver
  • 180. Setup the evolutionary process
  • 181. TSP Evolver
  • 182. TSP Evolver ‣ Generation size
  • 183. TSP Evolver ‣ Generation size ‣ Choose genetic operations
  • 184. TSP Evolver ‣ Generation size ‣ Choose genetic operations ‣ Probabilities of genetic operations
  • 185. TSP Evolver ‣ Generation size ‣ Choose genetic operations ‣ Probabilities of genetic operations ‣ e.g. 30% mutation, 70% x-over
  • 186. TSP Evolver ‣ Generation size ‣ Choose genetic operations ‣ Probabilities of genetic operations ‣ e.g. 30% mutation, 70% x-over ‣ Set exit condition
  • 187. TSP Evolver ‣ Generation size ‣ Choose genetic operations ‣ Probabilities of genetic operations ‣ e.g. 30% mutation, 70% x-over ‣ Set exit condition ‣ ...
  • 188. Go!
  • 189. Code and Demo!
  • 190. GA Challenges
  • 191. Genetic Algorithms
  • 192. Genetic Algorithms ‣ How to represent an individual?
  • 193. Genetic Algorithms ‣ How to represent an individual? ‣ Find a meaningful fitness function
  • 194. Genetic Algorithms ‣ How to represent an individual? ‣ Find a meaningful fitness function ‣ Can‘t be applied to boolean fitness functions (match, no match)
  • 195. Genetic Algorithms ‣ How to represent an individual? ‣ Find a meaningful fitness function ‣ Can‘t be applied to boolean fitness functions (match, no match) ‣ Define than blind guessing skip it! operations If it‘s worse efficient genetic
  • 196. Genetic Algorithms
  • 197. Genetic Algorithms ‣ Don‘t get lost in the metaphor! a problem! It‘s not about re-modeling the world, it‘s about solving
  • 198. Genetic Algorithms ‣ Don‘t get lost in the metaphor! a problem! It‘s not about re-modeling the world, it‘s about solving ‣ Non-determinism 1st run might find a very good solution, 2nd a totally bad one, ...
  • 199. Genetic Algorithms ‣ Don‘t get lost in the metaphor! a problem! It‘s not about re-modeling the world, it‘s about solving ‣ Non-determinism 1st run might find a very good solution, 2nd a totally bad one, ... ‣ Store your best solutions and use them as the origin for the next run!
  • 200. What is it good for again?
  • 201. Genetic Algorithms
  • 202. Genetic Algorithms ‣ Find good solutions for np hard combinatorical problems
  • 203. Genetic Algorithms ‣ Find good solutions for np hard combinatorical problems ‣ ... even for difficult search spaces!
  • 204. What else can be done?
  • 205. Genetic Algorithms
  • 206. Genetic Algorithms ‣ Find smart break conditions
  • 207. Genetic Algorithms ‣ Find smart break conditions ‣ e.g. exit if there is no change for n generations
  • 208. Genetic Algorithms ‣ Find smart break conditions ‣ e.g. exit if there is no change for n generations ‣ Implement more genetic operations and evaluate them.
  • 209. Genetic Algorithms
  • 210. Genetic Algorithms ‣ Optimize ratio between
  • 211. Genetic Algorithms ‣ Optimize ratio between ‣ Generation size
  • 212. Genetic Algorithms ‣ Optimize ratio between ‣ Generation size ‣ Operation propabilities
  • 213. Genetic Algorithms ‣ Optimize ratio between ‣ Generation size ‣ Operation propabilities ‣ Fasten your fitness function!
  • 214. Genetic Algorithms ‣ Optimize ratio between ‣ Generation size ‣ Operation propabilities ‣ Fasten your fitness function! ‣ Use heuristic fitness functions estimate fitness to be faster
  • 215. Genetic Algorithms ‣ Optimize ratio between ‣ Generation size ‣ Operation propabilities ‣ Fasten your fitness function! ‣ Use heuristic fitness functions estimate fitness to be faster ‣ Cache frequently computed values e.g. distances between cities
  • 216. FAQ
  • 217. FAQ
  • 218. FAQ ‣ Do you use EP/GA for your everyday work?
  • 219. FAQ ‣ Do you use EP/GA for your everyday work? ‣ Not very often ...
  • 220. FAQ ‣ Do you use EP/GA for your everyday work? ‣ Not very often ... ‣ ... but how often do you encounter np- hard problems in everyday‘s work?
  • 221. FAQ
  • 222. FAQ ‣ Why talk about it?
  • 223. FAQ ‣ Why talk about it? ‣ Interesting and generic methodology
  • 224. FAQ ‣ Why talk about it? ‣ Interesting and generic methodology ‣ Solves NP hard problems heuristically with minimal thought.
  • 225. FAQ ‣ Why talk about it? ‣ Interesting and generic methodology ‣ Solves NP hard problems heuristically with minimal thought. ‣ Gives a good understanding why some people are what they are: Just bad guesses :-)
  • 226. Further questions?
  • 227. Thank you for your attention! Headquarter: Rails Enterprise Hosting: http://www.avarteq.de http://www.enterprise- rails.de Blog: http://ww.treibstofff.de Rails Hosting: http://www.railshoster.de
  • 228. Resources
  • 229. Resources ‣ http://en.wikipedia.org/wiki/Travelling_salesman_problem
  • 230. Resources ‣ http://en.wikipedia.org/wiki/Travelling_salesman_problem ‣ http://en.wikipedia.org/wiki/Evolution
  • 231. Resources ‣ http://en.wikipedia.org/wiki/Travelling_salesman_problem ‣ http://en.wikipedia.org/wiki/Evolution ‣ http://en.wikipedia.org/wiki/Genetic_algorithm