Considering the NPhardness of MTEF problem, we attempt to develop an optimal algorithm that runs in pseudopolynomial time to compute the optimal solution. The high level idea of design is as follows. In order to address the energy constraint and the integrity constraint, we need to determine the rate scheduling policy and the choices of data packets for delivery. However, these two decisions are correlated with each other and difficult to be fixed simultaneously. Observing this, we attempt to deal with these two kinds of constraints separately in two layers. Thus, we propose a dynamical programming algorithm that consists of two layers of dynamical programming process, referred to as DLDP (Double Layers Dynamical Programming). The first layer enumerates to obtain the optimal distribution of power/rate, mainly dealing with the energy constraint, while the second layer mainly deals with the integrity constraints, i.e., the choices of packets to be transmitted. With correct packets selected by the second layer, the first layer returns the optimal rate schedule with the maximum value gained by transmitting the packets under the energy constraint.
3.1. First Layer of DLDP
In this subsection, we introduce the first layer of DLDP designed to determine the optimal rate policy.
Since the optimal rate policy can be determined once the water level at each time slot is found, we start by introducing a basic lemma about the water level [
14].
Lemma 3. For any optimal schedules, if the water level $w(t)$ increases or decreases at time slot t, then t must be an arrival time or a deadline of one or more packets, i.e., $t\in TS$.
According to the lemma above, it is obvious that water level $w(t)$ of the optimal schedule is a piecewise constant function that varies only at time $t\in TS$. Accordingly, we assume that a block in the optimal solution is the longest interval in which the optimal solution keeps at a constant water level. Immediately, we know that the optimal solution is composed of blocks, each with a certain constant water level.
Observing this, we attempt to figure out what does the shape of the optimal solution look like in terms of blocks. Our idea in designing the dynamical programming process here is to enumerate the possible water level of the last block in the optimal solution. Once we found the last block, we can combine it with the solution computed for the remaining intervals (which could be taken as a subproblem), and then return as the final solution. To achieve it, we need to address two issues, (1) how to enumerate the water level in the last block of the optimal solution considering the possible water level could be any real value, and (2) how to combine the results and return as the final solution.
First, we introduce the method on enumerating the water level of the last block in the optimal solution. Although the water level could be any real value, if the water level stays steady at a certain value
$w(t)=W$ in a specific period in the optimal solution, say
$({t}_{1},{t}_{2}]$ with
${t}_{1},{t}_{2}\in TS$, we show that it is possible to restrict it in a candidate set with a finite size. Obviously, the start time
${t}_{1}$ and end time
${t}_{2}$ of the block can be enumerated within
$O({n}^{2})$ time since
${t}_{1},{t}_{2}\in TS$. Furthermore, we have
where
$\tilde{L}$ is the total load/amount of data transmitted in that interval. Recall that
$h(t)$ is piecewise constant. To simplify the calculation, we assume that during
$({t}_{1},{t}_{2}]$, the function
$h(t)$ is composed of
m pieces, from the
ath piece to the
$(a+m1)$th piece. Thus, Equation (
10) can be rewritten as,
According to the property above, once the total load transmitted in that block is fixed, we can reversely determine the water level therein. Observing this, we only need to show that the total load transmitted in that interval in the optimal solution can be enumerated. Therefore, in the following discussion, we prove that if the interval
$({t}_{1},{t}_{2}]$ is chosen correctly, the total load transmitted in the optimal solution is the total workload of a certain subset of the input packets.
Lemma 4. In an optimal schedule, if ${t}_{1}$ and ${t}_{2}$ are both time points at which the water level changes, the total load transmitted during $({t}_{1},{t}_{2}]$ must be the total workload of a certain subset of the input packet set.
Proof. We use ${J}_{({t}_{1},{t}_{2}]}$ to denote the set of packets that are transmitted during $({t}_{1},{t}_{2}]$. We only need to show that no packet in ${J}_{({t}_{1},{t}_{2}]}$ is partially transmitted in interval $({t}_{1},{t}_{2}]$. Suppose a certain packet ${J}_{i}\in {J}_{({t}_{1},{t}_{2}]}$ is partially transmitted there. W.l.o.g., suppose it starts transmission at ${t}^{\prime}$ where ${t}^{\prime}\le {t}_{1}$ (the proof for the case that it ends transmission after ${t}_{2}$ is similar), and it also transmits at a time $\widehat{t}\in ({t}_{1},{t}_{2}]$. This implies ${r}_{i}\le {t}^{\prime}\le {t}_{1}<{d}_{i}$. According to the prior condition, the water level changes at ${t}_{1}$. W.l.o.g. we assume that the water level $w(\widehat{t})>w({t}_{1})$. Thus, applying Lemma 1, we can slightly reduce the water level by moving partial workload of ${J}_{i}$ at time $\widehat{t}$ to time ${t}_{1}$. This would reduce the energy consumption by Lemma 1, which contradicts the optimality of the schedule. Hence, all the packets in ${J}_{({t}_{1},{t}_{2}]}$ are all completely transmitted during $({t}_{1},{t}_{2}]$. This proves the lemma. ☐
Since the total workload of any subset in
J is an integer no greater than
$L(J)$, we can enumerate the load transmitted in interval
$({t}_{1},{t}_{2}]$ in
$O(L(J))$ time. Therefore, given a total load
$\tilde{L}$ and a specific period
$({t}_{1},{t}_{2}]$, we can solve Equation (
11) and get the value
W, which will be denoted by function
$GW(\tilde{L},{t}_{1},{t}_{2})$ for ease of discussion. That is,
Now we have a fierce relationship between
W and
$\tilde{L}$. Note that although
${t}_{1},{t}_{2}$ has not shown up in the right side of Equation (
12). They play a vital role since they provide a certain period which determines the values
${h}_{k}$ in that period. By enumerating
${t}_{1}$,
${t}_{2}$ and
$\tilde{L}$, we could figure out the shape of the last block in the optimal schedule.
The analysis above has provided a method to fix the last block of the optimal solution. Now, we are ready to derive the recursion function of $EOPT({t}_{s},{t}_{e},S,V)$. We need to fix the remaining intervals excluding the last block and return the final solution using dynamical programming process. Note that there is no need to make full use of the time in $({t}_{s},{t}_{e}]$ during the transmission.
Figure 4 demonstrates an example showing the recursive function of
$EOPT(\xb7)$. Given a general interval
$({t}_{s},{t}_{e}]$, suppose that the optimal solution keeps at a steady water level
W in the last block, say
$({t}^{\prime},{t}_{e}]$. Assume that the total value achieved therein is
${V}^{\prime}$ and the corresponding transmitted packets are chosen from a set
${S}^{\prime}\subseteq S$. Then, the energy consumption in
$({t}^{\prime},{t}_{e}]$ would be
${\int}_{{t}^{\prime}}^{{t}_{e}}W{\displaystyle \frac{1}{h(t)}}dt$ if the time in that period is
fully used to transmit a subset of packets from set
${S}^{\prime}$. Thus, as a trick, we use a binary function
$I({t}^{\prime},{t}_{e},{S}^{\prime},{V}^{\prime},W)$ (to be determined later) to identify whether there exists a feasible schedule that keeps at a water level
W in
$({t}^{\prime},{t}_{e}]$ and transmits a subset of packets from
${S}^{\prime}$ with the total value
${V}^{\prime}$ achieved by fully occupying the time in that period. Accordingly, the energy consumption in the remaining subinterval
$({t}_{s},{t}^{\prime}]$ can be returned recursively by function
$EOPT({t}_{s},{t}^{\prime},S\backslash {S}^{\prime},V{V}^{\prime})$, which transmits packets from the remaining set
$S\backslash {S}^{\prime}$ while achieving a total value
$V{V}^{\prime}$. Thus, the total energy consumption in
$({t}_{s},{t}_{e}]$ could be returned by combining these two parts. Therefore, if
$I(\xb7)=1$, then the total energy consumption
$EOPT({t}_{s},{t}_{e},S,V)$ in
$({t}_{s},{t}_{e}]$ equals to that of
$EOPT({t}_{s},{t}^{\prime},S\backslash {S}^{\prime},V{V}^{\prime})$ plus
${\int}_{{t}^{\prime}}^{{t}_{e}}W{\displaystyle \frac{1}{h(t)}}dt$. Otherwise, the value is set with
$EOPT({t}_{s},{t}_{e},S,V)=\infty $ when
$I(\xb7)=0$. To simplify the presentation, we use
$\overline{E}({t}^{\prime},{t}_{e},{S}^{\prime},{V}^{\prime},W)$ to return value
${\int}_{{t}^{\prime}}^{{t}_{e}}W{\displaystyle \frac{1}{h(t)}}dt$ if
$I(\xb7)=1$ and value ∞ otherwise. That is,
Note that in the analysis above, the solution to function $I(\xb7)$ is related to the question that which subset of packets should be chosen to be transmitted. We will leave the discussion on such solution in the next subsection.
It remains to show how to divide a packet set
S into two sets
${S}^{\prime}$ and
$S\backslash {S}^{\prime}$ during the recursive process above, considering this may cost exponential computation time. Hence, we observe what is the order of packet transmission in the optimal schedule, which is stated in the following lemma.
Lemma 5. Among optimal schedules, there always exists a schedule where all packets are transmitted without preemption and the transmission follows the FIFO rule.
Proof. Assume that in the optimal schedule, there are two intervals $({a}_{1},{a}_{2}]$ and $({a}_{2},{a}_{3}]$ with ${a}_{1}<{a}_{2}<{a}_{3}$. Suppose that there are two packets ${J}_{i}$, ${J}_{k}$ with $i>k$, where a segment of ${J}_{i}$ is transmitted during $({a}_{1},{a}_{2}]$ and a segment of ${J}_{k}$ is transmitted during $({a}_{2},{a}_{3}]$. Then, when swapping the transmission order of the packets in these two segments by transmitting packet ${J}_{k}$ earlier, though the transmission time of these two packets may change, the transmission process of these two packets will still start at ${a}_{1}$ and end by ${a}_{3}$. No deadline (or arrival time) constraints of the packets will be violated, because ${d}_{k}\le {d}_{i}$ and ${r}_{k}\le {r}_{i}$ stands when $i>k$. Moreover, swapping the transmitting order will not influence the transmission of segments before or after them. Hence, this proves the feasibility of the swap of two adjacent segments if the packet transmitted in the first segment has later deadline than the second.
With the feasibility of swapping operation above, it is not a harsh task to gather all the segments of the same packet to adjacent time periods by swapping, so that each packet is transmitted in a single piece. Therefore, for any optimal schedule, we can utilize the swapping operation to transform it into another optimal schedule without preemption. Similarly, we can further transform it into a schedule following the FIFO rule. This completes the proof. ☐
Remark 1. Recall that the water level function $w(t)$ directly determines the power function $p(t)$ and the rate function $r(t)$. The lemma above implies that once all the variants $w(t)$ and ${x}_{i}$ (indicating which packets are selected) are determined, then by transmitting the selected packets in FIFO order, we can decide how much workload of a packet should be transmitted at any time, i.e., the variables ${r}_{it}$. This allows us to focus on the discussion about how to determine the water level as stated above and the packet selection in the next subsection.
We use ${J}_{a,b}$ to denote the set of packets $S=\left\{{J}_{i}\righta\le i\le b\}$. Consider the full set $S=\left\{{J}_{i}\right1\le i\le n\}={J}_{1,n}$ first. Lemma 5 states that the transmission of the optimal schedule follows FIFO rule, thus the first ${k}^{\prime}$ (an index to be enumerated) packets with lower index in set S is transmitted before other packets. This allows us to partition packet set S into two separate parts by allocating the first ${k}^{\prime}$ packets into the first part (${J}_{1,{k}^{\prime}}=S\backslash {S}^{\prime}$) and allocating the others into the second part (${S}^{\prime}={J}_{{k}^{\prime}+1,n}$). Such partition is unique once ${k}^{\prime}$ is fixed and will not affect the optimality in calculating $EOPT(\xb7)$. For the general case that $S={J}_{1,k}$, then we have ${S}^{\prime}={J}_{{k}^{\prime}+1,k}$ and $S\backslash {S}^{\prime}={J}_{1,{k}^{\prime}}$.
Therefore, by numerating the possible values of
${k}^{\prime}$ and the possible values of
W, we have the final recursion function for
$EOPT(\xb7)$, as concluded in Theorem 1. Note that to shorten the equation, we present
$GW(l,{t}^{\prime},{t}_{e})$ as
$GW(l)$.
After deriving the recursive function for computing $EOPT(\xb7)$, we present its detailed implementation in Algorithm 1. In the algorithm, we introduce a threedimensional matrix $Eopt$. We use $Eopt\left[i\right]\left[j\right]\left[k\right]$ to denote the minimum energy needed to accomplish packets selected from the set made up of the first i packets which attains a total value j before time $TS\left[k\right]$. The recursion is then implemented in a bottomtotop manner.
This completes the design for the first layer of DLDP, which determines the water level and correspondingly the rate policy in the optimal solution. Note that it remains to determine the function $I(\xb7)$, which is related to the optimal choices of the packets to be transmitted and will be solved in the second layer of the dynamical programming process in DLDP.
3.2. Second Layer of DLDP
After fixing the rate policy, we now determine the optimal integral choices of packets to be transmitted. The answer to it is related to the computation of $I({t}^{\prime},{t}_{e},{S}^{\prime},{V}^{\prime},W)$, which is needed in computing $\overline{E}({t}^{\prime},{t}_{e},{J}_{{k}^{\prime}+1,k},W)$ in Theorem 1, where ${S}^{\prime}={J}_{{k}^{\prime}+1,k}$. For ease of presentation, we write ${S}^{\prime}={J}_{p,q}=\left\{{J}_{i}\rightp\le i\le q\}$ by replacing the indexes of ${S}^{\prime}$ in the following discussions.
Recall that the binary function $I(\xb7)$ is used to identify whether there exists a feasible schedule that transmits a subset of packets in ${S}^{\prime}$ at a steady water level W while achieving a total value ${V}^{\prime}$ in $({t}^{\prime},{t}_{e}]$. In order to give the answer to $I(\xb7)$, we introduce a new function $D({t}^{\prime},{S}^{\prime},{V}^{\prime},W)$, which denotes the minimum time needed to transmit a subset of packets from ${S}^{\prime}$ while achieving a total value ${V}^{\prime}$ with a steady water level W after time ${t}^{\prime}$. Thus, if there exists a feasible schedule transmitting a subset of packets from ${S}^{\prime}$ with the total value ${V}^{\prime}$ achieved by fully occupying the time in the period $({t}^{\prime},{t}_{e}]$, then we have $D(\xb7)={t}_{e}$. It is easy to see that $I(\xb7)=1$ if and only if $D(\xb7)={t}_{e}$, and furthermore, $I(\xb7)=0$ if and only if $D(\xb7)\ne {t}_{e}$. Therefore, we have transformed the computation of $I(\xb7)$ to the end time minimization problem in computing $D(\xb7)$.
Now we focus on the computation of $D(\xb7)$. Since partially transmitted packets contribute nothing, there must exist an optimal schedule that does not partially transmit any packet for the consideration of energy efficiency. Moreover, according to Lemma 5, the chosen packets are transmitted in FIFO order. Thus, we only need to discuss about the possible schedules that transmit packets in FIFO order and does not partially transmit any packet in $({t}^{\prime},{t}_{e}]$. Based on these observations, we introduce the other layer of dynamical programming process and compute $D(\xb7)$ by considering the packets one by one and distinguishing the cases whether a packet is selected or not.
To simplify the expression, we write
$\overline{D}(p,q,V)=D({t}^{\prime},\left\{{J}_{i}\rightp\le i\le q\},V,W)$ where
${t}^{\prime}$ and
W are not shown in the input of
$\overline{D}(\xb7)$. This allows us to focus on the calculation of
$\overline{D}(p,q,V)$. Thus, all the rate schedule mentioned below starts at time
${t}^{\prime}$, and during the transmission, the water level stays at a constant value
W by default.
Algorithm 1$EOPT({t}_{s},{t}_{e},J,V)$ 
Input:${t}_{s}$,${t}_{e}$,J,V Output:$minEC$ 1:
Use sorted array $TS$ to store all time points of the arrival time and deadline of packets in J.  2:
Let $Eopt$ be a threedimension matrix with size ($(J+1)\xb7(V+1)\xb7(TS+1)$) that is initiated with value $MAX\_VALUE=\infty $.  3:
for$i=1$to$\leftJ\right$, $j=0$toV, $k=1$to$\leftTS\right$do  4:
if $j=0$ then  5:
$Eopt\left[i\right]\left[j\right]\left[k\right]\leftarrow 0$  6:
continue  7:
end if  8:
$minE\leftarrow MAX\_VALUE$  9:
for $y=0$ to i do  10:
$SB\leftarrow \left\{{J}_{i}\right1\le i\le y\}$  11:
$SA\leftarrow \left\{{J}_{i}\righty<i\le \leftJ\right\}$  12:
for $v=0$ to j, $t=1$ to k do  13:
$z\leftarrow MAX\_VALUE$  14:
for $l=0$ to $L(SA)$ do  15:
if $I(TS[t],SA,v,GW(l))=1$ then  16:
$z\leftarrow min\{{\int}_{TS\left[t\right]}^{TS\left[k\right]}(GW(l){\displaystyle \frac{1}{h(t)}})dt,z\}$  17:
end if  18:
end for  19:
if $y>0$ then  20:
$tempWE\leftarrow Eopt\left[y\right][jv]\left[TS\right[t\left]\right]$  21:
else  22:
$tempWE\leftarrow 0$  23:
end if  24:
$minE\leftarrow min\{minE,z+tempWE\}$  25:
end for  26:
end for  27:
$Eopt\left[i\right]\left[j\right]\left[k\right]\leftarrow minE$  28:
end for  29:
return$Eopt\left[\rightJ\left\right]\left[V\right]\left[\rightTS\left\right]$

Denoted by $T(a,{J}_{k},W)$ the end time of transmitting ${J}_{k}$ when it is transmitted immediately after time a while the water level keeps steady at W. Note that such a value can be directly calculated given all known values of ${l}_{k}$, $h(t)$ and W by solving the unknown variant x in the equation ${\int}_{a}^{x}log(h(t)W)dt={l}_{k}$. Note that if the calculated end time is larger than ${d}_{k}$, then we would set $T(a,{J}_{k},W)=+\infty $. In the following discussion, we would simplify $T(a,{J}_{k},W)$ as $T(a,{J}_{k})$ if no ambiguity arises.
Based on this definition, we can derive a recursive function of
$\overline{D}(p,q,V)$ by distinguishing the cases whether
${J}_{q}$ is chosen to transmit or not.
Proof. Note that the variants $\{{x}_{p},{x}_{p+1},...,{x}_{q}\}$ determine the packets chosen to be transmitted in $\overline{D}(p,q,V)$. Recall Lemma 5 that there exists an optimal schedule transmitting the packets with FIFO order without preemption. Moreover, the optimal schedule would not partially transmit any packet for energy efficiency. Hence, we just integrally transmit the chosen packets in FIFO order. With such precondition, we will call $\overline{D}(p,q1,\xb7)$ to deal with the packets excluding the last one ${J}_{q}$. To derive the recursive function for $D(\xb7)$, we distinguish two cases that ${x}_{q}$ is 0 or 1.
Case 1 (${x}_{q}=1$): On one hand, if $T(max\{{r}_{q},\overline{D}(p,q1,V{v}_{q})\},{J}_{q})<\overline{D}(p,q,V)$, there exists a value $T(max\{{r}_{q},DP(p,q1,V{v}_{q})\},{J}_{q})$ that is smaller than $\overline{D}(p,q,V)$. Then the end time of $\overline{D}(p,q,V)$ can be reduced by scheduling ${J}_{q}$ right after time $max\{{r}_{q},D(p,q1,V{v}_{q})\}$, contradicting the optimality of $\overline{D}(p,q,V)$.
On the other hand, if $T(max\{{r}_{q},\overline{D}(p,q1,V{v}_{q})\},{J}_{q})>\overline{D}(p,q,V)$, then the end time used for scheduling packets $\left\{{J}_{i}\rightp\le i\le q1\}$ while achieving a value $V{v}_{q}$ should be at least $\overline{D}(p,q1,V{v}_{q})$. As a result, the end time used for scheduling packets $\left\{{J}_{i}\rightp\le i\le q\}$ while achieving a value V should be at least $T(max\{{r}_{q},\overline{D}(p,q1,V{v}_{q})\}$. This implies $\overline{D}(p,q,V)\ge T(max\{{r}_{q},\overline{D}(p,q1,V{v}_{q})\}>\overline{D}(p,q,V)$, leading to a contradiction again. Hence, if ${x}_{q}=1$, then $\overline{D}(p,q,V,)=T(max\{{r}_{q},\overline{D}(p,q1,V{v}_{q})\},{J}_{q})$.
Case 2 (${x}_{q}=0$): On one hand, if $\overline{D}(p,q1,V)>\overline{D}(p,q,V)$, then the absence of ${J}_{q}$ in the optimal schedule of $\overline{D}(p,q1,V)$ incurs a larger end time than $\overline{D}(p,q,V)$, which is impossible.
On the other hand, if $\overline{D}(p,q1,V)<\overline{D}(p,q,V)$, then the value of $\overline{D}(p,q,V)$ can be reduced to be $\overline{D}(p,q1,V)$ since ${x}_{q}=0$. Therefore, if ${x}_{q}=0$, then $\overline{D}(p,q,V)=\overline{D}(p,q1,V)$.
Based on the discussion above, we have the recursive function. ☐
After deriving the recursive function for computing
$D(\xb7)$, we present its detailed implementation in Algorithm 2.
Algorithm 2$D({t}_{s},J,V,W)$ 
Input:${t}_{s}$, J,V,W Output:$endTime$ 1:
Let $\tilde{D}$ be a twodimension matrix with size ($(J+1)\xb7(V+1)$) that is initiated with value $MAX\_VALUE$.  2:
for$j={v}_{1}$toVdo  3:
$\tilde{D}\left[1\right]\left[j\right]\leftarrow T(max\{{r}_{1},{t}_{s}\},{J}_{1})$  4:
end for  5:
for$i=2$to$\leftJ\right$do  6:
for $j=0$ to V do  7:
$minT\leftarrow \tilde{D}[i1]\left[j\right]$  8:
if ${v}_{i}\le j$ then  9:
$temp\leftarrow T(max(\tilde{D}[i1][j{v}_{i}],{r}_{i}),{J}_{i})$  10:
if $temp<minT$ and $temp\le {d}_{i}$ then  11:
$minT\leftarrow temp$  12:
end if  13:
end if  14:
$\tilde{D}\left[i\right]\left[j\right]\leftarrow minT$  15:
end for  16:
end for  17:
return$\tilde{D}\left[\rightJ\left\right]\left[V\right]$
