Prospects for Applied Mathematics and Data Analysis

Studying the Parameters of Genetic Algorithms and Their Impact on Problems of Finding the Optimal Solution

Ousama Asaad Bahbouh
Volume 1, Issue 2, pp. 28-36 (2023)
DOI: https://doi.org/10.54216/PAMDA.010203
Online: https://americaspg.com/journal/34/article/1510

Abstract

Interest in artificial intelligence has recently increased, because of its proven competence and effectiveness in addressing many outstanding issues and problems, as it is a modern science that derives its concepts from simulating the style of thinking and analysis in humans. Genetic algorithms are a branch of this science, which requires that their determinants be selected according to the problem at hand. In this paper, we examined the effect of changing some of the determinants of genetic algorithms, namely mutation probability and population size, on the accuracy of results for three problems of different frequency spectrum. The effect of the election algorithm in obtaining accurate results was also studied, by comparing the roulette wheel algorithm and Elitism algorithm.

Keywords: Artificial intelligence; Genetic Algorithms; Encoding; Selection; Mutation; Roulette Wheel; Elitism.

1. Introduction:

Due to the rapid development witnessed by our contemporary world, which has increased the complexity of systems to meet the urgent need of society to access systems with high performance and reliability, interest has recently increased in the science of artificial intelligence, because of its proven competence and effectiveness in addressing many outstanding issues and issues, as it is a modern science that derives its concepts from simulating the human method of thinking and analysis, based on a set of hypotheses and opinions. It is said that human intelligence is gained from experience and mental activity, to say that heredity is the largest role in this. These views have had an impact on the existence of several branches of artificial intelligence, such as neural networks, fuzzy logic, and genetic algorithms, which are the subject of interest in this research. Genetic algorithms are important techniques in the random search for the optimal solution, and they are a representation of the widespread belief that human intelligence is created with humans, and is acquired by heredity to a large extent, as it simulates the mating process between organisms of the same species. Several terms and qualities have been borrowed from genetics such as generation, parents, crossover and mutation, trying in this way to reach the most appropriate solution to the problem at hand, relying on the principle of the scientist Darwin in natural selection, based on retaining the advantages and good qualities found in the generation of parents to transfer them to the generation of children, with the aim of obtaining strong offspring with the best qualities of the predecessor generation at least. Due to its high ability to solve many complex problems and in various scientific fields, it has been used in several sciences, whether in the education sector[1], scheduling[2], [3], or in the field of electronic computers[4], even operations research and image processing[5], as well as sociology[6], and sports[7]. During the application of genetic algorithms, the problem posed to represent the chromosomes represented by the solutions is described by one of the coding methods. Then, a set of mathematical operations derived from biological processes, such as selection, crossover, and mutation, are applied to eventually obtain a set of chromosomes that represent the final generation, and each chromosome is only a member of the generation, and the best chromosome of the generation represents the optimal solution to be reached in the problem at hand. Therefore, the search process starts from a random set of solutions and not from a single solution or point, and the process of evolution continues to reach the final generation that often includes the best solution[8].

2. Chromosome Encoding:

Each generation in genetic algorithms consists of a fixed number of individuals or chromosomes called population size, which is an important factor on which the algorithm's performance depends. In general, it can be said that increasing the number of individuals to a large degree will make the time to obtain results large, which reduces the usefulness of these results sometimes, but inreturn reduces the error made in the result. There is also a problem when the size of the generation is small, as the accuracy of the results decreases significantly, because it won't cover the entire solution space well. To distinguish members of the generation expressed as chromosomes, each chromosome is encoded in a way that is easy to handle by the computer, depending on the problem at hand. The method of notation depends on the nature of the variables, and if they are discrete, they are of a finite number, so we can use binary representation to encode all cases. If the variables are continuous, they have an infinite number, and this requires determining the degree of permittivity of the value, or determining the number of binary digits at first, and then calculating the step size.

3. Encoding Methods:

There are several methods of encoding chromosomes where the nature of the problem dictates the appropriate method. Common encoding methods include Decimal Encoding, Value Encoding, and Binary Encoding, which are most commonly used because of their ease of handling[8], where each chromosome is a set of successive zeros and ones. Figure 1 shows an example of each notation:

Figure 1. Some types of chromosome encoding methods
Figure 1. Some types of chromosome encoding methods

4. Selection:

The selection process is the first stage in the genetic algorithms, where the new generation is selected form the old generation by placing all individuals in a group, and choosing the appropriate ones according to the suitability method used in an objective and unbiased manner. There are many selection procedures used, most of which seek to burden and increase the probability of selection the individual with the highest degree of fitness, but with different methods and visions. The formation of the fitness function that gives the degree of suitability is one of the most important points in genetic algorithms, because of its great impact on the validity of the results, as it is the real indicator of approaching or moving away from the solution[9]. Usually, this function is formed so that its value increases as we approach the optimal solution. Since there are many selection procedures, the appropriate procedure must be chosen because of its impact on the functioning of the genetic algorithm and obtaining the optimal solution as soon as possible. We explain below selection procedures used in this research:

4.1. Roulette Wheel Selection:

To simulate the Roulette Wheel Selection, it assumes the existence of a wheel divided into (100) equal sectors. The members of the generation are distributed among these sectors according to the average probability of selection for each member of the current generation, which is given mathematically by the relation:

i select

Where: Pselect(i): Probability of selection individual (i). Fi : fitness of the individual (i). n : the number of generation members. The selection process begins by randomly turning the wheel and waiting for it to stop at an indicator, at which point the individual indicated by the indicator is taken. Therefore, the greater fitness of an individual, the larger the area of his sector, and therefore the greater the probability of the wheel stopping and the indicator indicates one of the individual's most suitable sectors. This means increasing the probability that an individual will be selected and passed on to the successor generation. To simulate the process of a roulette wheel computerally, each individual is given a value that expresses the cumulative probability of C according to the relation j F i C Wheel segments are distributed to individuals according to the previous cumulative probability. A random number is then generated within the domain [1,100], and the sector individual whose number matches the generated random number is selected.

4.2. Elitism selection:

During the process of generating a new generation we cannot ignore the possibility of losing the optimal solution that exists in the current generation. From this point of view, and to retain good solutions in the successor generation of the predecessor, the method of selection was found on the principle of elitism algorithm. This procedure is based on copying a number of good solutions to the next generation and then completing the generation according to the roulette wheel procedure, for example. This means maintaining only the best solutions during the selection process.

5. Crossover:

Crossover is an important process in genetic algorithms that mimics biological mating between organisms. It is commonly believed that mating between well-defined individuals often results in individuals with at least good characteristics[10]. Thus, in genetic algorithms, individuals with a good fit scale are selected, and then the crossing process is applied between one individual and the next using one of the crossing methods, such as simple n-point crossover in which two consecutive chromosomes are selected from the generation, and (n) crossover points are selected with random values along the two chromosomes, and then the genetic chromosomes, i.e. genes, located between each individual crossing point and the next even point, are exchanged, noting that switching between the last crossing point to the end of the chromosome when the number of crossing points is odd. Note that the values of the crossing points are chosen randomly for each two consecutive chromosomes within the generation and their values do not exceed the length of the chromosome. Also, the crossing process It occurs with a probability defined as a constant at the beginning of the algorithm is the probability of crossover (Pc) for each individual within the generation. Figure (2) shows how to apply simple 2point crossover to two consecutive chromosomes of the parents' generation according to the following random values: The value of the first crossing point is equal to (2). The value of the second crossing point is equal to (6). Here it should be noted that after the selection of members of the current generation from the previous generation, the next stage is the implementation of the crossover process between each individual and the immediately following. Since the individual with the highest fitness has a higher chance of being selected more than once, this means that the current generation may involve repeating the same individual several times, which means that the probability of crossover between the individual and himself increases, thus reducing the severity of the flow towards the optimal solution. Therefore, in order to increase the randomness in the order of the members of the generation between the processes of selection and crossover, the process of Shuffling between these two stages has been added, which randomly changes the order of individuals within the generation.

Figure 2. simple 2-point crossover
Figure 2. simple 2-point crossover

6. Mutation:

Mutation is the last stage in a series of iterative processes that contribute well to reaching the optimal solution quickly. It is derived from the fact that genetic algorithms are a branch of random search techniques for the optimal solution, so a sudden and unexpected change in generation (random), even with a slight probability, will have a positive effect in approaching the optimal solution. When using the binary encoding method, the mutation is the opposite of one of the genes within the chromosome, i.e. Zero to one or vice versa. The probability of this change is known as the probability of mutation (Pm) and is chosen in most problems with a low value[10], [11]. Figure 3 shows how a mutation occurs in a binary coding chromosome:

Figure 3. Mutation on a binary chromosome
Figure 3. Mutation on a binary chromosome

7. Studying the Effect of Changes in Signals on Genetic Algorithm Parameters:

Genetic algorithms have been well spread and applied in various fields (engineering, mathematical, medical, etc.)[8], from solving mathematical problems such as the travel salesman problem (TSP)[10], to determining the weights of a neural network, to many other applications. Due to the wide scope in the selection of its parameters, published researches in this area have included guidance for the values of the best parameters. For example, to get good results in finding the local maximum values of a function, we can choose the size of the generation several hundred[11]. While we find Another study showing that the appropriate population size for the limit issue is (100) with the probability of the mutation being selected as very small (PM = 0.008)[12]. In another study, it is recommended to choose the population size (30)[13]. As for the number of generations, or in other words the number of iterations of the algorithm, it is related to the population size, as increasing the population size reduces the number of times the algorithm repeats to reach the solution[11], without clarifying the time cost. Of course, the time to reach the solution depends on the type of algorithm chosen, it may increase exponentially as the size of the problem increases, and it is possible to reduce the exponential increase with other conditions of the problem[14]. Several previous studies have shown optimal values for genetic algorithm parameters, such as population size and number of iterations for a number of different problems, taking into account the time cost of computation with the accuracy of the results[11]. But what is the effect of the distribution of solution points in the solution space on the domains of selecting the values of genetic algorithm parameters? Is a signal representing the solution space, for example, with many acute changes, and therefore involving several boundary points within a finite domain, treated with some specificity? This is what we will try to answer in the research, by studying the optimal values of the parameters of genetic algorithms when they are used to find the local maximum values of three problems with different functions in their changes. The first signal produced by the first function is characterized by soft variations, and therefore a low frequency spectrum. The second signal changes are not soft, meaning that its frequency harmonics are average. The latter signal has acute variations, which means that its frequency spectrum is wide.

7.1. Flow Chart of Genetic Algorithms:

Studying the effect of frequency spectrum on genetic algorithm parameters requires a high-level programming language with distinctive engineering capabilities, so the MATLAB environment was chosen to convert the flow chart of genetic algorithms shown in Figure (4) into an easy-to-handle program with multiple options. Some of the previously unmentioned stages of the flow chart can be illustrated as follows:

Figure 4. Flowchart of the genetic algorithm
Figure 4. Flowchart of the genetic algorithm

7.2. Practical Study:

To study the effect of the signal shape representing the problem-solving space on the selection domain of the genetic algorithm parameters, three signals were imposed and genetic algorithms were applied to find their maximum values within the time domain [0, 20ms]. Figure 5 shows the first signal within the studied domain with the frequency spectrum, where the temporal changes are soft because the frequency spectrum is a single relatively low frequency harmonic. Figure 6 shows the second signal with the frequency spectrum, where it is shown that the temporal variations It has less softness and there are several local maximum and minimum values, so the frequency spectrum is wider than the previous signal and is two frequency harmonics. Figure 7 shows the third signal with its frequency spectrum, where it is noted that its temporal variations are the highest, and therefore the frequency spectrum is wider and is three frequency harmonics. Here are the time equations of the three signals: signal1: f(t) = sin(2*pi*50*t); signal2: f(t) = sin(2*pi*50*t) + sin(2*pi*300*t); signal3: f(t) = sin(2*pi*50*t) + sin(2*pi*222*t) + sin(2*pi*500*t);

Figure 8 shows the three signals with the location of the local maximum values for each. Using the MATLAB environment, it is possible to find the coordinates of each local maximum value[16], so that the real values can be compared with the values that will be obtained when using genetic algorithms, and to know how accurately they are found. The coordinates of the maximum values of the signals are as follows: signal1: ( 5.006, 1.000 ); signal2: ( 4.195, 1.966 ); signal3: ( 6.368, 2.340 ); In order to compare the results when changing the values of the basic parameters of genetic algorithms, a simulation program was written with many capabilities and high accuracy, with two parameters identified to study them, namely mutation probability and population size, and the selection of the roulette wheel algorithm as an selection algorithm. Hence the iteration of execution for the algorithm of elitism. The number of generations generated was selected equal to (50) generations, with the choice of binary encoding for chromosomes, and the simple n-point crossover algorithm. In order to increase the accuracy of the results, the results were taken after the simulation process was carried out several times and the arithmetic average was taken.

Figure 7. Third signal in time and frequency
Figure 7. Third signal in time and frequency
Figure 5. First signal in time and frequency
Figure 5. First signal in time and frequency
Figure 6. Second signal in time and
Figure 6. Second signal in time and
Figure 8. The three signals in time domain
Figure 8. The three signals in time domain

domain

7.2.1. Effect of Mutation Probability:

We study the case of mutation probability change over the entire probability field and with a small step: Pm = [0:0.01:1], and we also choose the population size of (30) and the number of iterations (50). The vertical axis in Figure (9) represents the relative error value in calculating the local maximum value of the three signals. The horizontal axis represents the probability of the mutation. It is noted that the first signal has a very low relative error. This error increases in the next two signals, so the greater the time changes in the signal, the lower the accuracy of the result. For example, the average relative error of the first signal is (0.0218%), for the second (1.4607%) and for the third (1.9358%), as shown in Table (1). It is also noted that increasing the probability of mutation has a positive effect on decreasing the relative error value in all cases, which is an unexpected result, as many studies recommend a low probability of mutation[17]. Due to the small value of the error in the case of the first signal, the previous figure has been measured so that the changes appear in this case, and this is shown in Figure (10). The simulation was re-implemented by changing the selection algorithm to become the elitism in the same way, and it was found that the results are similar to the previous case in terms of a decrease in error in general with an increase in the probability value of the mutation and with a decrease in the frequency spectrum of the signal, i.e., an increase in the smoothness of time changes, and this is shown in Figure (11). However, it was noted that the elitism algorithm is better for soft signals and that the roulette wheel is better when the frequency spectrum of the signals increases, and this is evident in Table (1).

Figure 11. Relationship of relative error with probability of mutation by choice of
Figure 11. Relationship of relative error with probability of mutation by choice of
Figure 9. Relationship of relative error with mutation probability with roulette
Figure 9. Relationship of relative error with mutation probability with roulette
Figure 10. Standardization of Figure 9 to illustrate the relationship in the first signal
Figure 10. Standardization of Figure 9 to illustrate the relationship in the first signal

elitism

7.2.2. Effect of Population size:

Population size plays an important role in the functioning of the genetic algorithm, and each issue is chosen differently. The effect of Population size change on this type of question has been studied within the following domain: [6, 90] and with an increasing step (6). With the choice of the probability of the mutation equal to (0.5), and with the number of repetitions (50). Selection is also on the principle of roulette wheel, and simple crossing method. Figure 12 shows the result of the simulation where it is also observed that the first signal has a very low relative error, while this error increases in the next two signals. Thus, the greater the time changes in the signal, the lower the accuracy of the result, and this is evident in Table (1). The result is also improved by increasing the size of the population in general. Also, due to the small value of the error in the case of the first signal, the previous figure was measured so that the changes appear in this case, and this is shown in Figure (13) also the simulation was re-implemented by changing the selection algorithm to become the elitism and in the same manner, and it was found that the results are similar to the previous case in terms of reducing error in general with increasing population size and with decreasing the frequency spectrum of the signal, i.e. increasing the smoothness of time changes, and this is shown in Figure (14). Note that the relationship with the first signal is very low. It has been observed that the elite algorithm is better for soft signals and that the roulette wheel is better when the frequency spectrum of the signals increase, and this is evident in Table (1).

Figure 14. Relationship of relative error with population size by choice of elitism
Figure 14. Relationship of relative error with population size by choice of elitism
Figure 13. Standardization of Figure 12 to illustrate the relationship in the first signal Figure 12: Relationship of relative error
Figure 13. Standardization of Figure 12 to illustrate the relationship in the first signal Figure 12: Relationship of relative error
Table 1. Numerical values of mean relative error in three signals
Table 1. Numerical values of mean relative error in three signals

8. Conclu sion and results: Genetic algorithms are a way to simulate what nature does in the reproduction of organisms, and to use that method to solve complex problems to reach the best, or the closest possible solution to the optimal solution. In fact, there are several variables that play a prominent role in reaching the optimal solution quickly and efficiently. The values of these variables depend on the type of problem studied, where low values are sometimes recommended for the probability of mutation, other times high values, and so on for the rest of the variables. Three signals with increasing frequency spectrum, and therefore increasing temporal variations of intensity, were selected and the local maximum point was found using genetic algorithms, with optimal values of the variables determined. The results of the study showed a set of points, which are listed as follows:

1. The presence of a mutation within the evolution algorithm has a positive effect, and the error value decreases as the probability of mutation increases. 2. The roulette wheel algorithm can be considered better than the elitism algorithm for signals with wide spectrum, while the elitism algorithm is preferred when studying signals with soft changes. 3. The narrow spectrum, the more accurate the results and the easier it is to reach the optimal solution. 4. The larger the population size, the more accurate the results, but this will come at the expense of execution time.

References

[1]- T. Thepphakorn, S. Sooncharoen, and P. Pongcharoen, "Particle swarm optimization variants and its hybridization ratios for generating cost-effective educational course timetables", SN Computer Science, vol. 2, no. 4, pp. 1-12, 2021.

[2]- P. S. Chen, G. Y. H. Chen, S. F. Lien, and W. T. Huang, "Using Scrum and unified modeling language to analyze and design an automatic course scheduling system", Journal of the Chinese Institute of Engineers, vol. 42, no. 6, pp. 534-543, 2019.

[3]- T. Li, Q. Xie, and H. Zhang, "Design of college scheduling Algorithm based on improved genetic ant colony hybrid optimization", Security and Communication Networks, vol. 2022, article ID 2565639, 2022.

[4]- Raghavan, V. V., & Agarwal, B. (1987). "Optimal determination of user-oriented clusters: At application for the reproductive plan". Genetic algorithms and their applications: proceedings of the second International Conference on Genetic Algorithms, 241-246.

[5]- Fitzpatrick, J. M., Grefenstette, J. J., & Van Gucht, D. (1984). "Image registration by genetic search", Proceedings of IEEE Soutbeast Conference, 460-464.

[6]- Axelrod, R. (1985, November). "The simulation of genetics and evoluation". Paper presented at A conference on Evolutionary Theory in Biology and Economics, University of Bielefeld, Federal Republic of Germany.

[7]- B. Edo, T. Tadesse, and E. Mulugeta, "Student's and teacher's perceptions and experiences of course scheduling in undergraduate sports sciences program: an Ethiopian case study",  Journal of university Teaching and Learning Practice, vol. 16, no. 3, 4 pages, 2019.

[8]- E. Goldberg, David, “Genetic Algorithms in Search, Optimization, and Machine Learning “, Addison-Wesley Publishing Company, Inc, 1989.

[9]- O. Bahbouh, H. Risheh, " Genetic Algorithms Parameters Effects in Finding Optimal Solution ",  Damascus University Journal for Engineering Sciences, Volume 23, Issue 2, 2007.

[10]- H, Aurfie, M. Hajjar, M. Aubaid, " Genetic Algorithms",  Damascus University, FMEE, 2005.

[11]- O. Bahbouh, F. Dreie, A. Kataan, " Using Clustering in Optimization of Distributed Industrial Data Systems Performance ",  Damascus University Journal for Engineering Sciences, Volume 25, Issue 2, 2009.

[12]- Davis, L. (1991). "Handbook of Genetic Algorithms", Van Nostrand Reinhold, New York.

[13]- Grefenstette, J.J. (1986). "Optimization of control parameters for genetic algorithms". IEEE-SMC, SMC-16, 122-128.

[14]- Smith, T. (2005). "Artificial Intelligence". Computer Science 165A.

[15]- O. Bahbouh, W. Muzher, A. Daoud, " Simulation of the distributed database performance in real time environment with load sharing",  Damascus University Journal for Engineering Sciences, Volume 19, Issue 2, 2003.

[16]- O. Bahbouh, " MATLAB Engineers Language",  Aluons Publishing  (Syria), 2005.

[17]- Goldberg, D. E., & Lingle, R. (1985). "Alleles, loci, and the traveling salesman problem". Proceedings of an International Conference on Genetic Algorithms and Their Applications, 154-159.