# Minimization of Average Peak Age of Information for Timely Status Updates in Two-Hop IoT Networks
## 5 Average PAoI Minimization  
Based on the analysis in Section 4, we minimize the average PAoI \(\bar{A}\) through the JBG optimization, treating the blocklengths \(L_{1},L_{2}\) and the group size \(K\) as control variables. We begin by formulating the average PAoI as a function \(\bar{A}=\bar{A}(K,L_{1},L_{2})\) defined on the domain \(\mathcal{D}:=\mathcal{K}\times\mathbb{N}\times\mathbb{N}\), where \(\mathcal{K}\) denotes the set of all divisors of \(N\). Based on the relation  
\[\min_{(K,L_{1},L_{2})\in\mathcal{D}}\bar{A}(K,L_{1},L_{2})=\min_{K\in\mathcal{ K}}\min_{(L_{1},L_{2})\in\mathbb{N}^{2}}\bar{A}(K,L_{1},L_{2}),\]  
the average PAoI minimization is performed in two sequential steps. In the first step, we fix \(K\in\mathcal{K}\) and solve \[\big{(}L_{1}^{*}(K),L_{2}^{*}(K)\big{)}=\operatorname*{argmin}_{(L_{1},L_{2})\in \mathbb{N}^{2}}\tilde{A}(K,L_{1},L_{2}). \tag{11}\]  
Then, the minimum average PAoI for a given group size \(K\) is obtained as  
\[\tilde{A}_{\min}(K) :=\min_{(L_{1},L_{2})\in\mathbb{N}^{2}}\tilde{A}(K,L_{1},L_{2})\] \[=\tilde{A}\big{(}K,L_{1}^{*}(K),L_{2}^{*}(K)\big{)}\] \[=\left(\frac{K+1}{2}+\frac{N}{p_{s}}\right)\frac{L_{1}^{*}(K)}{B }+\left(1+\frac{N}{p_{s}K}\right)\frac{L_{2}^{*}(K)}{B}. \tag{12}\]  
In the second step, we determine the optimal group size by minimizing \(\tilde{A}_{\min}(K)\) over all \(K\in\mathcal{K}\):  
\[K^{*}=\operatorname*{argmin}_{K\in\mathcal{K}}\tilde{A}_{\min}(K). \tag{13}\]  
Then, the optimal blocklengths for transmissions in the first and second hops are given by  
\[\big{(}L_{1}^{*},L_{2}^{*}\big{)}=\big{(}L_{1}^{*}(K^{*}),L_{2}^{*}(K^{*}) \big{)}. \tag{14}\]  
Finally, the minimum average PAoI is obtained as  
\[\tilde{A}_{\min} :=\min_{(K,L_{1},L_{2})\in\mathcal{D}}\tilde{A}(K,L_{1},L_{2})\] \[=\tilde{A}(K^{*},L_{1}^{*},L_{2}^{*})\] \[=\left(\frac{K^{*}+1}{2}+\frac{N}{p_{s}}\right)\frac{L_{1}^{*}}{B }+\left(1+\frac{N}{p_{s}K^{*}}\right)\frac{L_{2}^{*}}{B}. \tag{15}\]  
In the above procedure, solving (11) is crucial to arrive at (13)-(15). To this end, we relax the constraint \((L_{1},L_{2})\in\mathbb{N}^{2}\) to \((L_{1},L_{2})\in\mathbb{R}_{+}^{2}\) and solve the system of equations \(\frac{\partial\tilde{A}}{\partial L_{1}}=0\) and \(\frac{\partial\tilde{A}}{\partial L_{2}}=0\). Note that such relaxation has been used in the recent literature to optimize blocklength, e.g., [15; 16; 17; 18]. Differentiating \(\tilde{A}=\tilde{A}(K,L_{1},L_{2})\) in (10) with respect to \(L_{i}\) for \(i=1,2\), we obtain  
\[\big{(}L_{1}^{*}(K),L_{2}^{*}(K)\big{)}=\operatorname*{argmin}_{(L_{1},L_{2})\in \mathbb{N}^{2}}\tilde{A}(K,L_{1},L_{2}). \tag{11}\]0 \[\big{(}L_{1}^{*}(K),L_{2}^{*}(K)\big{)}=\operatorname*{argmin}_{(L_{1},L_{2})\in \mathbb{N}^{2}}\tilde{A}(K,L_{1},L_{2}). \tag{11}\]1  
where \(\frac{\partial}{\partial L_{i}}\frac{1}{p_{s}}\) for \(i=1,2\) is derived as  
\[\big{(}L_{1}^{*}(K),L_{2}^{*}(K)\big{)}=\operatorname*{argmin}_{(L_{1},L_{2})\in \mathbb{N}^{2}}\tilde{A}(K,L_{1},L_{2}). \tag{11}\]2  
with  
\[\big{(}L_{1}^{*}(K),L_{2}^{*}(K)\big{)}=\operatorname*{argmin}_{(L_{1},L_{2})\in \mathbb{N}^{2}}\tilde{A}(K,L_{1},L_{2}). \tag{11}\]3  
We note that the partial derivatives in (16) and (17) represent the rate of change of the average PAoI with respect to the blocklengths \(L_{1}\) and \(L_{2}\), with \(L_{2}\) and \(L_{1}\) held fixed, respectively. In other words, they quantify the sensitivity of the average PAoI to variations in blocklength. The right-hand sides of (16) and (17) explicitly capture the effects of the control variables \(K\), \(L_{1}\), and \(L_{2}\). In particular, the term \(\frac{1}{p_{s}}\) corresponds to the average number of failed transmissions between two consecutive successful decodings at the edge server Consequently, the partial derivative \(\frac{\partial}{\partial L_{1}}\frac{1}{\rho_{k}}\) in (18) characterizes how this average changes with the blocklength \(L_{i}\), highlighting the tradeoff between reliability and transmission delay.