150 likes | 356 Views
Genetic Algorithms: Evolving Solutions to Problems. What is a Genetic Algorithm?. Pool of possible solutions Randomly creates initial algorithms Relies on “survival of fittest” Uses mutation and crossover Follows a cycle of generations. What can GAs be used for?.
E N D
What is a Genetic Algorithm? • Pool of possible solutions • Randomly creates initial algorithms • Relies on “survival of fittest” • Uses mutation and crossover • Follows a cycle of generations
What can GAs be used for? • Any problem that solutions can be rated for levels of success • Difficult optimization problems including NP-hard and NP-complete • Problems with “building blocks” • Problems with functions that are undefined or don’t exist
What are its accomplishments? • Recreating technology like A-D converter, antennas • Traveling Salesman Problem • Knapsack Problem • Outperforms hill-climbing and simulated-annealing
Hill-Climbing -Kangaroo hops to top of nearest mountain. Simulated-Annealing -Drunken kangaroo hops around randomly, sobers up, and hops uphill. How is it different from other optimization algorithms? Genetic Algorithm -Kangaroos are released and allowed to roam. Flood drowns kangaroos on low hills, survivors multiply.
How is a GA set up? • Data for the problem is encoded in each member • Method determined for making initial population • Fitness function is determined • Method of selection is chosen • Genetic operators are chosen • Population size, mutation probability
Million Monkeys Example 1 million monkeys try to write the word: “shakespeare” Data Encoding: string 11 characters long, character set 26 characters(a-z) Create Initial population: 20 random strings of the 26 allowed characters Fitness Function: Difference of each letter from correct letter Genetic Operators: Single Crossover, Mutation Selection: Top 50%
1st generation xgagqlqohxn 62 uwifceuigqb 65 ghhmvntcqqf 67 tpcahvntllp 72 mulhbkubxrf 76 fihsoghlfoh 77 qdnbnvedhov 79 nmnxovhkaqv 81 tanjxinrcqu 85 ltlboligpsm 89 rtufqrkeuoq 91 rntdphpnxsk 94 mfsqxcuucoj 98 huvbcvwpmpr 104 kcigyfpaxrx 104 vgnqijaqxpw 106 nyljlfhbyxr 108 oxqblcqgylq 113 oavxnemsvha 120 gnqwkqusshy 121 2nd generation ghhmceuigqb 56* nkifceuigqb 58* tpcahvnrcqu 61* wgagqlqohxn 61 uwifceuigqb 65 ghhmvntcqqf 67 tpcahvntllp 72 uwifcehlfoh 72* tanjxincqqf 73* fihsogtcqqf 75* mulhbkubxrf 76 qdnbnvedxrf 76* fihsoghlfoh 77 qdnbnvedhov 79 nmnxovhkaqv 81 xgnjxinrcqu 83* tanjxinrcqu 85 ltlboligpsm 89 mulbnvedhov 90* ltnxovhkaqv 90* Crossover ghhmvntcggf and uwifceuiggb = ghhmceuiggb Mutation xgagglgohxn wgagglgohxn
Fitness • Should reflect potential • May need to provide constraints • Penalties- Subtract from fitness • Repairs- Repairs code outside const. • Decoder- Change way of making algorithm, any individual is valid • May need to be scaled
Selection • Roulette- random by fitness, many spins • Stochastic Universal Sampling- many pointers, One spin • Ranking- proportional by fitness • Tournament- random algorithms compete • Aging- given time to live, no selection • Crowding- new algorithms replace similar old • Multiple copies of same algorithm • Elitism- Best algorithms in next gen.
Crossover and Mutation • Crossover can kill ideal solutions (1*****10) • Single crossover is the worst • Multi-point crossover • Uniform crossover • Genetic Diversity vs. Selective Pressure • Incest Prevention/ Speciation • Mutation better for diversity • May not allow “supers” to breed
Messy Genetic Algorithms • Provide data in an unorganized fashion (position, value) ((5,0) (9,1) (4,1) (2,0)) • Crossover less damaging • More genetic diversity • Over-specification: May give too many values ((3,1) (4, 0) (3,0) (2,1) (1,1)) • Under-specification: May not give enough values ((4,0) (2,1))
Plants and Eaters Example • 16 possible states • Able to “See” square directly in front of it • 4 possible actions( turn left, turn right, move forward, move backward) • Acts on current state and what it can “See” • When it takes an action it sets a new state http://math.hws.edu/xJava/GA/