Genetic Algorithms Evolutionary Methods Methods inspired by the process of biological evolution. Main ideas: Population of solutions Generate new solutions (offspring) Assign a score or fitness value to each solution Retain the best solutions (survival of the fittest) Figure 7.2 Genetic Algorithms The fundamental unit of representation is a chromosome. A chromosome is a bit of strings representing a solution to our problem. 00010011110011111 In our case, a chromosome will be a classifier or hypothesis. A hypothesis is good if it has a high fitness value. What is a fitness value? In classification, for example, the fitness value could be the accuracy of the hypothesis on test examples. Parameters A genetic algorithm has the following parameters: A fitness function that gives a score to every hypothesis. Θ: A fitness threshold above which we stop and take the hypothesis with best fit. L: The number of hypothesis in the current population. Pco: the fraction of hypothesis replaced by cross-over. Pmut: the mutation rate. Algorithm Initialize population with L hypotheses at random Repeat For each hypothesis h compute its fitness Rank all hypotheses based on their fitness value Generate a new population using genetic operators Until max_fitness > Θ Return the hypothesis with highest fitness Figure 7.13 Genetic Operators The most common operators are crossover, mutation, and replication. Crossover (exploration): There are different variations. The most common is called single-point crossover: Initial Strings Crossover Mask 11101001000 Offspring 11101010101 11111000000 00001010101 00001001000 Genetic Operators Mutation: The idea is to produce small changes to a string at random. Under a uniform distribution, we select one bit and switch its value. 00001010101 01001010101 Select second bit. Replication: A chromosome is simply reproduced, and left unchanged. Figure 7.14 New Population Create a new generation Ps: 1. Replicate (1-Pco)L members of P and add them to Ps (Exploitation). The probability of selecting a member is P(hi) = Fitness (hi) / Σj Fitness (hj) 2. Crossover.- select (Pco L)/2 pairs of hypotheses from P according to P(hi) (Exploration). For each pair (h1,h2) produce two offspring by applying the Crossover operator. Add all offspring to Ps. 3. Mutate.- Choose (Pmut L) members of Ps with uniform probability. Invert one bit in the representation randomly (Exploration). 4. Update P with Ps Representing Hypotheses We need to represent each hypothesis as a binary string. We can encode as bits of strings: Neural Networks Decision Trees etc. Figure 7.15 Fitness Function and Selection Selection. The typical approach is the “fitness proportionate selection” or “roulette wheel selection”: P(hi) = Fitness (hi) / Σj Fitness (hj) Other options are rank selection: Rank according to fitness, but then select based on rank only. Further Heuristics Other heuristics exist to improve performance: 1. Adjust the mutation and crossover rates to ensure that convergence is fast. One way to do it is by encoding their values and letting the genetic algorithm adapt them. 2. Use ternary or n-ary chromosomes (instead of binary). The advantage is that classifiers become easier to encode. Exploration vs Exploitation Exploitation: Maximize reward by exploiting optimal and known solutions. vs Exploration: Maximize long-term reward by searching for new solutions. John H. Holland Born in Indiana 1929. Author of “Adaptation in Natural and Artificial Systems” written in 1975, providing the basis of genetic algorithms. Recipient of the McArthur Fellowship. Genetic Programming Genetic programming is a form of evolutionary computation in which the individuals in the population are computer programs. Programs are normally represented by trees. A program is executed by parsing the tree. Example: + F = sin(x) + sqrt( x^2 + y) sin sqrt x + ^ x y 2 Vocabulary To apply genetic programming one has to define the functions that can be applied: Example: sin, cos, sqrt, +, -, etc. A genetic programming algorithm explores the space of combinations of these functions. The fitness of an individual is determined by executing the program on a set of training data. Cross Over The crossover operator is performed by replacing subtrees of one program with subtrees of another program. + + Sin ^ Sin 2 x + x y sqrt x + ^ x y 2 Cross Over: Result + + Sin ^ Sin 2 x ^ x y sqrt x + + x y 2 Figure 7.17 J.R. Koza Author of “Genetic Programming I II III and IV”. Professor Stanford University Member of several editorial boards.