Presentation is loading. Please wait.

Presentation is loading. Please wait.

Genetic Algorithms By: Jacob Noyes 4/16/2013. Traveling Salesman Problem Given:  A list of cities  Distances between each city Find:  Shortest path.

Similar presentations

Presentation on theme: "Genetic Algorithms By: Jacob Noyes 4/16/2013. Traveling Salesman Problem Given:  A list of cities  Distances between each city Find:  Shortest path."— Presentation transcript:

1 Genetic Algorithms By: Jacob Noyes 4/16/2013

2 Traveling Salesman Problem Given:  A list of cities  Distances between each city Find:  Shortest path to reach every city once

3 Traveling Salesman Problem Brute force  Exact Algorithms Exact Algorithms Pro:  Will find the right answer Con:  Does not scale well

4 Evolution Change in inherited characteristics over time Natural Selection:  A mechanism through which evolution happens  Survival of the fittest  Genes of the more suitable organisms get passed on more often Deoxyribonucleic acid(DNA):  Genes encoded in amino acids  Used to pass genes from parent to offspring

5 Genetic Algorithms: The Basics Genetic algorithms are specialized search heuristics which use the fundamental principles of evolution through natural selection to find the best solution to a problem.

6 Genetic Algorithms: The Basics Encoding Initialization Selection Crossover Mutation

7 Encoding Changeable representation of individual's traits is created Completed only at the start Its “string” is designed a series of bits Concatenate multiple parameters

8 Examples: Max y-values? Example 1:  y = -x^ x  0 ≤ x ≤ 255  String: ≤ x ≤ Example 2:  y = 2w + x + 3z  0 ≤ w ≤ 7, 0 ≤ x ≤ 7, 0 ≤ z ≤ 7  String: 000/000/000 – 111/111/111

9 Initialization Beginning population is created Each bit(gene) is randomly generated to create variety Performed only for the first generation and not repeated

10 Example: Initialization Given  y = -x^ x  0 ≤ x ≤ 255 X Binary x

11 Selection Assign a fitness  measure of how close a solution is to fulfilling the problem  Assigned to each individual Select individuals  Individuals with higher fitness will reproduce more often  Non-selected individuals will “die off”

12 Example: Fitness Given  y = -x^ x  0 ≤ x ≤ 255 X Binary xFitness

13 Optimums Local optimum: A point where small changes will lead to worse results Overall optimum: The best solution

14 Selection: Categories Proportionate Selection: Fitness relative to other individuals Ranking Selection: Chance to reproduce based on order Tournament Selection: Pits individuals against each other in smaller brackets Gender Specific Selection: Splits Individuals into groups based on “sex” Genetic Relatedness Based Selection: Individuals are selected based on their genetic distance from others in the population

15 Selection: Proportionate Selection Roulette wheel selection Deterministic Sampling Stochastic Remainder Sampling with Replacement Stochastic Remainder Sampling without Replacement Stochastic Universal Selection

16 Roulette Wheel Selection 1. Find Pf: Population fitness = sum of all fitness factors 2. Find Psel: Each individual's probability of selection  Psel = (fitness factor) / Pf 3. Load each Psel into an array 4. Generate random number between Start at beginning of array, subtract each Psel from number until number <= 0

17 Deterministic Sampling 1. Average fitness is found 2. Individual fitnesses are divided by the average 3. Whole number results = number of spots in the mating pool 4. Extra slots filled starting by highest decimal 5. Random numbers generated to select individuals from the mating pool

18 Stochastic Remainder with Replacement Uses Deterministic Sampling to fill slots with whole number results Left over slots are then filled using the remainders with the Roulette Wheel Selection Method

19 Stochastic Remainder without Replacement Uses Deterministic Sampling to fill slots with whole number results Uses a “weighted-coin toss” to determine the rest  1. Each remainder multiplied by 100  2. Random number between generated  3. If random number <= remainder, accept  4. Loop until all spots are filled

20 Ranking Selection Chance to breed based on order of fitness, not proportion Pro: Easy to implement and understand Con: Generally less accurate, less efficient, and phase out diversity too quickly Due to cons, not used often Types:  Linear ranking selection  Truncate Selection

21 Linear Ranking Selection 1. Probabilities are set up for each rank before fitnesses are even assessed 2. Individuals are ordered based on fitness level 3. The predefined probabilities are assigned to their rank 4. Individuals are selected based on the probabilities

22 Truncate Selection 1. Candidates are put in order based on fitness 2. The top predefined percentage are chosen to reproduce

23 Tournament Selection Individuals are pitted against each other in smaller brackets The winner(s) of each bracket reproduces Bracket participants only need to know fitness levels of others in bracket  No need for total or average population fitness factors  Good for situations when it is impossible or implausible to calculate totals

24 Tournament Selection: Categories Binary Tournament Selection Larger Tournament Selection Boltzmann Tournament Selection Correlative Tournament Selection

25 Binary Tournament Selection 1. Two candidates are randomly selected out of possible solutions 2. Candidate with best fitness factor is chosen to reproduce

26 Larger Tournament Selection 1. More than two candidates are randomly selected out of possible solutions 2. Candidate with best fitness factor is chosen to reproduce Only difference from Binary Tournament Selection is number of candidates in each bracket  More candidates = higher selection pressure

27 Boltzmann Tournament Selection N = temperature = variable describing number of differences in bit string between two individuals 1. First candidate is chosen randomly 2. Second candidate is chosen as having exactly n differences in gene string from first candidate 3. Third candidate is chosen  Half of the time has exactly n differences in gene string from first AND second candidate (strict choice)  Other half of the time has exactly n difference in gene string from ONLY first candidate (relaxed choice) 4. Choose the winner of the three to reproduce

28 Correlative Tournament Selection Not so much a separate selection method as much as an extension of other tournament selections Once mating pool is selected, pairs are created based on how closely they are related Pairing similar individuals allows a better chance of passing on their (probably) good similar trait

29 Gender Specific Selection Genetic Algorithm with Chromosome Differentiation(GACD) Restricted Mating Correlative Family-based Selection

30 Genetic Algorithms with Chromosome Differentiation Every individual has an extra 00 or 01 attached to their bit string  00 = female, 01 = male  When a male and female mate each parent randomly selects a bit to pass onto the child Females(00) can pass on 0 or 0 Males(01) can pass on 0 or 1 Hamming distance: the sum of the differences between each bit of two individuals  Ex: and have a hamming distance of 3.

31 Genetic Algorithm With Chromosome Differentiation 1. Males generated first randomly 2. Females created for each male with maximum hamming distance 3. Select individuals to put into mating pool by either:  Using a separate selection method for each sex  Or, lumping them together and using one selection method over all of them 4. Mate each individual in the mating pool twice 5. If there are fewer of one sex in the mating pool, mate leftovers with the highest fitness individual of the opposite sex

32 Restricted Mating In nature, different species cannot or will not mate Restricted mating is based on species differentiations Certain traits (predefined sections of the bit string) must be the same to mate two candidates Keeps several variations from converging to a local optimum

33 Correlative Family-based Selection 1. Two candidates are mated together twice 2. Between the two candidates and the two children, the most fit solution is chosen 3. The hamming distance is calculated for each individual compared to the other three 4. The individual with the highest hamming distance is also chosen to reproduce

34 Genetic Relatedness Based Selection Purpose is to search unexplored areas of the search space Groups candidates based on similar fitness factors Does not try to find most fit candidates Includes:  Fitness Uniform Selection Scheme(FUSS)  Reserve Selection

35 Fitness Uniform Selection Scheme Candidates with similar fitness factors are grouped together Random numbers are generated from the range of minimum fitness to maximum fitness Candidates with fitnesses closest to the random number are selected This gives a higher probability of selecting unexplored areas Helps avoid local optimums

36 Reserve Selection Candidates split into two categories  Non-reserved: Normal candidates with normal selection process applied  Reserved: Specific less fit candidates that are carried over from generation to generation to keep variety in the population Keeps pool out of local maximums

37 Elitism Automatically carry over most fit individual to next generation Extension of other selection methods Makes sure best fit does not just get unlucky

38 Example: Selection Given  y = -x^ x  0 ≤ x ≤ 255  Top half truncate selection Gene pool X Binary xFitness

39 Crossover Genes(bit strings) are combined from both parents to create offspring Locus: the randomly generated point(s) at which each parent's bit string is separated

40 Example: Crossover CandidateGene poolLocus ParentsP1 String P2 StringOffspring 1, , , , , , , ,

41 Mutation in The Natural World Brings diversity to a population Without mutation, just different combinations of the same traits Mutations happen when DNA is not copied properly If the mutation has a benefit, or is just not a hindrance, it may be passed on to new generations

42 Mutation in Genetic Algorithms Purposely inject after crossover Rate of mutation is decided beforehand  Ex: 1/2000th chance of mutation per bit For every bit in a population, a random number is generated If the probability hits, the bit is XOR'ed with 1

43 Given  mutation rate: 1/64 Example: Mutation Pre-mutatedXOROffspring

44 Genetic Algorithms: End Fitness threshold based  Each solution's fitness level is checked after each generation  If a given minimum fitness level is achieved, the algorithm finishes running and outputs the maximum fitness candidate Generation threshold based  Genetic algorithm runs for a predefined number of generations  Most fit solution over all generations is outputted

45 Uses of Genetic Algorithms Optimal water network layouts Facial recognition Robotics Trajectories for spacecraft Fun with walking Much More

46 Questions?

Download ppt "Genetic Algorithms By: Jacob Noyes 4/16/2013. Traveling Salesman Problem Given:  A list of cities  Distances between each city Find:  Shortest path."

Similar presentations

Ads by Google