## 3 Design and Implementation of the Algorithm
### Expert System  
The structure diagram of the expert system is shown in Figure 4. Except that the expert system can improve the initial value according to the patient's information, it also facilitates user preference matching and analysis of population diversity. Based on the existing knowledge base, user preference matching can analyse the user preference and find the chromosome that is most similar to the current user preference [30]. The selected chromosome replaces the one with the worst fitness in the existing population. The chromosomes in the knowledge base are the final chromosomes for the fitted patients. Population diversity analysis is used to prevent the prematurity phenomenon. If the population diversity is low, the algorithm increases the mutation probability, the crossover probability and the search step to enrich the current population. (1) User preference matching  
In the IEC algorithm, the user preference for the chromosome is reflected in the individual evaluation. During the self-fitting process, the chromosome that is most similar to the current user preference is selected according to user feedback and is added to the existing evolution population. The chromosome with the worst fitness in the current evolution population is also removed to accelerate the evolution and improve the optimization process. The chromosome is composed of the gains of different frequencies. For the \(i\)-th chromosome \(x_{i}=\{g_{i1},g_{i2}...g_{iN}\}\), \(N\) is the number of parameters, and \(g_{ik}\) is the \(k\)-th gain of the \(i\)-th chromosome, which is expressed in 7-bit binary, and \(g_{ik}^{j}\) is the \(j\)-th bit of the \(k\)-th gain in the \(i\)-th chromosome with a value of 0 or 1. The validity \(F(g_{k}^{j})\) of the allele unit \(g_{k}^{j}\) is described as:  
\[F(g_{k}^{j})=\frac{\sum\limits_{i=1}^{N}g_{ik}^{j}P_{n}^{x_{i}}}{\sum\limits_ {i=1}^{N}(1-g_{ik}^{j})P_{n}^{x_{i}}} \tag{7}\]  
where the evaluation value of the current chromosome \(x_{i}\) is \(P_{n}^{x_{i}}\), which is shown in Formula (1). Because the fitness evaluation of the chromosome is subjective and the human evaluation might change over time, it is inevitable that the individual evaluation criteria will change during the evaluation process. At the beginning of the fitting, the cognition of the chromosome quality is fuzzy. As the evaluation process proceeds, the patient's psychological standard of chromosome evaluation is gradually unified, and at this time, the evaluation is credible. Therefore, the confidence function \(R(N)\) is introduced to simulate the credibility of the subjective evaluation. \[R(N)=\left\{ \begin{array}{l}1+e^{-a\times N_{s}}-e^{-a\times N},N<N_{s}\\ 1,N\geq N_{s}\end{array} \right. \tag{8}\]  
where \(a\) is the confidence coefficient. During the process of self-fitting, if the evaluation of speech quality is slow, \(a\) should be larger and \(N_{s}\) should be smaller. Otherwise, \(a\) is larger and \(N_{s}\) is smaller. Here, \(N_{s}\) is 5 and \(a\) is 0.15. The preference \(P(g_{k}^{j})\) of the allele unit \(g_{k}^{j}\) is adjusted by the confidence function, which is described as follows:  
Figure 4: Structure diagram of the hearing aid expert system. \[P(g_{k}^{j})=R(N)\times F(g_{k}^{j}) \tag{9}\]  
The preference similarity \(\sigma_{k}(u_{1},u_{2})\) of gene unit \(g_{k}\) between the patient \(u_{1}\) and \(u_{2}\) in the knowledge base is defined as  
\[\sigma_{k}(u_{1},u_{2})=\sqrt{\frac{1}{L}\sum\limits_{j=0}^{L-1}\left(\left(P_{ u1}(g_{k}^{j})-P_{u2}(g_{k}^{j})\right)\times 2^{j}\right)^{2}} \tag{10}\]  
Here, \(L\) is the bit number of every parameter. Because the gene unit represents the frequency gain in binary form, the weight of different allele unit \(g_{k}^{j}\) is not the same. Therefore, the user preference for each bit is multiplied by the factor \(2^{j}\).