# Two-Stage Short-Term Power Load Forecasting Based on SSA-VMD and Feature Selection
## 3 Sparrow Search Algorithm Optimizes Variational Mode Decomposition
### Sparrow Search Algorithm  
The swarm intelligence optimization algorithm is a computational model of optimization inspired by the behavioral patterns of biological populations and obtained through the artificial work of simulation and abstraction, which can be used for solving optimization problems, distributed problems, etc. It is often used in combination with machine learning and deep neural network models, and is a good way to improve the precision of time series prediction. SSA is a novel swarm intelligence optimization algorithm, proposed by [PERSON] et al. [43] in 2020, and was mainly inspired by the foraging and anti-predatory behavior of sparrow populations. SSA is characterized by a strong merit-seeking ability, fast convergence and good robustness. As such, this paper proposes a method to find the optimal combination of parameters \(K\) and \(\alpha\) for VMD using SSA.  
In the simulation of sparrow foraging, the sparrows are divided into searchers and followers. As the leader of the group, the searchers have a larger foraging range than the followers, and are able to find better food; individuals outside the searchers are defined as followers; at the same time, an early warning mechanism is added to the foraging process, with a certain proportion of individuals selected to warn of danger and to give up food immediately if danger is detected.  
Searcher location update formula:  
\[x_{i,j}^{t+1}=\left\{\begin{array}{ll}x_{i,j}^{t}\cdot\exp\Bigl{(}\frac{-i}{ \sigma\cdot il\sigma_{\max}}\Bigr{)},R_{2}<ST\\ x_{i,j}^{t}+\beta\cdot L,&R_{2}\geqslant ST\end{array}\right. \tag{8}\]  
where \(x_{i,j}^{t+1}\) is the position of the \(j\) dimension of the \(i\) individual in the \(t+1\) generation population; \(\sigma\) is a random number that follows a standard uniform distribution; \(\beta\) is a random number that follows a standard normal distribution; \(R_{2}\) is a safety value and follows a standard uniform distribution in the range of \(R^{2}\in[0,1]\); \(ST\) is a warning threshold in the range of \(ST\in[0.5,1]\). When \(R_{2}\geqslant ST\), the searchers will move randomly around the current position according to the normal distribution such that their values converges to the optimal position.  
Follower position update formula:  
\[x_{i,j}^{t+1}=\left\{\begin{array}{ll}Q\cdot\exp\Bigl{(}\frac{x_{i,j}^{t}-x _{i,j}^{t}}{i^{2}}\Bigr{)},&i>\frac{n}{2}\\ X_{p}^{t+1}+\left|X_{i,j}^{t}-X_{p}^{t+1}\right|\cdot A^{+}\cdot L,&i\leqslant \frac{n}{2}\end{array}\right. \tag{9}\]  
where \(X_{p}^{t+1}\) is the optimal position of the \(t+1\) generation of followers; \(x_{\omega,j}^{t}\) is the worst position; \(A\) is a matrix of \(1\times d\) with elements randomly assigned to \(1\) or \(-1\), and \(A^{+}=A^{\top}\Bigl{(}\text{AA}^{\top}\Bigr{)}^{-1}\). The formula can be visualized as the follower finding a position near the current optimal position, and the variance from the optimal position will become smaller in each dimension.  
Vigilantes' location update formula:  
\[x_{i,j}^{t+1}=\left\{\begin{array}{ll}x_{b_{i,j}}^{t}+\beta\cdot\Bigl{(}x_{ i,j}^{t}-x_{b_{i,j}}^{t}\Bigr{)},f_{i}\
eq f_{g}\\ x_{i,j}^{t}+K\cdot\left(\frac{x_{i,j}^{t}-x_{b_{i,j}}^{t}}{|f_{i}-f_{\omega}| +\epsilon}\right),f_{i}=f_{g}\end{array}\right. \tag{10}\]  
where \(x_{b_{i,j}}^{t}\) is the optimal position of the vigilantes in the \(t\) generation; \(x_{w_{i,j}}^{t}\) is the worst position; \(f_{i}\) is the adaptation of the current sparrow; \(f_{g}\) and \(f_{\omega}\) are the global optimal adaptation and the worst adaptation, respectively; \(\beta\) is a random number that follows a standard normal distribution; \(K\) is a uniform random number of \([-1,1]\). When the vigilante is at the current optimal position, it will change position, and the distance it moves depends on the ratio of the distance from the worst position to the difference in fitness; when the vigilante is not in the current optimal position, it will move to the vicinity of the current optimal position.  
The flow chart of SSA is shown in Figure 2.