# Joint Trajectory and Communication Design for Buffer-Aided Multi-UAV Relaying Networks
## 3 The Proposed Algorithm
### Sub-Problem 1: Optimizing Relay Selection and UAV Power Control of a Given UAV Trajectory  
For a given UAV trajectory, the relay selection and transmit power allocation of Sub-problem 1 can be expressed as the following problem:  
\[\max_{A,P} \frac{1}{N}\sum_{n=2}^{N}\sum_{k=1}^{K}a_{k,D}\left[n\right]\log _{2}\left(1+\frac{p_{k}\left[n\right]\left|h_{k,D}\left[n\right]\right|^{2}}{ \sigma^{2}}\right) \tag{19}\] \[s.t. \left(6\right)-\left(10\right),\left(18b\right)\]  
We note that Problem (19) is still non-convex because the constraints in (6)-(8) involve integer constraints and the information causality constraint in (18b) is non-convex. To solve the integer constraints, we relax the binary variables in (8) into continuous variables, i.e.,\(\left\{S,D\right\},\forall k,n\). Furthermore, the slack variables \(\left\{u_{k,m}\left[n\right]\right\}\) are introduced. First, we consider the following problem:  
\[\max_{A,P,\left\{u_{k,m}\left[n\right]\right\}}\frac{1}{N}\sum_{n=2 }^{N}\sum_{k=1}^{K}a_{k,D}\left[n\right]u_{k,D}\left[n\right] \tag{20a}\] \[s.t. 0\leq a_{k,m}\left[n\right]\leq 1,m\in\left\{S,D\right\},\forall k,n\] (20b) \[\log_{2}\left(1+\frac{p_{k}\left[n\right]\left|h_{k,D}\left[n \right]\right|^{2}}{\sigma^{2}}\right)\geq u_{k,D}\left[n\right]\] (20c) \[\log_{2}\left(1+\frac{p_{S}\left|h_{k,S}\left[n\right]\right|^{2} }{\sigma^{2}}\right)\geq u_{k,S}\left[n\right]\] (20d) \[\sum_{i=2}^{n}a_{k,D}\left[n\right]u_{k,D}\left[n\right]\leq\sum_ {i=1}^{n}a_{k,S}\left[n\right]u_{k,S}\left[n\right],\forall k,n=2,\ldots,N\] (20e) \[\left(\ref{eq:20c}\right),\left(\ref{eq:20d}\right),\left(\ref{eq:20d}\right)\]  
It can be proven that when the constraints (20c) and (20d) take the equal sign, there is an optimal solution for Problem (20). Therefore, Problems (20) and (19) have the same optimal value and optimal solutions of \(A\) and \(P\). Next, we concentrate on solving Problem (20). However, Problem (20) is still non-convex since the variables \(A\) and slack variables \(\left\{u_{k,m}\left[n\right]\right\}\) are coupled and the objective function is non-concave. Generally, a maximization problem with a non-concave objective function is non-convex and thus difficult to solve optimally. Aiming at this problem, a local convex approximation method is adopted, which ensures the convergence to the local optimal solution. Thus, \(a_{k,m}\left[n\right]u_{k,m}\left[n\right],m\in\left\{S,D\right\}\) can be reformulated as [22]:  
\[a_{k,m}\left[n\right]u_{k,m}\left[n\right]=\frac{\left(a_{k,m}\left[n\right]+ u_{k,m}\left[n\right]\right)^{2}}{2}-\frac{a_{k,m}^{2}\left[n\right]+u_{k,m}^{2} \left[n\right]}{2} \tag{21}\]  
Then, as we all know that the first-order Taylor expansion of a convex function at any point is its global lower bound [23], the lower bound function of \(\left(a_{k,m}\left[n\right]+u_{k,m}\left[n\right]\right)^{2}\) at the points \(a_{k,m}^{f}\left[n\right]\) and \(u_{k,m}^{f}\left[n\right]\) can be expressed as:  
\[\left(a_{k,m}\left[n\right]+u_{k,m}\left[n\right]\right)^{2} \geq\left(a_{k,m}^{f}\left[n\right]+u_{k,m}^{f}\left[n\right] \right)^{2}+2\left(a_{k,m}^{f}\left[n\right]+u_{k,m}^{f}\left[n\right]\right) \left(a_{k,m}\left[n\right]-a_{k,m}^{f}\left[n\right]\right)\] \[s.t. \left(6\right)-\left(10\right),\left(18b\right)\]0  
Due to \(-a_{k,m}^{2}\left[n\right]\) and \(-u_{k,m}^{2}\left[n\right]\) being still non-convex, the constraint (20e) is non-convex. However, we find that the value of \(a_{k,m}^{2}\left[n\right]\) is approximate to zero or one and \(0\leq a_{k,m}\left[n\right]\leq 1\), so we let \(a_{k,m}\left[n\right]\) replace \(a_{k,m}^{2}\left[n\right]\). Furthermore, the value of \(u_{k,m}^{2}\left[n\right]\) is between zero and one; hence, \(u_{k,m}^{2}\left[n\right]\leq u_{k,m}\left[n\right]\).