## 2 Related Work
Therefore, the algorithm introduces the average distance between nodes and nodes residual energy into a threshold, so that a node with higher energy and closer to the base station will become a cluster head. Thus, the improved threshold formula is expressed as:  
\[T(s)=\left\{ \begin{array}{cc}\frac{p}{1-p\times\left(r\;mod\left(\frac{1}{p} \right)\right)}\times\omega_{i},&if\;s\in G\\ 0,&if\;s\
ot\in G\end{array} \right. \tag{7}\]  
where \(r\) is the round number, \(i\) is node ID, \(\omega_{i}\) is  
\[\omega_{i}=C_{1}\times\frac{1}{d_{(i)}}+C_{2}\times\left(1-\frac{1}{Number_{( i)}}\right)+C_{3}\times\left(\frac{S(i).E}{E_{are}\times K_{opt}}\right)+C_{4} \times\left(\frac{1}{d_{C_{i}-BS}}\right) \tag{8}\]  
where \(S(i).E\) is the nodes residual energy, \(d_{C_{i}BS}\) is the node distance from the base station, \(Number_{(i)}\) is the number of nodes in \(d_{0}\) range, \(d_{(i)}\) is an average distance between node \(i\) and neighbor nodes, \(E_{are}\) is the node average energy, \(K_{opt}\) is a constant value. \(C_{1}\) is the control parameter of the relative distance between nodes, \(C_{2}\) is the degree of the node, \(C_{3}\) is the nodes residual energy and \(C_{4}\) is the node distance to the base station [26]. Another algorithm, focusing on the distances from sensors to the base station, that optimally balances the energy consumption among the sensors, is described in [27]. It's a distance-based threshold for distributed cluster head election, where the authors propose LEACH with distance-based thresholds, called LEACH-DT, in which the probability of a node to become a cluster head depends on its distance to the base station or the sink:  
\[T_{i,r}=\left\{ \begin{array}{cc}\frac{p_{(i)}}{1-p_{(i)}\times\left(r\;mod \frac{1}{p_{(i)}}\right)},&if\;G_{i}(r)=0\\ 0,&if\;G_{i}(r)=1\end{array} \right. \tag{9}\]  
At the beginning of each group of rounds, \(G_{i}(r)\) is set to 0 for [1/_p_] successive groups, to ensure that a node becomes a cluster head once in every group of rounds of [1/_p_] rounds. Base station initially evaluates the distance based on the nodes signal strength to estimate the probability \(p\) and broadcasts it to all the nodes. The nodes then autonomously make decisions without any centralized control. The authors in [28] also introduce an improved threshold assignment algorithm using node distance from BS. They determine smaller \(p\) for distant nodes from base station so that distant clusters will be bigger in size and distant nodes will have less opportunity to be selected as a cluster head than closer nodes to BS. Before first setup, base station broadcasts a packet declaring a \"start\" of network task. Sensor nodes receive this packet including signal strength and estimate the distance from BS. Nodes then send their distances to BS by a carrier sense multiple access (CSMA) protocol. Therefore, base station evaluates the maximum and minimum distances in the network. Thence, base station broadcasts these two packets to all the nodes in the wireless network. Thus, new probability \(p\) for cluster head election:  
\[p_{new}(n)=p\left(1-\alpha\bigg{(}\frac{d_{n}-d_{M}}{d_{max}-d_{M}}\bigg{)}\right) \tag{10}\]  
is for when \(p_{new}(n)<1\), and \(1\) for otherwise. Where, \(p\) is the probability to choose a node as a cluster head, \(d_{n}\) is the distance of \(n\)-th node from BS and \(d_{m}\) is an average distance:  
\[d_{m}=\frac{d_{min}+d_{max}}{2} \tag{11}\]  
and \(\alpha\) is:  
\[\alpha=\frac{d_{max}-d_{min}}{d_{max}} \tag{12}\]  
and a new threshold assignment with consumed energy value used in threshold is:  
\[T(n)=\frac{p}{1-p\left(r\;mod\bigg{(}\frac{1}{p}\bigg{)}\right)}\times\bigg{[} \frac{E_{n,\;current}}{E_{n,\;max}}+\bigg{(}r_{n,\;s}\text{div}\bigg{(}\frac{1} {p}\bigg{)}\bigg{)}\bigg{(}1-\frac{E_{n,\;current}}{E_{n,\;max}}\bigg{)}\bigg{]} \tag{13}\]  
where \(E_{n,current}\), \(E_{n,max}\) are residual and initial energy of \(n\)-th node, \(r_{n,\;s}\) is consecutive rounds in which \(n\) has not been a cluster head and \(r\) is a number of rounds.