# DNNs Based Computation Offloading for LEO Satellite Edge Computing
## 5 Proposed Algorithm
Therefore, when satisfying the bandwidth constraint, the utility function value of the system is only related to the transmission delay of the user \(n\) offloading its task \(m\) to the edge server, so the optimization problem (P2) becomes an optimization problem (P3):  
\[(\text{P3}):J^{*}(I,\mathbf{x})=\min\limits_{\mathbf{b}}\sum\limits_{n=1}^{N}\sum \limits_{m=1}^{M}\frac{l_{mm}}{r_{n}}x_{nm} \tag{12}\]  
\[\text{subject to }\sum\limits_{n=1}^{N}b_{n}\leq B, \tag{12a}\] \[b_{n}\geq 0,\forall n\in N. \tag{12b}\]  
In this paper, the number of users is \(N\), each user has \(M\) different tasks, and this paper thinks that each user generates one computing task in the same time slot each time, and each iteration consists of \(M\) time slots, so each iteration can process all tasks. Therefore, using the Lagrangian multiplier method for the \(N\) computing tasks generated in the \(m\)th time slot, the Lagrangian function of problem P3 can be expressed as:  
\[G=\sum\limits_{n=1}^{N}\frac{l_{nm}}{r_{n}}x_{nm}+\lambda(\sum\limits_{n=1}^{N }b_{n}-B). \tag{13}\]  
In the above formula, \(l_{mm}\) represents the size of the \(m\)th computing task generated by \(n\)th user, \(x_{nm}\) represents the offloading decision for the \(m\)th computing task generated by \(n\)th user, \(b_{n}\) represents the bandwidth allocated to the \(n\)th user, and \(r_{n}\) represents the transmission rate when the \(n\)th user offloads the task. To obtain the optimal solution of problem P3, the KKT condition must be satisfied:  
\[\left\{ \begin{array}{l}\frac{\partial G}{\partial b_{n}}=-\frac{l_{mm}x_{nm} }{l_{n}^{2}\log_{2}\left(1+\frac{h_{m}x_{nm}}{\sigma}\right)}+\lambda=0\\ \sum\limits_{n=1}^{N}b_{n}-B=0\end{array} \right.. \tag{14}\]  
By solving the KKT condition (14), we can obtain the optimal bandwidth allocation scheme for each user in the system:  
\[b_{n}=\frac{\left(l_{nm}x_{nm}\right)^{1/2}\cdot B}{\left[\log_{2}\left(1+ \frac{h_{m}p_{n}}{\sigma}\right)\right]^{1/2}\cdot\sum\limits_{n=1}^{N}\left( \frac{l_{nm}x_{nm}}{\log_{2}\left(1+\frac{h_{m}p_{n}}{\sigma}\right)}\right)^ {1/2}}. \tag{15}\]  
The specific derivation process of (15) can be found in Appendix A. Thus far, we have come up with the optimal bandwidth allocation scheme after obtaining the offloading decisions. During the DNN update process, the system will use a gradient descent algorithm to minimize the average cross-entropy loss function to update the parameter value \(\mathbf{\theta}_{d}\) of \(d\) DNNs. Algorithm 1 shows a proposed algorithm for the computing offloading and bandwidth allocation in LEO satellite edge computing. Specifically, the input of our algorithm is the computing task size of the \(i\)th iteration, and the output is the optimal offloading decisions of the \(i\)th iteration. First, \(d\) DNNs are initialized with random parameter \(\mathbf{\theta}_{d}\) and the memory structure is emptied. Then, we input the computing task size \(\mathbf{I}^{i}\) of the \(i\)th iteration into \(d\) DNNs to generate \(d\) candidate offloadingdecisions \(\mathbf{x_{d}}\), allocate bandwidth for each user by the optimal bandwidth allocation scheme (15), and calculate the system utility function values \(\mathbf{J_{d}}\) by using the candidate offloading decisions and the optimal bandwidth allocation scheme. From \(d\) system utility function values, we select the candidate offloading decisions corresponding to the smallest system utility function value as the optimal offloading decisions of the \(i\)th iteration, and output the optimal offloading decisions \(\mathbf{x_{i}^{*}}\). Finally, we store the computing task size \(\mathbf{l^{i}}\) in the \(i\)th iteration and the optimal offloading decisions \(\mathbf{x_{i}^{*}}\) in the \(i\)th iteration into the memory to train DNNs to improve the system performance. ```
1:The user's computing tasks \(\mathbf{l^{i}}\) in the \(i\)th iteration. 2:Optimal offloading decisions \(\mathbf{x_{i}^{*}}\) in the \(i\)th iteration.