## 4 Problem Formulation  
We formulate an optimization problem to determine the optimal trajectory of UAV in C-V2X communication, where the UAV maximizes the number of served vehicles adhering to QoS and power constraints. In a transmission window (\(L_{w}\)), we maximize the UAV utility considering the priority of data transmission and link connection time, as well as minimizing the UAV energy consumption formulated as a bin packing problem. We consider the uplink and downlink capacities in vehicle edge servers for transmission rate maximization, energy minimization, and delay minimization. Due to the spatial and temporal correlations between the UAV energy and trajectory, the proposed optimization is a non-convex problem. The objective function and constraints are non-convex with respect to the backhaul link outages and transmission latency, leading to a mixed-integer non-convex optimization problem. Hence, the problem (\(\mathbf{P1}\)) of energy-efficient computing resource allocation in UAV is formulated as follows in Equation (10):\[ \begin{split} P1:&\min_{\psi^{(t)},\mathbf{w}^{(t)},\mathbf{ \mathcal{D}}^{(t)},\mathcal{T}}\Bigg{\{}w_{1}\underbrace{\Bigg{[}T\tau_{u}+ \sum_{t=1}^{T}\min\biggl{(}\max_{v\in\mathcal{V}}(d_{v}^{t}),\tau_{d}\biggr{)} \Bigg{]}}_{SP_{1}}+\\ & w_{2}\underbrace{\Bigg{[}\sum_{t=1}^{T}\sum_{v\in\mathcal{V}} \mathcal{D}_{v}^{(t)}\min(d_{v}^{(t)},\tau_{d})\Bigg{]}}_{SP_{2}}+w_{3} \underbrace{\Bigg{[}\sum_{t=1}^{T}\sum_{v\in\mathcal{V}}l_{v}^{(t)}\Bigg{]}}_{ SP_{3}}+\\ &\min_{\mathbf{\
u},\mathcal{P}_{1},l_{v}}\underbrace{\sum_{t=1}^{T} \Biggl{(}e_{i}(t)+\sum_{j\in\mathcal{V}}\sum_{k\in\mathcal{K}}t_{i}p_{i,j}^{( k)}(t)\Biggr{)}}_{SP_{4}}\\ \end{split} \] (10) subject to \[ \begin{split} C1:&\sum_{t=1}^{T}(1-l_{v}^{(t)})D _{v}^{(t)}=B_{v}^{(t)},\forall v\in\mathcal{V}\\ C2:&\mathcal{D}_{v}^{(t)}\in[\mathcal{D}_{min}, \mathcal{D}_{max}],\forall v\in\mathcal{V},\forall t\in\mathcal{T}\\ C3:&\mathcal{D}_{i}(t)\leq\mathcal{D}_{max}\text{ and } \mathcal{D}_{i}(T)=0\\ C4:&\psi_{v}^{(t)}\in\{0,1\},\forall n\in\mathcal{V}, \forall t\in\mathcal{T}\\ C5:& w_{n}^{(t)}\in\{1,\ldots,V\},\forall v\in \mathcal{V},\forall t\in\mathcal{T}\\ C6:&||\mathbf{q}_{i}(t+1)-\mathbf{q}_{i}(t)||\leq v_{max}(t)t_{ i+1}\\ C7:&||\mathbf{q}_{i}(t+1)-\mathbf{q}_{i}(t)||\geq d_{min}\\ \end{split}  \tag{12}\] \[ \begin{split} C8:&\mathbf{q}_{(x,y)}=\mathbf{q}_{(x _{0},y_{0})}\cdot e^{-\alpha\left(\frac{2}{\alpha^{2}}+\frac{2}{\beta^{2}} \right)}+\mathcal{H}\\ C9:& w_{max}(0)=\mathcal{D}_{m}\text{ and }w_{max}(T)=0\\ \end{split}  \tag{13}\]  
\[ \begin{split} C10:&\zeta_{i,j}^{(k)}(t)\in\{0,1\} \text{ and }s_{i,m}(t)\in\{0,1\}\\ C11:& s_{i}(b_{i}^{(n)},x^{(n)},y^{(n)})\geq\varrho_{i}s_{i }^{min},\quad\forall n,i\in\mathcal{I}\\ C12:& 0\leq b_{i}^{(n)}\leq\varrho_{i},\quad\forall n,i \in\mathcal{V}\\ C13:& D_{n}(\{\mathbf{q}(t)\},\{\mathbf{a}(t)\})=\int_{0}^{T}a_{k}(t)s _{n,\max}(\mathbf{q}(t))dt\\ C14:& a_{k}(t)=\{0,1\},\forall v\in\mathcal{V},t\in \mathcal{T}\\ \end{split}  \tag{14}\]  
where \(P1\) is a multi-objective optimization problem. The constraint \(C1\) is an indicator of the status of a TTI. It is identified as a binary value, \(0\) or \(1\), implying whether, in the \(i\)th TTI, the UAV is communicating with a vehicle or is idle. The constraints \(C2\) and \(C3\) imply that a vehicle is served by the UAV in the current \(L_{w}\) subject to an upper bound on delay given by \(D_{max}\). The constraints \(C4\) and \(C5\) impose an upper bound on the size of the packets (\(\psi\)) and model weights transmitted from a vehicle to the UAV. This ensures that the queue at the UAV is not overloaded and imply that the UAV computing resources consumed do not exceed the maximum baseband processing capacity. The constraints \(C6\) and \(C7\) restrict the UAV trajectory to ensure that the UAV is not out of the vehicle's coverage range for a long time and serves at least one vehicle in each TTI.