90 likes | 105 Views
The cycle of a Genetic Algorithms is presented below. Each cycle in Genetic Algorithms produces a new generation of possible solutions for a given problem. Genetic Algorithm Steps. The elements of the population are encoded into bit-strings , called chromosomes.
E N D
The cycle of a Genetic Algorithms is presented below Each cycle in Genetic Algorithms produces a new generation of possible solutions for a given problem
Genetic Algorithm Steps • The elements of the population are encoded into bit-strings, called chromosomes. • The performance of the strings, often called fitness, is then evaluated with the help of some functions f(x) , representing the constraints of the problem. • The crossover operation that recombines the bits (genes) of each two selected strings (chromosomes) . The crossover helps to span over the solution space
Genetic Algorithm Steps In Mutation the bits at one or more randomly selected positions of the chromosomes are altered. The mutation process helps to overcome trapping at local maxima Mutation of a chromosome at the 5th bit position. Example: The Genetic Algorithms cycle is illustrated in this example for maximizing a function f(x) = x2in the interval 0 = x = 31. In this example the fitness function is f (x) itself. Starts with 4 initial strings. The fitness value of the strings and the percentage fitness of the total are estimated in Table A.
Example Table A • 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 table B, we selected partner of string 1 to be the 2-nd string and partner of 4-th string to be the 2nd string. The crossover points for the first-second and second-fourth strings have been selected after 0-th and 2-nd bit positions respectively in table B. Table B
Example The second generation of the population without mutation in the first generation is presented in table C. Table C
gaex.m % Example in >>gatool 0-4, five bits 25 =32 (0-31) Fitness f(x) x -variable
GA- Problems • Use Gatool and maximize the quadratic equation • f(x) = x2 +4x-1 within the range • −5 ≤x≤0. 2. Use Gatool and maximize the function f(x1, x2, x3)= −5 sin(x1) sin(x2) sin(x3) + (- sin(5x1) sin(5x2)sin(x3)) where 0 <= xi <= pi, for 1 <= i <= 3. 3. Create a “gatool” to minimize the function f(x) = cos(2x) within the range 0≤x≤3.14