## 3 Optimal Design of Transmit Waveform and UAV Altitude
### Method for Obtaining the Optimal Solution Based on the PSO Algorithm
In this case, the fitness function, denoted by \(f_{\text{Fit}}(p_{m}^{(j)})\), becomes the objective function of problem \(\mathbf{P}_{2}^{\forall h}\), which is written as follows:  
\[f_{\text{Fit}}(p_{m}^{(j)})=\rho L_{\text{Rad}}\big{(}\mathbf{X}^{\star}(p_{m} ^{(j)}),\gamma^{\star}(p_{m}^{(j)})\big{)}+(1-\rho)L_{\text{WPT}}\big{(}\mathbf{ X}^{\star}(p_{m}^{(j)}),p_{m}^{(j)}\big{)}. \tag{28}\]  
Then, altitude \(p_{m}^{(j)}\) and velocity \(v_{m}^{(j)}\) are updated by minimizing \(f_{\text{Fit}}(p_{m}^{(j)})\). Finally, we obtain the optimal altitude, \(h^{\star}=g^{best}\), based on the PSO algorithm and then find the optimal \(\mathbf{X}(g^{best})\) and scaling factor \(\gamma(g^{best})\) by solving problem \(\mathbf{P}_{2}^{\forall h}\) with \(h=g^{best}\). The detailed procedure is described in Algorithm 1. In Algorithm 1, the overall computational complexity depends primarily on the SDP solver, which finds an optimal waveform by solving problem \(\mathbf{P}_{2}^{\forall h}\) for each particle at each iteration. In this case, the SDP solver utilizes the interior-point method, with its computational complexity depending on the number and size of both variables and the number of constraints [29; 30]. Specifically, calculating \(L_{\text{Rad}}(\mathbf{X},\gamma)\) with sample angle grids \([\theta_{i}]_{i=1}^{L}\) and \(L_{\text{WPT}}(\mathbf{X},h)\) with \(U\) EHDs in the objective function is equivalent to having additional \(L\) and \(U\) linear matrix equality constraints in the problem, respectively. Hence, the overall computational complexity of Algorithm 1 is  
\[\mathcal{O}\Big{(}\ln(1/\epsilon_{\text{SDP}})MJ\sqrt{L+2N+U}N^{4}\big{(}L+2N^ {2}+U\big{)}\Big{)}. \tag{29}\]  
where \(\epsilon_{\text{SDP}}>0\) is the prescribed accuracy of the SDP solver. Here, we note that the computational complexity of Algorithm 1, used to obtain the optimal solution, depends not only on the number of antennas (\(N\)), the number of EHDs (\(U\)), and the number of particles and iterations for the PSO algorithm (i.e., \(M\) and \(J\)) but also on the number of sample angle grids (\(L\)). Typically, \(L\) is relatively large for sophisticated beam patterns, as in our case. For example, \([\theta_{i}]_{i=1}^{L}\) is set as uniform samples in the range of \([-90^{\circ},90^{\circ}]\) with a resolution of \(0.1^{\circ}\)[23; 24]. ```
1:Input: A sampled angle grid \([\theta_{l}]_{l=1}^{L}\) and a desired transmit beam pattern \(\chi(\theta_{l})\), parameters on the channel statistics \((a_{1},b_{1},a_{2},b_{2},a_{3},b_{3})\), minimum and maximum altitude of \(H_{\min}\) and \(H_{\max}\), sum power constraint \(P_{T}\), all EHDs' horizontal distance, LoS component, and desired power, i.e., \([r_{u},\mathbf{a}_{u},p_{u}^{\mathrm{Des}}>0]_{u=1}^{L}\), coefficients for PSO algorithm \((\sigma,z_{1},z_{2})\)
2:for Particles \(m=1,2,\ldots,M\)do
3: Initialize \(p_{m}^{(0)}=H_{\min}+r_{m}^{(0)}(H_{\max}-H_{\min})\) and \(v_{m}^{(0)}=0\)
4: Initialize \(p_{m}^{best}\gets p_{m}^{(0)}\)
5: Obtain \(\mathbf{X}^{\star}(p_{m}^{best})\) and \(\mathbf{\gamma}^{\star}(p_{m}^{best})\) by solving problem \(P_{2}^{\forall h}\) with a given \(h=p_{m}^{best}\)
6: Compute the fitness function value \(f_{\text{Fit}}(p_{m}^{best})\) from (28)
7:endfor
8: Initialize \(g^{best}\leftarrow\arg\min_{[p_{m}^{best}]_{m=1}^{M}}f_{\text{Fit}}(p_{m}^{ best})\)
9:for Iterations \(j=1,2,\ldots,J\)do
10:for Particles \(m=1,2,\ldots,M\)do
11: Update \(v_{m}^{(j)}\) and \(p_{m}^{(j)}\) from (27) and (26), respectively.