Adjusted Rand Index-Guided DPSO for Clustering and Data Routing in Wireless Sensor Networks Authors: Sidi Mohamed Mohi Dine, Zhiyi Zhu, Patrick Finnerty, Chikara Ohta Published: 2026 ABSTRACT Establishing an energy-balanced data routing and clustering approach is among the most fundamental steps to extend the longevity of wireless sensor networks (WSNs). This study presents an intelligent and energy-aware framework for data routing and clustering in WSN employing an adjusted Rand index (ARI)-guided discrete particle swarm optimization algorithm: ARI-DPSO. This method uses Dijkstra’s algorithm to establish energy-efficient data paths and uses the network lifetime as the ARI-DPSO’s fitness function. The discrete particle swarm optimization searches for the globally optimal cluster configuration that extends the network’s operational lifetime. The novelty of the ARI-DPSO lies in its capability to avoid premature convergence by using the ARI metric to quantify the similarity between the swarm’s global best solution and the current particles. Based on this level of similarity, ARI-DPSO employs an ARI-derived mechanism to trigger a dynamic perturbation element to force the swarm of particles to explore new search areas. The simulation results show that the ARI-DPSO improves the dynamics and diversity of the swarm, thereby maximizing the stable operational lifetime of wireless sensor networks (first node death). 1. Introduction Wireless sensor networks have played an essential role in the rapid evolution of the Internet of Things (IoT), enabling its use in various industrial and environmental applications [1]. The limited energy supply poses a critical constraint on the viability of these tiny sensors, making maximizing their lifetimes a key design challenge [2]. Hierarchical clustering and data routing protocols have demonstrated significant efficiency in mitigating the primary source of energy consumption, namely the energy used for data aggregation and transmission across the network [3]. Clustering is a technique that partitions sensor networks into localized clusters, with each cluster containing a designated node as the cluster head (CH) to collect, aggregate, and transmit data from the cluster members to the base station [4]. Obtaining the optimal node-to-cluster configuration is computationally expensive for dense wireless networks, as it involves considering a tremendously large number of node assignments due to the combinatorial explosion of the solution space [5]. While deterministic clustering and routing methods, such as chain- and tree-based protocols [6,7], offer locally efficient solutions, they may not converge to a globally optimal solution. Advanced metaheuristic algorithms provide optimal solutions within reasonable computational resources [8] through a stochastic, intelligent, and self-correcting search framework. Adopting PSO techniques to optimize node-to-cluster membership requires a mathematical compatibility to apply continuous PSO search to a discrete search space [9]. Since the canonical PSO was introduced to search for an optimal solution in a continuous search space, it struggles with the combinatorial nature of the discrete space [10]. The discretization of PSO forces the particles to get trapped in the local minima, leading to premature convergence and diminishing the swarm diversity [11]. The discrete nature of applications, such as node-to-cluster assignment, imposes strict connectivity and topological constraints. Aggressively updating the particle search velocity may violate these constraints and lead to situations where particles contain clusters that are not connected or cannot transmit to the next destination. However, timid updates result in mediocre diversity, which may lead the swarm to get trapped in the local minima and trigger premature convergence. Therefore, it is critical to equip the discrete PSO with an adaptability feature that enables it to simultaneously escape premature convergence without violating network constraints. The adjusted Rand index (ARI) is a robust metric that quantifies the similarity between two partitions by examining the pairwise assignments of members in both partitions [12]. In the context of WSNs, pairwise member assignment means that the ARI checks whether each pair of nodes is grouped in the same cluster under both clustering configurations, or whether the pair is split between two distinct clusters. Based on the pairwise check, the ARI yields a similarity score ranging from −1 to 1, where 1 indicates complete agreement between the partitions being compared, 0 implies a level of similarity expected by random chance, and negative values indicate that the level of similarity is worse than random chance. To exploit the potential search capability of the discrete PSO while mitigating premature convergence, we employ the adjusted Rand index-guided discrete particle swarm optimization (ARI-DPSO) algorithm. The novelty of this study lies in enhancing the swarm’s diversity by improving its exploration capabilities. Specifically, we use the ARI metric to quantify the similarity between each particle’s cluster configuration and the swarm’s global best solution (gbest). Then, we employ an ARI-derived mechanism to force individual particles to unlock new search areas, thereby enhancing the swarm’s search behavior. Accordingly, the enhanced search behavior enables the swarm-optimization search to achieve energy-efficient cluster configuration and, consequently, extend the network lifetime. In the context of WSNs, network lifetime is defined by two distinct phases: the operational lifetime, defined as the lifetime until the last node death (LND), and the stable network lifetime, defined as the time until the first node death (FND). While LND measures the whole time taken until the death of the last node, FND is adopted as a lifetime definition for applications that require sensitive and accurate data from each sensor in the network. This study adopts FND as the main optimization metric. The fitness function of the ARI-DPSO is the lifetime obtained from the routing model used in this study, which employs Dijkstra’s algorithm to construct locally minimum-energy paths. To the best of our knowledge, the ARI metric has been used primarily as a diagnostic tool to assess the similarity between the final clustering results of two or more approaches in the domain of WSN clustering [13,14]. The primary novelty of the ARI-DPSO is that it shifts the application of the ARI metric from a simple diagnostic tool to an algorithmic driver, using it as a detection mechanism to prevent premature convergence. The contributions of this study are summarized as follows:Novel adaptive mechanism: We present a novel application of the ARI metric as a real-time stagnation detection mechanism by using this metric as an active tool to guide and control the swarm’s search.Premature Convergence Regulation: We employ an ARI-derived mechanism to enhance the swarm’s search behavior by dynamically forcing exploratory moves away from stagnation areas.Extended network longevity: Results from our extensive simulations reveal that the ARI-DPSO achieves a significant superiority over the genetic algorithm (GA), ant colony optimization (ACO), the standard DPSO, and the state-of-the-art energy-balanced path tree clustering and routing algorithm (EBPT-CRA) [15], in terms of extending the stable network lifetime (first node death).Search behavior: This study presents an in-depth search behavioral-diagnostic by tracking the swarm diversity and the history of the global best fitness. This quantification of behavior reveals the high diversity of the ARI-DPSO and its ongoing attempts to explore new search areas. Novel adaptive mechanism: We present a novel application of the ARI metric as a real-time stagnation detection mechanism by using this metric as an active tool to guide and control the swarm’s search. Novel adaptive mechanism: We present a novel application of the ARI metric as a real-time stagnation detection mechanism by using this metric as an active tool to guide and control the swarm’s search. Premature Convergence Regulation: We employ an ARI-derived mechanism to enhance the swarm’s search behavior by dynamically forcing exploratory moves away from stagnation areas. Premature Convergence Regulation: We employ an ARI-derived mechanism to enhance the swarm’s search behavior by dynamically forcing exploratory moves away from stagnation areas. Extended network longevity: Results from our extensive simulations reveal that the ARI-DPSO achieves a significant superiority over the genetic algorithm (GA), ant colony optimization (ACO), the standard DPSO, and the state-of-the-art energy-balanced path tree clustering and routing algorithm (EBPT-CRA) [15], in terms of extending the stable network lifetime (first node death). Extended network longevity: Results from our extensive simulations reveal that the ARI-DPSO achieves a significant superiority over the genetic algorithm (GA), ant colony optimization (ACO), the standard DPSO, and the state-of-the-art energy-balanced path tree clustering and routing algorithm (EBPT-CRA) [15], in terms of extending the stable network lifetime (first node death). Search behavior: This study presents an in-depth search behavioral-diagnostic by tracking the swarm diversity and the history of the global best fitness. This quantification of behavior reveals the high diversity of the ARI-DPSO and its ongoing attempts to explore new search areas. Search behavior: This study presents an in-depth search behavioral-diagnostic by tracking the swarm diversity and the history of the global best fitness. This quantification of behavior reveals the high diversity of the ARI-DPSO and its ongoing attempts to explore new search areas. The rest of the paper is organized as follows: in Section 2, we present a review of some of the techniques used in data routing and clustering in WSNs. We detailed the methodology of the ARI-DPSO method in Section 3. In Section 4, we present a performance analysis of ARI-DPSO, and we compare it to the standard DPSO and the state-of-the-art EBPT-CRA. Finally, we summarize the findings of this study and highlight promising domains of application of this method in Section 5. 2. Related Work 2.1. Hybrid Cluster-Tree Clustering and Routing Methods Low-energy adaptive clustering hierarchy (LEACH) is an adaptive routing protocol designed to reduce energy consumption in wireless sensor networks by grouping nodes into clusters [16]. A special node is chosen as the cluster head (CH) to collect data from the member nodes and transmit it to the sink. To ensure that the high-energy duty of the cluster head is rotated among all nodes in each cluster, LEACH employs a probabilistic approach to select the cluster head [17]. Mao et al. [18] improved the selection of the cluster head in LEACH by considering the distance to the sink and the residual energy of the cluster head candidates, while Bhih et al. [19] proposed the use of the LEACH K-means technique to select cluster heads. Early versions of the LEACH protocol relied on probabilistic cluster-head selection methods. Selecting an inappropriate node to serve as a cluster head might rapidly drain its energy. Newer variants of LEACH address this issue by integrating local metrics, such as distance or residual energy, into the selection process. However, these newer variants are susceptible to premature convergence to local optima. Chain-based and tree-based routing protocols are data routing paradigms that focus on constructing optimal routes from distant nodes to the sink rather than specific clusters. To improve the LEACH transmission protocol, Lindsey et al. [20] introduced the Power-Efficient Gathering in Sensor Information Systems (PEGASIS) technique. The key objective of PEGASIS is to reduce the energy spent on communication by forming chain-based routes instead of clusters. To tackle the issues of inefficient leader node selection and non-uniform chain formation in PEGASIS, Abose et al. [21] introduced the Improved Energy-Efficient Anytime Optimistic (IEEAO) protocol in which the leader is dynamically selected based on its energy, while Wang et al. [22] employed Jain’s Fairness Index (JFI) as a decision metric. Chain-based routing protocols rely on a single linear path for transmitting data from distant nodes to the gateway, which can lead to latency and a high dependency on that single link. To overcome this issue, tree-based routing methods are proposed. Unlike chain-based approaches, tree-based structures construct multiple branches connecting distant nodes to a gateway or the base station. The tree-like nature of these structures enhances fault tolerance and load balancing. To optimize the energy consumption and resolve the energy hole problem in WSN, Fan et al. proposed the energy-balanced path tree-based clustering and routing algorithm (EBPT-CRA) in [15]. The Energy-balanced path trees (EBPT) are constructed using Dijkstra’s algorithm, with the nodes’ residual energy and the energy required for data transmission between the sender and receiver as the path cost. To select the optimal cluster head, this study introduces the concept of node convergence betweenness (NCB), a metric that quantifies a node’s centrality in the network and the number of nodes in its subtree. Similar to LEACH techniques, chain- and tree-based protocols use local metrics to construct the transmission path from the source node to the destination, making these techniques susceptible to premature convergence to local optima. 2.2. Bio-Inspired Clustering and Routing Methods Bio-inspired algorithms have proven to be useful for optimizing energy consumption in wireless sensor networks. Genetic algorithm (GA), ant colony optimization (ACO), and particle swarm optimization (PSO) are among the most prominent algorithms adapted to address data routing in wireless sensor networks. Kedi et al. [23] proposed a two-level genetic algorithm that resolves the problem of the cluster head selection and the routing path selection by selecting the best possible set of nodes that can serve as cluster heads. The second-level GA serves as a subroutine to determine the most energy-efficient route for data from the set of selected cluster heads to the base station. Despite its efficiency in clustering and data routing in WSN, the GA algorithm is still prone to getting trapped in local optima. To overcome this issue, Jayachandran et al. [24] proposed a hybrid approach that combines the genetic algorithm (GA) to select the cluster head and Harris hawk optimization (HHO) to find the most efficient routes between the CHs and the base station. Wang et al. [25] introduced a novel pseudo-random proportional rule to optimize the state transition formula to improve the exploration of the ant colony optimization (ACO) algorithm. The inclusion of the residual node energy parameter ensures that path selection is based not only on path length but also on the node energy levels along the path. Similarly, Han et al. [26] introduced an optimized ACO to optimize the process of routing in WSNs for the Internet of Things (IoT) by adjusting pheromone concentration and transfer probability to account for nodes’ residual energy. In [27], Harris et al. proposed a novel particle swarm optimization (PSO) algorithm to enhance energy efficiency in WSNs through optimized cluster head selection. The core idea in this approach is the use of a double-exponential adaptive inertia (DEAI), which balances global exploration and local exploitation, helping the algorithm escape the trap of local minima. Parvin et al. [28] proposed the use of a PSO-based clustering technique to solve the problem of residual nodes, the nodes that are left without joining any cluster. Initially, this approach selects cluster heads based on nodes’ residual energy and their centrality in the network. However, some nodes might still fail to join any cluster. This is where a new PSO iteration starts, with the priority given to these residual nodes to serve as cluster heads. Authors in [29] proposed a quantum particle swarm optimization fuzzy logic approach in which a quantum-based cluster head selection method is used with a fuzzy-logic based data routing path construction. Bio-inspired routing protocols have significantly improved the cluster head selection and the inter-cluster routing, which has led to a significant energy optimization of WSN. However, these techniques often do not consider the intra-cluster as a primary clustering and routing metric, which may lead to over-utilizing intermediate relay nodes between a source node and its cluster head. Furthermore, the standard PSO-based clustering and routing techniques are prone to premature convergence. 2.3. Entropy and Similarity Metrics Clustering and Routing Methods The concept of entropy, a measure of disorder or uncertainty in information theory, has been adopted to address various challenges in WSNs. Energy-balanced clustering and data routing in wireless sensor networks are among the challenges addressed by entropy. By measuring the entropy difference between two or more network states, intelligent decisions can be made to optimize energy consumption in WSNs. General entropy methods and Kullback–Leibler (KL) divergence methods are efficient for decision-making and detecting changes in network states. In contrast, similarity metrics, such as the adjusted Rand index, are primarily used as external validity measures. Proceeding from the ability of general entropy to quantify the uncertainty in the data, Sahoo et al. [30] presented an entropy-weighted method integrated with a multi-criterion decision-making technique for cluster head selection. Manoharan et al. [31] used the relative entropy method to build the entropy-based bald eagle search (EBES) algorithm. In this method, the entropy value is used to select the most suitable node to relay the data to the next hop. Kullback–Leibler (KL) divergence is a powerful mathematical tool to quantify the differences between two probability distributions. The ability to measure differences between probability distributions makes the KL divergence a perfect tool for comparing several states of the system. Detecting data anomalies between transmitted data through the drastic changes in the KL values between consecutive rounds of transmissions is used to reduce the cost of redundant transmission [32,33]. Similarity metrics are external metrics employed to quantify the similarity between two solutions: the achieved solution and a reference solution. In the context of WSN, similarity metrics are used to compare the cluster configuration obtained by a clustering algorithm with a reference or desired solution. Kayalaap et al. [13] employed the ARI metric to validate the clustering performance of four evolutionary algorithms: the genetic algorithm (GA), PSO, gray wolf optimization (GWO), and biogeography-based optimization (BBO) against a reference solution: the k-means algorithm. Similarly, Kanaujia et al. [14] used the ARI metric as an external validation metric to assess the accuracy of their proposed clustering method, robust glowworm swarm clustering (RGSC), against the ground-truth solution, i.e., a known true cluster assignment. Entropy and similarity-based methods have been mainly used either to measure the network’s spatial variance or as a passive diagnostic tool to detect the level of similarity between two clustering states. As seen from the literature review, we can conclude that traditional clustering and routing techniques, such as LEACH and tree-based clustering techniques, are prone to premature convergence to local minima. The metaheuristic clustering and routing techniques are often susceptible to premature convergence. Although some recent studies employed statistical metrics to measure the network variance, these tools are merely used as passive diagnostic tools. This study employs sophisticated tree-based clustering and routing as a baseline for a swarm intelligence to achieve global optimization of the network. Crucially, we shifted the use of ARI from a simple diagnostic tool to an early-stage detection mechanism to avoid premature convergence and guide the swarm to new search areas. 3. Materials and Methods The proposed approach, ARI-DPSO, combines swarm intelligence with an energy-aware clustering and routing model to maximize the lifetime of wireless sensor networks. A fundamental concept in maximizing the lifetime of WSNs is the establishment of energy-efficient clustering and routing structures. To achieve this goal, the ARI-DPSO proposes a minimum-energy routing model to optimize the energy consumption of each node in each operational round. The discrete PSO is employed to find the optimal clustering configuration, using an ARI-derived dissimilarity mechanism to introduce a random perturbation component c3 to prevent premature convergence. 3.1. Radio Model For the purpose of evaluating our proposed routing protocol, we assume that energy depletion follows the first-order radio model as in [15]. In this model, an amount of energy Etx required to send l-bit of data over a transmission distance d depends on whether d exceeds a threshold distance d0: (1)Etx(l,d)=l · Eelec+l · ϵfs · d2, if d Index. Table 4 shows that Expected Index is the number of node pairs expected to agree purely by random chance, and Index is the actual number of agreeing node pairs. This means that a negative value of ARI denotes that X(p) and gbest are extremely dissimilar to the extent that even a random guess would have resulted in more agreeing pairs of nodes in X(p) and gbest. Therefore, Hubert et al. [12] stated that such negative ARI values have no practical use and offer no practical interpretations. In this study, allowing such non-useful ARI values leads to producing a negative perturbation coefficient, which could have a destructive effect on the algorithm logic. Therefore, we set the minimum value of the ARI score to zero, and we compute c3 as: (23)c3=Ccap · max(0,ARI), where Ccap is a hyperparameter. Algorithm 2 presents a summary of the steps needed to compute the ARI, while Table 4 outlines the components used in the ARI calculation. The following example presents the detailed steps required to compute the perturbation coefficient using ARI. Algorithm 2 Calculation of the adaptive perturbation coefficient c3.Require: Assignment Vector X(p), Global Best Vector gbest, Total number of nodes N, Max Perturbation Cap Ccap. Ensure: Adaptive Perturbation Coefficient c3 ▹ Step 1: Compute the Contingency Matrix and Marginals 1:Initialize the contingency matrix M where M[i,j]←ni,j 2:Calculate Marginal Sums: 3:ai←∑jnij ▹ Cluster size in X(p) 4:bj←∑inij ▹ Cluster size in gbest ▹ Step 2: Calculate Core Pair counts 5:PN←N2 ▹ Total number of pairs 6:Pa←∑iai2 ▹ Total pairs within X(p) clusters 7:Pb←∑jbj2 ▹ Total pairs within gbest clusters 8:Index←∑i,jnij2 ▹ Observed Agreement Index ▹ Step 3: Calculate Normalization Terms 9:Expected Index←Pa · PbPN ▹ Agreement expected by chance 10:Max Index←12(Pa+Pb) ▹ Maximum Possible agreement ▹ Step 4: Calculate Adjusted Rand Index (ARI) 11:ARI←Index−Expected IndexMax Index−Expected Index ▹ Step 5: Determine Adaptive Coefficient c3 12:Similarity←max(0,ARI) ▹ Round to 0 to prevent negative perturbation 13:c3←Ccap · Similarity14:return c3 1:Initialize the contingency matrix M where M[i,j]←ni,j Initialize the contingency matrix M where M[i,j]←ni,j 2:Calculate Marginal Sums: Calculate Marginal Sums: 3:ai←∑jnij ai←∑jnij 4:bj←∑inij bj←∑inij 5:PN←N2 PN←N2 6:Pa←∑iai2 Pa←∑iai2 7:Pb←∑jbj2 Pb←∑jbj2 8:Index←∑i,jnij2 Index←∑i,jnij2 9:Expected Index←Pa · PbPN Expected Index←Pa · PbPN 10:Max Index←12(Pa+Pb) Max Index←12(Pa+Pb) 11:ARI←Index−Expected IndexMax Index−Expected Index ARI←Index−Expected IndexMax Index−Expected Index 12:Similarity←max(0,ARI) Similarity←max(0,ARI) 13:c3←Ccap · Similarity c3←Ccap · Similarity 14:return c3 return c3 3.5.2. Example Proceeding from the clustering configuration shown in Table 2, the following example illustrates the steps involved in computing the ARI-based perturbation coefficient c3. We will apply the 5 steps to compute the coefficient of perturbation c3 as highlighted by Algorithm 2, with the definitions of the terms explained in Table 4. Step 1: The contingency matrix is presented in Table 3. Step 2: Core pair counts Total number of node pairs (PN) for a network of total number of nodes N=6 isPN=N2=62=6×52=15. Total number of node pairs (PN) for a network of total number of nodes N=6 isPN=N2=62=6×52=15. Row Pairs Sum (Pa): (Total pairs in X(p) clusters, with ai obtained from the Row Sum in Table 3)Pa=∑iai2=22+22+22=1+1+1=3. Row Pairs Sum (Pa): (Total pairs in X(p) clusters, with ai obtained from the Row Sum in Table 3)Pa=∑iai2=22+22+22=1+1+1=3. Column Pairs Sum (Pb): (Total pairs within gbest clusters, with bj obtained from the column sum in Table 3)Pb=∑jbj2=12+32+22=0+3+1=4. Column Pairs Sum (Pb): (Total pairs within gbest clusters, with bj obtained from the column sum in Table 3)Pb=∑jbj2=12+32+22=0+3+1=4. Index (Observed Agreement): Compute the pairs in the same cluster in both solutions by taking the sum of nij2 in all intersection cells in Table 3Index=∑i,jnij2 =12+12+02+02+22 +02+02+02+22 =0+0+0+0+1+0+0+0+1 =2. Index (Observed Agreement): Compute the pairs in the same cluster in both solutions by taking the sum of nij2 in all intersection cells in Table 3Index=∑i,jnij2 =12+12+02+02+22 +02+02+02+22 =0+0+0+0+1+0+0+0+1 =2. Step 3: Calculate normalization terms Expected Index (Agreement by chance)Expected Index=Pa · PbPN=3 · 415=1215=0.8. Expected Index (Agreement by chance)Expected Index=Pa · PbPN=3 · 415=1215=0.8. Max Index (Maximum Possible Agreement):Max Index=12(Pa+Pb)=12(3+4)=72=3.5. Max Index (Maximum Possible Agreement):Max Index=12(Pa+Pb)=12(3+4)=72=3.5. Step 4: Calculate adjusted Rand index (ARI)ARI=Index−Expected IndexMax Index−Expected Index=2−0.83.5−0.8=1.22.7≈0.4444. Step 5: Determine adaptive coefficient c3 From Equation (23), the coefficient of perturbation isc3=Ccap · max(0,ARI). 3.6. Adaptive Perturbation Mechanism and Swarm Dynamics The introduction of the perturbation component c3 aims to enhance the exploration of the swarm and to avoid the trap of the premature convergence of the discrete particle swarm optimization search. This parameter is introduced to complement the influence exerted by ω, c1, and c2 on the moves required for the velocity updates Vpt+1 of the discrete swarm: (24)Vpt+1=(ω⊗Vpt)⊕(c1⊗(Pbest⊖X(p)))⊕(c2⊗(gbest⊖X(p)))⊕(c3⊗Vrandom). The aim of introducing the perturbation element is to drive the current particle X(p) to a randomly selected particle X(k). The element Vrandom contains all the set of moves required to drive X(p) toward X(k), meaning that for every node j, the move 〈j,xj(p),xj(k)〉 is contained in Vrandom. However, not any triggered move for a node will be added to the velocity update vector. Similar to the filtering method in Equation (16), the ⊗ operator in c3⊗Vrandom filters these moves by comparing the value of the triggering component c3 to a random number between (0,1). A move 〈j,xj(p),xj(k)〉 to drive X(p) toward X(k) is added to the velocity update vector only if rand(0,1)1×10−9 then ▹ Validity check for the network connectivity 21: if fcurrent>fpBest(p) then22: Pbest←Xt+1(p);23: fpBest(p)←fcurrent24: end if25: if fcurrent>fgBest then26: gbest←Xt+1(p);27: fgBest←fcurrent28: end if29: X(p)←Xt+1(p) ▹ Commit position to main storage 30: else ▹ Move Failed (Non-viable): Hard Reset 31: X(p)←GenerateRandomValidAssignment()32: fpBest(p)←Fitness(X(p));33: Pbest←X(p)34: end if35: end for36:end for ▹ phase 3: Final Output 37:return gbest 1:for p=1 to P do for p=1 to P do 2: X0(p)←a0(p) X0(p)←a0(p) 3: Vp0←∅ Vp0←∅ 4: fcurrent←Fitness(X0(p)) fcurrent←Fitness(X0(p)) 5: Pbest←X0(p); Pbest←X0(p); 6: fpBest(p)←fcurrent fpBest(p)←fcurrent 7:end for end for 8:gbest←argmaxPbestfpBest(p) gbest←argmaxPbestfpBest(p) 9:fgBest←maxPbestfpBest(p) fgBest←maxPbestfpBest(p) 10:for t=0 to Tmax−1 do for t=0 to Tmax−1 do 11: for p=1 to P do for p=1 to P do 12: Xt(p)←X(p) Xt(p)←X(p) 13: ARI←AdjustedRandIndex(Xt(p),gbest) ARI←AdjustedRandIndex(Xt(p),gbest) 14: c3←Ccap · max(0,ARI) c3←Ccap · max(0,ARI) 15: Vpt+1←ω⊗Vpt⊕c1⊗(Pbest⊖Xt(p))⊕c2⊗(gbest⊖Xt(p))⊕c3⊗Vrandom Vpt+1←ω⊗Vpt⊕c1⊗(Pbest⊖Xt(p))⊕c2⊗(gbest⊖Xt(p))⊕c3⊗Vrandom 16: Xtrial(p)←Xt(p)⊕Vpt+1 Xtrial(p)←Xt(p)⊕Vpt+1 17: Vpt←Vpt+1 Vpt←Vpt+1 18: Xt+1(p)←Xtrial(p) Xt+1(p)←Xtrial(p) 19: fcurrent←Fitness(Xt+1(p)) fcurrent←Fitness(Xt+1(p)) 20: if fcurrent>1×10−9 then if fcurrent>1×10−9 then 21: if fcurrent>fpBest(p) then if fcurrent>fpBest(p) then 22: Pbest←Xt+1(p); Pbest←Xt+1(p); 23: fpBest(p)←fcurrent fpBest(p)←fcurrent 24: end if end if 25: if fcurrent>fgBest then if fcurrent>fgBest then 26: gbest←Xt+1(p); gbest←Xt+1(p); 27: fgBest←fcurrent fgBest←fcurrent 28: end if end if 29: X(p)←Xt+1(p) X(p)←Xt+1(p) 30: else else 31: X(p)←GenerateRandomValidAssignment() X(p)←GenerateRandomValidAssignment() 32: fpBest(p)←Fitness(X(p)); fpBest(p)←Fitness(X(p)); 33: Pbest←X(p) Pbest←X(p) 34: end if end if 35: end for end for 36:end for end for 37:return gbest return gbest In ARI-DPSO, the velocity updates: Vpt+1←ω⊗Vpt⊕c1⊗(Pbest⊖Xt(p))⊕c2⊗(gbest⊖Xt(p))⊕c3⊗Vrandom (line:15), are not only dictated by the conventional parameters: Inertia ω, c1 and c2 but also by the adjusted perturbation parameter c3 · Vrandom. Applying this move to the particle yields the trial assignment Xtrial(p) (line:16). The proposed move is only accepted if it results in a valid cluster configuration with a valid lifetime fcurrent>1×10−9 as in (line:20). This check ensures that only particles with connected clusters are accepted into the swarm. The particle’s personal best solution Pbest and the swarm’s global best solution gbest are updated in the case where an improved solution is achieved (lines:21–28). Particles that fail to exhibit a valid lifetime are hard-reset into a new random position to try to explore a new search area. This random position is set as the new personal best solution (lines:31–33). The global best clustering configuration gbest that yields the best lifetime L⋆ is returned after the preset number of iterations is complete (line:37). The integrated ARI-DPOS approach is summarized in the Algorithm 3, and Table 5 outlines the definition of the terms used in this algorithm. 4. Results and Discussion 4.1. Simulation Setup To ensure a fair comparison with the state-of-the-art EBPT-CRA [15], we evaluated the ARI-DPSO and the standard DPSO in a network configuration that mimics the state-of-the-art conditions in terms of network model and deployment, energy consumption model, initial node energy, and number of trials. 4.1.1. Network Model and Deployment The network consists of N=100 sensor nodes deployed uniformly at random in a sensing area of 300 m×300 m, with the sink located at the center of the sensing area. All sensor nodes are homogeneous and start with an initial energy of Einitial=1.0 J, and all the sensors in this study are static. The sink is assumed to receive control messages over the network and to have a sufficiently powerful power supply to handle the heavy clustering algorithm calculations. 4.1.2. Network Topology and Energy Consumption Model To establish a network topology in wireless sensor networks, a local neighbor discovery and a global network mapping are required. A method for local neighbor discovery based on path-loss estimation is presented in [35]. Each node sends a beacon message at its maximum transmission power. Neighbor nodes that receive this message measure the received signal strength indicator (RSSI) and deduce the path loss, Lpath in decibels (dB), as the difference between the maximum transmission power Ptx and the actual reception power Prx: (25)Lpath=Ptx−Prx. Both nodes recognize each other as neighbors and compute the minimum required transmission energy. The sink uses the flooding protocol [36] to construct a connectivity graph of the entire network. In this protocol, the sink broadcasts flooding messages across the network. Each receiver stores the sender’s ID as a potential parent and transmits the signal to the next node. Once the entire network has been traversed with these flooding messages, nodes can transmit their neighbor lists back to the sink via multi-hop relay nodes. To evaluate the performance of the ARI-DPSO, we adopted the first-order radio model described in detail in Section 3.1. This radio model is used by the state-of-the-art EBPT-CRA approach, thereby ensuring a fair comparison between the ARI-DPSO and EBPT-CRA. 4.1.3. Statistical Validation To ensure the validity and robustness of our approach, the results of our simulations are the average of 50 independent trials meant to give a large level of certainty that the achieved performance is not affected by the stochastic nature of the DPSO. The parameters used for this setup are summarized in Table 6. 4.2. Performance Evaluation To test the efficiency of our proposed algorithm, ARI-DPSO, we compared it to a standard DPSO implementation, a genetic algorithm (GA) implementation, an ant colony implementation, and the state-of-the-art EBPT-CRA method [15]. These five methods are compared in terms of network longevity, and their performance is shown in Figure 2, which plots the number of dead nodes over the iterations. Our external benchmark EBPT-CRA experiences first node death (FND) at around 200 rounds, and half of the network remains alive for 505 rounds for this method. The ACO experienced FND at 238 rounds, while its HND and LND occurred simultaneously at 580 rounds. Similarly, the GA sustained 278 rounds before the occurrence of FND and had its HND and LND simultaneously at 575 rounds. The standard DPSO exhibits robust performance by delaying the FND until 300 rounds and experiences the half-node death (HND) and last-node death (LND) after 629 and 639 rounds, respectively. Our proposed method, ARI-DPSO, outperforms the benchmarks in the early and middle stages of the network’s lifetime, securing an FND of 336 rounds. It outperforms the EBPT-CRA by 68 percent and improves on the standard DPSO by 12 percent. It also outperforms both the ACO and GA with 7 percent in terms of HND and 6 percent in terms of LND. Most importantly, it outperforms both approaches by 29 percent and 17 percent, respectively, in terms of FND. The ARI-DPSO method sustains its early stability by delaying the occurrence of the HND until 615 rounds. It is worth noting that the EBPT-CRA method achieves the longest LND among the five methods, with approximately 700 rounds. However, our proposed algorithm prioritizes prolonging the stable period during which the majority of the network’s nodes are operating. As discussed in Section 3, we built our network mainly to delay its occurrence by defining our fitness function by the death of the first node in the network. The comparison in this section illustrates that the ARI-DPSO not only outperforms the benchmark EBPT-CRA in the first half of the network lifetime, but it also surpasses the standard discrete PSO, which is a simpler version of ARI-DPSO. This points to the vital role played by the perturbation element in securing this supremacy. 4.3. The Role of the Perturbation Capacity Ccap The ARI-DPSO relies heavily on the perturbation components in the position and velocity updates of the particle. These components serve as a mechanism to avoid stagnation by repulsing the particles away from the global best solution. However, applying an excessive random perturbation to the swarm could severely destabilize the network. We conducted a sensitivity analysis to examine the effects of varying the values Ccap on the lifetime of the network and its stability. The number of particles reset reveals the effects of Ccap in the creation of non-viable particles. Thus, it is a suitable test for network stability. In this sensitivity analysis, we employed 30 particles and 100 iterations to obtain the optimal value of Ccap, which achieves network stability and enhances its lifetime. Figure 3 highlights the effects of varying Ccap from 0.0 to 1.0 on the lifetime and the average number of particle resets per round. The optimal lifetime reaches its peak at a Ccap of 0.2, by achieving 319 rounds, while it did not surpass 290 rounds and 315 rounds for Ccap values of 0.0 and 0.1, respectively. At Ccap of 0.0, the effect of the perturbation component c3 is deactivated (multiplied by the value of Ccap: 0.0). Therefore, the ARI-DPSO at this stage behaves as a standard DPSO, and its average number of particle resets at a Ccap of 0.0 is less than one reset per round. The values of the average particle resets per round are around 5 and 8 resets at Ccap of 0.1 and 0.2, respectively. As the Ccap values increase over 0.2, the swarms start to experience the effect of excessive perturbation, manifesting through a rapid increase in the particle resets that reaches around 15 resets and a drop in the lifetime to reach 301 at Ccap=0.5. The lifetime oscillated at the Ccap values of 0.9 and 1.0 to settle to 309 rounds at 1.0, while the average number of particle resets oscillated around 18 resets for both Ccap values. This analysis reveals that there is a safe zone for the perturbation tuning parameters. Ccap value of 0.2 was a suitable value to inject a sufficient perturbation to propel the particles away from stagnation. It was also moderate to prevent excessive destructive perturbation that might lead to network destabilization. It is relevant to highlight that the ARI-DPSO secured an average lifetime of 336 rounds in Section 4.2 while it did not achieve over 319 rounds in this sensitivity analysis. The reason is that, in this sensitivity analysis, the ARI-DPSO method was tested under 25 trials, completely different from the 50 trials mentioned in Section 4.1, whose results are reported in Section 4.2. The aim is to run the sensitivity analysis on 25 trials to select the value of the optimal Ccap, then use this value to run the total experiment on a larger, different input set (the 50 trials). 4.4. Swarm Dynamics The efficacy of any swarm particle search depends heavily on the dynamic movement of this swarm and on its diversity to explore various search areas. To examine the effects of the movement and diversity on the DPSO variant approaches, the standard DPSO and the ARI-DPSO, we will study their diversity and movement over 100 iterations. To weigh the measure of diversity between particles over the course of iterations, we use the values of the 1-ARI measure, which is an ARI-derived dissimilarity measure, to contrast the efficiency of the search behavior of the DPSO approach and the ARI-DPSO. We also record the trajectory of the global best lifetime for both approaches and the number of particle resets. The diversity, the trajectory of the best lifetime, and the average number of resets at iteration in both methods are depicted in Figure 4, Figure 5 and Figure 6. Figure 4 shows that both approaches start with a high diversity, but the DPSO experiences a rapid collapse by reaching a value of 0.1 within 20 iterations and settles near 0.02 for the last 50 iterations. The ARI-DPSO sustains a relatively higher diversity throughout all 100 iterations. Although it experiences a decrease at the beginning of the process, it manages to secure a diversity score above 0.5 for 50 percent of the process and settles around 0.4 for the last 20 percent of the optimization process. These results provide a visual demonstration of the role played by the perturbation component in preventing premature convergence by introducing randomness into particles that exhibit a high level of similarity to the global best solution. The lack of randomness perturbation drove the DPSO to rapid premature convergence. Figure 5 reveals that the DPSO and the ARI-DPSO started with almost the same lifetime, around 250 rounds at the first iteration. However, the DPSO did not improve after the 20th iteration, where it reached a lifetime of 300 rounds and remained stagnant for the rest of the optimization search. Conversely, the ARI-DPSO continuously and gradually kept improving over the search iteration, enabling it to secure 336 rounds. This continuous improvement is a result of the swarm diversity that enabled the ARI-DPSO to explore new search areas that are inaccessible to the DPSO. The particle reset, a mechanism triggered when a particle constructs a non-viable cluster configuration, is strongly correlated with swarm diversity. At the beginning of the search, when particles are still chaotic, the DPSO experienced a relatively high number of resets of around 11 resets per round, as seen in Figure 6. However, at the end of the first 20 iterations, when the DPSO starts to stagnate, the number of average resets per round drops to approach zero. The ARI-DPSO maintained a relatively high number of resets per round, ranging from 6 to 11. The average per-round lifetime trajectory and diversity illustrate the dynamic and search behavior of the DPSO and the ARI-DPSO. This experiment highlights the role of the perturbation parameter in addressing one of the most critical drawbacks of DPSO: premature convergence. This proposed method is proactive, as it targets the problem of particles converging on the global best and injects a random component to resolve this complication at its source. It also applies the ARI metric, a powerful tool for quantifying the similarity and applying the proportional perturbation needed to alleviate the effects of possible premature convergence. The relatively high rate of resets, if it is kept within reasonable limits, is an indicator of the successful and dynamic nature of the particle in the ARI-DPSO, as it reveals the swarm’s continuous exploration of new search areas. The improved performance rewards this attempt, while the reset count is a price the swarm pays for its exploration. 4.5. Scalability To test the scalability of ARI-DPSO, we executed it on larger networks: a network of 150 nodes and a network of 200 nodes. Figure 7 and Figure 8 show the lifetime progression of ARI-DPSO and the standard PSO under these dense networks. In the 150-node network, ARI-DPSO secured a lifetime of 360 rounds before the FND occurrence and has both HND and LND at 721 rounds. Similarly, the standard PSO experienced FND at 331 rounds; its HND and LND occurred at 724 rounds for the same network. For the 200-node networks, ARI-DPSO secured 378 rounds before the occurrence of its FND, while the standard PSO did not surpass 353 rounds. In this network, both the ARI-DPSO and the standard PSO have their LND and HND at 839 rounds. The results above show that ARI-DPSO has around a 7 percent improvement in terms of FND over PSO for 150-node networks and maintains almost the same ratio of improvement for 200-node networks. This shows that ARI-DPSO is capable of maintaining the proportional performance for dense networks, which indicates that ARI-DPSO is scalable to dense networks. 5. Conclusions In this study, we presented the adjusted Rand index-guided DPSO algorithm (ARI-DPSO) to maximize the longevity of wireless sensor networks. The key step to achieving this goal is the formation of a balanced clustering configuration and the minimum energy routing paths. However, we established through comparative analysis of the performance of the ARI-DPSO and the standard DPSO that the premature convergence impedes the latter from reaching new search areas that might contain optimal solutions. Unlike the standard DPSO, the ARI-DPSO approach employs an adaptive measure: the adjusted Rand index, which acts as an early-stage detection mechanism of the premature convergence. This mechanism proactively detects the likelihood of premature convergence by perpetually comparing the level of similarity between the global best solution and the individual particles in the swarm. Accordingly, it triggers a dynamic perturbation coefficient c3. This perturbation parameter, in turn, enhances the swarm search behavior by ensuring that individual particles are driven away from a rapid convergence to the global best solution. Results from our extensive simulations confirm the superiority of the ARI-DPSO approach over the state-of-the-art EBPT-CRA approach and the standard DPSO algorithm. This superiority is a result of the enhanced swarm search behavior in the ARI-DPSO, which turns the clustering problem into a dynamic and diversity-aware search. In future work, the ARI-DPSO approach has promising applications in more complex wireless sensor network scenarios, such as those requiring a multi-objective function that optimizes multiple network parameters.