# Energy and Environment-Aware Path Planning in Wireless Sensor Networks with Mobile Sink
## 4 Formulation for Optimal Solution
### Optimal Cluster Head Selection Problem  
The second problem in this paper is how to select the optimal cluster head with the objective of minimizing the intra-cluster distance. A set of constraints is defined for such optimization problems, including energy and reliability constraints. For each node \(x\), the nodes in its candidate neighbor set \(N\!EB_{x}\) that are not covered by any cluster head are added to the final candidate member set \(NM_{x}\); formally, as in Equation (38):  
\[NM_{x}=\{y|y\in N\!EB_{x},\Gamma_{y}=1\} \tag{38}\]  
where  
\[\Gamma_{y}= \begin{cases}1&\text{if $node$ $y$ is not covered by any cluster head}\\ 0&\text{otherwise}\end{cases} . \tag{39}\]  
As WSNs rely on reliable data transmission, dependable wireless networks are needed to transfer data packets from member nodes to cluster heads. However, in a WSN, the packet losses are quite inevitable since it is being deployed in harsh environmental conditions. As a result, it needs more time and energy to retransmit lost packets, which degrades timely data delivery and network lifetime [6; 7; 8; 9]. The proposed clustering technique incorporates link quality into the cluster heads selection decision to overcome this problem and improve network throughput. In addition, the retransmission reduction decreases energy consumption, which enhances network lifetime. Equation (40) presents the proposed new link quality metric of candidate cluster head \(x\) at time \(t\):  
\[QM_{x}=\sum_{l\in NM_{x}}(1-PRR_{xl}). \tag{40}\]  
According to Equation (40), the proposed quality metric function is designed to express the quality of links between the candidate cluster head \(x\) and its neighbor nodes \(N\!EB_{x}\). Moreover, this is designed because the maximum link quality value is \(1\). Hence, through the quality metric function, the closer the link quality value is to \(1\), the lower the resulting value for the proposed function, leading to choosing the cluster head that can provide the more reliable links for data transmission from its members. Each cluster's head receives, aggregates, and sends data to the sink. Therefore, cluster heads lose energy quicker than sensors. To balance energy consumption across all nodes and extend network lifetime, the clustering must avoid low-residual-energy nodes. Therefore, each cluster head's energy weight should be an exponential function of node residual energy, Equation (41):  
\[EM_{x}(t)=\text{exp}\bigg{(}\frac{RE_{x}(t)}{IE_{x}}-1\bigg{)}. \tag{41}\]  
As indicated in Equation (41), the energy metric of each candidate cluster head is constructed because the exponential function is a sort of function where tiny changes in variables may produce big changes in function values [32]. This kind of function is used to build an energy weight function. Therefore, when sensor nodes' residual energy fluctuates with a minor value, it will result in a considerable variation in the proposed function's output. This should result in the best energy cluster head being chosen. Reduced intra-cluster distance is the goal.