Genetic Algorithms: Evolving Solutions to Problems.

15
Genetic Algorithms: Evolving Solutions to Problems

Transcript of Genetic Algorithms: Evolving Solutions to Problems.

Page 1: Genetic Algorithms: Evolving Solutions to Problems.

Genetic Algorithms: Evolving Solutions to Problems

Page 2: 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

Page 3: Genetic Algorithms: Evolving Solutions to Problems.

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

Page 4: Genetic Algorithms: Evolving Solutions to Problems.

What are its accomplishments?

• Recreating technology like A-D converter, antennas

• Traveling Salesman Problem

• Knapsack Problem

• Outperforms hill-climbing and simulated-annealing

Page 5: Genetic Algorithms: Evolving Solutions to Problems.

How is it different from other optimization algorithms?

Hill-Climbing

-Kangaroo hops to top of nearest mountain.

Simulated-Annealing

-Drunken kangaroo hops around randomly, sobers up, and hops uphill.

Genetic Algorithm

-Kangaroos are released and allowed to roam. Flood drowns kangaroos on low hills, survivors multiply.

Page 6: Genetic Algorithms: Evolving Solutions to Problems.

What process does it follow?

Page 7: Genetic Algorithms: Evolving Solutions to Problems.

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

Page 8: Genetic Algorithms: Evolving Solutions to Problems.

Million Monkeys Example1 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 charactersFitness Function: Difference of each letter from

correct letterGenetic Operators: Single Crossover, MutationSelection: Top 50%

Page 9: Genetic Algorithms: Evolving Solutions to Problems.

1st generationxgagqlqohxn 62uwifceuigqb 65ghhmvntcqqf 67tpcahvntllp 72mulhbkubxrf 76fihsoghlfoh 77qdnbnvedhov 79nmnxovhkaqv 81tanjxinrcqu 85ltlboligpsm 89rtufqrkeuoq 91rntdphpnxsk 94mfsqxcuucoj 98huvbcvwpmpr 104kcigyfpaxrx 104vgnqijaqxpw 106nyljlfhbyxr 108oxqblcqgylq 113oavxnemsvha 120gnqwkqusshy 121

2nd generationghhmceuigqb 56*nkifceuigqb 58*tpcahvnrcqu 61*wgagqlqohxn 61uwifceuigqb 65ghhmvntcqqf 67tpcahvntllp 72uwifcehlfoh 72*tanjxincqqf 73*fihsogtcqqf 75*mulhbkubxrf 76qdnbnvedxrf 76*fihsoghlfoh 77qdnbnvedhov 79nmnxovhkaqv 81xgnjxinrcqu 83*tanjxinrcqu 85ltlboligpsm 89mulbnvedhov 90*ltnxovhkaqv 90*

Crossover

ghhmvntcggf and

uwifceuiggb =

ghhmceuiggb

Mutationxgagglgohxnwgagglgohxn

Page 10: Genetic Algorithms: Evolving Solutions to Problems.

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

Page 11: Genetic Algorithms: Evolving Solutions to Problems.

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.

Page 12: Genetic Algorithms: Evolving Solutions to Problems.

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

Page 13: Genetic Algorithms: Evolving Solutions to Problems.

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))

Page 14: Genetic Algorithms: Evolving Solutions to Problems.

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/

Page 15: Genetic Algorithms: Evolving Solutions to Problems.

Questions?