## 3 Design and Implementation of the Algorithm
### Evolution Module  
The evolution module is designed based on the improved IEC algorithm. Because the self-fitting algorithm requires high efficiency to reduce user fatigue, the high randomness of parameter mutation in  
Figure 2: Overall structure diagram of self-fitting. the traditional genetic algorithm is unreliable. Therefore, the parameter iteration process is optimized to accelerate convergence according to different patients. The algorithm flowchart is shown in Figure 3.  
1. Initialize the chromosome population. The algorithm parameter is encoded in binary, which is defined as the structural data of the genotype (i.e., chromosome). According to the patient's age, sex, duration of hearing impairment, and audiogram, \(M-1\) historical patients whose information is closest to that of the current patient's information (minimum Euclidean distance) are selected from the expert system. Here, \(M\) is the population size. The parameters of the selected patients and the last group of parameter based on the prescription formula NAL-NL2 [22] construct the whole \(M\) parameters. Even with the same audiogram, the real fitting results are influenced by the patient's cognitive level and personal habits, among other factors [22]. So, the proposed self-fitting algorithm optimally sets the signal gain set according to the patient information [25] and feedback. The signal gain in every frequency band is taken as a gene. Because the gain ranges from 0 to 120 dB, it is coded in 7-bit binary. 2. Compute the fitness of the chromosome. For the self-fitting algorithm of the hearing aid, fitness is determined based on the feedback from the patient. Considering the evaluation resolution and user fatigue, the fitness is divided into five levels: bad, poor, medium, good and excellent. Every level is represented in the specific value. The evaluation scale is highly important to the practicality and convergence of the interactive fitting. If the evaluation scale is too accurate, the burden of the algorithm is too large to cause user fatigue. Instead, although it is easier for the user to accept a rough evaluation, a larger quantization error leads to low convergence. Earlier research showed that the five-level evaluation scale is a compromise selection [27]. The performance of the algorithm is directly affected by the numerical selection, and thus the fitness values are selected based on the hyper-geometric operator. The genetic probability of each level is described as: \[P_{n}=\frac{1}{\gamma\times n^{q}}\] (1)  
Figure 3: Flowchart of the improved genetic algorithm. where \(\gamma\) is set as \(\sum\limits_{k=1}^{5}{(1/k^{q})}\), and \(q\) is a constant of 0.5. Use of the genetic probability as the fitness can make the genetic algorithm more stable. In addition, the prematurity problem can be avoided to a certain extent. 3. Calculate the optimal solution. If the current chromosome is determined as the optimal solution or the maximum number of iterations is reached, the process ends. Otherwise, the optimization proceeds. When the iterations end, the output is the optimal solution in the iteration process. 4. Gene selection. The individuals with higher fitness in the current population are transmitted to the next-generation population according to a certain rule. In this work, the roulette selection rule is applied, i.e., the probability that the individual is selected and transmitted to the next generation is proportional to the individual fitness. One circle is divided into \(M\) pieces according to the probability \(P_{n}\). During selection, the circle is rotated, and if a point falls into the \(i\)-th sector, then individual \(i\) is selected. The characteristic of the roulette selection rule is that each individual has an opportunity to be selected. 5. Genetic crossover. Selected chromosomes from two individuals are exchanged with probability \(P_{c}\) to obtain two new individuals. The algorithm uses the single-point crossover function. Chromosome pairing and the crossing point selection are two key factors.