## 2 Proposed Algorithm
### Interval Type-2 Fuzzy System
#### 2.1.1 Variables of the Type-2 Fuzzy System  
For this approach, we have employed four input variables and one output variable for the interval fuzzy system. The inputs have been designed taking into account two fundamental aspects related to the lifetime of the network. First, two inputs are related to the energy of the nodes. As a consequence, as much energy a node has, it is more likely to be considered as a cluster head. Second, the other two inputs are based on the performance of a node when it acts as a cluster head. The four inputs used are described as follows:  
Figure 2: Diagram of a Type-2 Fuzzy System. * \(E_{r}\). Remaining energy. This variable measures the percentage of energy that a node has with respect to its initial one. Thus, it ranges from 1 (full battery) to 0 (empty battery). If this value is low, the probability of the node of being chosen as CH should be smaller. * \(N_{CHr}\). This input evaluates the number of times a node has become a CH compared with the total of advice messages of surrounding CHs that it has previously received. \(N_{CHr}\) follows Equation (1). If the node has not been selected as a CH for a long time, this value will be high hence. As a consequence of this, the probability of becoming CH will increase: \[N_{CHr}=1-\frac{N_{CH}}{N_{total}}.\] (1) where \(N_{CH}\) is the number of times that the node has been selected as CH and \(N_{total}\) is the total number of advice messages received from other CH since the network started to operate. * \(E_{rCH}\). It is the energy that the node has when compared with the average energy of all the nodes that were selected as CHs in the previous round. Consequently, each time a node becomes a CH, it includes its remaining energy in the advice message and then each node computes the average of all the values received from the CHs in the previous iteration to obtain this value. The value is normalized according to Equation (2): \[E_{rCH}=\left\{ \begin{array}{l l}1&if&E\geq 1.5\,mean(E_{CH})\\ \frac{E}{1.5\,mean(E_{CH})}&if&E<1.5\,mean(E_{CH})\end{array} \right.\] (2) where \(E\) is the energy of the node and \(mean(E_{CH})\) is the average of the energy values received in the advice messages in the preceding iteration. This message is sent to the entire sensing area, so it reaches all nodes. The election of the value 1.5 for the normalization parameter of the threshold in the equation is due to the need for limiting the range of the variability of \(E_{CH}\). We have empirically determined that setting \(E_{CH}\) to a value greater than \(1.5 mean(E_{CH}\) does not affect the results significantly. We also observed that the proposed setting also reduces the fluctuation of the system. Alternatively, a node that has been chosen as a CH in a previous round is very likely to have lower energy than those nodes which have only been sensors. In this case, this value will be small, and it would not be chosen again as CH. * \(R_{noCHr}\). It is a function of the number of rounds past since a node became CH. It is calculated as indicated in Equation (3): \[R_{noCHr}=\left\{ \begin{array}{l l}1&if&R\geq N_{nodes}\\ \frac{R}{N_{nodes}}&if&R<N_{nodes})\end{array} \right.\] (3) where \(R\) is the number of rounds since a node has not been CH and \(N_{nodes}\) is the total number of sensors in the network. If a node has not acted as CH for a long time, this variable will have a high value, which will try to increase the output of the IT2 FS. This input prevents a node from remaining as a contributing sensor for a long time. Those four inputs are fuzzified into three interval Type-2 sets as shown in Figure 3. The three fuzzy sets are: (i) \"low\" (L), (ii) \"medium\" (M), and (iii) \"high\" (H). Each input value is fuzzified with those sets whose design overlaps between them. The inference engine uses the rules stored in the knowledge base (see Section 2.1.2) to obtain the output membership function that is based on the fuzzified values of the input variables commented above.