# Joint Energy Supply and Routing Path Selection for
## 3 A Joint Algorithm of Energy Supply and Routing Selection
### Routing Selection  
In WSNs, most sensor nodes cannot directly transfer data to the sink node by reason of the limited communication range, and the sensing data needs to be transmitted to the base station in a multi-hop manner through some relay nodes. Therefore, how to establish a data path from the source node to the sink node is the first consideration of any routing algorithm. In the traditional minimum energy routing strategy for saving energy and extend network lifetime, the transmission energy consumption to the next-hop node is minimized, so that the total transmission cost is the lowest. However, it is difficult to ensure that the energy consumption of subsequent transmission is minimized by only considering the minimum transmission energy consumption, and when sensor nodes are simultaneously on multiple energy minimum routes, their energy will be rapidly consumed, thereby accelerating the arrival of death. In addition, as we have described in Section 1.1, it is well-known that the minimum energy consumption which individually emphasizes the maximization of network lifetime is detrimental to network performances and a balance must be reached [26; 46]. ```
Input: the flight velocity of mobile charger \(v_{m}\), the coordinates \(C\) of all charged nodes in the current charging schedule. Output: the shortest travel path \(\Psi\) and the travel time of mobile charger \(t_{m}\). \(\Psi\leftarrow\Psi(i)\) /*generate an initial path according to the coordinates \(C^{*}\)/ \(L(\Psi(i))\) /*the length of the current path*/ \(\Re\) /*used to control the cooling rate*/ \(\Gamma\) /*the high initial temperature*/ \(\Gamma\_min\) /* the lowest temperature in the search process */ while(\(\Gamma>\Gamma\_min\) ) \(\Delta\gets L\big{(}\Psi\big{(}i+1\big{)}\big{)}-L\big{(}\Psi\big{(}i \big{)}\big{)}\) if(\(\Delta\geq 0\))  update \(\Psi\leftarrow\Psi(i+1)\) /*receive the better solution*/ else if(\(\mathit{exp}\big{(}\Delta\,/\,\Gamma\big{)}>\mathit{random}\big{(}0,1\big{)}\)  update \(\Psi\leftarrow\Psi(i+1)\) /*receive the new solution according to probability*/  end if  end while  update \(\Gamma\leftarrow\Re\)*\(\Gamma\) /*lower the temperature */ \(i++\)  end while  Calculate the travel time of mobile charger. return\(\Psi\) and \(t_{m}\). ```  
**Algorithm 2**The Shortest Travel Path Based on the Simulated Annealing Algorithm  
Therefore, for sake of a trade-off between the network lifetime and network performances, jointly considering the effect of the node's state and our energy supply strategy, the routing weight of each forward neighbor node is defined in this paper. Meanwhile, we adopt the transmission energy consumption of current node \(i\) to the next-hop node \(j\), the forward energy consumption of node \(j\) and the estimated energy of node \(i,j\) as the decision factors. After that, the candidate next-hop node with the smallest weight is selected as the actual next-hop node during the process of considering the route, and finally data packets are delivered. Here, we define the weight of the connected edge \(E(i,j)\) from node \(i\) to its forward neighbor node \(j\), that is, the routing cost of selecting node \(j\) as the forwarding node is:  
\[u_{i,j}=\alpha*\frac{C_{i,j}}{\epsilon_{i,t}}+\beta*\frac{C_{j,s}}{\epsilon_{j, t}},j\in NF(i) \tag{7}\]  
where \(j\) belongs to the forward neighbor node set of current node \(i\) to avoid the return of data packets or forming a routing loop, \(C_{i,j}\) represents the energy consumption of node \(i\) sending data to next-hop node \(j\), and \(C_{j,s}\) denotes the forward energy consumption of node \(j\), both of which can be computedby the energy consumption model in [47].