# Instantaneous Beam Prediction Scheme against Link Blockage in mmWave Communications
## 4 Proposed LSTM-Based Recovery Scheme
### Operating Modes  
The network operates in learning and training modes (I and II), as explained in the pseudocode in Algorithm 1. ```
Input:\(I\), \(J\), \(N_{\text{MS}}\), \(N_{\text{BS}}\), \(I_{n}\), \(R_{\text{MS}}\), \(R_{\text{BS}}\), \(d\), \(f_{n}\), \(P_{tr}\), \(C_{\text{MS}}\), \(P_{\text{BS}}\), \(\mathbb{I}(x)\), \(\rho\), \(b\) Mode I:\(T_{\text{learn}}<\ T_{\text{train}}/\)Use conventional recovery schemes at (\(t\))th time step, Collect Observations for Dataset If \(y_{\text{MS}}\)\(<\)\(\delta_{th}\) s.t. \(\delta_{\textit{init}}\)\(<\)\(\delta_{\textit{th}}\)//signal drops below threshold value \(\delta_{\textit{init}}\)\(<\)\(min\big{\{}\log_{2}(1+10^{1. (\text{SNR}-\Omega)}),\delta_{\textit{max}}\big{\}}\) \(max\big{\{}y_{\text{MS}}(c^{t}_{i},p^{t}_{j})\):\(\forall c^{t}_{i}\in C_{\text{MS}}\)&&\(\forall p^{t}_{j}\)\(\in\)\(P_{\text{BS}})//Measure the received signal at all \(c^{t}_{i}\), \(p^{t}_{j}\)\(\big{\{}c^{t}_{i},\ p^{t}_{j}\big{\}}_{\textit{bs}}\)\(\vdash\)\(max(y_{\text{MS}})/\)Select the best (\(c^{t}_{i}\), \(p^{t}_{j}\)) pair at (\(t\))th time step that return maximum signal. \(\delta_{\textit{init}}\)\(\geq\)\(min\big{\{}\log_{2}(1+10^{1. (\text{SNR}-\Omega)}),\delta_{\textit{max}}\big{\}}\) Output: Dataset that include multiple pairs of (\(c^{t}_{i}\), \(p^{t}_{j}\))\({}_{\textit{bs}}\) at different (\(t\))th time steps. ```  
**Algorithm 1** LSTM-Based Beam Prediction Algorithm against Link Blockage  
Learning Mode (Mode I): The MS and BS perform a traditional recovery scheme to compute the best beams at (\(t\)) th time step. The network here operates in an early stage and it does not have enough labeled datasets from previous observations. When link blockage occurs, the MS and BS use conventional recovery schemes to select the best beam to compute the best beams at (\(t\)) th time step for learning period \(T_{\textit{learn}}\). However, the network here collects observed data during this learning period \(T_{\textit{learn}}\). Now if the signal level and the SNR at the MS drops below a threshold level, \(y_{\text{MS}}\)\(<\)\(\delta_{\textit{th}}\) and \(\delta_{\textit{init}}\)\(<\)\(\delta_{\textit{th}}\), respectively, then the BS anticipates that a beam blockage will occur in the subsequent (\(t+1\)) th time step, hence it aims to find an alternative beam indices (\(c^{t}_{i}\), \(p^{t}_{j}\)) that yield the highest signal level and optimum SNR, i.e., y testing the signal strength and instantaneous capacity at every pair \(\forall c^{t}_{i}\in C_{\text{MS}}\) and \(\forall p^{t}_{j}\)\(\in\)\(P_{\text{BS}}\). The result is a unique pair that results in the highest signal and instantaneous SNR, i.e., \((c^{t}_{i}\), \(p^{t}_{j})\)\({}_{\textit{bs}}\)\(\vdash\)\(max(y_{\text{MS}})\). The output of this mode is the best alternative pair and a labeled dataset after \(T_{\textit{learn}}\) elapsed time period that include multiple pairs of (\(c^{t}_{i}\), \(p^{t}_{j}\))\({}_{\textit{bs}}\) at different (\(t\)) th time steps. During this mode, the MS and BS will feed their best beams at every time step into the deep learning algorithm for use during the training process. After the model is well-trained, the MS and BS estimate the next primary beam to be used if blockage occurs, as shown in Mode II. Training Mode (Mode II): The network now has learned incoming traffic and indices of frequently blocked beams. When the signal level drops below the threshold level, \(y_{\text{MS}}\)\(<\)\(y_{\textit{th}}\) and \(\delta_{\textit{init}}\)\(<\)\(\delta_{\textit{th}}  
best subsequent beam. This mode constitutes the processing and training phases for the reconfigurable learning model and operates as follows. Processing Phase: Each cell in the LSTM network is composed of a state consisting of input \(g_{t}^{in}\), input modulation \(g_{t}^{mod}\), forget \(g_{t}^{f}\) and output \(g_{t}^{out}\) gates that determine information entering the cell state.