1.26k likes | 1.4k Views
Genetic Algorithms. Chapter 9, Complexity: A Guided Tour. Evolution by Natural Selection. Charles Darwin. Evolution by Natural Selection. Organisms inherit traits from parents. Charles Darwin. Evolution by Natural Selection. Organisms inherit traits from parents
E N D
Genetic Algorithms Chapter 9, Complexity: A Guided Tour
Evolution by Natural Selection Charles Darwin
Evolution by Natural Selection • Organisms inherit traits from parents Charles Darwin
Evolution by Natural Selection • Organisms inherit traits from parents • Traits are inherited with some variation, via mutation and sexual recombination Charles Darwin
Evolution by Natural Selection • Organisms inherit traits from parents • Traits are inherited with some variation, via mutation and sexual recombination • Due to competition for limited resources, the organisms best adapted to the environment tend to produce the most offspring. Charles Darwin
Evolution by Natural Selection • Organisms inherit traits from parents • Traits are inherited with some variation, via mutation and sexual recombination • Due to competition for limited resources, the organisms best adapted to the environment tend to produce the most offspring. • This way traits producing adapted individuals spread in the population Charles Darwin
Evolution by Natural Selection in computers • Organisms inherit traits from parents • Traits are inherited with some variation, via mutation and sexual recombination • Due to competition for limited resources, the organisms best adapted to the environment tend to produce the most offspring. • This way traits producing adapted individuals spread in the population Computer (e.g., programs) Charles Darwin
Evolution by Natural Selection in computers • Organisms inherit traits from parents • Traits are inherited with some variation, via mutation and sexual recombination • Due to competition for limited resources, the organisms best adapted to the environment tend to produce the most offspring. • This way traits producing adapted individuals spread in the population Computer (e.g., programs) Charles Darwin John Holland
Evolution by Natural Selection in computers • Organisms inherit traits from parents • Traits are inherited with some variation, via mutation and sexual recombination • Due to competition for limited resources, the organisms best adapted to the environment tend to produce the most offspring. • This way traits producing adapted individuals spread in the population Computer (e.g., programs) Charles Darwin Genetic Algorithms (GAs) John Holland
Some real-world uses of genetic algorithms • Used by GE to automate parts of aircraft design
Some real-world uses of genetic algorithms • Used by GE to automate parts of aircraft design • Used by pharmaceutical companies to discover new drugs
Some real-world uses of genetic algorithms • Used by GE to automate parts of aircraft design • Used by pharmaceutical companies to discover new drugs • Used by the London Stock Exchange to automatically detect fraudulent trades
Some real-world uses of genetic algorithms • Used by GE to automate parts of aircraft design • Used by pharmaceutical companies to discover new drugs • Used by the London Stock Exchange to automatically detect fraudulent trades • Used to generate realistic computer animation in the movies Lord of the Rings: The Return of the King and Troy
Some real-world uses of genetic algorithms • Used by GE to automate parts of aircraft design • Used by pharmaceutical companies to discover new drugs • Used by the London Stock Exchange to automatically detect fraudulent trades • Used to generate realistic computer animation in the movies Lord of the Rings: The Return of the King and Troy • Used to model and understand evolution in nature!
Example: Evolving Strategies for Robby the Robot Input: Contents of N, S, E, W, C(Current)
Example: Evolving Strategies for Robby the Robot Input: Contents of N, S, E, W, C(Current) Possible actions: Move N Move S Move E Move W Move random Stay put Try to pick up can
Example: Evolving Strategies for Robby the Robot Input: Contents of N, S, E, W, C(Current) Possible actions: Move N Move S Move E Move W Move random Stay put Try to pick up can Rewards/Penalties (points): Picks up can: 10 Tries to pick up can on empty site: -1 Crashes into wall: -5
Encoding a Strategy Code: MoveNorth = 0 MoveSouth = 1 MoveEast = 2 MoveWest = 3 StayPut = 4 PickUpCan = 5 MoveRandom = 6
Encoding a Strategy Code: MoveNorth = 0 MoveSouth = 1 MoveEast = 2 MoveWest = 3 StayPut = 4 PickUpCan = 5 MoveRandom = 6
Encoding a Strategy 0 Code: MoveNorth = 0 MoveSouth = 1 MoveEast = 2 MoveWest = 3 StayPut = 4 PickUpCan = 5 MoveRandom = 6
Encoding a Strategy 0 2 Code: MoveNorth = 0 MoveSouth = 1 MoveEast = 2 MoveWest = 3 StayPut = 4 PickUpCan = 5 MoveRandom = 6
Encoding a Strategy 0 2 6 Code: MoveNorth = 0 MoveSouth = 1 MoveEast = 2 MoveWest = 3 StayPut = 4 PickUpCan = 5 MoveRandom = 6
Encoding a Strategy 0 2 6 5 . . . 3 . . . 4 Code: MoveNorth = 0 MoveSouth = 1 MoveEast = 2 MoveWest = 3 StayPut = 4 PickUpCan = 5 MoveRandom = 6
Encoding a Strategy 243 values 0 2 6 5 . . . 3 . . . 4 Code: MoveNorth = 0 MoveSouth = 1 MoveEast = 2 MoveWest = 3 StayPut = 4 PickUpCan = 5 MoveRandom = 6
Genetic algorithm for evolving strategies for Robby • Generate 200 random strategies (i.e., programs for controlling Robby)
Genetic algorithm for evolving strategies for Robby • Generate 200 random strategies (i.e., programs for controlling Robby) • For each strategy, calculate fitness (average reward minus penalties earned on random environments)
Genetic algorithm for evolving strategies for Robby • Generate 200 random strategies (i.e., programs for controlling Robby) • For each strategy, calculate fitness (average reward minus penalties earned on random environments) • The strategies pair up and create offspring via “sexual recombination” with random mutations ― the fitter the parents, the more offspring they create.
Parent 1: Parent 2:
Parent 1: Parent 2:
Parent 1: Parent 2: Child:
Genetic algorithm for evolving strategies for Robby • Generate 200 random strategies (i.e., programs for controlling Robby) • For each strategy, calculate fitness (average reward minus penalties earned on random environments) • The strategies pair up and create offspring via “sexual recombination” with random mutations ― the fitter the parents, the more offspring they create. • Keep going back to step 2 until a good-enough strategy is found!
My hand-designed strategy: “If there is a can in the current site, pick it up.”
My hand-designed strategy: “If there is a can in the current site, pick it up.” “Otherwise, if there is a can in one of the adjacent sites, move to that site.”
My hand-designed strategy: “If there is a can in the current site, pick it up.” “Otherwise, if there is a can in one of the adjacent sites, move to that site.” “Otherwise, choose a random direction to move in.”
My hand-designed strategy: “If there is a can in the current site, pick it up.” “Otherwise, if there is a can in one of the adjacent sites, move to that site.” “Otherwise, choose a random direction to move in.” Average fitness of this strategy: 346 (out of max possible 500)
My hand-designed strategy: “If there is a can in the current site, pick it up.” “Otherwise, if there is a can in one of the adjacent sites, move to that site.” “Otherwise, choose a random direction to move in.” Average fitness of this strategy: 346 (out of max possible 500) Average fitness of GA evolved strategy: 486 (out of max possible 500)
My hand-designed strategy: “If there is a can in the current site, pick it up.” “Otherwise, if there is a can in one of the adjacent sites, move to that site.” “Otherwise, choose a random direction to move in.” Average fitness of this strategy: 346 (out of max possible 500) Average fitness of GA evolved strategy: 486 (out of max possible 500) ???
One Run of the Genetic Algorithm Best fitness in population Generation number
Generation 1 Best average score = 81
Time: 0 Score: 0 0 1 23 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9
Time: 1 Score: 0 0 1 23 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9
Time: 2 Score: 5 0 1 23 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9
Time: 2 Score: 5 0 1 23 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9
Time: 3 Score: 10 0 1 23 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9