# Joint Energy Supply and Routing Path Selection for
## 3 A Joint Algorithm of Energy Supply and Routing Selection
### Two-Stage Energy Replenishment Strategy
Therefore, the charging time in the first stage is preliminarily computed as:  
\[t^{\prime}_{i}=\frac{t_{i}}{\sum_{i=1}^{N}t_{i}}.T_{c} \tag{5}\]  
where \(T_{c}<\sum_{i=1}^{N}t_{i}\), this is because our paper focuses on the charging strategy with limited energy recharge capability, that is, we think the WCD cannot supplement the battery ceiling for all nodes, and it is also consistent with the actual situation. At the same time, we assume that WCD's charging rate for each node is a constant, so in order to reflect the limited energy capability, the value of \(T_{c}\) is given in our charging schedule. With a certain total charging duration, the charging time of each node can be determined according to Equations (4) and (5), however, it is difficult to maximize the network lifetime just by this. According to the definition in Section 2, the network lifetime refers to the death time of the first node, and the node with lower energy level in each round will get closer to death, so the network lifetime finally will be most likely decided by these nodes. Besides, in the case of insufficient WCD energy supply capacity, if we ignore this fact that some nodes with sufficient remaining lifetime during a certain period of time actually do not need or only need a small amount of energy supplement, and allocate the energy in accordance with the ratio of the maximum chargeable time, then, eventually, nodes with insufficient remaining lifetime cannot improve their energy level as much as possible, and WCD's limited energy also fails to achieve a better effect. Therefore, this article further proposes a novel time update strategy to optimize energy allocation. After the first phase of dividing the charging time, each node corresponds to an element (\(N_{i}\), \(t_{i}^{\prime}\)) where \(N_{i}\) denotes a node numbered \(i(1\leq i\leq n)\), and \(t_{i}^{\prime}\) denotes the original charging time of node \(N_{i}\). In a round of charging duration, the energy that can be added to the network is also limited, so in order to prolong the network lifetime, it is necessary to supply as much energy as possible to the fastest node in energy consumption, that is, we need to adjust the original charging time. As shown in Algorithm 1, the final charging time can be obtained by the following time update strategy:  
* The strategy takes the mean value of historical data of each node \(i\) for a period of time as the future energy consumption rate \(\dot{e}_{i,t}\), then calculates the remaining lifetime \(l_{i,t}\) for all nodes and sorts them from low to high to receive an element set that needs to be updated: \[M=\big{\{}\left(N_{i},t_{i}^{\prime}\right)\big{\}}_{i=1}^{n}\] (6) where \(M\) is the set of elements with \(l_{i,t}<l_{i+1,t}(1\leq i\leq n-1)\). Then, it defines two pointers, that is \(k\) and \(m\), whose initial values are set to \(1\) and \(n\), respectively, pointing to the first element and the tail element of the set \(M\). * Taking into account the WCD's limited energy supply capacity and the efficient usage of charging energy, the algorithm needs to adjust the original charging time. Firstly, when the charging time of node \(N_{k}\) is \(t_{k}^{\prime}+t_{m}^{\prime}\), and if the battery capacity ceiling has not been reached, then all the charging time of node \(N_{m}\) is cut to node \(N_{k}\) while the pointer \(m\) forward displacement of one, namely this pointer plus \(1\); otherwise, we cut part of \(t_{m}^{\prime}\) to node \(N_{k}\) to make it full of energy, and the pointer \(k\) backward displacement of one (that is, the pointer \(k\) minus \(1\)). The algorithm continuously performs this step until the values of pointers \(k\) and \(m\) are equal or the remaining lifetime of node \(N_{m}\) is less than \(\partial*T\). Here, we must explain the above parameter \(\partial*T\). In our work, we provide the network with a periodic and continuous charging scheme to enhance the network lifetime.