# A PSO-Based Uneven Dynamic Clustering Multi-Hop Routing Protocol for Wireless Sensor Networks
## 5 Proposed Algorithm
### Steady-State Phase  
Before sending data to the BS, energy-efficient transmission routes from sensor nodes to the BS must first be established. This paper proposes a connecting line aided route construction method to address the issue. Intra-cluster communications are based on single-hop transmission. If the distance between non-CH nodes and the BS is less than \(d_{0}\), non-CH nodes directly send data to the BS via single-hop transmission. Each cluster member transmits data directly to its respective CH node.  
Based on the distance from CH nodes to the BS, inter-cluster communication uses single-hop or multi-hop transmission. If the distance between CH nodes and the BS is less than \(d_{0}\), CH nodes send data directly to the BS via single-hop transmission. Otherwise, CH nodes transmit data to the BS via a multi-hop route established by the connecting line aided route construction method to reduce the energy consumption of multi-hop transmission. When the CH node selects the next hop node of a multi-hop route, it comprehensively considers the distance from the next hop to itself, the connection line connecting the CH node and the BS and the residual energy of next hop. Figure 12 shows how to establish a specific transmission route from CH node \(i\) to the BS.  
CH node \(i\) selects CH node \(j\) as the next hop. CH node \(j\) is selected according to Equation (20).  
\[W_{j}=u_{1}\times\frac{d_{v}}{d_{0}}+u_{2}\times\frac{d_{j}}{d_{0}}+u_{3}\times \frac{E_{0}}{E_{j}},\ u_{1}+u_{2}+u_{3}=1,1\leq j\leq m \tag{20}\]  
\[d_{v}=\frac{\left|\left(BS_{y}-CH_{yi}\right)\times NH_{xj}+\left(CH_{xi}-BS_{x }\right)\times NH_{yi}+BS_{x}\times CH_{yi}-BS_{y}\times CH_{xi}\right|}{\sqrt {\left(BS_{y}-CH_{yi}\right)^{2}+\left(CH_{xi}-BS_{x}\right)^{2}}} \tag{21}\]  
where \(W_{j}\) is the weight used to determine the next hop. The node with the smallest weight is selected as the next hop. \(m\) is the number of CH nodes, the coordinate of CH node \(i\) is \(\left(CH_{xi},CH_{yi}\right)\), the coordinate of the candidate next hop node \(j\) is \(\left(NH_{xj},\,NH_{yi}\right)\), \(d_{j}\) is the distance between CH\({}_{i}\) and the candidate node \(j\), \(d_{v}\) is the vertical distance from the candidate node \(j\) to the connecting line, which is calculated by Equation (21). \(u_{1}\), \(u_{2}\) and  
The candidate node with minimum weight would be selected as the next hop. Figure 14 is the routing process in simulation environment. It can be seen that the transmission path of each CH node is as close as possible to the linear distance to the BS, and the CH node close to the BS mainly acts as a relay. The routing method minimizes the energy consumption for the routes and balances the energy consumption between the CH nodes. The connecting line aided route construction method can ensure that the transmission distance between the CH nodes is as short as possible and the transmission distance from the CH nodes to the BS is as close as possible to the linear distance from the CH node to the BS. The residual energy of next hop is considered to prevent the nodes to die prematurely. Hence, the energy consumed by data transmission is significantly reduced and balanced.