## 4 Formulation for Optimal Solution
This means the closest neighbourhood zone will have a larger environmental impact. So, the final environmental metric should be proportional to the attenuation coefficient. Finally, the exponential function is used where a small attenuation coefficient value results in a reasonably large decrease in the proposed metric result. We must assess the impact of the environmental characteristics on each sensor node or/and sink node since the routing algorithm must avoid risky regions. According to Equation (11), the following is the ultimate environmental effect measure for a sensor/sink node \(x\) in zone \(i\) is defined in Equation (11) as follows:  
\[EIM_{x}^{i}(t)=FEI_{i}(t) \tag{11}\]  
In an optimal sink selection algorithm, in order to avoid the sink node in the danger zones, the sink nodes in the candidate sink node set \(SN^{t}\) that have a final environmental impact metric larger than the threshold value are added to the final candidate sink node-set, \(FSN^{t}\). Formally, as in Equation (12),  
\[FSN^{t}=\Big{\{}s_{i}\big{|}s_{i}\in SN^{t},EIM_{s_{i}}^{i}(t)\,>EI_{th}\Big{\}}. \tag{12}\]  
Actually, due to the use of a multi-hop routing technique, the sink node neighbors must be used as relay nodes. That is to say, the residual energy of the sink's neighbors can reflect the load of the corresponding sink. Therefore, to achieve load balancing among multiple sink nodes, the sink node suffering from a heavy load should be avoided, and thus some measures should be taken to make the sensor nodes transmit their data to the other sink nodes. In this paper, the minimum residual energy of the sink node neighbors is used as a measure of each sink node load. Equation (13) presents the sink load metric of candidate sink node \(s_{i}\) at time \(t\):  
\[SLM_{s_{i}}(t)=\min\big{(}RE_{SNE_{i}}\big{)} \tag{13}\]Indeed, developing a routing algorithm that balances energy usage and energy awareness while being suitable for real-time applications is a big challenge. Therefore, the routing algorithm should prioritize energy-efficient transmission while being suitable for real-time applications. Consequentially, in our model, the distance-hop metric is incorporated into the optimal sink selection decision. As indicated in Equation (14), the energy metric of each sink node \(s_{i}\) is constructed by using the minimum hop counts from the source node \(s\) to the candidate sink \(s_{i}\) as follows:  
\[DhM_{s_{i}}^{s}=\frac{1}{mhc_{s}^{s_{i}}} \tag{14}\]  
The real-time data must be sent to the mobile sink within predefined deadlines; performance is assessed by how many packets are received before the deadline. Therefore, urgent messages must be transmitted with the proper latency, reducing packet loss. For a particular sink node \(s_{i}\) selected by sensor node \(x\), the desired delivery speed for the message is defined by Equation (15) as follows [32]:  
\[Ds_{x}^{s_{i}}=\frac{ED_{(x,s_{i})(t)}}{Deadline} \tag{15}\]  
According to Equation (15), the desired speed is directly proportional to the sink node distance. As the sink's distance grows, the needed speed increases. Therefore, critical messages will not arrive in time. Consequently, the increase in lost packets affects real-time performance. Therefore, taking into account the minimization of the distance to sink nodes in selecting the optimal sink node is highly required to enhance real-time performance. Consequently, this paper considers the distance to the sink node, whereas the sink node with the minimum distance should be selected as the optimal sink node. In case of events occurring in some areas, the routing procedure is invoked. Hence, this paper's main problem is finding the optimal sink node and route for data transmission. The developed routing algorithm aimed at minimizing packet loss ratio and end-to-end delay of the routing path simultaneously. A set of constraints is defined for such optimization problems, including energy consumption balance, environmental impact minimization, reliability of data transmission, and real-time data delivery.