## 3 Design and Implementation of the Algorithm
### Evolution Module
The function of chromosome pairing is to avoid the crossover of two similar chromosomes, which affects the search for the optimal solution. In addition, different crossing points lead to different effects for the same crossover pairs. In the worst case, if the new chromosome pairs after crossover are the same as the original pairs, the operation is invalid. To avoid this problem, an improved method is adopted. 1. Before the chromosome is paired, the correlation between two chromosomes is firstly analysed. The uncorrelated exponent of chromosome \(x_{l}=\{g_{l1},g_{l2}\cdots g_{lN}\}\) and \(x_{m}=\{g_{m1},g_{m2}\cdots g_{mN}\}\) is defined as: \[r(x_{l},x_{m})=\sum\limits_{k=1}^{N}{g_{lk}\oplus g_{mk}}\] (2)  
The selection process for chromosome pairing is as follows. First, the chromosome pairing pool (the pairing pool includes all chromosomes that have not been paired in a population) is defined as \(\{y_{1},y_{2},...,y_{S}\}\), and \(S\) is the number of chromosomes. After one chromosome \(x\) is randomly selected, another chromosome \(y_{i}\) is selected from the pairing pool to perform the crossover operation. If the difference between the selected individual and the others in the pool is not clear, the efficiency of the crossover operation is greatly affected. Therefore, the unequal probability pairing strategy [28; 29] is used. The individual with the larger uncorrelated exponent in the pairing pool is set with the greater probability, and the probability \(P(y_{i}/x)\) with which the individual \(y_{i}\) is selected to pair with the individual \(x\) is defined as follows:  
\[P(y_{i}/x)=\frac{1}{S}\bigg{(}1+\lambda\frac{r(x,y_{i})-r_{\rm{avg}}}{r_{\rm{ max}}-r_{\rm{min}}}\bigg{)}  
\[\left\{ \begin{array}{l}n_{\min}=\min\{k/g_{lk}\
eq g_{mk},k=1,2,...,N\}\\ n_{\max}=\max\{k/g_{lk}\
eq g_{mk},k=1,2,...,N\}\end{array} \right. \tag{4}\]  
In the crossover operation, if a coarse granularity and large step search strategy is adopted, it is favourable for global searching but has a negative effect on the local search performance. In addition, the role of the mutation operation is to compensate for the adverse effects of the crossover operation and to maintain the diversity of population. However, the performance of the fixed mutation probability used in the traditional genetic algorithm is poor in the later stages of the algorithm. Based on the above reasons, an adaptive crossover mutation algorithm is used. If each individual fitness value tends to be consistent or similar to the local optimal solution, the crossover and mutation probability is increased to pick out the local optimal solution. If the group fitness of the population is dispersed, the crossover and mutation probability is reduced to retain the excellent chromosomes. The self-fitting crossover formula is described as follows:  
\[P_{c}=\left\{ \begin{array}{l}\zeta\frac{P_{c}^{x}-P_{n}^{avg}}{P_{n}^{max}-P _{n}^{avg}},P_{n}^{x}>P_{n}^{avg}\\ P_{c}^{x},P_{n}^{x}\leq P_{n}^{avg}\end{array} \right. \tag{5}\]  
where \(\zeta\) is a constant of \(e^{-0.382}\), \(P_{c}^{\max}\) is the upper limit of crossover probability, \(P_{n}^{x}\) is the larger fitness value of the two individual chromosomes to be crossed, \(P_{n}^{\max}\) is the maximum fitness value of the population and \(P_{n}^{avg}\) is the average fitness value. (6) Mutation operation. The genes in each individual mutate with probability \(P_{m}\), and the probability formula is given as follows:  
\[P_{m}=\left\{ \begin{array}{l}(1-\zeta)\frac{P_{n}^{x}-P_{n}^{avg}}{P_{n}^{ max}-P_{n}^{avg}},P_{n}^{x}>P_{n}^{avg}\\ P_{m}^{\max},P_{n}^{x}\leq P_{n}^{avg}\end{array} \right. \tag{6}\]  
where \(P_{m}^{\max}\) is the upper limit of the mutation probability. Considering the characteristics of the hearing aid, the mutation steps should be directly related to the types of hearing loss and accelerate the evolution in a beneficial direction for the patient.