Comp215: Genetic Algorithms - Part 1 Mack Joyner, Dan S. Wallach (Rice University) Copyright 2016, Mack Joyner, Dan S. Wallach. All rights reserved.
Darwin s Theory of Evolution Individual organisms differ from each other Some traits inherited from ancestor Individuals best suited for environment survive produce offspring the makeup the next generation Some species change over time (mutation) new ones arise and old ones can disappear
John Henry Holland Pioneer of Genetic Algorithms (1975)
Genetic Algorithms A class of probabilistic optimization algorithms inspired by biological evolution Typically includes selection, reproduction, mutation Natural selection, common ancestor inheritance (Darwin) Genetic representation Represent an individual solution A fitness function determines the quality of the solution For pictures, fitness function could be if the picture is pretty Population of solutions exist Initial population is often generated randomly Choose best ones according to fitness function Evolution occurs with selected solutions to produce next generation
The Metaphor
The Metaphor Nature Genetic Algorithms
The Metaphor Nature Genetic Algorithms Environment Optimization problem
The Metaphor Nature Genetic Algorithms Environment Optimization problem Individuals living in that environment Feasible solutions
The Metaphor Nature Genetic Algorithms Environment Optimization problem Individuals living in that environment Feasible solutions Individual s degree of adaptation Fitness function
The Metaphor Nature Genetic Algorithms Environment Optimization problem Individuals living in that environment Feasible solutions Individual s degree of adaptation Fitness function A population of organisms (species) A set of feasible solutions
The Metaphor Nature Genetic Algorithms Environment Optimization problem Individuals living in that environment Feasible solutions Individual s degree of adaptation Fitness function A population of organisms (species) A set of feasible solutions Selection, reproduction, mutation Selection, recombination, mutation
The Metaphor Nature Genetic Algorithms Environment Optimization problem Individuals living in that environment Feasible solutions Individual s degree of adaptation Fitness function A population of organisms (species) A set of feasible solutions Selection, reproduction, mutation Evolution of populations to suit their environment Selection, recombination, mutation Iteratively applying a set of stochastic operators on a set of feasible solutions
Genetic Algorithm Applications (many more) Facial composite Traditional use: sketch artist Later: select individual features GA: evolve from groups of pictures Evolutionary Game Theory Prisoner s Dilemma Study cooperative behavior Applications: animals, economics, sports, politics.
Genetic Algorithm Applications (many more) Facial composite Traditional use: sketch artist Later: select individual features GA: evolve from groups of pictures Evolutionary Game Theory Iterate several times Prisoner s Dilemma Study cooperative behavior Applications: animals, economics, sports, politics.
Genetic Algorithm Applications (many more) Facial composite Traditional use: sketch artist Later: select individual features GA: evolve from groups of pictures Evolutionary Game Theory Iterate several times Prisoner s Dilemma Study cooperative behavior Applications: animals, economics, sports, politics. Years in jail
Genetic Algorithm Applications (many more) Facial composite Traditional use: sketch artist Later: select individual features GA: evolve from groups of pictures Evolutionary Game Theory Prisoner s Dilemma Study cooperative behavior Applications: animals, economics, sports, politics. Iterate several times Example: Cold War Years in jail
Why Use Genetic Algorithms? Find a good solution from many possible good solutions Don t need the best solution Not sure which solution to evaluate first Start with a random set a possible solutions For some problems, finding the best solution may be impractical Large, unknown search space
Traveling Salesman Problem Visit every city exactly once and return to starting point Cost associated with visiting a city Goal: route with minimum cost
Traveling Salesman Problem Visit every city exactly once and return to starting point Cost associated with visiting a city Goal: route with minimum cost http://xkcd.com/399
Traveling Salesman Problem Visit every city exactly once and return to starting point Cost associated with visiting a city Goal: route with minimum cost NP-complete problem http://xkcd.com/399
Traveling Salesman Problem Visit every city exactly once and return to starting point Cost associated with visiting a city Goal: route with minimum cost NP-complete problem Time to find optimal solution increases quickly as cities increase http://xkcd.com/399
Traveling Salesman Problem Visit every city exactly once and return to starting point Cost associated with visiting a city Goal: route with minimum cost NP-complete problem Typically solved with heuristic Time to find optimal solution increases quickly as cities increase http://xkcd.com/399
Genetic Algorithm Search Start with a group of the possible solutions Initially, randomly pick the candidate solutions Select best solutions to use for next generation Get rid of the worse ones Use recombination to get new solutions Decompose two solutions and randomly mix parts Forms new candidate solutions (children) Mutate solutions by randomly changing candidate solution
TSP: Selection A vector v = (i1 i2 in) represents a tour (v is a permutation of {1,2,,n}) Fitness f of a solution is the inverse cost of the corresponding tour Higher the value, the better the solution Initially use a random sample of permutations of {1,2,.,n} Apply fitness to determine which solutions to use for next generation
TSP: Reproduction Build offspring Choose tour subsequence from 1st parent Preserve relative city order from 2nd parent p1 = (1 2 3 4 5 6 7 8 9) p2 = (4 5 2 1 8 7 6 9 3) o1 = (x x x 4 5 6 7 x x) o2 = (x x x 1 8 7 6 x x)
TSP: Reproduction Build offspring Choose tour subsequence from 1st parent Preserve relative city order from 2nd parent p1 = (1 2 3 4 5 6 7 8 9) p2 = (4 5 2 1 8 7 6 9 3) o1 = (x x x 4 5 6 7 x x) o2 = (x x x 1 8 7 6 x x) Copy segment between cut points to offspring
TSP: Reproduction Start from the second cut point of one parent Copy cities from other parent in same order Skip ones already in offspring p1 = (1 2 3 4 5 6 7 8 9) p2 = (4 5 2 1 8 7 6 9 3) o1 = (x x x 4 5 6 7 x x) o2 = (x x x 1 8 7 6 x x)
TSP: Reproduction Start from the second cut point of one parent Copy cities from other parent in same order Skip ones already in offspring p1 = (1 2 3 4 5 6 7 8 9) p2 = (4 5 2 1 8 7 6 9 3) (9 3 4 5 2 1 8 7 6) (9 3 2 1 8) o1 = (x x x 4 5 6 7 x x) o2 = (x x x 1 8 7 6 x x)
TSP: Reproduction Start from the second cut point of one parent Copy cities from other parent in same order Skip ones already in offspring p1 = (1 2 3 4 5 6 7 8 9) p2 = (4 5 2 1 8 7 6 9 3) (9 3 4 5 2 1 8 7 6) (9 3 2 1 8) o1 = (x x x 4 5 6 7 x x) (2 1 8 4 5 6 7 9 3) o2 = (x x x 1 8 7 6 x x)
TSP: Reproduction Similarly for the 2nd offspring. p1 = (1 2 3 4 5 6 7 8 9) p2 = (4 5 2 1 8 7 6 9 3) o1 = (x x x 4 5 6 7 x x) (2 1 8 4 5 6 7 9 3) o2 = (x x x 1 8 7 6 x x) (3 4 5 1 8 7 6 9 2)
TSP: Mutation Reverse substring between two randomly selected points in the path Example: (1 2 3 4 5 6 7 8 9) is changed into (1 2 7 6 5 4 3 8 9)
TSP: Mutation Reverse substring between two randomly selected points in the path Example: (1 2 3 4 5 6 7 8 9) is changed into (1 2 7 6 5 4 3 8 9) Simple inversion guarantees that the resulting offspring is also a legal tour
Genetic Algorithms: Pretty Pictures A picture is really just a function: (x, y) -> (R, G, B) Selection: User picks the prettiest ones Reproduction: Combine two function trees to create a new tree Mutation: Randomly change a node in the tree to something else Artificial Evolution for Computer Graphics, Karl Sims, 1991
Genetic Algorithms: Pretty Pictures
Genetic Algorithms: Pretty Pictures
Genetic Algorithms: Pretty Pictures
Live Demo: Pretty Pictures on the Web http://gregstoll.dyndns.org/ppga/#details