## 3 Joint Optimization Algorithm Design
### Joint Optimization Algorithm  
After obtaining the association relationship between the buoys and UAVs, we aimed to determine the UAV-OBS association relationship. The considered association relationship subproblem of the UAV-OBS with the given \(\mathbf{V}\), \(\mathbf{\psi}\) and \(\mathbf{P}\) is formulated as  
\[(\mathrm{P4}):\max_{\mathbf{A}}\sum_{k=1}^{K}\sum_{u=1}^{U}R_{u,0,k} \tag{28}\] \[\text{s.t.C4,C6,C11,C12,C15,C16}.\]  
Although agents choose to offload the data, they cannot determine whether the actions satisfy the relevant constraints of subproblem \(\mathrm{P4}\). Hence, a heuristic algorithm of the UAV-OBS association is proposed to guarantee that the UAV's actions satisfy these constraints. The detailed procedure is shown in Algorithm 3. In particular, lines 3-10 determine whether the current action selections \(\chi_{k}\) of the UAVs satisfy the relevant constraints and update the action selections \(\chi_{k}^{\text{new}}\). In line 5, the bandwidth occupied by each UAV is not available due to the uncertainty of the UAV-OBS association. Hence, we take the maximum value \(B\) satisfying constraints C15 and C16 when solving the problem \(\mathrm{P4}\). ```
1:\(\mathcal{U}^{\text{co}},\chi^{\text{new}}_{k}\), \(V_{k},c^{\text{buoy}}_{k}\), \(\kappa_{k}\), \(\mathcal{P}=\left\{P_{u,k},\forall u\in\mathcal{U}^{\text{co}}\right\}\), and \(h_{u,m,k},\forall u\in\mathcal{U},m\in\mathcal{M}\). 2:Set \(i=0\). 3:for\(u=1\) to \(U^{\text{co}}\)do
4:\(P\text{max}=\max(\mathcal{P})\). 5: Let the transmit power of all buoys be \(P^{\text{max}}\), and delete \(P^{\text{max}}\) from \(\mathcal{P}\). 6: Obtain the preference matrix \(\mathbf{G}\) according to \(h_{u,m,k}\) and \(P^{\text{max}}\). 7: Obtain the energy consumption \(E^{\text{pr}}_{u},\forall u\in\mathcal{U}^{\text{co}}\) according to \(V_{k}\). 8: Obtain the energy consumption of all buoys \(E_{m},\forall m\in\mathcal{M}\) according to \(P^{\text{max}}\). 9:for\(m=1\) to \(M\)do
10:if\(c^{\text{buoy}}_{m,k}=0\), or \(g_{u,m,k}\), \(E^{\text{pr}}_{u}\), or \(E_{m}\) does not satisfy C3 and C6 then
11: Set \(g_{u,m,k}=0\) in \(\mathbf{G}\), so as to obtain the new preference matrix \(\mathbf{G}^{\prime}\). 12:endif
13:endfor
14:for\(n=1\) to \(U^{\text{co}}\)do
15: Obtain the maximum SNR \(g^{\text{max}}\) in \(\mathbf{G}^{\prime}\). 16:if\(g^{\text{max}}\
eq 0\)then
17: Obtain the UAV number \(u\) and buoy number \(m\) corresponding to \(g^{\text{max}}\), and \(\kappa_{u,k}=m\). 18: Delete the UAV number \(u\) from \(\mathcal{U}^{\text{co}}\), and set \(\chi^{\text{new}}_{u,k}=0\). 19: Set the row \(u\) and column \(m\) of \(\mathbf{G}^{\prime}\) equal to \(0\), and then, update \(\mathbf{G}^{\prime}\). 20:else
21: break. 22:endif
23:endfor
24:if\(\mathcal{U}^{\text{co}}=\emptyset\)then
25: break. 26:endif
27:endfor
28:Let \(\kappa^{\prime}_{k}\) indicate the set of UAVs that are first transformed. 29:if UAV \(u\) is not associated with any buoy then
30: Set \(\chi^{\text{new}}_{u,k}=1\), and add the number of UAVs \(u\) to \(\kappa^{\prime}_{k}\). 31:endif
32:if\(\chi_{u,k}=1\) and \(\chi^{\text{new}}_{u,k}=1\)then
33: Set \(\chi^{\text{new}}_{u,k}=2\), and \(\kappa_{k}=-1\). Then, add the number of UAVs \(u\) to \(\kappa^{\prime}_{k}\). 34:endif
35:return\(\chi^{\text{new}}_{u,k},\kappa_{k},\kappa^{\prime}_{k}\). ```  
**Algorithm 2** SMP-based buoy-UAV association algorithm (SAA). In summary, the problem P1 could be solved effectively and efficiently with the proposed SAA, UAA, and MAHPO algorithms. The detailed process is shown in Algorithm 4. Specifically, we first obtain \(\chi_{k}\) according to the actions of the agents at time slot \(k\) in Algorithm 1. According to \(\chi_{k}\), we divide the number of UAVs into two initial groups: collection \(\mathcal{U}^{\text{co}}\) and offloading \(\mathcal{U}^{\text{of}}\). In line 8, we perform Algorithm 3 to judge \(\mathcal{U}^{\text{of}}\).