# A Short-Term Forecast Model of foF2 Based on Elman Neural Network
## 2 Model Principle
### Improved Particle Optimization Algorithm
#### 2.2.1 Particle Swarm Optimization for ENN  
The particle swarm optimization algorithm randomly initializes a group of particles, each of which has three characteristics of position, velocity and fitness function value, representing a potential solution to the problem. The position of the particle with the optimal function fitness is marked as the optimal particle position. The position of each particle is updated according to its historical optimal positions and the global optimal position [12]. Finally, particles converge to the global optimal solution. The process of particle swarm optimization for the ENN is as follows:  
1. In order to calculate the value of the weight matrix in the ENN, the element of the weight matrix is transformed into a vector, which is the position of the particle. Suppose \(k\) is the length of the particle, then \(m\) represents the number of particle iterations. The position of the particle can be expressed as \(\mathbf{P}(m)\ =\ (\mathbf{p}_{1}(m),\mathbf{p}_{2}(m)\cdots\mathbf{p}_{k}(m))\). The velocity of the particle determines the change of its position in the next iteration, which can be expressed as \(\mathbf{V}(m)\ =\ (v_{1}(m),v_{2}(m)\cdots v_{k}(m))\). Initialize \(\mathbf{P}(1)\) and \(\mathbf{V}(1)\) between [0,1].  
2. Evaluating the fitness of each particle by using the root mean square error (RMSE); the calculation formula is as follows:  
\[\text{RMSE}\ =\ \sqrt{\frac{1}{N}\sum_{t=1}^{N}\left(y(t)-f_{o}(t)\right)^{2}} \tag{6}\]  
where \(y(t)\) represents the output of the network, \(N\) represents the number of input sets, \(f_{o}(t)\) represents the observed value. \(\mathbf{P}_{\text{best}}\)\(=(p_{1},p_{2}\cdots p_{t})\) represents the optimal position that the particle has searched thus far, and \(\mathbf{G}_{\text{best}}\)\(=(g_{1},g_{2}\cdots g_{t})\) represents the optimal position that all particles has searched thus far. The initial \(\mathbf{P}_{\text{best}}\) and \(\mathbf{G}_{\text{best}}\) take the position of the first particle.  
3. Replace \(\mathbf{P}_{\text{best}}\) or \(\mathbf{G}_{\text{best}}\) with the position of the particle, if the current fitness of the particle is better than \(\mathbf{P}_{\text{best}}\) or \(\mathbf{G}_{\text{best}}\). Update the speed and position of the particle as follows:  
\[\left\{\begin{array}{c}\mathbf{V}_{i}(m+1)=\omega\mathbf{V}_{i}(m)+c_{1}r( \mathbf{P}_{\text{best}}-\mathbf{P}_{i}(m))+c_{2}r(\mathbf{G}_{\text{best}}- \mathbf{P}_{i}(m))\\ \mathbf{P}(m+1)=\mathbf{P}_{i}(m)+\mathbf{V}_{i}(m+1)\end{array}\right. \tag{7}\]  
where \(\omega\) represents the weight coefficient, \(c_{1}\) and \(c_{2}\) represent the non-negative acceleration constants and \(r\) is a random number between [0,1]. In this paper, we make \(\omega\ =0.8\), \(c_{1}=c_{2}=2.1\).  
4. The network training stops and the \(\mathbf{G}_{\text{best}}\) is output, when \(\mathbf{G}_{\text{best}}\) satisfies the convergence condition, or the number of iterations reaches the maximum. Otherwise, the training returns to the second step and continues to iterate until the termination condition is satisfied.