# Optimizing Rule Weights to Improve FRBS Clustering in Wireless Sensor Networks
## 2 Materials and Methods
### Description of the Fuzzy System
The exact design of the fuzzy sets for the input variables is depicted in Figure 3.  
Regarding the output of the proposed fuzzy control system, it only has one variable, defined as the chance of a node becoming a CH. Therefore, if the conditions that surround a node are propitious, the fuzzy system will infer a high chance, whereas in other cases, the chance obtained will reduce the possibilities of a node becoming a CH. It must be noted that the proposed clustering method is centralized. This means that all the executions of the fuzzy engine are accomplished by the BS, so that, for each \(round\), the BS evaluates every node, executing the inference engine with the values for the input variables and obtaining the chance for all the nodes (the selection algorithm will be detailed in Section 2.2). Nevertheless, the output variable _chance_ has a more complex layout that the input variables, being defined by 11 triangular fuzzy sets, as can be observed in Figure 3. The names of the fuzzy sets are as follows: very very weak (vvw), very weak (vw), weak (w), little lower medium (llm), lower medium (lm), higher medium (hm), medium (m), little higher medium (lhm), little strong (ls), strong (s), very strong (vs), and very very strong (vvs). We defined 11 fuzzy sets for the output variable, because the number of output fuzzy sets depends, to some extent, on the number of rules. Therefore, when there are many rules, the number of fuzzy sets should be increased. When the number of inputs is small and has few sets, there are few rules and the output is usually in five sets, when the number of inputs is increased, the output is usually increased. In [39], the fuzzy system used four inputs, and consequently the output variable was composed of seven fuzzy sets. In our case, by increasing the number of inputs to five, we decided to increase the number of fuzzy sets of the output to 11, thus also increasing the variability, which allows greater adaptability in the optimization process. In particular, triangular sets were used because they also provide an immediate solution to the optimization problems that arise in fuzzy modeling [40]. Continuing with the description of the fuzzy control system, the knowledge base, as was previously mentioned, binds the inputs and the output through a set of linguistic rules that were designed by the research team based on their expert knowledge. For this approach, there are five input variables defined by three fuzzy sets each. As a result, the total number of rules to define is \(3^{5}=243\) rules. All these rules were stored in a Excel file and can be consulted at the published dataset (See data availability statement). As an example, an excerpt of the rules can be found in Table 1.  
As can be observed in Table 1, the initial weight of the three rules is set to one (as for all the other rules not shown initially). Then, as detailed later in the paper, these weights are optimized for three different BS locations to obtain a general approximation for different types of scenarios. Returning to the rules presented in Table 1, the first rule represents the situation of a node that is close to the BS but with a low centrality and node degree. This means that the node has poor connectivity. It also has a low energy and has been moderately selected as a CH. Consequently, this node will have a medium probability (llm). In the case of the second rule, the node is placed in an adequate location, it also has a good connectivity (C \begin{table}
\begin{tabular}{c c c c c c c} \hline \hline
**dBS** & **C** & **ND** & **RE** & **CHR** & **Weight** & **Output** \\ \hline C & L & L & L & M & 1 & llm \\ A & H & H & M & M & 1 & ls \\ F & H & H & H & H & 1 & s \\ \hline \hline \end{tabular}
\end{table} 
Table 1: Samples of rules in the KB. and \(ND\) high), but its energy is decreasing and it has been selected several times previously as a CH. Thus, the output probability will be better than the first rule, giving a value of ls.