1 / 54

Introduction to Genetic Algorithms

Introduction to Genetic Algorithms. Speaker: Moch. Rif’an rifan@ub.ac.id. What are genetic algorithms?. Genetic algorithms (GAs) is a search technique used in computing to find exact or approximate solutions to optimization and search problems.

claral
Download Presentation

Introduction to 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. Introduction toGenetic Algorithms Speaker: Moch. Rif’an rifan@ub.ac.id

  2. What are genetic algorithms? • Genetic algorithms (GAs) is a search technique used in computing to find exact or approximate solutions to optimization and search problems. • Genetic algorithms are categorized as global search heuristics. • Genetic algorithms are a particular class of evolutionary algorithms (also known as evolutionary computation) that use techniques inspired by evolutionary biology such as inheritance, mutation, selection, and crossover (also called recombination).

  3. A short history of genetic algorithms 1954 - computer simulations of evolution started by the work of Nils Aall Barricelli 1960s - Hans Bremermann published a series of papers that adopted a population of solution to optimization problems 1963 - Barricelli had simulated the evolution of ability to play a simple game 1970s - artificial evolution became a widely recognized optimization method 1970 - the first books that described the used methods (Fraser and Burnell) 1980s - The First International Conference on Genetic Algorithms, Pennsylvania; General Electric started selling the world's first genetic algorithm product 1989 - Axcelis, Inc. released Evolver, the world's second GA product and the first for desktop computers

  4. Genetic Algorithms - History • Pioneered by John Holland in the 1970’s • Got popular in the late 1980’s • Based on ideas from Darwinian Evolution • Can be used to solve a variety of problems that are not easy to solve using other techniques

  5. Biological Background (1) – The cell • Every animal cell is a complex of many small “factories” working together • The center of this all is the cell nucleus • The nucleus contains the genetic information

  6. Biological Background (2) – Chromosomes • Genetic information is stored in the chromosomes • Each chromosome is build of DNA • Chromosomes in humans form pairs • There are 23 pairs • The chromosome is divided in parts: genes • Genes code for properties • The posibilities of the genes for one property is called: allele • Every gene has an unique position on the chromosome: locus

  7. Biological Background (3) – Genetics • The entire combination of genes is called genotype • A genotype develops to a phenotype • Alleles can be either dominant or recessive • Dominant alleles will always express from the genotype to the fenotype • Recessive alleles can survive in the population for many generations, without being expressed.

  8. Biological Background (4) – Reproduction • Reproduction of genetical information • Mitosis • Meiosis • Mitosis is copying the same genetic information to new offspring: there is no exchange of information • Mitosis is the normal way of growing of multicell structures, like organs.

  9. Biological Background (5) – Reproduction • Meiosis is the basis of sexual reproduction • After meiotic division 2 gametes appear in the process • In reproduction two gametes conjugate to a zygote wich will become the new individual • Hence genetic information is shared between the parents in order to create new offspring

  10. Biological Background (6) – Reproduction • During reproduction “errors” occur • Due to these “errors” genetic variation exists • Most important “errors” are: • Recombination (cross-over) • Mutation

  11. Biological Background (7) – Natural selection • The origin of species: “Preservation of favourable variations and rejection of unfavourable variations.” • There are more individuals born than can survive, so there is a continuous struggle for life. • Individuals with an advantage have a greater chance for survive: survival of the fittest.

  12. Biological Background (8) – Natural selection • Important aspects in natural selection are: • adaptation to the environment • isolation of populations in different groups which cannot mutually mate • If small changes in the genotypes of individuals are expressed easily, especially in small populations, we speak of genetic drift • Mathematical expresses as fitness: success in life

  13. How GA are Different than Traditional Search Methods • GAs work with a coding of the parameter set, not the parameters themselves. • GAs search from a population of points, not a single point. • GAs use payoff information, not derivatives or auxiliary knowldege. • GAs use probablistic transition rules, not deterministic rules.

  14. 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”

  15. Start with a Dream… • Suppose you have a problem • You don’t know how to solve it • What can you do? • Can you use a computer to somehow find a solution for you? • This would be nice! Can it be done?

  16. A dumb solution A “blind generate and test” algorithm: Repeat Generate a random possible solution Test the solution and see how good it is Until solution is good enough

  17. Can we use this dumb idea? • Sometimes - yes: • if there are only a few possible solutions • and you have enough time • then such a method could be used • For most problems - no: • many possible solutions • with no time to try them all • so this method can not be used

  18. A “less-dumb” idea (GA) Generate a set of random solutions Repeat Test each solution in the set (rank them) Remove some bad solutions from set Duplicate some good solutions make small changes to some of them Until best solution is good enough

  19. Silly Example - Drilling for Oil • Imagine you had to drill for oil somewhere along a single 1km desert road • Problem: choose the best place on the road that produces the most oil per day • We could represent each solution as a position on the road • Say, a whole number between [0..1000]

  20. Road 0 500 1000 Solution1 = 300 Solution2 = 900 Where to drill for oil?

  21. Digging for Oil • The set of all possible solutions [0..1000] is called the search space or state space • In this case it’s just one number but it could be many numbers or symbols • Often GA’s code numbers in binary producing a bitstring representing a solution • In our example we choose 10 bits which is enough to represent 0..1000

  22. Drilling for Oil Solution1 = 300 (0100101100) Solution2 = 900 (1110000100) Road 0 1000 O I L 30 5 Location

  23. Classes of Search Techniques Search Techniqes Calculus Base Techniqes Enumerative Techniqes Guided random search techniqes Sort Dynamic Programming Fibonacci DFS BFS Evolutionary Algorithms Tabu Search Hill Climbing Simulated Anealing Genetic Programming Genetic Algorithms

  24. Search Space • For a simple function f(x) the search space is one dimensional. • But by encoding several values into the chromosome many dimensions can be searched e.g. two dimensions f(x,y) • Search space can be visualised as a surface or fitness landscape in which fitness dictates height • Each possible genotype is a point in the space • A GA tries to move the points to better places (higher fitness) in the space

  25. Fitness landscapes

  26. Search Space • Obviously, the nature of the search space dictates how a GA will perform • A completely random space would be bad for a GA • Also GA’s can get stuck in local maxima if search spaces contain lots of these • Generally, spaces in which small improvements get closer to the global optimum are good

  27. GA Algorithm • Generate a set of random solutions • Repeat • Test each solution in the set (rank them) • Remove some bad solutions from set • Duplicate some good solutions • make small changes to some of them • Until best solution is good enough

  28. The Evolutionary Cycle parents selection modification modified offspring initiate & evaluation population evaluate evaluated offspring deleted members discard

  29. A genetic algorithm maintains apopulation of candidate solutionsfor theproblemat hand,and makes it evolve byiteratively applyinga set of stochastic operators

  30. Vocabulary • Gene – An single encoding of part of the solution space. • Chromosome – A string of “Genes” that represents a solution. • Population - The number of “Chromosomes” available to test.

  31. Adding Sex - Crossover • Although it may work for simple search spaces our algorithm is still very simple • It relies on random mutation to find a good solution • It has been found that by introducing “sex” into the algorithm better results are obtained • This is done by selecting two parents during reproduction and combining their genes to produce offspring

  32. Adding Sex - Crossover • Two high scoring “parent” bit strings (chromosomes) are selected and with some probability (crossover rate) combined • Producing two new offspring (bit strings) • Each offspring may then be changed randomly (mutation)

  33. Methodology Genetic algorithms are implemented as a computer simulation in which a population of abstract representations (called chromosomes or the genotype or the genome) of candidate solutions (called individuals, creatures, or phenotypes) to an optimization problem evolves toward better solutions.

  34. A typical genetic algorithm requires two things to be defined: • A genetic representation of the solution domain • A fitness function to evaluate the solution domain A standard representation of the solution is as an array of bits. Arrays of other types and structures can be used in essentially the same way. The fitness function is defined over the genetic representation and measures the quality of the represented solution.

  35. Initialization Initially many individual solutions are randomly generated to form an initial population. The population size depends on the nature of the problem (hundreds or thousands of possible solutions ). Traditionally, the population is generated randomly, covering the entire range of possible solutions.

  36. Selecting Parents • Many schemes are possible so long as better scoring chromosomes more likely selected • Score is often termed the fitness • “Roulette Wheel” selection can be used: • Add up the fitness's of all chromosomes • Generate a random number R in that range • Select the first chromosome in the population that - when all previous fitness’s are added - gives you at least the value R

  37. Example: Discrete Representation (Binary alphabet) • Representation of an individual can be using discrete values (binary, integer, or any other system with a discrete set of values). • Following is an example of binary representation. CHROMOSOME GENE

  38. ... • Anything? Example: Discrete Representation (Binary alphabet) 8 bits Genotype Phenotype: • Integer • Real Number • Schedule

  39. Example: Discrete Representation (Binary alphabet) Phenotype could be integer numbers Genotype: Phenotype: = 163 1*27 + 0*26 + 1*25 + 0*24 + 0*23 + 0*22 + 1*21 + 1*20= 128 + 32 + 2 + 1 = 163

  40. Example: Discrete Representation (Binary alphabet) • Phenotype could be Real Numbers • e.g. a number between 2.5 and 20.5 using 8 binary digits Genotype: Phenotype: = 13.9609

  41. Example: Discrete Representation (Binary alphabet) • Phenotype could be a Schedule • e.g. 8 jobs, 2 time steps Time Step Job 1 2 3 4 5 6 7 8 2 1 2 1 1 1 2 2 Genotype: = Phenotype

  42. Selection During each successive generation, a proportion of the existing population is selected to breed a new generation. Individual solutions are selected through a fitness-based process, where fitter solutions are to be selected. Certain selection methods rate the fitness of each solution and preferentially select the best solutions. Other methods rate only a random sample of the population, as this process may be very time-consuming.

  43. Individual i will havea probability to be chosen Example (selection1) Next we apply fitness proportionate selection with the roulette wheel method: We repeat the extraction as many times as the number of individuals we need to have the same parent population size (6 in our case) Area is Proportional to fitness value 1 2 n 3 4

  44. Reproduction The next step is to generate a second generation population of solutions from those selected through genetic operators: crossover (also called recombination) and/or mutation. For each new solution, a pair of "parent" solutions is selected for breeding from the pool selected previously. By producing a "child" solution using crossover and mutation, a new solution is created which shares many of the characteristics of its "parents". New parents are selected for each child and the process continues until a new population of solutions of appropriate size is generated.

  45. Termination This generational process is repeated until a termination condition has been reached: • A solution is found that satisfies minimum criteria • Fixed number of generations reached • Allocated budget (computation time/money) reached • The highest ranking solution's fitness is reaching or has reached a plateau such that successive iterations no longer produce better results • Manual inspection • Combinations of the above.

  46. Example (initialization) • We toss a fair coin 60 times and get the following initial population: • s1 = 1111010101 f (s1) = 7 • s2 = 0111000101 f (s2) = 5 • s3 = 1110110101 f (s3) = 7 • s4 = 0100010011 f (s4) = 4 • s5 = 1110111101 f (s5) = 8 • s6 = 0100110000 f (s6) = 3

  47. Simple Example • f(x) = {MAX(x2): 0 <= x <= 32 } • Encode Solution: Just use 5 bits (1 or 0). • Generate initial population. • Evaluate each solution against objective.

  48. Pseudo-code algorithm • Choose initial population • Evaluate the fitness of each individual in the population • Repeat • Select best-ranking individuals to reproduce • Breed new generation through crossover and mutation (genetic operations) and give birth to offspring • Evaluate the individual fitnesses of the offspring • Replace worst ranked part of population with offspring • Until termination

  49. Simple Example (cont.) • Create next generation of solutions • Probability of “being a parent” depends on the fitness. • Ways for parents to create next generation • Reproduction • Use a string again unmodified. • Crossover • Cut and paste portions of one string to another. • Mutation • Randomly flip a bit. • COMBINATION of all of the above.

More Related