# A Model-Assisted Combined Machine Learning Method for Ionospheric TEC Prediction
## 2 Materials and Methods
### Methods
#### 2.2.3 Modeling of Neural Network Optimization Based on Genetic Algorithm
It can be seen from Formula (8) that the fitness of individuals with smaller fitness values is higher, so the reciprocal of fitness values is taken to calculate the selection probability. Step 4: Crossover operation. Since the individuals are coded by real numbers, the crossover operation method is the real number crossover method. Two random numbers need to be set to cross individuals, as two points are used for crossing operations. Let two crossing points cross at the same time. When crossing at the \(m\) time, the changes of individual \(a_{k}\) (\(k=1,2,\ \cdots,135\)) and individual \(a_{l}\) (\(l=1,2,\ \cdots,135\)) in the population can be expressed by the following formula:  
\[ \begin{array}{c}a_{km}=a_{km}(1-b_{1})+a_{lm}b_{1}\\ a_{lm}=a_{lm}(1-b_{2})+a_{km}b_{2}\end{array}  \tag{9}\]  
where, \(a_{km}\) and \(a_{lm}\) are individual \(a_{k}\) and \(a_{l}\) at the \(m\) crossover time. \(b_{1}\) and \(b_{2}\) are the random number in the interval of \([0,1]\). Since the adaptive genetic algorithm is adopted, the probability of the cross operation of individual \(a_{k}\) and individual \(a_{l}\) is [40]:  
\[P_{kl}= \begin{cases}\frac{k_{1}(E_{max}-E_{kl})}{E_{max}-E_{avg}},E_{kl}\geq E _{avg}\\ k_{2},E_{kl}<E_{avg}\end{cases} , \tag{10}\]  
\(E_{max}\) is the maximum population fitness. \(E_{avg}\) is the average population fitness. \(E_{kl}\)\(=max\{E_{k},\ E_{l}\}\) is the larger adaptation value of individual \(a_{k}\) and individual \(a_{l}\). \(k_{1}\)\(=0.3,\ k_{2}\)\(=0.5\) are the coefficients. Step 5: Variation operation. Mutative operation is performed on a weight \(W\) or threshold \(V\). Select gene \(a_{kp}\) and gene \(a_{kq}\) of individual \(a_{k}\) for the mutation operation as follows:  
\[a_{k(p,q)}= \begin{cases}a_{k(p,q)}+\Big{(}a_{k(p,q)}-a_{max}\Big{)}\Big{(}1- \frac{g}{C_{max}}\Big{)}^{2}r,\ r>0.5\\ a_{k(p,q)}+\Big{(}a_{min}-a_{k(p,q)}\Big{)}\Big{(}1-\frac{g}{C_{max}}\Big{)}^{2 }r,r\leq 0.5\end{cases} , \tag{11}\]  
where, \(r\) is a random number in the range of \([0,1]\). \(g\) is the current iteration number. \(G_{max}\) is the maximum number of evolutions. Due to the adaptive genetic algorithm, the mutation probability of gene \(a_{kp}\) in individual \(a_{k}\) is expressed by the following formula:  
\[P_{kp}= \begin{cases}\frac{k_{1}(E_{max}-E_{k})}{E_{max}-E_{avg}},E_{k}\geq E _{avg}\\ k_{4},E_{k}<E_{avg}\end{cases} , \tag{12}\]where \(E_{k}\) is the fitness of the individual \(a_{k}\). \(k_{3}\)\(=0.1,\ k_{4}\)\(=0.2\) are the coefficients. Step 6: A new generation of population is generated from crossover and mutation, then return to Step 2. Repeat the process 100 times. Finally, the relative optimal solution of weights and thresholds of each BP-NN layer is obtained. Step 7: The BP-NN is trained and optimized by MMAapGA, and the error is calculated. The gradient descent method is used to update the weights and thresholds again. Finally, MMAapGA-BP-NN with errors within the allowed range is obtained, and the model is tested by predicting the TEC of the test set.