# Energy and Environment-Aware Path Planning in Wireless Sensor Networks with Mobile Sink
## 5 Swarm Based Solution
### Routing Problem  
The original ACO method has been updated since it must minimize both time and complexity for the suggested algorithms to be acceptable for real-time applications.  
Any urgent data packets should be routed via the cluster head relay nodes until they reach the mobile sink if the cluster head is located in a region that the mobile sink has already visited or has not yet visited, and the cluster head possesses the necessary data. It looks at the cluster heads of its neighbors and unicasts the packet to the best one using the ACO algorithm probability. The packet is then routed via this neighbor, who has chosen the best cluster head among its neighbors, until it reaches the mobile sink. This shows that a route from the cluster head carrying critical data to the mobile sink has been identified, and the data packet arrives there simultaneously. By doing this, the time and complexity of the original ACO method are reduced. It is decided during packet transmission which path the urgent data packet will take.  
Two steps make up the suggested solution. If a particular cluster head in the first phase has to communicate urgent data to the mobile sink through the routing process, it sends a forward ant across neighboring cluster head nodes, which serves as a relay node until the mobile sink receives the data. Before choosing the relay nodes, each node must determine which of its cluster head neighbors are allowed to take part in the routing operations. The neighbor nodes that can achieve the necessary delay are the ones that are qualified to be regarded candidate relay nodes and participate in the routing process. The neighbor node is qualified if it can transmit the data packet to the mobile sink in a period of time that is less than or equal to the packet's remaining deadline. On the other side, we will cooperate with all neighbor nodes if no neighbor node meets such a requirement.  
Second, the forward ant chooses the subsequent hop at each cluster head that serves as a relay node based on a probability. The likelihood of choosing a cluster head neighbor to serve as the next-hop relay node, which is specified by Equation (99), is computed using a number of variables including the relaying latency, environmental effect metric, energy consumption load metric, and connection quality, along with the pheromone value:  
\[P_{xy}^{k}(t)=\frac{\left[\tau_{xy}^{3}(t)\right]^{inchp_{1}}\left[\eta_{xy}^{ 3}(t)^{inchp_{2}}\left[\lambda_{xy}^{3}(t)\right]^{inchp_{3}}\left[\beta_{xy}^ {3}(t)\right]^{inchp_{4}}\left[\gamma_{xy}^{3}(t)\right]^{inchp_{5}}}{\sum \limits_{l\in FCHN_{x}}\left[\tau_{xl}^{3}(t)\right]^{inchp_{1}}\left[\eta_{xl}^ {3}(t)\right]^{inchp_{2}}\left[\lambda_{xl}^{3}(t)\right]^{inchp_{3}}\left[ \beta_{xl}^{3}(t)\right]^{inchp_{4}}\left[\gamma_{xl}^{3}(t)\right]^{inchp_{5}}} \tag{99}\]where \(\tau^{3}_{xy}(t)\) is the pheromone value of the link (\(x\), \(y\)) at the time \(t\), \(\eta^{3}_{xy}(t)\), \(\lambda^{3}_{xy}(t)\), \(\beta^{3}_{xy}(t)\), and \(\gamma^{3}_{xy}(t)\) are the heuristic information; \(inch\varphi_{1}\), \(inch\varphi_{2}\), \(inch\varphi_{3}\), \(inch\varphi_{4}\), and \(inch\varphi_{5}\) are the control factors that control the pheromone value and the heuristic information parameters, respectively. A flowchart of the proposed routing approach is shown in Figure 5.