## 4 MMS-DSR Mathematical Formalization  
MMS-DSR is designed with a unique multi-metric scoring function that adapts in real-time to the dynamic nature of Mobile Ad-Hoc Networks, incorporating beamforming strategies to enhance signal quality and reliability. This scoring function serves as the backbone for making robust and efficient routing decisions, especially in the complex and rapidly changing environments of smart cities. The scoring function \(S(r,t)\) in MMS-DSR is defined as follows:  
\[S(r,t)=\alpha\cdot\sum_{i=1}^{n}w_{i}(t)\cdot m_{i}(r)+\delta\cdot P_{\text{ prediction}}(r,t)+\lambda\cdot BF(r,t) \tag{2}\]  
In the Equation (2), \(m_{i}(r)\) represents the metrics for each route, while \(w_{i}(t)\) denotes weights that vary with time. The term \(\alpha\) serves as a coefficient for the real-time summation component and \(\delta\) acts as a factor that incorporates the predictive reliability score, denoted as \(P_{\text{prediction}}(r,t)\). Additionally, \(\lambda\) functions as a weighting factor for the beamforming score expressed as \(BF(r,t)\). The weights \(w_{i}(t)\) are dynamically adjusted based on real-time network analytics and predictions from the Machine Learning-Based Prediction Unit to reflect the changing urban conditions. This adjustment is given by the following:  
\[w_{i}(t+1)=w_{i}(t)-\eta\frac{\partial f(w,t)}{\partial w_{i}(t)} \tag{3}\]  
where \(\eta\) represents the learning rate and \(\frac{\partial f(w,t)}{\partial w_{i}(t)}\) is the gradient of the cost function with respect to weight \(w_{i}(t)\). The cost function \(J(w,t)\) is designed to minimize the difference between the current metric values and their predicted values, ensuring that the weights reflect the most relevant network conditions. The cost function is defined as follows:  
\[J(w,t)=\sum_{i=1}^{n}\left(\frac{m_{i}(r,t)-\hat{m}_{i}(r,t)}{\hat{m}_{i}(r,t)} \right)^{2} \tag{4}\]  
The term \(m_{i}(r,t)\) denotes the network metric for route \(r\) at time \(t\) and \(\hat{m}_{i}(r,t)\) is the predicted value of the metric provided by the Machine Learning-Based Prediction Unit. In order to understand how the parameters \(P_{\text{prediction}}(r,t)\) and \(BF(r,t)\) are obtained it is necessary to introduce Hybrid CNN-LSTM models. Hybrid Deep Learning models combining CNN and LSTM can improve the prediction accuracy [29; 30; 31; 32]. The spatial and temporal features can be thoroughly extracted using hybrid models, where CNN is utilized to capture the spatial features of traffic data, while LSTM is employed to extract the temporal features. Let us consider traffic state data of \(K\) locations \(s_{i}\) (\(i=1,2,\ldots,K\)) as inputs to predict the traffic states at times \(t,t+1,\ldots,t+h\). The real-time measured data can be arranged, as explained in [32; 33; 34], into a matrix:  
\[S= \begin{bmatrix}s_{1}\\ s_{2}\\ \vdots\\ s_{K}\end{bmatrix} = \begin{bmatrix}s_{1,t-N}&s_{1,t-N+1}&\cdots&s_{1,t-1}\\ s_{2,t-N}&s_{2,t-N+1}&\cdots&s_{2,t-1}\\ \vdots&\vdots&\ddots&\vdots\\ s_{K,t-N}&s_{K,t-N+1}&\cdots&s_{K,t-1}\end{bmatrix}  \tag{5}\]In \(P_{\text{prediction}}(r,t)\), the matrix element \(s_{k,t}\) represents a vector that includes latency (\(L\)), bandwidth (\(B\)), reliability (\(R\)), and beamforming efficacy (\(BE\)). In \(BF(r,t)\), the element \(s_{k,t}\) contains the Channel State Information (\(CSI\)). The real-time data matrix \(S\) is processed by a CNN, which extracts high-level spatial features. These features are then passed into LSTM models to produce predictions. The high-level spatial feature map produced by the CNN can be expressed as follows:  
\[X= \begin{bmatrix}x_{1}\\ x_{2}\\ \vdots\\ x_{L}\end{bmatrix} = \begin{bmatrix}x_{1,t-N}&x_{1,t-N+1}&\cdots&x_{1,t-1}\\ x_{2,t-N}&x_{2,t-N+1}&\cdots&x_{2,t-1}\\ \vdots&\vdots&\ddots&\vdots\\ x_{L,t-N}&x_{L,t-N+1}&\cdots&x_{L,t-1}\end{bmatrix}