Professional Documents
Culture Documents
Genetic Algo
Genetic Algo
Soumen Paul Department of Computer Science and Informatics Haldia Institute of Technology
ICARE Complex, HIT Campus, P.O HIT,PIN 721657 Haldia, West Bengal
Soft Computing
Exploration
The Genetic algorithm (GA) is a randomized search and optimization technique guided by the principle of natural genetic systems. Recently, there has been a great deal of interest in GAs and their application to various engineering fields.
Application of GA
The GA is being applied to a wide range of optimization and learning problems in many domains. GA is being applied to a wide range of optimization and learning problems in many domains. GA also lend themselves well to power system optimization problems, since there known to exibit robustness, require no auxulliary, and can offer significant advantages in solution methodology and optimization performance.
Genetic Algorithm
The main advantage of the GA formulation is that fairly accurate results may be obtained using a very simple algorithm. The objective of fitness function is a judge of GAs attempts. GAs do not know how to derive a problems solution, but they do know, from the objective function, how close they are to a better soln.
Sometimes near optimal solutions that can be generated quickly, using GAs, are more desirable than optimal solutions which require a large amount of time.
Using GAs, problems can be modelled as optimization problems.
GAs work with a coding of the parameter set, not the parameters themselves. Therefore they can easily handle integral or discrete variables.
GAs can provide globally optimum solutions.
GA use only objective function information, not derivatives or other auxiliary knowledge. Therefore, they can deal with the non-smooth, non-continuous, and non differentiable functions. GA use probabilistic transition rules, not deterministic rules.
GA Problem Formulation
States: A population of individuals, each with an associated fitness value Operators: Transform the population into a new generation, using Darwinian principle of reproduction and survival of the fittest Goal test: Criterion for terminating the search
Formalization
Binary coding
2 2 2 2 11 5 2 1 Remainder 1 1 0 Binary equivalent of 11 is 1011
Procedures of GA
Suppose we wish to maximize a function of k variables, f(x1,x2,.xk): Rk->R. Suppose further that each variable xi can take values from a domain Di=[ai,bi] and f(x1,x2,.xk) > 0 for all xi in Di. We wish to optimize the function f with required precision say upto 6 decimal places for the variables. Then Di must be cut into (bi-ai)*106 equal sized ranges.
Procedures of GA
Let mi be the smallest integer such that 2mi-1<=(bi-ai)*106 <=2mi. Then mi be the size of the Chromosome.
The equivalent value for any mi bit string can be obtained as xi=xil+[(xiu-xil)/(2mi-1)]*(decoded value of string)
Fitness Measures
Numerical evaluation Fitness = f(character in S) The character representation in S is also referred as chromosomes.
Population size (M) Maximum number of generations in a run (G) Number of runs (N) Selection & Replacement strategy Selection function to identify the result (goal)
the population I.e., randomly select individuals and randomly apply operators among:
Reproduction
Crossover Mutation
Select the fittest individual as a solution Run the GA many (N) times.
Stages of GA
A GA operates through a simple cycle of stages i) Creation of a population of strings, ii) Evaluation of each string, iii) Selection of best strings and iv) Genetic manipulation to create new population of strings.
Description of stages of GA
Each cycle in GA produces a new generation of possible solutions for a given problem. In the first phase, an initial population, describing representatives of the potential solution, is created to initiate the search process. The elements of the population are encoded into bitstrings, called
After selection of the population strings is over, the genetic manipulation process consisting of two steps is carried out. In the first step, the crossover operation that recombines the bits (genes) of each two selected strings (chromosomes) is executed. Various types of crossover operators are found in the literature. The single point and two points crossover operations are illustrated in fig. 15.2 and 15.3 respectively. The crossover points of any twochromosomes are selected randomly.
The second step in the genetic manipulation process is termed mutation, where the bits at one or more randomly selected positions of the chromosomes are altered. The mutation process helps to overcome trapping at local maxima. The offsprings produced by the genetic manipulation process are the next population to be evaluated.
Crossover Rate
In GA literature, the term cross over rate is usually denoted as PC, the probability of crossover. The probability varies from 0 to 1. This is calculated in GA by finding out the ratio of the number of pairs to be crossed to some fixed population. Typically for a population size 30 to 200, cross over rates are ranged from 0.5 to 1.
Mutation Rate Pm
Mutation rate is the probability of mutation which is used to calculate number of bits to be muted. The mutation operator preserves the diversity among the population which is also very important for the search. Typically, the simple genetic algorithm uses the population size of 30 to 200 with the mutation rates varying from 0.001 to 0.5.
Sample Problem I
Example 15.1: The GA cycle is illustrated in this example for maximizing a function f(x) = x2 in the interval 0 x 31. In this example the fitness function is f (x) itself. The larger is the functional value, the better is the fitness of the string. In this example, we start with 4 initial strings. The fitness value of the strings and the percentage fitness of the total are estimated in the 1st table
Solution by GA
Since fitness of the second string is large, we select 2 copies of the second string and one each for the first and fourth string in the mating pool.The selection of the partners in the mating pool is also done randomly. Here in 2nd table , we selected partner of string 1 to be the 2-nd string and partner of 4-th string to be the 2nd string.
Solution by GA..
The crossover points for the first-second and second-fourth strings have been selected after o-th and 2-nd bit positions respectively in 2nd table. The second generation of the population without mutation in the first generation is presented in 3rd table
Sample problem
Solution by GA
Representation: In this case a binary vector (chromosome) has been considered to represent the real values of the variable x. Let six places after the decimal point is our required precision. The domain of the variable x has a length equal to three; the precision requirement implies the [-1,2]
Solution by GA...
It should be divided into at least 3,000,000 equal-sized intervals. This means that 22 bits are required to represent one binary vector (chromosome): 2,097,152=221<3000000<=222 =4,194,304 The mapping
Solution
The mapping from a binary string to a real number x is performed in two steps. 1. Convert the binary string from base to base10 and set it equal to x1, and 2. Find a corresponding real number x=1+[3/(222-1)]* x1, where -1.0 be left boundary and 3 is the length of the domain.
Solution .
Of course the Chromosomes (0000000000000000000000) and (1111111111111111111111) represent boundaries of domain i.e -1 and 2 respectively. For example three chromosomes V1=(1000101110110101000111) V2=(0000001110000000010000) V3=(1110000000111111000101)
Solution.
correspond to the values x1=0.637197, x2=-0.958973,x3=1.627888. consequently the evaluation function as follows eval(v1)=f(x1)=1.586345 eval(v2)=f(x2)=0.078878 eval(v3)=f(x3)=2.250650
Solution .
Genetic operators: (mutation) v31=(110000001111111000101). Correspondingly, x31=1.630818 and f(x31)=2.343555, an improvement over original value of f(x3)=2.250650. Crossover operator: v2=(00000|01110000000010000) v3=(11100|00000111111000101)
Solution .
The offspring evaluate to f(v21)=f(-0.998113)=0.940865 f(v31)=f(1.666028)=2.459245 For this particular problem, pop_size=50, Pc =0.25, Pm=0.01 The best chromosome after 200 generations was Vmax=(1111001101000100000101) which corresponds to value xmax=1.850773
In the Traveling Salesman Problem (TSP) location of all the cities is given and the salesmans task is to find the shortest route connecting them all, with each city visited only once and returns to city of origin. Since it is NP complete problem, the method of finding an optimal solution must search in a solution space that expands exponentially with the number of cities.
Step 1: Generate random population of n Chromosome. Step 2: Evaluate the fitness f(x) of each Chromosome x in the population. Step 3: Create a new population by repeating the following. Steps until the new population by repeating the following.
Fitness Measure
Fitness function fit(tk) (k=1,2,pop_size) is defined as fit(fx) = 1/[(ci,ci+1)+ d(cn,c1)] where d(ci,ci+1): travelling distance from city ci to ci+1. If city ci is represented by pixel at point P(x,y) and city ci+1 is represented by pixel at point q(s,t) and d(ci,ci+1) is Euclidean distance between two points P(x,y) and q(s,t) which is defined as d(ci,ci+1)=|(x-s)|+ |(y-t)| = (x-s)2+(y-t)2
Distance Table
1 2 3 4 5 6 0 10 17 20 17 10
1
0 10 17 20 17
2
0 10 17 20
3
0 10 17
4
0 10
5
0
6
Solution of TSP by GA
(Parent 1)P1: 1 3 4 2 5 6 (Parent 2)P2: 1 2 3 6 5 4 Offspring1: (if randomly starting from city 6) 6 5 4 2 3 1 -> 1 3 2 4 5 6 Offspring2: (if randomly starting from city 3) 3 2 1 6 5 4 -> 1 6 5 4 3 2
Thank you!