Download presentation
Presentation is loading. Please wait.
1
Genetic Algorithm (GA)
Presented By: Sakeena Javaid Supervised By: Dr. Nadeem Javaid Research Domain: Energy Management in Smart Grid Department of Computer Science Comsats Institute of Information Technology, 44000, Islamabad, Pakistan.
2
Introduction GAs were developed
By John Holland, David E. Goldberg and his students At the University of Michigan This is in line with the Darwinian Theory [1] “Survival of the Fittest” Fittest: ability to adapt to the environment More individuals are produced each generation that can survive Phenotypic variation exists among individuals and the variation is heritable Those individuals with heritable traits better suited to the environment will survive Darwin’s Quotation "Variation is a feature of natural populations and every population produces more progeny than its environment can manage. The consequences of this overproduction is that those individuals with the best genetic fitness for the environment will produce offspring that can more successfully compete in that environment. Thus the subsequent generation will have a higher representation of these offspring and the population will have evolved." [1] Darwin's Theory of Evolution by Natural Selection. Available online: (last accessed on 2 Feb 2017)
3
Why GA? Exhaustive search (where every possible combination is checked) accurate result time consuming inefficient when the numbers of variables are large optimizers tend to : limit the number of variables they use limit the number of values these variables can take The genetic algorithm (does not try every possible combination) Optimal solution by selecting variables intelligently Far more variables can be utilized All values of a variable can be checked Simultaneous searching Less likely to become stuck in "local minima" Less time Efficient Solving Difficult Problems There is a large set of problems, which are NP-Hard
4
Why GA is applied? At least three situations where GA is applied [2]
GA work with the coding of the parameters Randomly generates population GAs use objective function information (without any derivative or auxiliary information) GAs use probabilistic transition rules (instead of deterministic transition rules) GAs search from population of points instead of using single point [2] Golberg, D. E. (1989). Genetic algorithms in search, optimization, and machine learning. Addion Wesley. Reading.
5
Basic Terminologies of GA
Representation Binary strings Crossover N-point or uniform Mutation (probability) Bitwise bit-flipping Parent selection Fitness-Proportionate Survivor selection children replace parents Speciality Emphasis on crossover
6
What is GA (1/2)? A search based algorithm based on the concepts of:
natural selection and genetics [3] To find true or approximate solutions Particular class of evolutionary algorithms Use techniques inspired by evolutionary biology Inheritance Mutation Selection Crossover ( Recombination) [3] Genetic Algorithm. Available online: (last accessed 2 Feb 2017)
7
Figure 1: Solution Representation
What is GA (2/2)? Solutions are represented in binary as strings 0s and 1s, however, Other encodings are also possible Implemented as a computer simulation Using abstract representations called Chromosomes, genotypes, phenotypes Candidate solutions (called individuals), Starts from a population Randomly generated individuals In each generation, fitness of every individual is evaluated Multiple individuals are selected (based on their fitness) The new population is used in next iteration Figure 1: Solution Representation
8
GA Requirements A typical genetic algorithm requires two things
The solution domain (set search space) A fitness function to evaluate the solution A standard representation of the solution is as an array of bits Chromosomes could be Bit strings ( ) Real numbers ( ) Permutations of element (E11 E3 E7 ... E1 E15) Lists of rules (R1 R2 R3 ... R22 R23) Program elements (genetic programming)
9
GA Steps (1/13) Complete cycle consists of some steps
Initialization Selection Reproduction Survival Selection Termination Termination is based on the specified criteria Figure 2: GA Steps
10
GA Steps (2/13) Initialization
Two primary methods to initialize a population in a GA Random Initialization Populate the initial population with completely random solutions. Random population is created with a group of individuals (the search space) Population size depends on the nature of the problem (typically contains several hundreds or thousands of possible solutions) Heuristic initialization Populate the initial population using a known heuristic for the problem. Starts with the couple of good solutions.
11
GA Steps (3/13) Selection Fitness Proportionate
Every individual can become a parent with a probability Which is proportional to its fitness Fitter individuals have a higher chance of mating Propagating their features to the next generation Two popular fitness proportionate techniques Roulette Wheel Selection Tournament Selection
12
GA Steps (4/13) B A C Roulette Wheel Selection
Main idea: better individuals get higher chance Chances proportional to fitness Implementation: roulette wheel technique Assign to each individual a part of the roulette wheel Spin the wheel n times to select n individuals A C 1/6 = 17% 3/6 = 50% B 2/6 = 33% fitness(A) = 3 fitness(B) = 1 fitness(C) = 2
13
GA Steps (5/13) Tournament Selection Binary tournament
Two individuals are randomly chosen The fitter of the two is selected as a parent Probabilistic binary tournament Two individuals are randomly chosen; with a chance p, 0.5<p<1, The fitter of the two is selected as a parent Larger tournaments n individuals are randomly chosen The fittest one is selected as a parent
14
GA Steps (6/13) Fitness Function
A fitness function simply defined is a function Which takes the solution as input Produces the suitability of the solution as the output In some cases, the fitness and the objective function may be same Premature convergence Fitness too large Relatively superfit individuals dominate population Population converges to a local maximum Too much exploitation; too few exploration Slow finishing Fitness too small No selection pressure After many generations, average fitness has converged, but no global maximum is found; not sufficient difference between best and average fitness Too few exploitation; too much exploration
15
GA Steps (7/13) Crossover and Mutation
Crossover (also called recombination), and/or mutation Exploration: Discovering promising areas in the search space, i.e. gaining information on the problem Exploitation: Optimising within a promising area, i.e. using information Crossover is explorative It makes a big jump to an area somewhere “in between” two (parent) areas Mutation is exploitative Creating random small diversions, thereby staying near (in the area of ) the parent
16
GA Steps (8/13) Crossover Operator
Generating offspring from two selected parents Single point crossover Two point crossover (Multi point crossover) Uniform crossover Choose a random point on the two parents Split parents at this crossover point Create children by exchanging tails Pc typically in range (0.6, 0.9) Crossover is a generalization of one point crossover Wherein alternating segments are swapped To get new off-springs
17
GA Steps (9/13) Uniform crossover Mutation
We don’t divide the chromosome into segments We treat each gene separately We essentially flip a coin for each chromosome To decide whether or not it’ll be offspring We can also bias the coin to one parent Mutation Is used to maintain and introduce diversity Is usually applied with a low probability Bit Flip Mutation Random Resetting Swap Mutation Scramble Mutation Inversion Mutation
18
GA Steps (10/13) Bit flip mutation Random Resetting Swap Mutation
We select one or more random bits and flip them Used for binary encoded GAs Random Resetting Extension of the bit flip for the integer representation A random value from the set of permissible values is assigned to a randomly chosen gene Swap Mutation We select two positions on the chromosome at random Interchange the values
19
GA Steps (11/13) Scramble Mutation Inversion Mutation
Popular with permutation representations Entire chromosome, a subset of genes is chosen Their values are scrambled or shuffled randomly Inversion Mutation Select a subset of genes like in scramble mutation Instead of shuffling the subset invert the entire string in the subset
20
GA Steps (12/13) approaches Most of methods above used for parent
selection Survivor Selection Policy Which individuals are to be kicked out Which are to be kept in the next generation Survivor selection can be divided into two approaches Age-Based Selection e.g. SGA In SSGA can implement as “delete-random” (not recommended) or as first-in-first-out (a.k.a. delete-oldest)
21
GA Steps (13/13) Fitness-Based Selection Elitism Termination Criteria
Using one of the methods above Elitism Always keep at least one copy of the fittest solution Termination Criteria No improvement in the population Absolute number of generations Objective function value has reached a certain pre-defined value
22
Algorithm Algorithm Randomly generate population
Evaluate fitness of population While (termination criteria is reached) do Parent selection Crossover with probability pc Mutation with probability pm Decode and fitness calculation Survivor selection Find best Return best
23
GA Example 1 (1/3) Example x2 example: selection
Population of four strings Initial population is generated Simple ‘x’ value is calculated Fitness is evaluated For the specified criteria x2
24
Example 1 (2/3) Example 1 x2 example: Crossover Number of strings
1-bit crossover is chosen For finding the suitable offspring Crossover point is selected Offspring after crossover Simple ‘x’ value is calculated Fitness value (x2) is determined
25
Example 1 (3/3) Example 1 x2 example: Mutation
To maintain the population diversity 1-bit mutation is applied Four strings are taken X value is calculated Fitness function is evaluated
26
Example 2 Example 2 f(x) = {MAX(x2): 0 <= x <= 32 }
Encode Solution Use 5 bits (1 or 0) Generate initial population Evaluate each solution against objective Create next generation of solutions Probability of “being a parent” depends on the fitness Ways for parents to create next generation Reproduction Crossover (Cut and paste portions of one string to another) Mutation (Randomly flip a bit) A 1 B C D Sol. String Fitness % of Total A 01101 169 14.4 B 11000 576 49.2 C 01000 64 5.5 D 10011 361 30.9
27
Example 3 Example 3 Works by constructing a table listing
which edges are present in the two parents if an edge is common to both, mark with a + e.g. [ ] and [ ]
28
Example 4 Edge Selection Pick an initial element at random
put it in the offspring Set the variable current element entry Remove all references to current element from the table Examine list for current element: If there is a common edge, pick that to be next element Otherwise pick the entry in the list, which itself has the shortest list Ties are split at random In the case of reaching an empty list: Examine the other end of the offspring is for extension Otherwise a new element is chosen at random
29
Applications Other Applications Optimization Parallelization
Most commonly used in optimization problems To maximize or minimize a given objective function value under a given set of constraints Parallelization Good parallel capabilities, and prove to be very effective means in solving certain problems, and also provide a good area for research Image Processing Used for various digital image processing (DIP) tasks as well like dense pixel matching Scheduling applications GAs are used to solve various scheduling problems Particularly the time tabling problem
30
Thanks Questions and Answers
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.