Optimization of Different Fitness Functions Using Reproduction, Crossover and Mutation of Genetic Algorithm With Binary Number Scheduling


 Genetic algorithms are search algorithms based on the mechanics of natural selection and natural genetics. In this paper, we investigate a novel approach to the binary coded testing process based on a genetic algorithm. This paper consists of two parts. Thefirst part addresses the problem in the traditional way of using the decimal number system to define the fitness function to study the variations of counts and the variations of probability against the fitness functions. Second, the initialpopulationsare defined using binary coded digits (genes). For the evaluation of the high fitness function values,three genetic operators, namely, reproduction, crossover and mutation, are randomly used. The results show the importance of the genetic operator, mutation, which yields the peak values for the fitness function based on binary coded numbers performed in a new way.


Introduction
Many problems in engineering, mathematical modeling, and numerical optimization can be solved e ciently using global optimization algorithms [1][2][3][4][5][6][7]. To addressglobal optimization problems, researchers have proposed many optimization techniques, such as the Davidon-Fletcher-Powell algorithm, conjugate gradient method, and gradient-based algorithm [8][9][10][11]. These algorithms have achieved good results in solving engineering problems. However, many new optimization algorithms inspired by nature have been proposed in recent years, and one such algorithm is known as the "genetic algorithm". It is a class of evolutionary algorithms that generate solutions to optimization problems using techniques inspired by natural evolution, such as reproduction, crossover and mutation.
The idea of a genetic algorithm comes from the natural rule [12].Each organism lives with speci c features coded in genes that are stored in chromosomes. They are allowed to transfer their genes to create new generations, and the process is called crossover. During reproduction, mutation possibly occurs, which involves the changing of one gene in a chromosome of offspring. The offspring that can t to the environment better will be left. The genetic algorithm imitates this hereditary procedure in a mathematical way, which means that after random selection, crossover and mutation, the best result whose tness is highest will be obtained. The aim of the title paper is to use the above operators only to nd that operator that yields the highest tness function.

Description of genetic algorithm
Genetic Algorithm for Test Data Generation: We will not describe the basic idea of a genetic algorithm here, since it is well known. We indicate only its adaptation as applied to the problem being solved. In this case, the chromosomes are the data variants received at the program input. In this paper, we assume that the data are numerical. The purpose of the algorithm is to select such a multitude of test data variants that would provide the maximum coverage of the code, that is, to pass through as many program operations as possible. This goal is realized through the formulation of the tness function of a certain kind, which expresses how well a particular data variant is adapted for mutual coexistence with other individuals in a given generation. Let us introduce the important de nitions as given below: Population: a set of individuals of a speci ed size.
Individuals of a population are sets of task parameters coded in the form of chromosomes.
Chromosomes: ordered sequences of genes (chains or coded sequences) Gene: is a single element in the genotype Genotype: is a set of chromosomes of a given individual (can be a single chromosome) Initialization: The initial population is formed randomly taking into account constraints on the variables' values.
Population assessment: Each of the chromosomes is evaluated by a tness function.
Random Selection: After the value of the tness function for each of the chromosomes is calculated, the best chromosomes are selected for crossover.
Fitness Function: This measures tness of adaptation of a given individual to the environment. The function allows the evaluation of the degree of tness of particular individuals in the population, and based on this degree of tness, we select the individuals who t best.
New generation: a newly created population of individuals (offspring generations) Reproduction: To form a new solution, a couple of solutions from the previous generation are selected for breeding from the pool selected previously. It creates a child solution by means of crossover and mutation techniques. This new solution shares many of the characteristics of its parents. The process continues until a new population of solutions of appropriate size is generated.
Crossover: In GA, crossover is a genetic operator used to vary the programming of a chromosome or chromosomes from one generation to the next. It is analogous to reproduction and biological crossover, upon which genetic algorithms are based. In the present research, a single crossover point was used for each chromosome. In other words, each string of a proposed solution is split into two to be recombined and create a member of the next generation.
Mutation: a genetic operator used to maintain genetic diversity from one generation of a population of algorithm chromosomes to the next. It is analogous to biological mutation, in which new offspring are born with certain changes that are not inherited from their parents. In other words, mutation randomly alters the values of genes in a parent chromosome before the crossover operation is performed. Uniform random mutation was employed in the present algorithm. The tness function is used to measure the adaptability of chromosomes and usually needs to be maximized. The form of the tness function depends on the real problem, and a suitable transform seems to be necessary when we face a minimum optimization problem.
To maximize the tness functions f(x) = x 2 , x 2 + x, x 3 and x 3 + x, x £ (0, 31) Here, x represents a ve digit number using integers. Therefore, we select a randomly generated preset of solution as [13].  We show one generational cycle done by hand. Therefore, the maximum function f(x) can be treated as the tness function of this problem. After determining the tness function of the solved problem, the evaluation of each chromosome is carried out according to the tness functions. The higher the value of the tness function is, the better the result of the solved maximization problem.

Reproduction
The reproduction operator allows individual strings to be copied for possible inclusion in the next generation. The chance that a string will be copied is based on the string tness value calculated from a tness function. For each generation, the reproduction operator chooses strings that are placed into a mating pool, which is used as the basis for creating the next generation.

Crossover
In the natural world, the genes of children are formed from both of their parents. To imitate this situation, we crossed the chromosomes of selected parents to generate offspring. Crossover just happens between two chromosomes. Therefore, the rst stage of crossover is arranging the chromosomes of the selected parent's population in pairs that are made randomly. After that, we should decide the crossover point. If the length of each chromosome is (i.e., for ch = 11000) and the length of this chromosome is 5, we draw a random number, which belongs to interval (1,4).Then, the genes of the parents are exchanged from the gene on position. As a result, a pair of offspring is created. Example: A pair of parent A pair of offspring Parent 10100 crossover -> ch1 10000 Parent 01000 ch2 11100

Mutation
Different from crossover, mutation occurs quite rarely in genetic algorithms. Therefore, we give a very small mutation rate, which is often in the interval (0, 0.03).Every gene should be given a random mutation probability. If the drawn probability is less than or equal to random mutation probability, then this gene value should be changed to the opposite value (binary from 0 to 1 or from 1 to 0), which means that mutation occurs.

Obtaining new generation (Optimal Solution)
The parent population undergoes selection, crossover and mutation, creating offspring. It is then possible that the offspring are probably not feasible solutions at all. Therefore, we need tomodify them or compel them to satisfy the conditions. After that, we obtain new feasible solutions, the so-called current population, with the same size as their parent's population.

Stopping process
The process for stopping the genetic algorithm depends on the speci c situation of the application of the genetic algorithm. If the stopping process is met, then the best result is taken.Otherwise, we have to go back to the initial step.

Best result of tness function
The stop process should be checked when we obtain a new generation. If it is satis ed, then we stop the whole program and output the nal result. Otherwise, we will return to the initial step until we achieve the stop process. The best result should be a chromosome that has the highest tness function value.

Results And Discussion
The origin of evolutionary algorithms is an attempt to mimic some of the process taking place in natural evolution. Although the details of biological evolution are not completely understood, there are some points supported by strong experimental evidence [14][15][16][17][18]. Genetic algorithms are one of the most popular evolutionary algorithm techniques based on the concept of imitating the evolution of a species. In the case of GA, a population of chromosomes is generated using an intelligent method or a random selection method. Each of these individuals is encoded as a binary string that represents a possible candidate solution to the problem at hand. In each iteration, the survival strength of each candidate solution is measured by a tness function. Afterwards, the evolutionary process is constrained by three genetic operators: selection, crossover, and mutation. Through the selection procedure, individuals are selected that enter into the crossover process.
The crossover operator alters two or more parents to create offspring, where a probabilistic crossover rate is usually used to generate offspring. The mutation operator produces one child from one parent by ipping slightly(s) of the parent. A probabilistic mutation rate is usually used to determine whether a particular change occurred within an individual [19][20][21][22][23]. There are some important characteristics of crossover and mutation operators that are not captured by the other. Bła˙zej et al [24] have clearly pointed out that it has never been theoretically shown that mutation is in some sense less powerful than the crossover and vice versa. Mutation serves to create random diversity in the population, while crossover serves as an accelerator that promotes emergent behavior from components.
It is impossible for mutations to simultaneously achieve high levels of construction and survival. This would appear to be important since one without the other may not be extremely useful. High construction levels are accomplished at the expense of survival, while good survival is at the expense of construction [24][25]. In our study, we obtain high tness function values for different mutation rates.  Four pairs of graphs that are drawn based on the parameter values given in Tables (1 to 7) are presented above.In all eight graphs, the de ned tness functions represented by numerical values are taken along the x-axes, while the probability is taken along the y-axes, as shown in Figure 2(a), Figure 3(a), Figure 4(a) and Figure 5(a). The y-axes in the rest of the graphs, i.e., Figure 2(b), Figure 3(b), Figure 4(b) and Figure  5(b), represent the values of the count (in seconds) against the very same tness functions as in the former graphs.
The rst pair of graphs providesinformation based on the tness function de ned as f(x) = x 2 , the second being f(x) = x 2 + x, the third being f(x) =x 3 and f(x) = x 3 + x. Figure 2(a) illustrates that the probabilities for different tness functions represent almost a straight line passing through the origin with a slope of 45 with the horizontal. Although the graph has been plotted only with four randomly chosen initial population values, using decimal numbers, the probability for any other tness function will be well within the straight line without any uctuations. We note that the behaviors of Figure 3(a), Figure 4(a) and Figure 5(a) are similar to that of Figure  2(a).Although the behaviors of Figure 2(b) and Figure 4(b) are quite similar, Figure 3(b) and Figure 5(b) illustrate an inverted slanting alphabet 'Z'. The widths of Z in all three graphs are different, which may be due to the difference in the de nitions of the tness function. A detailed study to explore the splitting of counts is worth attempting.
ln thesecond part of the paper a novelidea is introduced, in the sense, the initial population values are represented not as a decimal number but as a binary coded digits and they are taken along the x-axes in all the twelve graphs and they are the four groups of graphs, each containing a set of three graphs providing information for the four randomly de ned tness functions, namely, f(x) = x 2 , f(x) = x 2 + x,f(x) =x 3 and f(x) = x 3 + x.They have the sameinitial population valuestaken along their x-axes. (A collection of an ordered list of arti cial chromosomes wherein every chromosome represents a sequence of nodes is known as the initial population. An important fact is that each gene of a chromosome takes a no delabel in such a way that no node appears twice in the same chromosome). As in the traditional binary coded genetic algorithm, the variables of interest are coded as binary digits (genes), which are plotted along the x-axes in all the above graphs.ln the rst set of graphs wherein probability versusinitial population is plotted, the curves resemble an inverted part of a nonnegative sine wave [ Figure 6(a), Figure 7(a), Figure 8(a)and Figure 9(a)]. lt clearly indicates that the probability varies between 0 and 0.5 for all four de ned tness functions. lt is also observed that this variation is quite similar to the variation of probability (between 0 and 0.5) for any value of x, as shown in the former set of graphs presented above.
The second set of curves is plotted between the initial population taken along the x-axes and counts taken along the y-axes. The two graphs in Figure 6(b) and Figure7(b) illustrate that the variation in the observedcount is well in phase with the actual count. However, there are variations in the values of the counts. Both plots clearly illustrate that the observed counts are less than the actual counts observed, and both coincide at one particular value of the initial population's value, as shown in Figures  6(b) and 7(b). However, Figure 8(b) and Figure9(b) indicate that the observed count is more than the actual counts but coincides at more than one place, as depicted by Figure 6(b) and Figure7(b).The third set of curves is plotted for different tness functions against the same initial population, and they are a 3in-1 representation since three different types of curves are drawn, namely, the tness function values, i) for offspring before reproduction ii) for offspring after crossover and iii) for offspring after mutation against the initial population. ln all four plots, the offspring-after-mutation curves represent the peak values for the tness functions, as shown in Figure  expectthat it should bedesigned in such a way that better solutions will have a higher tness function value than worse solutions. This seems to have been felicitated by mutation since the main goal of mutation is to obtain a solution that could not be obtained from existing genes.
The variation of the tness function values against the initial population for offspring after crossover resembles a part of the nonnegative sine wave [cloured red]. lt establishes the fact that it has never been theoretically shown that mutation is in some sense less powerful than crossover and vice versa, as pointed out in theliterature [P. Bła˙zej, M. Wne¸trzak, and P. Mackiewicz, "The role of crossover operator in evolutionary-based approach to the problem of genetic code optimization," Bio Systems, vol.
150, pp. 61-72, 2016.] [27].Mutation serves to create random diversity in the population, while crossover serves as an accelerator that promotes emergent behavior from components. The issue is the relative importance of diversity and construction, and one without the other may not be extremely useful.
The third type of curves inFigure 6(c), Figure 7(c), Figure 8(c) and Figure 9(c) are drawn for offspring before reproduction, which are generally similar to each other, representing part of the nonnegative sinewaves in all four cases. An analysis of these graphs illustrates that these variations are quite similar to the variations of i) probability and ii) count against the initial population. Generally, the objectives are con icting for multiple-objective problems, hindering concurrent optimization of each objective. The probability of mutation, the initial population and the number of generations have been varied to study its effect on the tness value involving genetic operations such as crossover and mutation andthe present studyprovidesevidenceto the factthat the genetic operator mutation yields the peak values for the tness function offering goodness of solution On the whole the general observations of all the plots offer su cient scope for further works to deal with practical engineering problems in future.

Conclusion
This paper aims to introduce one of the very useful optimization methods, namely, the genetic algorithm.The ow chart vividly illustrates the various steps adopted in the present optimization method.The terminologiesinvolved in the title paperhave been explained. All the necessary parameters involved in the computational processes are tabulated. The rst part of the paper clearly explains the two types of plots, and thesigni cant observation is that the probabilities for different tness functionsrepresent almost a straight line passing through the origin with a slope of 45 with the horizontal. Although the graph has been plotted only with four randomly chosen initial population values, using decimal numbers, the probability for any other tness function will be well within the straight line without any uctuations.The shape of the graphs between the tness function and counts resembles that of a slanting alphabet 'Z', and its breadth depends on the de nition of different tness functions.A signi cant observation is the fact that quite similar behavior is observed, as reported in the literature.
In the second part of the paper, a novel idea is introduced.In the sense, the initial population values are represented not as a decimal number but as a binary coded digit, and they are plotted in four groups of graphs as shown above. Three steps of graphs are plotted for the four randomly chosen tness functions. In the rst set of graphs wherein probability versusinitial population is plotted, the curves resemble an inverted part of a nonnegative sine waveline, clearly indicatingthat the probability varies between 0 and 0.5 for all four de ned tness functions. The second set of curvesplotted between the initial population (coded as a binary digit) taken along the x-axes and counts taken along the y-axes illustrate that the variation of the observedcount is well in phase with the actual count. However, there are variations in the values of the counts, sometimes both coinciding with each other atone or more points.
The third set of curves is a 3-in-1 representation, namely, initial population against the tness function values i) for offspring before reproduction (cloured black) type-l, ii) for offspring after crossover (colored red) type-ll and iii) for offspring after mutation(colored green) type-lll. An analysis of type-l graphs illustrates that these variations are quite similar to the variations of i) probability and ii) count against the initial population, and an analysis of type-l curves resembles a part of the nonnegative sine wave. ln all four types of lll plots, the offspring-after-mutation curves represent the peak values for the tness functions and offer better solutions since the tness function is a de ned function that measures the goodness of a solution. This seems to have been facilitated by the type-lll curves in the title paper. lt implies that when we face various practical problems depending on the requirement of the question, we could adjust the mutation rate.
Abbreviations GA: Genetic Algorithm