## 4 Design and Method
### Distribute Algorithm for Maximizing Data Collection Rate  
The goal of the maximum data collection rate routing protocol is to deliver all the data packets generated by sensor nodes to base stations as soon as possible, subject to node harvesting energy, node capacity and link capacity constraints such that the data flow until the first (set of) sensor node with minimum data generation rate is maximized followed by data flow until the second (set of) sensor node with minimum value is maximized, and so on. Now, we formulate this problem as a line programming, which is given by:  
\[Max\quad g_{i}\] \[Subject\quad\text{to}:\] \[\sum_{j\in\overline{S}_{i}}(\lambda_{j}\varphi(j,i)+g_{j}(1- \rho(j,i)))=\sum_{j\in\overline{S}_{i}}\lambda_{i}\varphi(i,j) \tag{14}\] \[e_{r}\sum_{j\in\overline{S}_{i}}(\lambda_{j}\varphi(j,i)+g_{j})+ e_{tr}\sum_{j\in\overline{S}_{i}}(\lambda_{i}\varphi(i,j)+g_{i})\] \[+e_{g}g_{i}\leq E_{i}\] (15) \[\lambda_{i}=\sum_{i,j\in V,j\in\overline{S}_{i}}(\lambda_{j} \varphi(j,i)+g_{j}(1-\rho(j,i)))\] (16) \[\sum_{j\in\overline{S}_{i}}\varphi(j,i),\sum_{j\in\overline{S}_{i }}\varphi(i,j)\leq R_{i},\forall i,j\in V\] (17) \[\varphi(j,i),\varphi(i,j)\geq 0,\forall i,j\in V,j\in S_{i}\] (18) \[0\leq g_{i}\leq R_{i}\] (19) \[E_{i}\leq B,E_{1}=W_{1}\] (20) \[\lambda_{1}=g_{1} \tag{21}\]  
The first set of constraints in Equation (14) ensures that the inflow after aggregating with raw generation data equals the outflow. The second constraint in Equation (15) ensures that nodes do not consume more energy than they collect, which includes the energy consumption in sensing, packet transmissions, and packet receptions. The third constraint in Equation (16) formulates the \(\lambda_{i}\) of node \(i\). Equations (17)-(18) state that the data flow and available energy do not go below zero and do not go above the link capacity or battery capacity. The set of constraints in Equation (19) ensures that the data collection rate of a node is positive and finite. Equation (20) states that the available energy in the system initialization is the initial battery level. The last Equation (21) states the data aggregation rate equals data collection rate for a leaf or edge node without upstream neighbors.  
According to the Equation (12), the first set of constraints models the data flow conservation at each node. We change the variable to \(q=1/g\), which indicates the generation time for each unit of the packet. We define decay \((q(i))\) as the inverse of data collection rate \((q(i)=1/g(i),g(i)>0)\). Therefore, maximum data collection rate can be converted to the minimum time per unit of packet generation. We obtain an equivalent linear programming formulation.  
Here again, the flow conservation and power conservation constraints should be satisfied first. There are additional constraints that enforce all \(q_{i}\) to be equal. Again we consider a quadratic objective function that is strictly convex in the \(q_{i}\). Also, to ensure that the dual function is differentiable, we restrict the domain to \(0\leq q_{i}\leq q\), for some loose upper bound \(q\). In addition, we use a simple approach similar to that used in [69]. We change the primal objective function to \(q_{i}^{2}\), since minimizing \(q_{i}\) is the same as minimizing \(q_{i}^{2}\). This is the optimization problem such that the maximum problem to maximize data collection rate is converted to the minimum problem to minimize data generation time for per unit of byte information, which will be solved in a distributed manner. We can interpret the above problem as minimizing the maximum ratio of time elapsed to collet a packet at a node. The linear