# Energy Storage Overflow-Aware Data Delivery Scheme for Energy Harvesting Wireless Sensor Networks
## 3 ESO-Aware Data Delivering Scheme
### The EAMP
 \tag{16}\]  
Additionally, from (4), (5), (6), and (9), we obtain the total ESO in the nodes under the DDD \(\varphi\) as follows:  
\[ \begin{split}&\hat{E}_{tot}(\varphi)=\hat{E}_{(S)}+\sum\limits _{i=1}^{k}\sum\limits_{j=1}^{|R_{i}|}\hat{E}_{(i,j)}\\ &=\left[P_{b(S)}+H_{(S)}-\sum\limits_{i=1}^{k}E_{i}(\varphi)-B \right]^{+}+\sum\limits_{i=1}^{|R_{i}|}\left[P_{b(i,j)}+H_{(i,j)}-E_{(i,j)}( \varphi)-B\right]^{+}\\ &=\left[P_{b(S)}+H_{(S)}-B-\sum\limits_{i=1}^{k}\varphi_{i}u[ \varepsilon_{0}+\varepsilon_{1}(d_{(S,i)})^{\gamma}]\right]^{+}+\sum\limits_ {i=1}^{k}\sum\limits_{j=1}^{|R_{i}|}\left[P_{b(i,j)}+H_{(i,j)}-B-\varphi_{i}u [2\varepsilon_{0}+\varepsilon_{1}(d_{(i,j)})^{\gamma}]\right]^{+}.\end{split}  \tag{17}\]  
Taking (16) and (17), we now formulate the Optimization Problem (OP) in (18) that minimizes the total ESO and maximizes the total residual energy simultaneously, in which Equations (1) and (15) are used as constraints. \[\begin{split}& Min\quad\alpha\hat{E}_{tot}(\varphi)+(1-\alpha)[P_{ tot}(\varphi)]^{-1}\\ & w.r.t.\quad\varphi_{1},\varphi_{2},\cdots,\varphi_{k}\\ &\text{s.t. }\left\{\begin{array}{l}\sum\limits_{i=1}^{k} \varphi_{i}=L;\\ \\ P_{b(S)}+H_{(S)}-u\sum\limits_{i=1}^{k}\varphi_{i}[\varepsilon_{0}+ \varepsilon_{1}(d_{(S,i)})^{\gamma}]>\left[P_{b(i,j)}+H_{(i,j)}-E_{(i,j)}( \varphi)-B\right]^{+};\\ \\ P_{b(i,j)}+H_{(i,j)}-\varphi_{i}u[2\varepsilon_{0}+\varepsilon_{1}(d_{(i,j )})^{\gamma}]>\left[P_As shown in Figure 4, the main mechanisms in the GA include selection, crossover, and mutation operations. For any one of the OPs, we use the following GA to find its solution:  
(1) Initial population. A chromosome is called \"feasible chromosome\" of the OP if it satisfies the three constraints in the OP. We set the initial population by randomly generating \(M\) feasible chromosomes with each being produced by the \"feasible chromosome generating process\" as follows. To generate a feasible chromosome \(\varphi^{(j)}=(\varphi^{(j)}_{1},\varphi^{(j)}_{2},\cdots,\varphi^{(j)}_{k})\) (\(j\)\(\in\){1, 2,..., \(M\)}), where (\(i\) = 1, 2,..., \(k\)) is the number of TUs that flows through the \(i\)-th path, we first generate random numbers \(r_{1},r_{2},\cdots,r_{k}\in[0,1]\) and then use them to produce \(k\) integers \(\varphi^{(j)}_{1},\varphi^{(j)}_{2},\cdots,\varphi^{(j)}_{k}\in[0,L]\) as follows:  
\[\left\{ \begin{array}{l}\varphi^{(j)}_{i}=\left\lfloor L\frac{r_{i}}{\sum_{k= 1}^{k}r_{s}}\right\rfloor_{i}=1,2,\cdots,k-1;\\ \varphi^{(j)}_{k}=L-\sum\limits_{v=1}^{k-1}\varphi^{(j)}_{v},\end{array} \right. \tag{19}\]  
where \(\lfloor\cdot\rfloor\) is the floor function. Obviously, the generated chromosome \((\varphi^{(j)}_{1},\varphi^{(j)}_{2},\cdots,\varphi^{(j)}_{k})\) satisfies (1). If it satisfies the other two constraints in the OP, then it is a feasible chromosome. Otherwise, we regenerate a chromosome in (19) until the one satisfying the other two constraints is produced, which finishes generating the feasible chromosome. (2) Selection operation. We choose the fitness functions of the OP in (18) as \(f(x)=\alpha\hat{E}_{tot}(\varphi)+(1-\alpha)[P_{tot}(\varphi)]^{-1}\). In the current population, we evaluate each chromosome using its fitness function and select the chromosome with the minimum fitness to be passed to the next generation. In addition, a chromosome is copied into the next generation according to the probability of \(f^{-1}(\varphi^{(j)})/\sum_{j=1}^{M}f^{-1}(\varphi^{(j)})\) via Roulette wheel (\(j=1,2,\ldots,M\)), which indicates that a chromosome with a smaller fitness has more copies in the next generation. (3) Crossover operation. The chromosomes are randomly paired for crossover. For the pair of \(\varphi^{(a)}=(\varphi^{(a)}_{1},\varphi^{(a)}_{2},\cdots,\varphi^{(a)}_{k})\) and \(\varphi^{(b)}=(\varphi^{(b)}_{1},\varphi^{(b)}_{2},\cdots,\varphi^{(b)}_{k})\) to be crossed over, we randomly pick  
Figure 4: Genetic algorithm (GA). an integer, say \(v\), in \([1,\,2,\ldots,k-1]\) as a crossover point.