data. We denote the actual consumed energy in the $i^{\text{th}}$ time frame by $p_{\text{c}}(i)$, where $$\label{eq:power_level}
    p_{\text{c}}(i) = \begin{cases}
        p(i), &\text{if  $e(i-1)+u(i)\geq p(i)$},\\
        e(i-1)+u(i), &\text{otherwise}.
    \end{cases}$$ Moreover, because the transmitter cannot spend more energy than what has been generated (i.e., energy causality), we have the following causality constraints: $$\label{energy_causality}
e(0)+U(t)\geq P_{c}(t),\quad\forall t,$$ where $U(t)\triangleq\sum_{i=1}^{t}u(i)$ and $P_{c}(t)\triangleq\sum_{i=1}^{t}p_{\text{c}}(i)$ are the total energy harvested and consumed in the first $t$ time frames, respectively. Here, we assume that the transmitter knows the battery state perfectly.

Data Buffer
-----------

In the $i^{\text{th}}$ frame, $a(i)$ bits of data arrive at the transmitter, and is stored in the transmitter buffer. The buffer has a capacity of $d_{\max}$ bits, and the number of bits in the buffer in the $i^{\text{th}}$ time frame is $d(i)$. When a packet of data is transmitted and decoded by the receiver correctly, the data packet is removed from the transmitter buffer, and it is considered to be served. Let $s(i)$ denote the amount of data served in the $i^{\text{th}}$ frame. Assuming that the transmitter sends $r(i)$ bits over the channel in the $i^{\text{th}}$ time frame, we can clearly see that $s(i)=r(i)$ if the receiver is able to decode the transmitted data, and $s(i)=0$ 