## 6 Online Power Allocation Policies  
Inspired by the offline optimal algorithm, the online algorithm should have similar structural features. The offline optimal solution can calculate \(p_{s}\), \(p_{r}\), \(V_{s}\) and \(V_{r}\) exactly by the full information about the energy arrivals and channel states; then, the optimal power allocation is decided by these thresholds and \(p_{o}\) or \(p_{o}(h_{i})\). However, when considering the online policies, we only know the information of the present moment and past moment, and so these thresholds need to be predicted. The prediction equations in [13] are  
\[\alpha\int_{p_{s}}^{+\infty}{(e-p_{s})f_{E}(e)de}=\int_{0}^{p_{r}}{(p_{r}-e)f_{E} (e)de} \tag{52}\]  
\[\int\int_{0}^{+\infty}{\alpha[e-[V_{s}-\frac{1}{h}]}^{+}]-[V_{r}-\frac{1}{h}-e ]^{+}f_{E,H}(e,h)dedh=0 \tag{53}\]  
In (52), \(f_{E}(e)\) is the probability density function of \(e\). In (53), \(f_{H}(h)\) is the probability density function of \(h\), \(f_{E,H}(e,h)\) is the joint probability density function of \(e\) and \(h\), and \(f_{E,H}(e,H)=f_{E}(e)\cdot f_{H}(h)\) because the two variables are independent of each other. The disadvantage of this prediction method is that the calculated thresholds are fixed, which is not feasible for all time slots and \(\alpha\). Based on the solution of Equations (52) and (53), an adaptive-threshold algorithm is proposed in this paper. For the time-invariant channel, we first get \(p_{s}\) from (52); then, the adaptive threshold should be  
\[p_{si}=p_{s}(1+\frac{(1-\alpha)}{N-i+1}) \tag{54}\]  
In (54), two factors will affect the threshold: the storage efficiency \(\alpha\) and time slot \(i\). Obviously, the value of the threshold will increase when \(\alpha\) becomes smaller or \(i\) becomes larger, and the strategy is reasonable because the transmitter should use more energy instead of storage when a time slot is close to the end or the storage efficiency \(\alpha\) is small. In addition, \(p_{ri}\) is calculated by (22), according to the analysis in the offline part; then, the online power allocation policy should be  
\[p_{i}=\left\{ \begin{array}{l}\max(p_{o},p_{si}),\ \ E_{i}-a>p_{si}\\ \max(p_{o},E_{i}-a),\ \ p_{ri}\leq E_{i}-a\leq p_{si}\\ \max(p_{o},E_{i}+\min(B_{i-1},r_{i})-a),\ \ E_{i}<p_{ri}\end{array} \right. \tag{55}\]  
\[l_{i}=\frac{E_{i}-s_{i}+\min(r_{i},B_{i-1})}{p_{i}+a} \tag{56}\]  
For the time-varying channel, we first get \(V_{s}\) and then  
\[V_{si}=V_{s}(1+\frac{(1-\alpha)}{N-i+1}) \tag{57}\]  
\(V_{ri}\) is calculated by (44) and the online power allocation method is  
\[p_{i}=\left\{\begin{array}{l}0,\distribution. We consider 10 time slots, and the length of each of time slot is 1 second. \(B_{0}=0\) and the capacity of the battery has no limit. The circuit consumption power is set to be 5 mW. Figure 2 shows the performance changes of each algorithm as the storage efficiency of the battery is changed when the channel is time-invariant. The energy arrivals obey the uniform distribution of [5; 15] mJ. The non-storage strategy means that the energy of the current slot is completely expended in the slot and the power allocation policy is as in (27) and (28). It can be seen from the figure that the algorithm proposed in this paper is obviously superior to the algorithm in [13] because compared with the algorithm in [13], the factor of circuit consumption is considered in our optimization process. The curve of the adaptive-threshold online algorithm proposed in this paper is close to the offline optimal strategy curve while the gap between the double-threshold offline algorithm in [13] and its corresponding fixed-threshold online algorithm is larger, which shows that the adaptive-threshold is more beneficial to improve the throughput. From Figure 2, it can be also found that under the low storage efficiency, the strategy of non-storage has a great advantage, and with the increasing of storage efficiency, the disadvantage of non-storage strategy is gradually reflected.