2.3. Implementation and Empirical Tuning Methods for GAs
(1) Mapping Objective Functions to Fitness Form. For the optimization of sonophotocatalysis developed in this study, the objective is most naturally stated as the minimization of the cost function . However, for GA optimization (search), the metric must be non-negative; therefore, the following cost-to-fitness transformation iss used:
where Cmax may be taken as the largest value observed thus far. .
(2) Fitness Scaling: To achieve the best results for GAs, it is necessary to regulate the level of competition among members of the population. This was precisely what we performed using fitness scaling. The regulation of copy number is especially important in small-population genetic algorithms. At the start of the GAs runs, it was common to have a few extraordinary individuals in the population of mediocre colleagues. If left to the normal selection rule
, extraordinary individuals would take over a significant proportion of the finite population in a single generation, and this was undesirable, a leading cause of premature convergence. Later, during a run, we encountered a very different problem. Late in the run, there may still be significant diversity within the population. However, the average fitness of the population may be similar to that of the population. If this situation is left alone, the average members and best members get nearly the same number of copies in future generations, and the survival of the fittest necessary for improvement becomes a random walk among the mediocre. In both cases, fitness scaling can help at the beginning of the run and as the run matures. There are several methods of fitness scaling, that is, the ranking method [
16] and linear scaling. We tested both of them and found that linear scaling was simple and efficient for our problem.
Let us define the raw fitness
and scaled fitness
f. Linear scaling requires a linear relationship between
and
f, as per
.
and
require
to be the number of expected copies desired for the best population member. In our problem, we tried different values of
ranging from 1.1 2.5. According to our experience,
ranging from 1.2 to 2 has been used successfully and independently. From the above equation, we obtain
In this way, simple scaling helps prevent the early domination of extraordinary individuals, while later, it encourages healthy competition among near-equals. This improves the performance of GAs in practice.
(3) Constraints. We deal with the dimension constraints by coding equations and deal with time constraints as follows: A genetic algorithm generates a sequence of parameters to be tested using the system model, objective function, and constraints. We simply run the model, evaluate the objective function, and check whether any constraints are violated. Otherwise, the parameter set is assigned a fitness value corresponding to the objective function evaluation. If the constraints are violated, the solution is infeasible and, thus, has no fitness.
(4) Codings. When GAs manage a practical problem, the parameters of the problem are coded into bit-strings. Coding designs for a special problem are key to using GAs effectively. There are two basic principles for designing GAs coding [
15], where the user should select a coding so that short, low-order schemata are relevant to the underlying problem and relatively unrelated to schemata over other fixed positions, and the user should select the smallest alphabet that permits a natural expression of the problem.
The reason for using crossed binary coding, because this codification was suitable for our problem owing to the behavior of process variables, should be analyzed in theory as follows: First, because of the strong relationship among the parameters, the highest bit in each local string in binary coding determines the basic structure among every parameter, and the second highest bit in each local string determines the finer structure among every parameter, and so on for the third, the fourth, etc.
The schema-defining length under crossed coding was shorter than the length under concatenated, mapped, fixed-point coding . According to the schema theorem, short schemata cannot be disturbed with high frequency and the schema under crossed coding has a greater chance of being reproduced in the next generation. Because it combines the characteristics of function optimization with the schema theorem and a successful binary alphabet table, crossed coding demonstrates greater effectiveness than the ordinary coding method in our implementation.
Local string formation was achieved as follows: for a parameter that needs to be coded, it was first transformed to a binary coding (appropriate length is determined by the desired degree of precision) and then mapped to the specified interval . Thus, the precision of this mapped coding may be calculated using . This means that the interval from to was divided into parts because the largest binary string that has a length of equals the decimal number . We can then obtain , and a local string for parameter with a length of is obtained.
To illustrate the coding scheme for the size variables more clearly, we considered this simple example for the minimization problem,
, in which
and
, if we adopted a string length of 5 for each local string and
,
was an initial solution, we will get the chromosome
, therefore, we obtained:
(5) Reproduction. The reproduction operator can be implemented in an algorithmic form in a number of ways. In this study, we consider the easiest methods for roulette wheels [
15].
(6) Crossover. The crossover operator can take various forms, that is, one-point crossover and multipoint crossover [
17]. It is commonly believed that multipoint crossover exhibits a better performance. The number of crossover points in a multipoint crossover operator is determined by the string structure. In this study, a four-point crossover operator is adopted. The crossover rate plays a key role in GAs implementation. Different values for crossover rates ranging from 0.05 to 1.0 were tried, and the results demonstrated that the values ranging from 0.25 0.75. In this study, we take 0.25 as a crossover rate.
(7) Mutation operation. After selection and crossover, the mutation was applied to the resulting population with a fixed mutation rate. The number of individuals on which the mutation procedure was carried out to the integer part of the population size was multiplied by the mutation rate. These individuals were chosen randomly from the population, and the procedure was then applied. The mutation rates used in this paper were 0.01.
(8) Elitism. Elitism consisted of keeping the best individual from the current population to the next one. In this study, we used 1 as the elitism value.
(9) Population-related Factors.
(a) Population Size. GAs performance was heavily influenced by population size. Various values ranging from 20 to 200 were tested. Small populations run the risk of seriously under-covering the solution space; a small population size causes the GAs to quickly converge on a local minimum, because it insufficiently samples the parameter space, while large populations incur severe computational penalties. According to our experience, a population size range of 50–200 is sufficient to solve this problem. In this study, according to our experience, we take 200 as the population size.
(b) Initial Population. It was demonstrated that a high-quality initial value obtained from another heuristic technique can help GAs find better solutions rather quickly than it could be from a random start. However, a possible disadvantage is that the chance of premature convergence may increase. In this study, the initial population was randomly chosen.
(10) Termination Criteria. It should be pointed out that there are no general termination criteria for GAs. Several heuristic criteria were employed in GAs, that is, computing time or number of generations, no improvement in the search process, or comparing the fitness of the best-so-far solution with the average fitness of all solutions. All the termination criteria above tried the criterion of computing time was proven to be simple and a simulation of approximately 200-1000 generations simulation is sufficient for the sonophotocatalysis optimization problem. The best results were obtained when the number of generations was 1000. Therefore, briefly, when applying GAs, a number of parameters must be specified. An appropriate choice of parameters affects the convergence speed of the algorithm. However, the optimization approach is terminated by the specified number of generations.