## 4 REEMR: Reliable Energy-Efficient Multi-Level Routing Algorithm
### Fuzzy Logic Rules for Clustering  
To balance energy consumption of nodes, REEMR constructs clusters at each round similar to LEACH. To get a cluster head election chance, three fuzzy sets and different fuzzy production rules for knowledge representation are considered. The fuzzy variables that are used in the fuzzy production rules are defined as follows. 1. Residual Energy: The remaining energy of each node. The more residual energy the node has, the more data is processed and transmitted, and the longer lifetime of the node is. 2. Number of Neighbors: The number of neighbor nodes of each node. The number of neighbors affects in some way for proper cluster head election. It is more reasonable to select a cluster head in a region where the node has more neighbors. Figure 4: Fuzzy Petri nets representation of type 3 rules. Figure 3: Fuzzy Petri nets representation of type 2 rules. 3. Centrality: The sum of the distances between the node and its neighbors represents how central the node is to the cluster. The more central the node is to a cluster head, the more is the energy efficiency for it to transmit the data through the cluster head. The node centrality is the sum of distances between a node and its neighbor nodes. The above fuzzy variables are input fuzzy variables for the fuzzy production rules, and the output variable is the node's cluster head election chance. The trapezoid functions are employed as the membership functions corresponding to the fuzzy linguistic variables [22], which can be defined as follows. * The fuzzy variable \"residual energy\" has three fuzzy sets--high, medium and low, and its membership function is shown in Figure 5(a). * The fuzzy variable \"number of neighbors\" has three fuzzy sets--many, medium and few. The possible fuzzy quantization of the range [1,10] for the number of neighbors is an experimental result [23]. The membership function is shown in Figure 5(b). Figure 5: Membership functions of the fuzzy variables. * The fuzzy variable \"centrality\" has three fuzzy sets--far, medium and close, and its membership function is shown in Figure 5(c). * The outcome to represent the node's cluster head election chance has five fuzzy sets--smallest, small, medium, large, and largest, and its membership function is shown in Figure 5(d). These membership functions can be set according to the practical need. To calculate a chance to be a cluster head, a typical form of fuzzy production rules for cluster head election is exemplified as follows. **IF**_the residual energy is high_ **AND**_the number of neighbors is few_ **AND**_the centrality is close_ **THEN**_the node's cluster head election chance is largest._  
Since each input variable has \(3\) linguistic states, the total number of possible fuzzy inference rules is \(3\times 3\times 3=27\). According to the composite fuzzy production rule Type 1 in Section 3, a typical fuzzy Petri net model for the above fuzzy production rule is shown in Figure 6, where \"residual energy\", \"number of neighbors\", and \"centrality\" are input fuzzy variables, \(W_{1},W_{2},W_{3}\) are weights, and the node's cluster head election chance is the output fuzzy variable. Assuming the truth degrees of the proposition \"the residual energy is very high\", the proposition \"the number of neighbors is few\" and the proposition \"the centrality is close\" are 1, 1 and 0.9, respectively. Assuming the weights of the arcs are 0.6, 0.3 and 0.1, the threshold is 0.5, and the certainty factor is 0.9. When the transition \(t\) is enabled and fires, the truth degree value is calculated as \(\alpha(p_{4})=(1\times 0.6+1\times 0.3+0.9\times 0.1)\times 0.9=0.891\). From the fuzzy Petri net model, each node can get the fuzzy variable _chance_. According to the cluster head election chance \(C_{i}\), we can get the time \(t_{i}\) of the \(i\)th node broadcasting the cluster declaring message ADV_Head, as shown in the following. \[t_{i}=C_{i}\times T \tag{3}\]  
where \(T\) is predefined as the maximum time of cluster heads competing.