prev

next

of 54

View

243Download

3

Tags:

Embed Size (px)

- Slide 1

Genetic Algorithms Slide 2 2 Introduction To Genetic Algorithms (GAs) Slide 3 3 What Are Genetic Algorithms (GAs)? Genetic Algorithms are search and optimization techniques based on Darwins Principle of Natural Selection. Slide 4 Characteristics of GA Parallel-search procedures that can be implemented on parallel processing machines for speeding operations Applies to both continuous and discrete optimization problems Stochastic in nature and less likely to get caught in local minima Facilitates both structure and parameter identification Slide 5 5 Darwins Principle Of Natural Selection I IF there are organisms that reproduce, and IF offsprings inherit traits from their parents, and IF there is variability of traits, and IF the environment cannot support all members of a growing population, THEN those members of the population with less- adaptive traits (determined by the environment) will die out, and THEN those members with more-adaptive traits (determined by the environment) will thrive The result is the evolution of species.species Slide 6 Working of GA GA encodes each point in a parameter space into a binary bit called chromosome Each point is associated with a fitness function Gene pool is a population of all such points In each generation GA constructs a new population using genetic operators Crossover Mutation Slide 7 Components of GA Encoding schemes Crossover operators Mutation operators Slide 8 Encoding schemes Transforms points in parameter space into string representations Eg (11,6,9) is represented as 101101101011 Encoding schemes provide a way of translating problem-specific knowledge directly into GA framework After this the fitness function is evaluated Next selection is based on the fittest survivor Slide 9 Fitness evaluation Slide 10 How is it different from other optimization and search procedures? 1. Works with a coding of the parameter set, not the parameters themselves 2. Search for a population of point and not a single point 3. Use objective function information and not derivatives or other auxiliary knowledge Slide 11 How GA is used and different from other optimization techniques? The first step in GA is to code the parameter x as a finite length string Example 1 can be code as string of 5 bits with an output f=f(s), where s=string of bits Successive populations are generated using the GA For effective check GA requires only objective functions associated with individual strings Slide 12 Simple genetic algorithm Reproduction:- individual strings are copied according to their objective fn: values f(FITNESS FUNCTION) Crossover:- Members of the newly reproduced strings are mated at random. Each pair of strings undergoes crossing overs. Mutation:-supplements reproduction and crossover and acts as an insurance policy against premature loss of important notions Slide 13 13 Basic Idea Of Principle Of Natural Selection Select The Best, Discard The Rest Slide 14 Example 1 Maximize f(x) =x 2 on the integer scale from 0-31 0 31 x f(x) 1000 Slide 15 Example 1 No:StringFitness% of total 10110116914.2 21100057649.2 301000645.5 41001136130.9 Total1170100 Slide 16 Roulette wheel with slots sized according to fitness Slide 17 Crossover A1=0 1 1 0 1 A2=1 1 0 0 0 A1=0 1 1 0 0 A2=1 1 0 0 1 Slide 18 Simple GA by Hand(Reproduction) No:Stringxf(x) x 2 pselect fi/ f Expected count n.pselect Actual count (Roulette Wheel0 10110113169.14.581 21100024576.491.972 3010000864.060.240 410011193610.311.241 Sum11701.0044.0 Average2930.251.001.0 Maximum576.491.972 Slide 19 Crossover Mating Pool after Reproduction(Cross Site shown) MateCrossov er New populationxF(x) 0110|1 240 1 1 0 012144 1100|0 141 1 0 0 125625 11|000 421 1 0 1 127729 10|011 321 0 0 0 016256 Sum1754 Average439 Maximum729 Probability of mutation in this test is 0.001. With 20 transferred bit positions we should expect 20*0.001=0.02 Slide 20 Grist for the search mill How does the directed search guide help improvement? Seeking similarities among strings in population Causal relationships between similarities and high fitness SCHEMATA Slide 21 21 Evolution in the real world Each cell of a living thing contains chromosomes - strings of DNA Each chromosome contains a set of genes - blocks of DNA Each gene determines some aspect of the organism (like eye colour) A collection of genes is sometimes called a genotype A collection of aspects (like eye colour) is sometimes called a phenotype Reproduction involves recombination of genes from parents and then small amounts of mutation (errors) in copying The fitness of an organism is how much it can reproduce before it dies Evolution based on survival of the fittest Slide 22 Basic Idea Of Principle Of Natural Selection Select The Best, Discard The Rest Slide 23 Algorithm Generate Initial Population do Calculate the F itness of each member do { Select Parents from current population Perform Crossover add offspring to the new population Merge new population into the current population Mutate current population till result is obtained } Slide 24 Population Chromosomes could be: Bit strings (0101... 1100) Real numbers (43.2 -33.1... 0.0 89.2) Permutations of element (E11 E3 E7... E1 E15) Lists of rules (R1 R2 R3... R22 R23)... any data structure... population Slide 25 Algorithm Generate Initial Population do Calculate the F itness of each member do { Select Parents from current population Perform Crossover add offspring to the new population Merge new population into the current population Mutate current population till result is obtained } Slide 26 Algorithm Generate Initial Population do Calculate the F itness of each member do { Select Parents from current population Perform Crossover add offspring to the new population Merge new population into the current population Mutate current population till result is obtained } Slide 27 Fitness Function A fitness function quantifies the optimality of a solution so that that particular solution may be ranked against all the other solutions. A fitness value is assigned to each solution depending on how close it actually is to solving the problem. Ideal fitness function correlates closely to goal + quickly computable. Slide 28 Algorithm Generate Initial Population do Calculate the F itness of each member do { Select Parents from current population Perform Crossover add offspring to the new population Merge new population into the current population Mutate current population till result is obtained } Slide 29 Algorithm Generate Initial Population do Calculate the F itness of each member do { Select Parents from current population Perform Crossover add offspring to the new population Merge new population into the current population Mutate current population till result is obtained } Slide 30 Crossover Mimics biological recombination Some portion of genetic material is swapped between chromosomes Typically the swapping produces an offspring Slide 31 CROSSOVER (1 2 9 3 0 7 ) (1 2 9 7 9 5) (4 6 1 7 9 5 ) (1 2 9 3 0 7 ) ( 4 6 1 7 9 5) Slide 32 Algorithm Generate Initial Population do Calculate the F itness of each member do { Select Parents from current population Perform Crossover add offspring to the new population Merge new population into the current population Mutate current population till result is obtained } Slide 33 Algorithm Generate Initial Population do Calculate the F itness of each member do { Select Parents from current population Perform Crossover add offspring to the new population Merge new population into the current population Mutate current population till result is obtained } Slide 34 Mutation Selects a random locus gene location with some probability and alters the allele at that locus The intuitive mechanism for the preservation of variety in the population Slide 35 Mutation: Local Modification Before: (1 0 1 1 0 1 1 0) After: (0 1 1 0 0 1 1 0) Before: (1.38 -69.4 326.44 0.1) After: (1.38 -67.5 326.44 0.1) Slide 36 The Problem The Traveling Salesman Problem is defined as: Given: 1) A set of cities 2) Symmetric distance matrix that indicates the cost of travel from each city to every other city. Goal: 1) Find the shortest circular tour, visiting every city exactly once. 2) Minimize the total travel cost, which includes the cost of traveling from the last city back to the first city. Slide 37 Traveling Salesperson Problem Slide 38 38 Encoding Represent every city with an integer. Consider 6 Indian cities Mumbai, Nagpur, Calcutta, Delhi, Bangalore and Pune assign a number to each. Mumbai 1 Nagpur 2 Calcutta 3 Delhi 4 Bangalore 5 Pune 6 Slide 39 39 Encoding Thus a path would be represented as a sequence of integers from 1 to 6. The path [1 2 3 4 5 6] represents a path from Mumbai to Nagpur - Nagpur to Calcutta - Calcutta to Delhi - Delhi to Bangalore - Bangalore to Pune and pune to Mumbai. Slide 40 Fitness Function The fitness function will be the total cost of the tour represented by each chromosome. This can be calculated as the sum of the distances traversed in each travel segment. The Lesser The Sum, The Fitter The Solution Represented By That Chromosome. Slide 41 123456 1086319871407998163 28630112410121049620 3198711240146118811844 4140710121461020611437 59981049188120610841 6163620184414378410 Distance/Cost Matrix For TSP Slide 42 Fitness Function (contd.) So, for a chromosome [4 1 3 2 5 6 ], the total cost of travel or fitness will be calculated as shown below Fitness = 1407 + 1987 + 1124 + 1049 + 841 = 6408 kms. Since our objective is to Minimize the distance, the lesser the total distance, the fitter the solution. Slide 43 Initial Population for TSP (5,3,4,6,2)(2,4,6,3,5)(4,3,6,5,2) (2,3,4,6,5)(4,3,6,2,5)(3,4,5,2,6) (3,5,4,6,2)(4,5,3,6,2)(5,4,2,3,6) (4,6,3,2,5)(3,4,2,6,5)(3,6,5,1,4) Slide 44 Select Parents (5,3,4,6,2) (2,4,6,3,5)(4,3,6,5,2) (2,3,4,6,5)(4,3,6,2,5)(3,4,5,2,6) (3,5,4,6,2)(4,5,3,6,2)(5,4,2,3,6) (4,6,3,2,5) (3,4,2,6,5) (3,6,5,1,4) Try to pick the better ones. Slide