## 4 Solution Approach
### Personalized Federated Learning with Attention Mechanism
The attention weights \(\vec{\mathfrak{V}}_{t}\) from past states at time \(t\) are gathered from the UAV's context \(\vec{\mathfrak{T}}_{t}\) using an attention mechanism \(A_{t}\) as \(\vec{\mathfrak{V}}_{t}=A_{t}(\vec{\mathfrak{T}}_{t})\), where \(A\) is a deterministic attention mechanism that leads to a sequence of functions \(\{A_{t}\}_{t}\), \(A_{t}:\to[0,1]^{t}\). Here, \(A\) is a set ofactions that maps a UAV's context \(\vec{\gamma}_{t}\) to a set of attention weights \(\vec{\vec{\psi}}_{t}\). The model output is a sequence of attention weights at each time step that enables to learn the model hyper-parameter \(\theta\) and to infer a UAV's current state from the posterior distribution \(p_{\theta}(\vec{\vec{\Psi}}_{t}\,|\,\vec{\tau}_{t})\). Here, we utilize variational learning to jointly learn the model hyper-parameter \(\theta\) and an inference network assists to approximate the posterior distribution \(p_{\theta}(\vec{\vec{\Psi}}_{t}\,|\,\vec{\tau}_{t})\). Using variational learning, we maximize the expected lower bound as  
\[\log p_{\theta}(\vec{\vec{\tau}}_{T})\geq\mathbb{E}_{m_{\phi}}\Big{[}\log p_{ \theta}(\vec{\vec{\tau}}_{T},\vec{\vec{\Psi}}_{T})-\log m_{\phi}(\vec{\vec{ \Psi}}_{T}\,|\,\vec{\tau}_{T})\,\Big{]} \tag{21}\]  
where \(m_{\phi}(\vec{\vec{\Psi}}_{T}\,|\,\vec{\vec{\tau}}_{T})\) is an intermediate variational distribution that approximates the posterior distribution \(p_{\theta}(\vec{\vec{\Psi}}_{T}\,|\,\vec{\vec{\tau}}_{T})\). This intermediate variational distribution is modeled as \(m_{\phi}(\vec{\vec{\Psi}}_{T}\,|\,\vec{\vec{\tau}}_{T})\) using a jointly trained inference network as  
\[\phi^{*},\theta^{*} = \arg\max_{\phi,\theta}\,\mathbb{E}_{m_{\phi}}\Big{[}\log p_{ \theta}(\vec{\vec{\tau}}_{T},\vec{\vec{\Psi}}_{T})-\log m_{\phi}(\vec{\vec{ \Psi}}_{T}\,|\,\vec{\tau}_{T})\,\Big{]} \tag{22}\]  
Hence, by calculating the estimations of \(\theta\) and \(\phi\) from the training data, we calculate \(p_{\theta}(\vec{\vec{\tau}}_{T},\vec{\vec{\Psi}}_{T})\) to extract the environmental knowledge, and the inference network \(m_{\phi}(\vec{\vec{\Psi}}_{T}\,|\,\vec{\vec{\tau}}_{T})\) to infer the trajectory of the UAV. The inference network \(m_{\phi}(\vec{\vec{\Psi}}_{T}\,|\,\vec{\vec{\tau}}_{T})\) infers the structure of the posterior distribution. \[p_{\theta}(\vec{\vec{\Psi}}_{T}\,|\,\vec{\vec{\tau}}_{T})=p_{\theta}(\psi_{1} \,|\,\vec{\vec{\tau}}_{T})\prod_{t=1}^{T}p_{\theta}(\psi_{t}\,|\,\vec{\vec{ \psi}}_{t-1},\vec{\vec{\Psi}}_{t-1},\vec{\vec{\tau}}_{t:T}) \tag{23}\]  
For the inference network, for all TTIs,  
\[m_{\phi}(\vec{\vec{\Psi}}_{T}\,|\,\vec{\vec{\tau}}_{T})=m_{\phi}(\psi_{1}\,| \,\vec{\vec{\tau}}_{T})\prod_{t=1}^{T}m_{\phi}(\psi_{t}\,|\,\vec{\vec{\psi}}_ {t-1},\vec{\vec{\Psi}}_{t-1},\vec{\vec{\tau}}_{t:T}). \tag{24}\]  
The attention weights generated in \(A\) are used to infer the statistical characteristics of \(\psi_{t}\). We calculate an estimate of the distribution \(\approx p_{\theta}(\psi_{t}\,|\,\vec{\vec{\tau}}_{t})\) to consider the impact of past states with their relevant contributions, which are indicated by the attention weights. We estimate the gradients via stochastic backpropagation and update the parameters of the attention mechanism from their maximum likelihood estimates. The attention function enables sharing of the parameters between the vehicle's clusters to accelerate learning. The attention function \(m_{\phi}(\psi_{t}\,|\,\vec{\vec{\tau}}_{T})\) stores the attention weights with \(\vec{\vec{\Psi}}_{t-1}\) and \(\vec{\vec{\tau}}_{t:T}\) for state transitions. The inference network leads the posterior network to learn the relevant trajectory coordinates and the variance of gradient estimates. This enables us to precisely identify the UAV's location and the vehicles to which the resources should be allocated in a TTI.