





Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!






Denny Hermawanto Indonesian Institute of Sciences (LIPI), INDONESIA Mail: [email protected]
Abstract
This paper explains genetic algorithm for novice in this field. Basic philosophy of genetic algorithm and its flowchart are described. Step by step numerical computation of genetic algorithm for solving simple mathematical equality problem will be briefly explained.
Basic Philosophy
Genetic algorithm developed by Goldberg was inspired by Darwin's theory of evolution which states that the survival of an organism is affected by rule "the strongest species that survives". Darwin also stated that the survival of an organism can be maintained through the process of reproduction, crossover and mutation. Darwin's concept of evolution is then adapted to computational algorithm to find solution to a problem called objective function in natural fashion. A solution generated by genetic algorithm is called a chromosome, while collection of chromosome is referred as a population. A chromosome is composed from genes and its value can be either numerical, binary, symbols or characters depending on the problem want to be solved. These chromosomes will undergo a process called fitness function to measure the suitability of solution generated by GA with problem. Some chromosomes in population will mate through process called crossover thus producing new chromosomes named offspring which its genes composition are the combination of their parent. In a generation, a few chromosomes will also mutation in their gene. The number of chromosomes which will undergo crossover and mutation is controlled by crossover rate and mutation rate value. Chromosome in the population that will maintain for the next generation will be selected based on Darwinian evolution rule, the chromosome which has higher fitness value will have greater probability of being selected again in the next generation. After several generations, the chromosome value will converges to a certain value which is the best solution for the problem.
The Algorithm
In the genetic algorithm process is as follows [1]: Step 1. Determine the number of chromosomes, generation, and mutation rate and crossover rate value Step 2. Generate chromosome-chromosome number of the population, and the initialization value of the genes chromosome-chromosome with a random value
Step 3. Process steps 4-7 until the number of generations is met Step 4. Evaluation of fitness value of chromosomes by calculating objective function Step 5. Chromosomes selection Step 6. Crossover Step 7. Mutation Step 8. Solution (Best Chromosomes)
The flowchart of algorithm can be seen in Figure 1
Figure 1. Genetic algorithm flowchart
Numerical Example
Here are examples of applications that use genetic algorithms to solve the problem of combination. Suppose there is equality a + 2 b + 3 c + 4 d = 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
Solutions
Chromosome Chromosome Chromosome Chromosome
Evaluation
\ā
ith Population
Roulette wheel
Selection
Crossover
Mutation
End?
Best Chromosome
Best Solution
N i=i+
Y
encoding
Decoding
Next generation
= Abs(85 - 30) = 55
Step 3. Selection
The probability for each chromosomes is formulated by: P [i] = Fitness [i] / Total P [1] = 0.0106 / 0. = 0. P [2] = 0.0123 / 0. = 0. P [3] = 0.0119 / 0. = 0. P [4] = 0.0213 / 0. = 0. P [5] = 0.0105 / 0. = 0. P [6] = 0.0179 / 0. = 0.
From the probabilities above we can see that Chromosome 4 that has the highest fitness, this chromosome has highest probability to be selected for next generation chromosomes. For the
selection process we use roulette wheel, for that we should compute the cumulative probability values: C [1] = 0. C [2] = 0.1254 + 0. = 0. C [3] = 0.1254 + 0.1456 + 0. = 0. C [4] = 0.1254 + 0.1456 + 0.1408 + 0. = 0. C [5] = 0.1254 + 0.1456 + 0.1408 + 0.2521 + 0. = 0. C [6] = 0.1254 + 0.1456 + 0.1408 + 0.2521 + 0.1243 + 0. = 1.
Having calculated the cumulative probability of selection process using roulette-wheel can be done. The process is to generate random number R in the range 0-1 as follows. R [1] = 0. R [2] = 0. R [3] = 0. R [4] = 0. R [5] = 0. R [6] = 0.
If random number R [1] is greater than C [1] and smaller than C [2] then select Chromosome [2] as a chromosome in the new population for next generation: NewChromosome [1] = Chromosome [2] NewChromosome [2] = Chromosome [3] NewChromosome [3] = Chromosome [1] NewChromosome [4] = Chromosome [6] NewChromosome [5] = Chromosome [3] NewChromosome [6] = Chromosome [4]
Chromosomes in the population thus became: Chromosome [1] = [02;21;18;03] 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. Pseudo-code for the crossover process is as follows:
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 population = 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. ā 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 [1] = [02;05;17;01] Chromosome [2] = [10;04;13;14] Chromosome [3] = [12;05;23; 02 ] Chromosome [4] = [20;04;13;14] Chromosome [5] = [10; 05 ;18;03] Chromosome [6] = [20;01;10;06]
Finishing mutation process then we have one iteration or one generation of the genetic algorithm. We can now evaluate the objective function after one generation:
Chromosome [1] = [02;05;17;01] F_obj [1] = Abs(( 02 + 205 + 317 + 401 ) - 30) = Abs((2 + 10 + 51 + 4 ) - 30) = Abs(67 - 30) = 37 Chromosome [2] = [10;04;13;14] F_obj [2] = Abs(( 10 + 204 + 313 + 414 ) - 30) = Abs((10 + 8 + 33 + 56 ) - 30) = Abs(107 - 30) = 77 Chromosome [3] = [12;05;23;02] F_obj [3] = Abs(( 12 + 205 + 323 + 402 ) - 30) = Abs((12 + 10 + 69 + 8 ) - 30) = Abs(87 - 30) = 47 Chromosome [4] = [20;04;13;14] F_obj [4] = Abs(( 20 + 204 + 313 + 414 ) - 30) = Abs((20 + 8 + 39 + 56 ) - 30) = Abs(123 - 30) = 93 Chromosome [5] = [10;05;18;03] F_obj [5] = Abs(( 10 + 205 + 318 + 403 ) - 30) = Abs((10 + 10 + 54 + 12 ) - 30) = Abs(86 - 30) = 56 Chromosome [6] = [20;01;10;06] F_obj [6] = Abs(( 20 + 201 + 310 + 406 ) - 30) = Abs((20 + 2 + 30 + 24 ) - 30) = Abs(76 - 30) = 46 From the evaluation of new Chromosome we can see that the objective function is decreasing, this means that we have better Chromosome or solution compared with previous Chromosome generation. New Chromosomes for next iteration are: Chromosome [1] = [02;05;17;01] Chromosome [2] = [10;04;13;14] Chromosome [3] = [12;05;23;02] Chromosome [4] = [20;04;13;14] 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 produce new generation of Chromosome for the next iteration. This process will be repeated until a