# Fuzzy-Logic Based Distributed Energy-Efficient Clustering Algorithm for Wireless Sensor Networks
## 4 EEDCF Algorithm
### Cluster Head Competition Phase  
After updating the information table, each node chooses node residual energy (NE), node degree (ND), and neighbor nodes' average residual energy (NNE) as the input parameters and converts them into fuzzy linguistic variables to perform the fuzzy logic analysis, and figure out the performance evaluation of the node. Their fuzzy sets are shown as Equation (7). \[ \begin{array}{l}A_{1}(NE)=\{X_{1}=\textit{``low''},X_{2}=\textit{``medium''},X_{3}= \textit{``high''}\}\\ A_{2}(ND)=\{X_{1}=\textit{``less''},X_{2}=\textit{``average''},X_{3}=\textit{`` ernormous''}\}\\ A_{3}(NNE)=\{X_{1}=\textit{``weak''},X_{2}=\textit{``normal''},X_{3}=\textit{``strong''}\} \\ \end{array}  \tag{7}\]  
As we can see, the fuzzy linguistic variable for node residual energy has the membership degree division as: _\"low\"_, _\"medium\"_ and _\"high\"_, the fuzzy linguistic variable for node degree has the membership degree division as: _\"less\"_, _\"average\"_ and _\"enormous\"_, and the fuzzy linguistic variable for neighbor nodes' average residual energy has the membership degree division as: _\"weak\"_, _\"normal\"_ and _\"strong\"_. \[\mu_{TRI}(x)=\left\{ \begin{array}{ll}0&x\leq a_{1}\\ \frac{x-a_{1}}{b_{1}-a_{1}}&a_{1}\leq x\leq b_{1}\\ \frac{c_{1}-x}{c_{1}-b_{1}}&b_{1}\leq x\leq c_{1}\\ 0&c_{1}\leq x\\ \end{array} \right. \tag{8}\]  
\[\mu_{TRA}(x)=\left\{ \begin{array}{ll}0&x\leq a_{2}\\ \frac{x-a_{2}}{b_{2}-a_{2}}&a_{2}\leq x\leq b_{2}\\ 1&b_{2}\leq x\leq c_{2}\\ \frac{d_{2}-x}{d_{2}-c_{2}}&c_{2}\leq x\leq d_{2}\\ 0&d_{2}\leq x\\ \end{array} \right. \tag{9}\]  
The most widely used membership functions for fuzzy inference system are triangular membership function shown in Equation (8) and trapezoidal membership function shown in Equation (9). \(\mu_{TRI}(x)\) and \(\mu_{TRA}(x)\) stand for the membership degree in their respective membership function to describe the dynamic change of corresponding fuzzy linguistic variable. \(a_{1}\), \(b_{1}\) and \(c_{1}\) are the mapping values on the \(X\) axis of the three vertices of the triangle respectively. \(a_{2}\), \(b_{2}\), \(c_{2}\) and \(d_{2}\) are the mapping values on the \(X\) axis of the four vertices of the trapezoid respectively. In general, the trapezoidal membership function is used for boundary variables and triangular membership function is used for intermediate variables [29]. Furthermore, by combining the membership function of each linguistic variable in the fuzzy set of the subordinate parameter, we can get the overall membership function for the corresponding parameter. These membership functions of input fuzzy parameters mentioned above are formulated by referring [30] as well as some of our own experimental experiences, which are shown in Figures 2-4 respectively. Figure 2: Nodes energy membership function. Those membership functions are used for the process of fuzzification. Figure 2 shows the membership function of node energy. The three membership functions for _\"low\"_, _\"medium\"_ and _\"high\"_ are, respectively, correspond to the fuzzy elements (_\"low\"_, _\"medium\"_, _\"high\"_) contained in node energy fuzzy set, and we use them to convert current crisp node energy into the corresponding membership degree set as the fuzzy variable. For example, assuming node energy is 0.3, corresponding to the _\"low\"_ function, we can obtain the membership degree as 0.4; corresponding to the _\"medium\"_ function, we can obtain the membership degree as 0.6; corresponding to the _\"high\"_ function, also we can obtain the membership degree as 0. Thus, we can get the corresponding energy membership set as (0.4, 0.6, 0), which is the node energy fuzzy variable, and it can participate in the following further fuzzy logic analysis. This is also the same for Figures 3 and 4. Figure 3 shows the membership function of node degree.