## 4 Optimal Offline Power Allocation for the Time-Invariant Channel  
We first study the time-invariant channel scene where \(h_{i}=h,i=1,\ldots,N\) and the energy arrivals are \(E_{i},i=1,\ldots N\). The instantaneous transmission rate is (4); then, the optimization problem P1 can be described as  
\[\max_{\{s_{i},r_{i},l_{i}\}}\frac{1}{N}\sum_{i=1}^{N}l_{i}R\big{(}\frac{E_{i}-s _{i}+r_{i}-al_{i}}{l_{i}}\big{)} \tag{5}\]  
\[\text{s.t.}B_{i}=\sum_{j=1}^{i}\left(\alpha s_{j}-r_{j}\right)\geq 0,\;\;i=1, \ldots,N \tag{6}\]  
\[p_{i}=E_{i}-s_{i}+r_{i}-al_{i}\geq 0,i=1,\ldots,N \tag{7}\]  
\[s_{i}\geq 0,r_{i}\geq 0,0\leq l_{i}\leq 1,\;i=1,\ldots,N \tag{8}\]  
The condition in (6) means that the amount of energy in the battery is nonnegative, which reflects the energy causality. The condition in (7) means the power is nonnegative. Observing this optimization problem, it can be found that \(R(p)\) is concave in \(p\) and all conditions are linear, so P1 is a convex optimization problem and the Lagrange multiplier method and KKT conditions can be used. The Lagrange function is  
\[ \begin{array}{ll}L=\sum\limits_{i=1}^{N}\left(\frac{1}{N}l_{i}R(\frac{E_{i}- s_{i}+r_{i}-al_{i}}{l_{i}})+\right.&\left.\lambda_{i}\left(\sum\limits_{j=1}^{i} \left(\alpha s_{j}-r_{j}\right)\right)+\mu_{i}(E_{i}-s_{i}+r_{i}-al_{i})\\ &\left.\
u_{i}s_{i}+r_{i}+\theta_{i}l_{i}+\sigma_{i}(1-l_{i})\right)\end{array}  \tag{9}\]  
where \(\lambda_{i},\mu_{i},\
u_{i,i},\theta_{i},\sigma_{i},i=1,\ldots N\) are nonnegative Lagrange multipliers for the restrictive conditions. Taking the derivatives with respect to \(s_{i},r_{i},l_{i}\), we can obtain  
\[\frac{\partial L}{\partial s_{i}}=-\frac{h}{1+{hp_{i}}^{*}}+\alpha\sum \limits_{j=i}^{N}\lambda_{j}-\mu_{i}+\
u_{i}=0\;\;\;i=1,\ldots,N \tag{10}\]  
\[\frac{\partial L}{\partial r_{i}}=\frac{h}{1+{hp_{i}}^{*}}-\sum\limits_{j=i}^ {N}\lambda_{j}+\mu_{i}+_{i}=0\;\;\;i=1,\ldots,N \tag{11}\]  
\[\frac{\partial L}{\partial l_{i}}=\frac{1}{2}\log(1+{hp_{i}}^{*})-\frac{h({p_ {i}}^{*}+a)}{2(1+{hp_{i}}^{*})}-a\mu_{i}+\theta_{i}-\sigma_{i}=0,\;\;\;i=1, \ldots N \tag{12}\]  
where \({p_{i}}^{*}=\frac{E_{i}-s_{i}+r_{i}^{*}-al_{i}}{l_{i}}\). The remaining KKT conditions are  
\[\lambda_{i}\sum\limits_{j=1}^{i}\left({as_{j}}^{*}-{r_{j}}^{*}\right)=0,\;\;\; i=1,\ldots,N \tag{13}\]  
\[\mu_{i}(E_{i}-{s_{i}}^{*}+{r_{i}}^{*}-al_{i}^{*})=0,\;\;\;i=1,\ldots,N \tag{14}\]  
\[{v_{i}}{s_{i}}^{*}=0_{i},{r_{i}}^{*}=0,\theta_{i}l_{i}^{*  
If \({l_{i}}^{*}=0\), \({p_{i}}^{*}=0\); If \(0<{l_{i}}^{*}\leq 1\), \({p_{i}}^{*}>0\) and \(\mu_{i}=\theta_{i}=0\), (16) and (17) can be written as  
\[{p_{i}}^{*}=\frac{1}{\alpha{\sum_{j=i}^{N}\lambda_{j}+\
u_{i}}}-\frac{1}{h}= \frac{1}{\sum_{j=i}^{N}\lambda_{j}+_{i}}-\frac{1}{h},i=1,\ldots,N \tag{18}\]  
\[\frac{1}{2}\log(1+{hp_{i}}^{*})=\frac{h({p_{i}}^{*}+a)}{2(1+{hp_{i}}^{*})}+ \sigma_{i},i=1,\ldots,N \tag{19}\]  
We first analyze (18). Since the system exhibits storage losses, the optimal solution cannot be achieved by using a conventional water-filling algorithm or the DWF (Directional Water-Filling) algorithm in [6]. Reference [13] defines two thresholds according to (18):  
\[p_{si}=\frac{1}{\alpha{\sum_{j=i}^{N}\lambda_{j}}}-\frac{1}{h},i=1,\ldots,N \tag{20}\]  
\[p_{ri}=\frac{1}{\sum_{j=i}^{N}\lambda_{j}}-\frac{1}{h},i=1,\ldots,N \tag{21}\]  
Obviously, \(p_{si}>p_{ri}\), and the two thresholds have the following relationship:  
\[\frac{1+{hp_{ri}}}{1+{hp_{si}}}=\alpha,i=1,\ldots,N \tag{22}\]  
In [13], the authors have analyzed \(p_{ri}\leq{p_{i}}^{*}\leq p_{si}\), which means that the optimal power should be between two thresholds. If \(p_{i}\) is greater than \(p_{si}\), the part of the energy which exceeds \(p_{si}\) should be stored in the battery, so \(p_{si}\) is called the storage threshold; if \(p_{i}\) is less than \(p_{ri}\), the system needs to retrieve energy from the battery, so \(p_{ri}\) is called the retrieval threshold. According to Lemma 3 in [13], the threshold should be monotonically increasing and its value changes only when the battery is empty.