# Research on Price Prediction of Construction Materials Based on VMD-SSA-LSTM
## 2 Methodology
### Optimization Algorithm  
[PERSON] et al. [32] proposed a method to improve prediction accuracy and address the challenges associated with random selection and the difficulty of choosing parameters for LSTM networks. They employed the Sparrow Search Algorithm (SSA) algorithm to optimize model parameters and demonstrated that this approach significantly enhances prediction accuracy. This study employs the SSA to optimize three parameters of the LSTM model, with the aim of enhancing both prediction accuracy and model stability. The SSA is a novel swarm intelligence optimization technique inspired by the natural foraging and anti-predatory behaviors of sparrows. Figure 2 presents a detailed flowchart outlining its steps and mechanisms.  
The SSA optimization process is specifically as follows:  
1. Producer update: A portion of sparrows (usually a certain percentage of the population, such as 10-20%) are considered producers. They are responsible for finding better food resources (i.e., better solutions) in the search space. The position update formula for producers is as follows: \[X_{i,j}^{t+1}=\left\{\begin{matrix}X_{i,j}^{t},\exp(-\frac{i}{\alpha\cdot T})& R_{2}<S_{T}\\ X_{i,j}^{t}+Q\cdot L&R_{2}\geq S_{T}\end{matrix}\right.\] (5) where \(X_{i,j}^{t}\) represents the position in the \(j\)-th dimension of the \(i\)-th sparrow in the \(t\)-th generation. \(\alpha\) is a random number within the interval \((0,1]\), usually around 0.5, \(T\) is the maximum number of iterations for the algorithm. \(R_{2}\in[0,1]\) and \(S_{T}\in[0.5,1]\) represent the range of the warning values and the range of the safe values, respectively. \(Q\) is a random number that follows a standard normal distribution. \(L\) is a matrix filled with ones.  
Figure 2: The flow chart of SSA.  
This formula allows producer sparrows to explore in the search space. As the number of iterations increases, the exploration range gradually decreases.
2. Consumer update: The remaining sparrows are considered consumers. They follow the producers to find food resources. Consumer sparrows update their positions by randomly selecting a producer and approaching it. At the same time, they are also influenced by random factors to increase search diversity. The position update formula for consumers is as follows: \[X_{i,j}^{t+1}=\left\{\begin{array}{ll}Q\cdot\exp(\frac{X_{w}ost^{t}-X_{i,j}^{ t}}{t^{2}})&i>\frac{n}{2}\\ X_{p}^{t+1}+\left|X_{i,j}^{t}-X_{p}^{t+1}\right|\cdot A^{+}\cdot L&i\leq\frac{n} {2}\end{array}\right.\] (6) where \(X_{w}ost^{t}\) represents the position of the global worst sparrow in the \(t\)-th generation, \(X_{p}^{t+1}\) denotes the best position occupied by consumers in generation \(t+1\), \(n\) is the total number of sparrow populations, \(A\) is a \(1\times d\) matrix, and each element in the \(A^{+}\) matrix is randomly assigned a value of \(1\) or \(-1\).
3. Scout update: In the sparrow population, there will also be some sparrows acting as scouts, responsible for monitoring the danger of the surrounding environment. When the warning value is less than the safety value, the scouts will guide the sparrow group to fly to other safe places. The position update formula for scouts is as follows: \[X_{i,j}^{t+1}=\left\{\begin{array}{ll}X_{b}est^{t}+\beta\cdot\left|X_{i,j}^ {t}-X_{b}est^{t}\right|&f_{i}>f\\ X_{i,j}^{t}+K\cdot(\frac{\left|X_{i,j}^{t}-X_{w}ost^{t}\right|}{(f_{i}-f_{w})+ \epsilon})&f_{i}=f_{g}\end{array}\right.\] (7) where \(X_{b}est^{t}\) represents the position of the global best sparrow in the \(t\)-th generation, and \(\beta\) is a random number following a standard normal distribution. \(K\) is a random number in the range \([-1,1]\), \(f_{i}\) represents the fitness value of the \(i\)-th sparrow, \(f_{g}\) represents the fitness value of the global best sparrow, \(f_{w}\) represents the fitness value of the global worst sparrow, and \(\epsilon\) is a very small number.