# Fuzzy-Logic Based Distributed Energy-Efficient Clustering Algorithm for Wireless Sensor Networks
## 4 EEDCF Algorithm
### Cluster Head Competition Phase
The three membership functions for _\"less\"_, _\"average\"_ and _\"enormous\"_ are, respectively, correspond to the fuzzy elements (_\"less\"_, _\"average\"_, _\"enormous\"_) contained in node degree fuzzy set, and we use them to convert current crisp node degree into the corresponding membership degree set as the fuzzy variable. Figure 4 shows the membership function of neighbor node's energy. The three membership functions for _\"weak\"_, _\"normal\"_ and _\"strong\"_ are, respectively, correspond to the fuzzy elements (_\"weak\"_, _\"normal\"_ _\"strong\"_) contained in neighbor node energy fuzzy set, and we use them to convert current crisp neighbor node's energy into the corresponding membership degree set as the fuzzy variable. The membership functions of _\"low\"_, _\"medium\"_, _\"high\"_, _\"average\"_, _\"weak\"_, _\"normal\"_ and _\"weak\"_, _\"normal\"_ and _\"weak\"_, _\"normal\"  
\"_strong_\" are the triangular and the membership functions of \"_less_\" and \"_enormous_\" are the trapezoidal. These specific shapes come from some of the existing conclusions and engineering experiences. The segmented membership function for all the input fuzzy linguistic variables can be found in Figures 2-4. The fuzzy inference system will convert the original crisp values to the fuzzy linguistic variables accordingly. Further, we can develop the IF-THEN rules in accordance to the mechanism of TSK deductive system. The IF-THEN rules table of the EEDCF algorithm is shown in Table 2. NE stands for the residual energy, ND stands for the node degree, and NNE stands for the neighbor nodes' average residual energy. The fuzzy inference system (FIS) converts the original crisp input variables into corresponding fuzzy linguistic variables based on the input membership functions mentioned above. In the fuzzy logic field, the most widely used method to model human beings' thinking is to make instantiation of linguistic expressions, such as the well-known IF premise, THEN conclusion, where the premise is the decision condition described by the fuzzy linguistic variables in the fuzzy set of input parameters, and the conclusion is regarded as the fuzzy output variable. The IF-THEN rule-based knowledge representation is based on natural language representations and models. It means that the fuzzy engine calculates the value of the output variables based on the rules which capture the experts' knowledge of the evaluation systems [31]. The fuzzy rules and empirical data from our previous experiments are shown in Table 2. However, different from Mamdani method, the proposed TSK fuzzy system uses Equation (10) to calculate the crisp value as the consequence parameter instead of fuzzy linguistic variable. \[y^{i}(X)=p_{0}^{i}+p_{1}^{i}A_{1}(NE)+p_{2}^{i}A_{2}(ND)+p_{3}^{i}A_{3}(NNE) \tag{10}\] \begin{table}
\begin{tabular}{c c c c c} \hline \hline
**List** & **NE** & **ND** & **NNE** & **Probability (\%)** \\ \hline
1 & Low (0.31) & Less (3) & Weak (0.25) & 0.26 \\
2 & Low (0.37) & Less (2) & Normal (0.47) & 0.24 \\
3 & Low (0.28) & Less (4) & Strong (0.52) & 0.36 \\  
trong (0.77) & 0.81 \\ \hline \hline \end{tabular}
\end{table} 
Table 2: IF-THEN rules. The definition of TSK model output \(\hat{y}\) is shown as Equation (11). \[\hat{y}=\frac{\sum\limits_{j=1}^{m}\alpha_{j}y_{i}}{\sum\limits_{j=1}^{m}\alpha_ {j}} \tag{11}\]  
where \(m\) is the number of fuzzy rules and \(\alpha_{j}\) represents the membership function of the corresponding linguistic variable of fuzzy input parameter in the \(j\)th rule. In order to facilitate the calculation, we define \(\beta_{j}\) as Equation (12). Then, we get the following Equation (13) to describe the output \(\hat{y}\).