



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
Soft computing notes from Chitkara univeristy
Typology: Cheat Sheet
1 / 7
This page cannot be seen from the preview
Don't miss anything!
Example: Suppose there is equality a + 2b + 3c + 4d = 30, genetic algorithm will be used to find the value of a, b, c, and d that satisfy the above equation. First, we should formulate the objective function, for this problem the objective is minimizing the value of function f(x) where f(x) = ((a + 2b + 3c
F_obj[5] = Abs((01 + 204 + 313 + 419) - 30) = Abs((01 + 08 + 39 + 76) - 30) = Abs(124 - 30) = 94 F_obj[6] = Abs((20 + 205 + 317 + 401) - 30) = Abs((20 + 10 + 51 + 04) - 30) = Abs(85 - 30) = 55 Step 3. Selection
Chromosome[2] = [10;04;13;14] Chromosome[3] = [12;05;23;08] Chromosome[4] = [20;05;17;01] Chromosome[5] = [10;04;13;14] Chromosome[6] = [20;01;10;06] In this example, we use one-cut point, i.e. randomly select a position in the parent chromosome then exchanging sub-chromosome. Parent chromosome which will mate is randomly selected and the number of mate Chromosomes is controlled using crossover_rate (ρc) parameters. For random number R above, parents are Chromosome[1], Chromosome[4] and Chromosome[5] will be selected for crossover. Chromosome[1] >< Chromosome[4] Chromosome[4] >< Chromosome[5] Chromosome[5] >< Chromosome[1] After chromosome selection, the next process is determining the position of the crossover point. This is done by generating random numbers between 1 to (length of Chromosome – 1). In this case, generated random numbers should be between 1 and 3. After we get the crossover point, parents Chromosome will be cut at crossover point and its gens will be interchanged. For example, we generated 3 random number and we get: C[1] = 1 C[2] = 1 C[3] = 2 Then for first crossover, second crossover and third crossover, parent’s gens will be cut at gen number 1, gen number 1 and gen number 3 respectively, e.g. Chromosome[1] = Chromosome[1] >< Chromosome[4] = [02;21;18;03] >< [20;05;17;01] = [02;05;17;01] Chromosome[4] = Chromosome[4] >< Chromosome[5]
Chromosome[5] = Chromosome[5] >< Chromosome[1] = [10;04;13;14] >< [02;21;18;03] = [10;04;18;03] Thus, Chromosome population after experiencing a crossover process: Chromosome[1] = [02;05;17;01] Chromosome[2] = [10;04;13;14] Chromosome[3] = [12;05;23;08] Chromosome[4] = [20;04;13;14] Chromosome[5] = [10;04;18;03] Chromosome[6] = [20;01;10;06] Step 5. Mutation Number of chromosomes that have mutations in a population is determined by the mutation_rate parameter. Mutation process is done by replacing the gen at random position with a new value. The process is as follows. First, we must calculate the total length of gen in the population. In this case the total length of gen is total_gen = number_of_gen_in_Chromosome * number of populations = 4 * 6 = 24 Mutation process is done by generating a random integer between 1 and total_gen (1 to 24). If generated random number is smaller than mutation_rate(ρm) variable then marked the position of gen in chromosomes. Suppose we define ρm 10%, it is expected that 10% (0.1) of total_gen in the population that will be mutated: number of mutations = 0.1 * 24 = 2.4 ≈ 2 Suppose generation of random number yield 12 and 18 then the chromosome which have mutation are Chromosome number 3 gen number 4 and Chromosome 5 gen number 2. The value of mutated gens at mutation point is replaced by random number between 0-30. Suppose generated random number are 2 and 5 then Chromosome composition after mutation are:
Chromosome[5] = [10;05;18;03] Chromosome[6] = [20;01;10;06] These new Chromosomes will undergo the same process as the previous generation of Chromosomes such as evaluation, selection, crossover and mutation and at the end it produces new generation of Chromosome for the next iteration. This process will be repeated until a predetermined number of generations. For this example, after running 50 generations, best chromosome is obtained: Chromosome = [07; 05; 03; 01] This means that: a = 7, b = 5, c = 3, d = 1 If we use the number in the problem equation: a + 2b + 3c + 4d = 30 7 + (2 * 5) + (3 * 3) + (4 * 1) = 30 We can see that the value of variable a, b, c and d generated by genetic algorithm can satisfy that equality.