## 3 Model for Security Resource Scheduling Based on MHALSTM-MPC
### Multi-Head Attention Long Short-Term Memory Network (MHALSTM)  
Recent advancements in time-series prediction have demonstrated the effectiveness of integrating attention mechanisms with LSTM networks to enhance model performance. For instance, swarm optimization-tuned multi-headed LSTM networks have been successfully applied to fuel price forecasting [19], and hybrid models combining multi-head attention with LSTM have shown remarkable accuracy in predicting workloads and resources in cloud data centers [20]. These successes highlight the potential of combining multi-head attention mechanisms with LSTM networks to address complex prediction tasks. In this study, the MHALSTM model integrates the multi-head attention mechanism, taken from Transformer architectures, with the LSTM layer. This integration is motivated by the complementary strengths of the two techniques. LSTM networks excel at capturing long-term dependencies in time-series data and mitigate the vanishing gradient problem, making them well suited for passenger flow prediction. However, standalone LSTM models may struggle to focus on the most relevant time steps or features when faced with highly dynamic or noisy data. Multi-head attention mechanisms address this limitation by dynamically assigning weights to different time steps, allowing the model to prioritize the most critical segments of the data. By combining these strengths, the MHALSTM model can simultaneously capture nuanced temporal patterns and contextual relationships in passenger flow data. This capability enhances prediction accuracy and robustness, providing a reliable foundation for resource scheduling at high-speed railway stations. The following sections detail the working principles of the MHALSTM model. Figure 1: The MHALSTM-MPC architecture diagram. The basic formulas of the LSTM layer include the forget gate, input gate, output gate, cell state, and hidden state. These components work together to capture long-term dependencies and forget information that is no longer needed. 1 Forget gate (\(f_{t}\)):  
\[f_{t}=\sigma\Big{(}W_{f}\cdot[h_{t-1},x_{t}]+b_{f}\Big{)} \tag{1}\]  
This gate controls how much information from the previous cell state (\(c_{t-1}\)) is forgotten. \(W_{f}\) is the weight matrix for the forget gate, \(b_{f}\) is the bias term, \([h_{t-1},x_{t}]\) represents the concatenation of the previous hidden state and the current input state, and \(\sigma\) is the sigmoid activation function that compresses the output between 0 and 1. 2 Input gate (\(i_{t}\)):  
\[i_{t}=\sigma(W_{i}*[h_{t-1},x_{t}]+b_{i}) \tag{2}\]  
The input gate decides the degree to which information from the current input (\(x_{t}\)) will update the cell state. \(W_{i}\) is the weight matrix for the input gate, and \(b_{i}\) is the bias term. 3 Candidate cell state (\(\widetilde{c}_{t}\)):  
\[\widetilde{c}_{t}=tanh(W_{c}\cdot[h_{t-1},x_{t}]+b_{c}) \tag{3}\]  
This is a temporary state that creates new candidate values in order to update the cell state. \(W_{c}\) is the weight matrix, \(b_{c}\) is the bias term, and \(tanh\) is the activation function that compresses the output between \(-1\) and \(1\). 4 Cell state (\(c_{t}\)):  
\[c_{t}=f_{t}\odot c_{t-1}+i_{t}\odot\widetilde{c}_{t} \tag{4}\]  
The current cell state is updated by partially forgetting the previous cell state through the forget gate and adding new candidate cell states through the input gate, allowing the LSTM to retain long-term information. 5 Output gate (\(o_{t}\)):  
\[o_{t}=\sigma(W_{o}\cdot[h_{t-1},x_{t}]+b_{o}) \tag{5}\]  
The output gate controls which part of the current cell state is used as the output for this step. \(W_{o}\) is the weight matrix for the output gate, and \(b_{o}\) is the bias term. 6 Hidden state (\(h_{t}\)):  
\[h_{t}=o_{t}\odot tanh(c_{t}) \tag{6}\]  
The hidden state is a filtered version of the cell state; only the part allowed by the output gate can pass through. This output is used for the input of the next time step or as the final output.