Presentation is loading. Please wait.

Presentation is loading. Please wait.

Genetic Algorithms An Evolutionary Approach to Problem Solving.

Similar presentations


Presentation on theme: "Genetic Algorithms An Evolutionary Approach to Problem Solving."— Presentation transcript:

1 Genetic Algorithms An Evolutionary Approach to Problem Solving

2 Illusions of Design Living things in nature seem to be like they were designed by a skilled engineer/designer. Living things in nature seem to be like they were designed by a skilled engineer/designer. Evolution Theory: Too exquisitely designed to be “random”. Evolution Theory: Too exquisitely designed to be “random”. If not random, then what is the non-random process?

3 Evolution A process of cumulative selection Individuals with new traits are developed through Mutations Sexual Reproduction Individuals with better traits are more likely to survive and are more likely to transfer those traits to their descendents.

4 Key Principles of Evolution http://www.pbs.org/wgbh/evolution/library/11/2/e_s_4.html Variety: population of individuals with different set of traits Variety: population of individuals with different set of traits Through reproduction: The importance of sexual reproductions versus asexual reproduction ( http://www.pbs.org/wgbh/evolution/library/01/5/l_015_03.html ) Through reproduction: The importance of sexual reproductions versus asexual reproduction ( http://www.pbs.org/wgbh/evolution/library/01/5/l_015_03.html ) Random mutations Random mutations Evaluation & Selection (through constraints in the environment) Evaluation & Selection (through constraints in the environment) Reproduction: Transfer of traits to offsprings Reproduction: Transfer of traits to offsprings

5 From Evolution of life in Nature to Evolution of Solutions Can evolutionary principles be used to develop solutions to problems? Can these principles be used to do Data Mining?

6 Computation Analogy of Evolution What is the equivalent of an individual (chromosome)? What is the equivalent of an individual (chromosome)? What is the equivalent of an individual having “good” genetic material/good set of traits? What is the equivalent of an individual having “good” genetic material/good set of traits? What is the equivalent of a population of individuals? What is the equivalent of a population of individuals? What is the equivalent of reproduction? What is the equivalent of reproduction? What is the equivalent of survival of the fittest? What is the equivalent of survival of the fittest?

7 What is an individual A collection of traits Example: An individual has the following traits Color: Black or White Color: Black or White Speed: Fast, Medium, Slow or Very Slow Speed: Fast, Medium, Slow or Very Slow Intelligence: Very Smart, Smart, Somewhat Smart, Medium Smart, Dumb or Very Dumb Intelligence: Very Smart, Smart, Somewhat Smart, Medium Smart, Dumb or Very Dumb Computation Analogy of Evolution Computation Analogy of Evolution

8 GA – Generic Strategy Start with a “population” of solutions (individuals) Start with a “population” of solutions (individuals) Repeat Repeat Choose 2 solutions from the population Choose 2 solutions from the population With a certain probability Apply a crossover to create child1, child2 With a certain probability Apply a crossover to create child1, child2 With a certain probability, mutate child1 and child2 With a certain probability, mutate child1 and child2 Update the population (discard of bad solutions). Update the population (discard of bad solutions). Until stopping criteria has been met Until stopping criteria has been met Output the best solution(s) in the population Output the best solution(s) in the population

9 What is an individual A collection of traits Example: An individual has the following traits Color: Black or White Color: Black or White Speed: Fast, Medium, Slow, Very Slow Speed: Fast, Medium, Slow, Very Slow Intelligence: Very Smart, Smart, Somewhat Smart, Medium Smart, Dumb or Very Dumb Intelligence: Very Smart, Smart, Somewhat Smart, Medium Smart, Dumb or Very Dumb Typically a coding system is used to code each trait. E.g., binary coding. Typically a coding system is used to code each trait. E.g., binary coding.

10 Representing Solutions

11 The Fitness Function: Evaluation of Individual Solutions A “fitness function”. A “fitness function”.

12 Process of Evaluating the Fitness

13 How a Population of Solutions Looks Like

14 Reproduction: Crossover BlackSlowSmart WhiteMediumDumb Crossover between parents’ traits creating two children. There are many crossover operators 1. Randomly choose a position and cross over contents before that position. Crossover pointWhiteSlowSmartBlackMediumDumbChildren:

15 2. Randomly choose a set of traits (genes) and cross over those. Examples: Cross over color and intelligence Examples: Cross over color and intelligence Reproduction Crossover BlackSlowSmart WhiteMediumDumb BlackMediumSmartWhiteSlowDumbChildren:

16 The purpose of mutations is to take a single solution and introduce some random “shock” or changes to it to create a new solution. Implementation: Randomly chose a trait for each child and randomly change its value to another valid value Reproduction Mutation BlackMediumSmart BlackFastSmart WhiteSlowDumb WhiteSlowIntelligent

17 What is the equivalent of survival of the fittest? Simply give solutions with better fitness a higher probability of being chosen for reproduction. Sample with replacement: solutions with bigger fitness will be selected more times.

18 Population What will be the composition of population in future generations?

19 The Traveling Salesman Problem A travelling salesman who has to visit a set of n cities. A travelling salesman who has to visit a set of n cities. Find the order in which the salesman visits cities so as to minimize total distance. Find the order in which the salesman visits cities so as to minimize total distance. Variants of this problem are found in several domains. Variants of this problem are found in several domains. As n gets very large, exhaustive search becomes impossible due to the combinatorial nature of the problem. As n gets very large, exhaustive search becomes impossible due to the combinatorial nature of the problem. Need heuristic methods to find good solutions, even if these are not guaranteed to be the “best”. Need heuristic methods to find good solutions, even if these are not guaranteed to be the “best”.

20 Consider the TSP problem 5 cities to visit: London, Oxford, Cambridge, Brighton, and Bath. What is the best path? The Traveling Salesman Problem London Cambridge Oxford Brighton Bath

21 Genetic Algorithms Solution Step-1: An individual is a “candidate solution”, a path. Examples of candidate solutions for the TSP: London, Oxford, Cambridge, Brighton, Bath London, Oxford, Cambridge, Brighton, Bath London, Bath, Oxford, Brighton, Cambridge London, Bath, Oxford, Brighton, Cambridge Brighton, London, Cambridge, Bath, Oxford. Brighton, London, Cambridge, Bath, Oxford. … The Traveling Salesman Problem

22 Coding Scheme for Candidate Solutions Example: Example: London  Oxford  Cambridge  Brighton  Bath London  Oxford  Cambridge  Brighton  Bath Oxford  London  Cambridge  Bath  Brighton Oxford  London  Cambridge  Bath  Brighton 21354 Order in sequence of London Order in sequence of Oxford Order in sequence ofCambridge Order in sequence of Brighton Bath 12345 The Traveling Salesman Problem

23 Step 2: Fitness Function How “good” are the following solutions? London, Oxford, Cambridge, Brighton, Bath London, Oxford, Cambridge, Brighton, Bath London, Bath, Oxford, Brighton, Cambridge London, Bath, Oxford, Brighton, Cambridge Brighton, London, Cambridge, Bath, Oxford. Brighton, London, Cambridge, Bath, Oxford. The Traveling Salesman Problem

24 Fitness in TSP Problem: Distance Table Distance (in Miles) Distance (in Miles) London Oxford Cambridge Brighton Bath London Oxford Cambridge Brighton Bath London0 350 50 280 470 Oxford 0 130 270 310 Cambridge 0 210 340 Brighton 0 220 Bath 0 The Traveling Salesman Problem

25 Creating New Solutions Crossover Operation : Randomly choose a position and cross over contents before that position. Crossover Operation for TSP: part of the first parent is copied and the rest is taken in the same order as in the second parent 15324 12345 Crossover pointLondonOxfordCambridgeBrightonBath The Traveling Salesman Problem

26 15324 12345 Crossover point Child : 12435 LondonOxfordCambridgeBrightonBath ReproductionThe Traveling Salesman Problem London  Oxford  Cambridge  Brighton  Bath London  Brighton  Cambridge  Bath  Oxford London  Oxford  Brighton  Cambridge  Bath

27 15234 15324 12345 Crossover pointLondonOxfordCambridgeBrightonBath London  Oxford  Cambridge  Brighton  Bath London  Brighton  Cambridge  Bath  Oxford London  Cambridge  Brighton  Bath  Oxford Child : ReproductionThe Traveling Salesman Problem

28 Mutation in the TSP Problem Randomly changing one gene won’t work. Randomly changing one gene won’t work. Design mutations around the “swap” concept: Design mutations around the “swap” concept: 12345 Reproduction12445 12543 LondonOxfordCambridgeBrightonBath

29 GA for TSP For the TSP problem we have: For the TSP problem we have: Solution representation Solution representation A fitness evaluation function A fitness evaluation function Crossover operations on parents Crossover operations on parents Mutation on a single solution Mutation on a single solution Start with a population of solutions, and let them evolve Start with a population of solutions, and let them evolve

30 Next Step: Initialize a population Decision parameter: population size Let us choose 5 solutions in our population. We will now randomly initialize the population. London, Oxford, Cambridge, Brighton, Bath (-1320) London, Oxford, Cambridge, Brighton, Bath (-1320) Oxford, London, Cambridge, Bath, Brighton (-1230) Oxford, London, Cambridge, Bath, Brighton (-1230) Cambridge, Oxford, Brighton, Bath, London (-1140) Cambridge, Oxford, Brighton, Bath, London (-1140) Bath, London, Brighton Cambridge, Oxford (-1400) Bath, London, Brighton Cambridge, Oxford (-1400) Bath, Oxford, Cambridge, London, Brighton (-990) Bath, Oxford, Cambridge, London, Brighton (-990)

31 Evolving Solutions for TSP Repeat (Until stopping criteria has been met) Repeat (Until stopping criteria has been met) Choose 2 solutions from the population Choose 2 solutions from the population With a certain “crossover probability” (say, 0.8) apply a crossover operator to create child1, child2 With a certain “crossover probability” (say, 0.8) apply a crossover operator to create child1, child2 With a certain “mutation” probability (say 0.1), mutate child1, child2 With a certain “mutation” probability (say 0.1), mutate child1, child2 Place the resulting 2 children in the population Place the resulting 2 children in the population Selection: which 5 solutions survive – the probability of each individual to survive is propositional to its fitness function Selection: which 5 solutions survive – the probability of each individual to survive is propositional to its fitness function After stopping, output the best chromosome in the population for the solution After stopping, output the best chromosome in the population for the solution

32 Over time solutions mate and traits passed on to the offspring. Children with “better” traits have a ability to survive. The weak solutions gradually disappear from the population. Good solution predominate the population Overview of the Selection Process

33 Building Solutions through Evolution http://www.pbs.org/saf/1103/video/watcho nline.htm

34 GA – Advantages: Not engineering : enables finding surprising solutions to problems Not engineering : enables finding surprising solutions to problems Quickly and reliably solve problems that are hard to tackle by traditional means. Quickly and reliably solve problems that are hard to tackle by traditional means. Implicit parallelism makes GAs a very efficient optimization algorithm. Implicit parallelism makes GAs a very efficient optimization algorithm. Great property is the ability to find approximate solutions to combinatorially explosive problems. Great property is the ability to find approximate solutions to combinatorially explosive problems.

35 GA - Disadvantages A heuristic: GAs may find only near- optimal solutions. A heuristic: GAs may find only near- optimal solutions. Further restrictions are the difficulties of choosing a suitable representation technique, and making the right decision regarding the choice of the selection method and the genetic operator probabilities Further restrictions are the difficulties of choosing a suitable representation technique, and making the right decision regarding the choice of the selection method and the genetic operator probabilities


Download ppt "Genetic Algorithms An Evolutionary Approach to Problem Solving."

Similar presentations


Ads by Google