## 3 The Proposed Fuzzy Model and WSN Clustering Technique
### The Proposed Clustering Technique FL-EEC/D  
The _FL-EEC/D_ technique uses the aforementioned fuzzy model for CH election. It controls the distribution of CHs based on determining and enforcing a specific minimum separation distance between CHs to guarantee their fair distribution. Each CH must be far from the closest CH by the distance \(d\), as a minimum. The distance \(d\) is adaptive depending on the dimensions of the WSN, the number of nodes, and the desired CHs percentage. It is computed using Algorithm 1. ```
functionCalc_Min_Dist(\(N,p,dimX,dimY\)) \(N\): List of live nodes \(p\): percentage of CHs in WSN \(dimX\): length of X-dimension, \(dimY\): Length of Y-dimension \(cc\gets ceiling(p\times count(N))\) \(cc\): desired # of clusters \(c\gets 1\) \(r\gets 1\) \(r\): # of regional columns, initially set to 1 \(rf\gets cc-1\) \(df\): difference between # of created rectangles and the desired # of clusters, initially set to \(cc-1\) \(I\gets 1\) while\(I\leq ceiling(\sqrt{cc})\)do \(J\gets I\) while\(J\leq I+1\)do if\(df\geq|cc-(I\times J)|\)then \(cc\leftarrow|cc-(I\times J)|\) \(c\gets I\) \(r\gets J\) endif \(J\gets J+1\) endwhile \(I\gets I+1\) endwhile rX \(dimX\) rY \(d\leftarrow\frac{\gamma rX^{2}+rY^{2}}{2}\) return\(d\) \(d\): minimum distance between CHs endfunction
```  
**Algorithm 1** Calculation of the minimum forced distance between CHs. Firstly, Algorithm 1 virtually divides the WSN into identical regions that are aligned into rows and columns resembling the shapes of rectangles. For the purpose of keeping the shapes of these rectangles compacted, the dimensions of the rectangles are set to be as equal as possible. Therefore, the difference between the number of rows and columns is not allowed to be more than one. The domain for the allowed number of rectangles is the set of square numbers and the numbers that are products of two successive numbers. This set is defined as:  
\[K=\{(p_{i}\times p_{i}),(p_{i}\times p_{i+1});i\geq 1,p\geq 1\}\]  
In case the desired number of CHs does not belong to the set \(K\), then it will be changed to the nearest number within the set \(K\). For example, if the required number of CHs is three, then the resulting number of rectangles is either two or four. The number three does not belong to the set \(K\) because it is neither a square number, nor a number that can be factored into two successive numbers. However, the number two can be factored into the successive numbers two and one, and the number four is a square number. Since the rectangles are aligned in rows and columns, their total number does not always match exactly the number of the desired clusters. The algorithm continues to add new columns in each time until it creates a number of rectangles equal or as close as possible to the desired number of clusters. The algorithm also adds a new row in each iteration before adding a new column to keep the numberof rows as equal as possible to the number of columns. After that, the algorithm takes half of the diagonal of any rectangle as the forced minimum separation distance between CHs, as shown in the first rectangle by line \(|ab|\) in Figure 5.  
The algorithm initially considers the whole WSN as a single rectangle, initializing the number of column and rows to one. In each round of the outer loop of the algorithm, a new column of rectangles is added. Furthermore, in each round of the inner loop, a new row of rectangles is added, where the resulting number of rectangles is closer to the desired number of clusters. The outer loop continues to loop as long as the number of columns is less than or equal to the square root of the desired number of clusters, while the inner loop is responsible for adding rows loops twice for each outer loop round. The clustering scheme is based on forcing a minimum separation distance between CHs. It begins by selecting CHs using the proposed fuzzy inference model explained previously on the basis of separating CHs by distance \(d\) and ends by forming clusters by mapping each node \(n_{i}\) to the closest \(CH_{r}\).