# Optimizing Rule Weights to Improve FRBS Clustering in Wireless Sensor Networks
## 2 Materials and Methods
### Proposed Optimization Algorithm  
As was mentioned in Section 2.2, in this paper, we used a scheduling algorithm that fine-tuned the weight of rules within a fuzzy rule-based system [43], in order to obtain three different KBs that tried to optimize the performance and lifetime of the WSN:  
* \(KB_{initial}\) that maximizes the value of FND. * \(KB_{intermediate}\) that maximizes the value of HND. * \(KB_{final}\) that maximizes the value of LND. The tuning process employed a particle swarm optimization (PSO) strategy, referred to as PSO rule weight tuning (PSO-RWT). The reason for using PSO was its fast convergence, which makes it suitable for and widely used in other clustering methods in WSN [44]). In addition the authors have extensive experience in its use in other optimization problems. PSO-RWT was utilized to enhance the performance of FRBS by optimizing the rules involved. Consequently, each rule \(R_{i}\) was multiplied by a weight factor \(w_{i}\) (Figure 6). PSO has proven its effectiveness, taking advantage of the stochastic evolution of swarm intelligence and updating particles based on their internal velocities. A similar optimization can be found in [39]. In our proposal, the fitness function was changed to match the sensor network metrics (FND, HND, and LND). In PSO, each individual, called a 'particle', navigates within a multidimensional space that represents the search area. The system starts with a set of \(M\) particles randomly distributed throughout the n-dimensional search space \(\mathbb{R}^{N}\). Additionally, a real-valued function \(f\) is defined within this space, serving as the fitness function, \(f:\mathbb{R}^{N}\rightarrow\mathbb{R}\). This fitness function is defined by the maximum value obtained for the three instants that delimit the interval of use of any of the three new KBs. Thus, for the first KB, the fitness function is the maximum FND; for the second, the maximum HND; and for the third, the maximum LND. Throughout the iterations, the position of each particle is updated with the goal of finding the optimal position where the best value for  
Figure 6: Fuzzy rule-based system. optimal state is achieved. As mentioned earlier, we chose the maximum value as the fitness function criterion. This positional adjustment was controlled by the components detailed in Equations (6) and (7), which drove the process. \[v_{i}^{(t+1)}=d_{0}v_{i}^{t}+d_{1}r_{1}(Pb_{i}^{t}-x_{i}^{t})+d_{2}r_{2}(Gb^{t}-x _{i}^{t}) \tag{6}\]  
\[x_{i}^{(t+1)}=x_{i}^{t}+v_{i}^{(t+1)} \tag{7}\]  
Here, \(d_{1}\) and \(d_{2}\) are constant factors, \(Pb_{i}\) is the best position that particle \(i\) has achieved, and \(Gb_{i}\) denotes the best position found by the neighbors of particle \(i\). The terms \(r_{1}\) and \(r_{2}\) are random factors within the [0, 1] interval, and \(d_{0}\) is the inertia weight. To ensure the algorithm's convergence, velocity values \(v\) are restricted to the interval [\(v_{min}\), \(v_{max}\)]. Another critical factor for convergence is the efficient setting of the inertia weight \(d_{0}\). A higher \(d_{0}\) value promotes global search, whereas a lower value encourages local search. In other words, \(d_{0}\) can be adjusted to balance both global and local searches, reducing the number of operations needed to find the optimum value. Typically, \(w\) is set to decrease over \(i\) iterations, intensifying local searches after the entire space has been explored. It is usually initialized with a value close to one. The Table 3 presents the values used for these parameters, assuming a number of 100 for generations (\(maxgen\)). The proposed algorithm treats a particle as a weight set. A weight set is defined as the parameters that multiply each rule in a fuzzy knowledge base. Thus, a particle is structured as illustrated in Equation (8) (\(i\) is the number of particles and \(n\) is the number of rules). \[P_{i}= \begin{pmatrix}w_{1}^{i}\\...\\ w_{n}^{i}\end{pmatrix}  \tag{8}\]  
The particles are randomly generated, within a limited workspace.