1 / 13

Lecture 8: Genetic Algorithms

Lecture 8: Genetic Algorithms. Contents : Miming nature The steps of the algorithm Coosing parents Reproduction Mutation Deeper in GA Stochastic Universal Selection Elitarism Steady State. Miming Nature. Some considerations on evolution of organisms:

omer
Télécharger la présentation

Lecture 8: Genetic Algorithms

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Lecture 8: Genetic Algorithms Contents: Miming nature The steps of the algorithm Coosing parents Reproduction Mutation Deeper in GA Stochastic Universal Selection Elitarism Steady State

  2. Miming Nature Some considerations on evolution of organisms: • The organisms that are ill-suited for an environment have little chances to reproduce (natural selection) • Conversely, the best fitting have more chances to survive and reproduce • Offspring are similar to their parents • Random mutations occur and they can bring to better (or worse) fitting individuals “The Origin of the Species on the Basis of Natural Selection” C. Darwin (1859) • An organism is fully represented by its DNA string, that is a string over a finite alphabet (4 symbols) • Each element of this string is called gene • As for Neural Networks, the idea is that what woks in nature should be good also for artificial systems “All above in the assumption you are not Jehovah’s witnesses”

  3. Intro • An individual (an organisms) is intended to be a possible solution for the problem you want to solve • An individual is represented by a binary string. Such a string is intended to be the complete description of the individual • A fitness function is a function that says how good is a solution, i.e. how well an individual fit the environment • Example: Suppose you have to find a number between 0 and 255, which binary representation contains the same number of 1s and 0s. A individual is a string of 8 bits, ex: The fitness function is: note that the fitness function gets the minimum value (i.e. 0) when or and the maximum value (i.e. 8) when h = = 126

  4. Genetic Algorithm • A genetic algorithm is a way to obtain an individual that maximizes the fitness function Scheme of the (canonical) algorithm • Start with a population of N individuals • Apply the fitness function to all the individuals • Select the pairs of individuals for reproduction (repetition allowed). • Each pair generates two children (reproduction) • Apply a random mutation to the children. The children become the next generation • Apply steps 1,2,3 until some termination criteria applies In the following we explain the details of these steps using the previous example. Suppose to have the initial population:

  5. Selection • For each element, compute the its contribution to the global fitness as • The choice of the pairs for reproduction consists of randomly choosing the individuals (with replacement) with distribution given by P (roulette-wheel selection ) • How to do it? • Split the interval [0,1] in N parts of length • Generate a random value r in [0,1] and choose individual associated with the interval containing r

  6. Crossover • Suppose the chosen pairs are: and • The parents are combined by means of the crossover operator. This operator apply to a pair and return two individual. It consists of the following steps: • Randomly choose a cross over point “c”, i.e. a number between 1 and n • return two children: one composed by the first c bits of the first parent and the last n-c bits of the second parent, the other composed by the first c bits of the second parent and the n-c bits of the first parents

  7. Mutation • After all the children have been created, some of theirs bits are changed (with a small, independent probability), so implementing a mutation on the individuals • The following new generation is the result of the first loop • In this simple case we have a solution for which the fitness function is at its maximum, but in general it is not so easy: when to stop evolution?

  8. Stopping Criteria • Convergence: • A population is said to converge when all the genes have converged, I.e. when the value of every bit is the same at least in the 95% of the individuals in the population • Since convergence is not guaranteed, we must consider other stopping criteria: • Number of generations • Almost constant value of the best fitting individual • Almost constant value of the average fitness of the population

  9. Deeper in GAs • Have a deeper look to what we need to implement a GA and which are the degrees of freedom • Encoding: an individual (a solution) is encoded by a string of binary values that you have to provide. The encoding was the ‘identity function’ in the previous example. Suppose you have the following problem: Given a set of four numbers, find their position in an increasing ordered list. Ex: input = [ 41,11,23,25] solution = [3,0,1,2] • Fitness Function: can be useful to distinguish between Fitness Function and Evaluation Function (or Objective Function) • The evaluation function measures how a solution is good with respect to the parameters of the problem • The Fitness Function assigns the probability of being chosen for reproduction on the base of the results of the evaluation function.

  10. Applying Gas (cntd) • Suppose to use the following evaluation function Where a wrong pair is a pair of values in the string such that What is the evaluation of the following individual? Not legal Solutions • While to every solution corresponds a string, the converse is, in general, not true. • In the example above, there should not be two identical pair of bits (same position given to two numbers) • How to avoid it: • Strongly penalize the “illegal” individuals, so they have little chances to transmit they bad genes • Convert an illegal solution in a legal one, inverting the appropriate bits • Apply a crossover operator that does not produce illegal solution

  11. Applying Gas (cntd) • Selection: other techniques than roulette-wheel exist for selection Eg: Remainder Stochastic Sampling decompose the pie proportionally to the values After a spin of the pie, pick an individual for each pointer In this example we would select twice, and note: the pointers are equally spaced and their number is the size of the population

  12. Applying GAs Creating the new population: • Elitism: it consists in copying the best k individuals directly in the new population without combine them with any other, where k is some percentage of the population. The effect is to preserve the best solution found • Steady State: • choose two individuals from the population with roulette–wheel strategy and perform crossover to obtain their two children • “kill” two “low fitting” individuals from the population and put the children instead • Note that the concept of generation is not involved in this case

  13. Exercise • Suppose you want to solve the problem of the eight queens by means of a genetic algorithm. You have 8 queens to use, therefore you cannot have solutions where less or more than 8 queens are used: such a solutions are illegal. • Give an encoding that cannot represent these illegal solutions • Suppose to have the following encoding: a solution is a string of 64 bits (a bit for each square) where 0 indicates an empty square and 1 indicates a queen in the square. Furthermore, suppose your starting population is made of only legal solutions. Define a crossover operator that produces only legal children • Can your operator be applied to any pair of legal solutions? • Is the algorithm guaranteed to produce always populations of legal solutions?

More Related