Presentation is loading. Please wait.

Presentation is loading. Please wait.

Genetic Algorithm.

Similar presentations


Presentation on theme: "Genetic Algorithm."— Presentation transcript:

1 Genetic Algorithm

2 Introduction Adaptive heuristic search algorithm based on evolutionary ideas of natural selection and genetics Represent an intelligent exploitation of random search within a desired search space to solve a problem

3 What are evolutionary algorithms and Genetic Algorithm?

4 Steps of Genetic Algorithm
Randomly generate an initial population Compute and save the fitness for each individual in the current population Define selection probabilities for each individual Generate probabilistically selecting individuals from population to produce offspring via genetic operators Repeat step 2 until satisfying solution is obtained.

5 Outline of Basic Genetic Algorithm
[Start] Generate random population of n chromosomes (suitable solutions for the problem) [Fitness] Evaluate the fitness f(x) of each chromosome x in the population [New population] Create a new population by repeating following steps until the new population is complete [Selection] Select two parent chromosomes from a population according to their fitness (the better fitness, the bigger chance to be selected) [Crossover] With a crossover probability cross over the parents to form a new offspring (children). If no crossover was performed, offspring is an exact copy of parents.

6 Outline of Basic Genetic Algorithm
[Mutation] With a mutation probability mutate new offspring at each locus (position in chromosome). [Accepting] Place new offspring in a new population [Replace] Use new generated population for a further run of algorithm [Test] If the end condition is satisfied, stop, and return the best solution in current population [Loop] Go to step 2

7 Flowchart of Genetic Algorithm

8 The Initial Population
Represent solutions to problems As a bit string of length L Choose an initial population size Generate length L strings of 1s & 0s randomly Sometimes (rarely) done more intelligently Strings are sometimes called chromosomes Letters in the string are called “genes” Call the bit-string “individuals”

9 GA Requirements 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 main property that makes these genetic representations convenient is that their parts are easily aligned due to their fixed size, that facilitates simple crossover operation. Variable length representations may also be used, but crossover implementation is more complex in this case.

10 Representation Chromosomes could be: Bit strings (0101 ... 1100)
Real numbers ( ) Permutations of element (E11 E3 E7 ... E1 E15) Lists of rules (R1 R2 R3 ... R22 R23) Program elements (genetic programming) ... any data structure ...

11 Fitness Fitness is an important concept in genetic algorithms.
The fitness of a chromosome determines how likely it is that it will reproduce. Fitness is usually measured in terms of how well the chromosome solves some goal problem. E.g., if the genetic algorithm is to be used to sort numbers, then the fitness of a chromosome will be determined by how close to a correct sorting it produces. Find the best hypothesis best – one that optimizes a predefined numerical measure – called fitness If problem is approximating unknown function given inputs and outputs, fitness the accuracy of the hypothesis If playing chess, fitness could be number of games won

12 Calculating Fitness Use a fitness function
To assign a probability of each individual being used in the mating process for the next generation Usually use fitness(c) = g(c)/A Where A = average of g(c) over the entire population Other constructions are possible

13 The Selection Process We are going to combine pairs of members of the current population to produce offspring So, we need to choose which pairs to combine How many strings in schema S will be present in the next generation? Selecting the individuals according to their fitness and applying genetic operators (recombination and point mutations) to selected chromosomes, generate the offspring population

14 Selection Methods In Tournament Selection, q individuals are randomly selected from the population and the best of the q individuals is returned as a parent. In roulette wheel selection, individuals are given a probability of being selected that is directly proportionate to their fitness. Individuals are then chosen randomly based on these probabilities and produce offspring.

15 Selection Methods In truncation selection individuals are sorted according to their fitness. Only the best individuals are selected as parents to produce uniform at random offspring. The parameter for truncation selection is the truncation threshold Trunc. Trunc indicates the proportion of the population to be selected as parents and takes values ranging from 50%-10%. Individuals below the truncation threshold do not produce offspring. The term selection intensity is often used in truncation selection.

16 The Recombination Process
The population will only evolve to be better If best parts of the best individuals are combined Crossover techniques are used Which take material from each individual And adds it to “offspring” individuals Mutation techniques are used Which randomly alter the offspring

17 Single-Point Crossover
Crossover is applied as follows: Select a random crossover point. Break each chromosome into two parts, splitting at the crossover point. Recombine the broken chromosomes by combining the front of one with the back of the other, and vice versa, to produce two new chromosomes. produces 2 new offstring

18 Other types of Crossover
Usually, crossover is applied with one crossover point, but can be applied with more, such as in the following case which has two crossover points: Uniform crossover involves using a probability to select which genes to use from chromosome 1, and which from chromosome 2, randomly copied from first or second parent

19 Inversion Another possible operator to mix things up
Takes the material from only on parent Randomly chooses two points Takes the segment in-between the points Reverses it in the offspring Example:

20 The Mutation Process A unary operator – applies to one chromosome.
Random mutation Each bit in every offspring produced Is “flipped” from 0 to 1 or vice versa With a given probability (usually pretty small < 1%) Could use probability distribution To protect the best individuals in population

21 Replacement Incorporates the new candidate solution into the original population Replacement Approaches Replace All Replace the entire original population with the offspring Replace Worst Elitism is the name of the method that first copies the best chromosome (or few best chromosomes) to the new population. The rest of the population is constructed in ways described above. Elitism can rapidly increase the performance of GA, because it prevents a loss of the best found solution.

22 Termination Criteria A genetic algorithm is run over a number of generations until the termination criteria are reached. Typical termination criteria are: Stop after a fixed number of generations. Stop after a fixed amount of time Stop when a chromosome reaches a specified fitness level. Stop when a chromosome succeeds in solving the problem, within a specified tolerance. Human judgment can also be used in some more subjective cases.

23 Schematic Overview for Producing the Next Generation

24 Slides Taken from Different Websites


Download ppt "Genetic Algorithm."

Similar presentations


Ads by Google