## 4 A Heuristic Algorithm to Obtain the Hard Delay Constraint Policy
### The Heuristic Algorithm  
The optimization variable \(g_{th}(\zeta,k,l)\) in optimization problem (51) spans a total of \((K+1)\times K\times L(K)\) dimensions. Given the non-convex nature of this high-dimensional optimization problem, finding an optimal solution poses a significant challenge with no readily available standard algorithm. To address this, we introduce a suboptimal heuristic algorithm to explore solutions to the truncated channel inversion policy. Subsequently, we leverage gradient descent, initializing the process with the suboptimal policy solution to iteratively refine and approach an optimal policy. Specifically, we propose the first heuristic algorithm, setting  
\[g_{th}(\zeta,k,l)=g_{th}. \tag{60}\]  
Following this, we employ a one-dimensional exhaustive search policy to obtain a suboptimal solution to optimization problem (51). Utilizing this suboptimal policy as the initial point, we iteratively resolve the problem by employing both gradient descent and an exact line search method, as shown in Algorithm 1. ```
1:Initialize system parameters, e.g., \(K\), \(L(K)\), and channel distribution. 2:Determine the policy for \(g_{th}(\zeta,k,l)\in[0,+\infty)\) with the first heuristic policy or the second heuristic policy. 3:Set the optimized heuristic policy \(g_{th}(\zeta,k,l)=g_{th}^{*}\) as the initial point for subsequent optimization. 4:while\(|P_{ave}(\boldsymbol{g_{th}})-P_{ave}(\boldsymbol{g_{th}}+t\Delta g_{th})|<\zeta\)do
5:Determine a descent direction \(\Delta g_{th}\). 6:\(t=\arg\min_{s\in[0,+\infty)}P_{ave}(\boldsymbol{g_{th}}-s\Delta g_{th}).\)
7:\(\boldsymbol{g_{th}}=g_{th}-t\Delta g_{th}\). 8:endwhile
```  
**Algorithm 1** Algorithm combining a heuristic algorithm and gradient descent approach When using the gradient descent algorithm, it is necessary to compute the derivative of \(P_{ave}\) with respect to \(g_{th}(\zeta,k,l)\). As such, we define  
\[f_{1}(g_{th}(\zeta,k,l)) =\int_{g_{th}(\zeta,k,l)}^{\infty}\frac{PMe^{-x}(1-e^{-x})^{M-1}}{x}dx, \tag{61}\] \[f_{2}(g_{th}(\zeta,k,l)) =p(l|k,\zeta),\] (62) \[f_{3}(g_{th}(\zeta,k,l)) =\pi^{\boldsymbol{\mathcal{F}}}(\zeta). \tag{63}\]  
Based on this, we next formulate  
\[f_{4}(g_{th}(\zeta,k,l)) =\sum_{\zeta\in\mathcal{Q}}\sum_{k=1}^{K}\sum_{l=0}^{L(\zeta)}f_{ 1}(g_{th}(\zeta,k,l))f_{2}(g_{th}(\zeta,k,l))f_{3}(g_{th}(\zeta,k,l)), \tag{64}\] \[f_{5}(g_{th}(\zeta,k,l)) =\frac{f_{4}(g_{th}(\zeta,k,l))}{\sum\limits_{\xi\in\mathcal{Q}}f _{3}(g_{th}(\zeta,k,l))\zeta}\, \tag{65}\]  
where \(f_{5}(g_{th}(\zeta,k,l))\) is the objective function of problem (51), i.e., the average transmission power \(P_{ave}\) in Theorem 4. Next, we compute the derivative of \(f_{i}(g_{th}(\zeta,k,l)),\ i=1,2,3\), with respect to \(g_{th}(\zeta,k,l)\). Firstly, the derivative of \(f_{1}(g_{th}(\zeta,k,l))\) is  
\[\frac{df_{1}(g_{th}(\zeta,k,l))}{dg_{th}(\zeta,k,l)}=-\frac{PMe^{-g_{th}(\zeta, k,l)}\Big{(}1-e^{-g_{th}(\zeta,k,l)}\Big{)}^{M-1}}{g_{th}(\zeta,k,l)}. \tag{66}\]  
Secondly, we note that  
\[f_{2}(g_{th}(\zeta,k,l))=p(l|k,\zeta)=\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\! \!\!\!\  
Although the proposed algorithm is heuristic in nature, the simulation results demonstrate its superior performance. The algorithm shows a noticeable improvement over conventional transmission policies.  
We introduce an improved policy for the proposed heuristic algorithm by considering different channel thresholds for different numbers of encoded data packets \(\zeta\). Specifically, we propose the second heuristic algorithm, setting  
\[g_{th}(\zeta,k,l)=g_{th}(\zeta). \tag{75}\]  
Subsequently, we formulate a series of subproblems aimed at minimizing the average power components corresponding to different values of \(\zeta\in\mathcal{Q}\):  
\[\min_{\{g_{th}(\zeta)\}}\sum_{k=1}^{K}\sum_{l=0}^{L(\zeta)}p(l|k,\zeta)\bar{P}( g_{th}(\zeta,k,l)),\forall\zeta\in\mathcal{Q}. \tag{76}\]  
Using a similar method to Algorithm 1, we initialize the thresholds based on the solutions of the subproblems (76) and iteratively solve problem (51).