# Optimal Selection of the Cluster Head in Wireless Sensor Networks by Combining the Multiobjective Genetic Algorithm and the Gravitational Search Algorithm

Authors: Seyed Reza Nabavi; Vahid Ostovari Moghadam; Mohammad Yahyaei Feriz Hendi; Amirhossein Ghasemi
Journal: Journal of Sensors
 (2021)

---

## Abstract

With the development of various applications of wireless sensor networks, they have been widely used in different areas. These networks are established autonomously and easily in most environments without any infrastructure and collect information of environment phenomenon for proper performance and analysis of events and transmit them to the base stations. The wireless sensor networks are comprised of various sensor nodes that play the role of the sensor node and the relay node in relationship with each other. On the other hand, the lack of infrastructure in these networks constrains the sources such that the nodes are supplied by a battery of limited energy. Considering the establishment of the network in impassable areas, it is not possible to recharge or change the batteries. Thus, energy saving in these networks is an essential challenge. Considering that the energy consumption rate while sensing information and receiving information packets from another node is constant, the sensor nodes consume maximum energy while performing data transmission. Therefore, the routing methods try to reduce energy consumption based on organized approaches. One of the promising solutions for reducing energy consumption in wireless sensor networks is to cluster the nodes and select the cluster head based on the information transmission parameters such that the average energy consumption of the nodes is reduced and the network lifetime is increased. Thus, in this study, a novel optimization approach has been presented for clustering the wireless sensor networks using the multiobjective genetic algorithm and the gravitational search algorithm. The multiobjective genetic algorithm based on reducing the intracluster distances and reducing the energy consumption of the cluster nodes is used to select the cluster head, and the nearly optimal routing based on the gravitational search algorithm is used to transfer information between the cluster head nodes and the sink node. The implementation results show that considering the capabilities of the multiobjective genetic algorithm and the gravitational search algorithm, the proposed method has improved energy consumption, efficiency, data delivery rate, and information packet transmission rate compared to the previous methods.


---

## Body

## 1. Introduction

The wireless sensor networks (WSNs) are comprised of distributed microdevices with various measurement capabilities that monitor the environment and transmit information to the end users. The wireless sensor technology was introduced more than 20 years ago, and many projects have been conducted since then. Green calculations [1, 2] were presented in 2008 aiming to employ the limited resources and maximize the energy efficiency throughout the lifetime of a system. WSNs are usually comprised of a large number of sensor nodes equipped with limited energy resources, but they should operate for a long time without charge or battery replacement. To increase the network lifetime and reduce energy consumption of the sensor nodes of the network, clustering techniques have been presented to achieve an efficient relationship among the sensor nodes [3, 4].In the clustering techniques, the sensor nodes of a network are combined to constitute small separate clusters. Each cluster has a known leader called the cluster head (CH) and other nodes are known as the member nodes (MN). Selecting the CH is a fundamental challenge that is the topic of this study. The sensor nodes sense the environment information and transmit it to the corresponding CH. The CH nodes collect data from all sensor nodes of the cluster and transmit it to the base station after data aggregation and removing the duplicate data. Thus, the CH has to organize the network, collect data, and transmit data from the sensor nodes to the sink and the base station and it consumes more energy compared to other nodes [5–8].Data collection based on clustering-based approaches has various advantages compared to the conventional schemes. First, collecting data received from various sensor nodes in a cluster decreases the amount of data transmitted to the base station, because the duplicate data is removed considering the CH analysis [9]. Second, the sensor nodes of each cluster can transmit data directly to the sink nodes. But since data transmission in long intervals requires more energy consumption, direct data transmission is avoided. Instead, transmitting data to the CHs in adjacency of the member sensor nodes consumes less energy; hence, the energy requirement in the whole network for data transmission is reduced [10]. Third, rotation of the CHs helps to ensure balanced energy consumption in the network, such that the hunger of particular nodes due to energy shortage is prevented. However, selecting a proper CH with optimal capabilities, while balanced energy consumption rate and network efficiency are met, is a well-known NP-hard problem in WSNs [11–13].The NP-hard problems cannot be solved using linear or polynomial methods and require using artificial intelligence, swarm intelligence, or metaheuristic methods to find the nearly optimal solutions. In this regard, heuristic and metaheuristic methods have recently attracted attention in the context of sensor node clustering and CH selection in WSNs that aim at improving the contradicting objectives of the network simultaneously [14, 15].Given that the main challenge in wireless sensor networks is energy constraint, so, the performance of most applications in the WSN depends on energy consumption [15]. Hence, the main goal of this paper is at saving energy consumption in wireless sensor nodes. Since the amount of energy required to sense data from the environment and receive packets from other sensor nodes in the WSN is constant, therefore, most of the energy consumption is related to sending packets. The farther the next hop is from the current node, the more energy it takes to send data. So, the closest next hop that has the most remaining energy and least distance to sink not only can save energy but also could improve the quality of service (QoS) parameters. On the other hand, since finding the optimal path in wireless sensor networks has been introduced as an NP-hard problem, the best option to find the optimal solution is to use metaheuristic algorithms. Metaheuristic algorithms can find local optimizations according to local search but may find weakness or deadlock in finding optimal global solutions. Therefore, the use of algorithms with global search properties or a combination of metaheuristic algorithms can achieve optimal global solutions.Therefore, this study presents a novel optimization approach using the multiobjective genetic algorithm (MOGA) and the gravitational search algorithm (GSA) for clustering the WSNs. In this study, the multiobjective genetic algorithm based on reducing the intracluster distances and reducing the energy consumption of the MNs is used to select the CH and the nearly optimal routing based on the gravitational search algorithm is used to transfer information between the cluster head nodes and the sink node. Considering the capabilities of the multiobjective genetic algorithm and the gravitational search algorithm, the proposed method has improved energy consumption, efficiency, data delivery rate, and information packet transmission rate compared to the previous methods.The main motivation of this paper is the combination of the multiobjective genetic algorithm and gravitational search algorithm in order to find the optimal local clusters and the optimal global path in the wireless sensor network. Hence, the main contribution of the article is summarized as follows:(i)
Use of multiobjective genetic algorithm to find the optimal thread nodes in each cluster locally(ii)
Reduce energy consumption and create a balance between service quality parameters by using the multiobjective fit function(iii)
Use the gravitational search algorithm to find the optimal global path(iv)
WSN simulation and evaluation of the proposed method based on important criteria in the wireless sensor network and comparison with previous methodsThe rest of this paper is organized as follows. Section2 reviews the literature. Section 3 describes the details of the proposed method. Section 4 presents implementation and evaluation of the proposed method. Finally, the paper is concluded in Section 5.


## 2. Literature Review

In this section, the routing protocols based on swarm intelligence for WSNs are studied. The protocols employed in WSNs, including the ant colony optimization (ACO) algorithm, particle swarm optimization (PSO), bacterial foraging optimization (BFO), and artificial bee colony (ABC) algorithms, are discussed.The genetic algorithm-based energy efficiency clusters (GABEEC) is used to increase the network lifetime. The GA evaluates all chromosomes by calculating the fitness function. The fitness function has three parameters, including the round in which the first node dies, the round in which the last node dies, and the cluster distance. This algorithm tries to reduce the network lifetime by reducing the distance of the nodes, but the communication at the CHs is reinforced due to transmitting information about the residual energy to the base station (BS). The genetic clustering algorithm (GCA) employs two parameters, including the total transmission distance in a cluster and the number of CHs to achieve a longer lifetime [16]. The genetic algorithm-based energy efficiency clustering hierarchy (GAECH) performs the GA twice and improves CH selection considering the residual energy and total transmission cost [17].The ACO is one of the nature-inspired mechanisms that performs optimal routing. This protocol is dynamic and reliable and can provide data aggregation and collect the routing structure. Also, it prevents network congestion, reduces energy consumption, and supports multiroute data transmission to achieve reliable communications in WSNs. This protocol is aimed at preserving the maximum network lifetime during data transmission using an efficient method [18].In the network routing, the ACO-based techniques achieve a better overhead due to real-time computations and less control. The ACO has various shortcomings, for example, its performance depends on the previous cycle. It seems that using the ACO-based routing protocol in dynamic networks is suitable for preventing the link failure (a number of artificial ants are generated at each round and search for the shortest route between the source and the destination). In the last decade, the ACO has been used to solve hybrid optimization problems like NP-complete problems. In addition, the performance of the proposed method in finding the shortest route is reinforced in terms of network lifetime and load balance in WSNs using various solutions like sensor node clustering [19].In a study, the authors presented a CH selection algorithm using the ACO to construct balanced load clusters. This algorithm uses the residual energy of the node and the distance between the nodes to select the CH [20]. Another ACO-based clustering method organizes the energy efficient clustering protocol through local interactions among the sensor nodes. First, the CH nodes are selected among the nodes with high residual energy. Then, the clusters are constituted through random interaction of regular nodes. The interaction among sensor nodes is carried out via local message transmission. This algorithm puts pressure on the network by repeating the interaction of the sensor nodes and does not provide the sufficient energy clustering mechanism [21].PSO is a subset of swarm intelligence based on a population-based random optimization approach. PSO applies the social behavior of the birds or fishes to the real-world problems. This approach preserves local solutions and global solutions and generates the best fitness of an objective [19]. Also, swarm intelligence is used in the WSN for clustering optimization. In a study, the authors presented a clustering algorithm using PSO. They considered two types of nodes: natural sensor nodes and high-energy nodes. The high-energy nodes operate as CHs while the normal sensor nodes operate as members of the cluster [22]. PSO is also used in the information broadcast protocol. The selection measure for the CH is the residual energy, intracluster distance, and node degree. A hybrid protocol that combines the harmony search algorithm (HSA) and PSO is also used for clustering optimization. This hybrid algorithm selects the CH using the fitness function that includes the residual energy of the nodes, node degree, and the distance between the nodes. The metaheuristic HAS-PSO algorithm is used to select a fixed number of CHs. It does not guarantee to cover the whole network for a specific number of CHs. The CHs in HAS-PSO employ direct communication to transmit data to the BS that reduces the energy efficiency [23].The artificial bee colony (ABC) optimization also used constitute clusters in the WSN. WSN clustering using ABC (WSNCABC) employs the artificial bee colony to calculate the CH fitness using parameters like residual energy of the nodes and the distance between the BS and the nodes. However, this algorithm has a high cost for direct data transmission from the CH to the BS [24]. The clustering protocol based on ABC (ABC-C) has been presented in another study that improved the fitness function. The residual energy, distance of the node from the BS, and quality of the link are considered as the parameters of the fitness function. This algorithm selects the CH periodically [25]. The B-Sensor-C algorithm has been developed for event-oriented SNs. When an event occurs, the protocol constitutes the clusters and selects the CH. The most important node that verifies this event should be the CH and others should follow it [26]. The energy-aware bee colony approach (EABCA) improves the network performance with the fitness function. Multihop communications between the CH and the BS are not required for data delivery [27].Table1 compares the clustering-based methods based on swarm intelligence regarding important parameters of WSN clustering.Table 1
Comparison of the clustering methods based on swarm intelligence.
ProtocolLocationClustering algorithmApproachCluster head roundRouting the CH to the BSMobilityNode establishmentBS locationGABEECUnawareCentralizedGAAll roundsDirectStationaryRandomOutside the areaGCAUnawareDistributedGAAll roundsDirectStationaryRandomCenter of the areaGAECHUnawareCentralizedGAAll roundsDirectStationaryRandomOutside, corner, and center of the areahACOUnawareCentralizedACOAll roundsDirectMobileRandomOutside the areaANTCLUSTUnawareCentralizedACOAll roundsDirectStationaryRandomOutside the areaPSOUnawareCentralizedPSOAll roundsDirectStationaryRandomInside the areaPSO-SDUnawareCentralizedPSOAll roundsMultihopStationaryRandomInside the areaHAS-PSOUnawareCentralizedPSOAll roundsDirectSemistationaryRandomInside the areaWSNCABCUnawareCentralizedABCAll roundsDirectStationaryRandomCenter of the areaABC-CUnawareCentralizedABCAll roundsDirectStationaryRandomCenter of the areaBee-Sensor-CUnawareDistributedABCAll roundsMulti-hopMobileRandomOutside the areaEABCAUnawareCentralizedABCAll roundsMulti-hopStationaryRandomCenter of the area


## 3. The Proposed Method

As mentioned, in this study, a novel optimization approach is presented for WSN clustering using the multiobjective GA and the gravitational search algorithm. In this study, the multiobjective GA based on reducing the intracluster distance and energy consumption of the MNs is used to find the CHs and the nearly optimal routing based on the gravitational search algorithm is used to find the optimal route and transmit information between the CH nodes and the sink node. This study is presented to reduce the energy consumption of the sensor nodes, increase the network throughput, increase the data delivery rate, and reduce the information packet transmission delay. Figure1 shows flowchart of the proposed method.Figure 1
Flowchart of the proposed method.As shown in Figure1, the proposed method has three main steps as follows:
(i)
WSN configuration and random node clustering in the network(ii)
Determining the optimal CHs using GA(iii)
Determining the optimal route using the gravitational search algorithmIn the rest of this section, the aforementioned methods are described.


### 3.1. Initial Clustering

In the first section of the proposed method, the proposed WSN is simulated with 100 sensor nodes and one sink node. The initial parameters are considered based on the standard parameters of similar methods. Finally, the proposed method is compared with other available methods. After initial configuration of wireless sensor nodes in the network, a “Hello” message is transmitted by the sink node to all sensors to identify the nodes and determine the location of the existing nodes of the network. All sensors of the network transmit a routing reply (RREP) to the sink node after receiving the “Hello” message to obtain the exact location of each sensor node for initial clustering of the nodes. Since the energy required to transmit the RREP packets and data is different, different energy consumption constants are considered for each packet type. Thus, the energy consumption of the proposed method is examined accurately. In the next step, after receiving the RREP and identifying the initial location of the wireless sensor nodes, the proposed method clusters the nodes based on the random CHs. Since the initial energy of all nodes at the beginning steps is constant, random selection of the CHs does not interrupt the data transmission and early energy discharge of some sensor nodes does not occur. Then, the wireless sensor nodes are clustered based on their distance from the CH node. The distance of the sensor nodes from the CH node is measured based on the Euclidean distance, which is represented in equation (1) as follows.
(1)Euclidean−distance=xi−xj2+yi−yj21/2.in which xi,yi represents coordinate of the ith node. In this step, the CH nodes are given to the GA as the initial chromosomes so that the optimal location of the CH is found. In the proposed GA, an optimal node in the selected cluster might not be found as the CH. In this case, the cluster is wound up and upon finding an optimal CH around the cluster, clustering is carried out again.


### 3.2. Using GA to Determine the Optimal CHs

As mentioned, in the second step of the proposed method, the GA is used to find the new and optimal CHs instead of random CHs selected in the previous step. In the following, the chromosomes are configured and the fitness function of the GA for the proposed method is defined.


#### 3.2.1. Chromosome Encoding

The proposed GA receives an initial set of CHs as input and initiates by generating an initial population of the chromosomes, where each chromosome represents a possible solution for the clustering problem. Therefore, a chromosome is a vector of genes and the numbers inside each chromosome represent the index of a CH node. In Figure2, an example of the chromosomes of the proposed method is given.Figure 2
Chromosomes of the proposed method.As shown in Figure2, the chromosomes of the proposed method include a vector of genes where each gene represents an index of a CH node. The numbers inserted in each gene represent the CH selected randomly in the initial step. At the beginning, each chromosome is considered as the probabilistic clustering in the WSN that changes by applying the fitness function and mutation and crossover operators. Finally, the chromosome with maximum fitness is selected as the nearly optimal cluster.


#### 3.2.2. Fitness Function of the GA

The fitness function of each chromosome is determined considering the objective function that is a combination of residual energy of the CH, mean intracluster distance, and distance of the CH from the sink. For each possible clustering of the population, the fitness function is considered as the representative of the parameters of interest to balance the residual energy of the CH, mean intracluster distance, and distance of the CH from the sink. Since the scales of the distances between the nodes and energy of the sensor nodes is not the same, the values of the proposed method should be normalized to obtain a unit value as the fitness function; in the proposed method, MIN-MAX normalization, given in equation (2), is used [28].
(2)NX=Xi−minXmaxX−minX.where NX is the normalized data, Xi is the main data, minX is the minimum possible value of the data, and maxX is the maximum value of the data.The fitness function used to evaluate the given chromosomes using the proposed objective function is calculated based on equation (3).
(3)Fitness=min∑i=1M∑j=1nDi,j+∑i=1MDSi−∑i=1MEresi,subject to
(4)∑i=1MEresi>Emini,(5)∑i=1MDSi≤DSfaresrj,∑i=1M∑j=1nDi,j≤∑j=1nDSj,Mi≥0,DSi≥0,Di,j≥0,Considering the fitness function given in equation (3), the proper chromosomes are selected from the initial population and other chromosomes are transmitted to the mutation and crossover operators to diversify the population and generate new superior chromosomes. Each chromosome of the new offspring population is checked to see if it is a possible solution for the problem or not (does it minimize the fitness function and satisfy the given constraints or not). The impossible chromosomes that violate the existing constraints are penalized considering their fitness value such that they have a lower probability to be selected for generation and conversion to new chromosomes. The most proper chromosome that represents the nearly optimal clustering solution is preserved at each iteration and sorted based on its optimality. This process continues until the termination condition is met.


#### 3.2.3. The Crossover Operator

The crossover operator is an essential step of the GA to diversify the population and generate new chromosomes. To increase the search domain and public feasible solutions, the GA should apply the crossover operator between two chromosomes (parents) and generate new offspring as the new population. The crossover operator is performed as a random replacement of a number of genes of the first chromosome with the second chromosome. Thus, the parameter that is essential in the crossover operator is called the crossover probability orP-crossover, which is defined as follows for random crossover.
(6)P−crossover=roundk∗Gmax−Gmin,kisarandin0,1,in which Gmax is the maximum number of genes and Gmin is the minimum number of genes of the chromosome. The parameter k is considered as a random number in the range of 0 and 1. The value of P-crossover is considered as a part of the chromosome that should be exchanged between the first chromosome and the second chromosome; the beginning and ending points are called the crosspoints. The beginning crosspoint might be selected from the beginning of the chromosome or any other part of the chromosome, and the ending crosspoints are added to the P-crossover. Figure 3 shows the crossover operator.Figure 3
An example of crossover of two chromosomes.As shown in Figure3, each gene, Ti, represents a CH node and Ri represents the cluster of each gene for any of the solutions.


#### 3.2.4. Mutation Operator

The mutation operator, like the crossover operator, also plays a significant role in generating a new population and diversifying the chromosomes. This operator can increase the search domain and the possible solutions and generate new offspring as the new population. Thus, in this operator, the probability parameter is of great importance that is considered as a chromosome that should mutate. TheP-mutate parameter or the mutation probability can be calculated.
(7)P−mutate=roundk∗Gmax−Gmin,kisarandin0,1.TheP-mutate parameter represents the mutation probability, and the parameter k can be considered as a value between zero and one; zero or one can be considered as the first or the last gene of the chromosome. The difference of the mutation and the crossover operators is that the crossover operator changes several genes of a chromosome with another chromosome but the mutation operator only changes the value of one gene to generate a new chromosome. Figure 4 shows the mutation operator.Figure 4
An example of population diversity of the chromosomes.As shown in Figure4, there are two chromosomes with different genes that change at i+1 and N−2, independently. At i+1, the value of the gene changes from R2 to R4. Similarly, the value of the gene mutates from R5 to R2 at N−2. The gene mutation might yield excellent results. Sometimes the results might not be satisfactory. However, the gene mutation is essential to preserve population diversity.


#### 3.2.5. Selection Operator

The selection operator, after the crossover and the mutation operators, selects the chromosomes with maximum fitness or the nearly optimal solution among the new population and the chromosomes generated as the next generation for the clustering problem to reduce energy consumption in the WSN. In this case, the CHs assigned to each cluster with maximum residual energy, minimum mean intracluster distance, and minimum distance to the CH are examined to balance the energy consumption of each cluster. Therefore, the efficiency of the clustering algorithm is optimized to balance the energy consumption of the WSN.


### 3.3. Using the Gravitational Search Algorithm to Find the Optimal Route

As shown in Figure1, in the third step of the proposed method, the gravitational search algorithm finds the best route based on the CHs selected by the proposed GA. In this step, considering the selected CHs, the information transmission routes from each cluster to the sink node are specified. Therefore, the CHs in each cluster are considered as particles of the gravitational search algorithm. Thus, at each information packet transmission step, the gravitational search algorithm measures the particles’ weight and leaves the particles that do not have sufficient quality and other particles are selected as proper solutions.The weight of the selected particles is determined based on the objectives. In other words, in the proposed method, at each information transmission step, the gravitational search algorithm checks if the route between the sensor nodes and the sink node that requires information transmission decreases the total energy consumption and the end-to-end delay and increases the data delivery rate and the network throughput or not. The routes that optimize these measures are selected as the optimal routes, and the routes that worsen even one of these measures are considered as the abandoned routes. Therefore, the fitness function of the proposed gravitational search algorithm is as given in equation (8).
(8)CSfitness=min∑i=1n∑j=1ndelayi,j+∑i=1nEcons−∑i=1nDDRi−∑i=1nthrouputi,subject to
(9)∑i=1n∑j=1ndelayi,j≥0,∑i=1nEcons<Einit,∑i=1nDDRi>0,∑i=1nthrouputi>0,where CSfitness is the fitness function value of the gravitational search algorithm, delayi,j is the end-to-end delay of nodes i and j, Econs is the total energy consumption of the network, Einit is the initial energy of the network, DDRi is the data delivery rate at each node, and throuput is the network throughput. According to the fitness function, each population that obtained the minimum fitness value can be selected as a practical solution for information transmission.


## 3.1. Initial Clustering

In the first section of the proposed method, the proposed WSN is simulated with 100 sensor nodes and one sink node. The initial parameters are considered based on the standard parameters of similar methods. Finally, the proposed method is compared with other available methods. After initial configuration of wireless sensor nodes in the network, a “Hello” message is transmitted by the sink node to all sensors to identify the nodes and determine the location of the existing nodes of the network. All sensors of the network transmit a routing reply (RREP) to the sink node after receiving the “Hello” message to obtain the exact location of each sensor node for initial clustering of the nodes. Since the energy required to transmit the RREP packets and data is different, different energy consumption constants are considered for each packet type. Thus, the energy consumption of the proposed method is examined accurately. In the next step, after receiving the RREP and identifying the initial location of the wireless sensor nodes, the proposed method clusters the nodes based on the random CHs. Since the initial energy of all nodes at the beginning steps is constant, random selection of the CHs does not interrupt the data transmission and early energy discharge of some sensor nodes does not occur. Then, the wireless sensor nodes are clustered based on their distance from the CH node. The distance of the sensor nodes from the CH node is measured based on the Euclidean distance, which is represented in equation (1) as follows.
(1)Euclidean−distance=xi−xj2+yi−yj21/2.in which xi,yi represents coordinate of the ith node. In this step, the CH nodes are given to the GA as the initial chromosomes so that the optimal location of the CH is found. In the proposed GA, an optimal node in the selected cluster might not be found as the CH. In this case, the cluster is wound up and upon finding an optimal CH around the cluster, clustering is carried out again.


## 3.2. Using GA to Determine the Optimal CHs

As mentioned, in the second step of the proposed method, the GA is used to find the new and optimal CHs instead of random CHs selected in the previous step. In the following, the chromosomes are configured and the fitness function of the GA for the proposed method is defined.


### 3.2.1. Chromosome Encoding

The proposed GA receives an initial set of CHs as input and initiates by generating an initial population of the chromosomes, where each chromosome represents a possible solution for the clustering problem. Therefore, a chromosome is a vector of genes and the numbers inside each chromosome represent the index of a CH node. In Figure2, an example of the chromosomes of the proposed method is given.Figure 2
Chromosomes of the proposed method.As shown in Figure2, the chromosomes of the proposed method include a vector of genes where each gene represents an index of a CH node. The numbers inserted in each gene represent the CH selected randomly in the initial step. At the beginning, each chromosome is considered as the probabilistic clustering in the WSN that changes by applying the fitness function and mutation and crossover operators. Finally, the chromosome with maximum fitness is selected as the nearly optimal cluster.


### 3.2.2. Fitness Function of the GA

The fitness function of each chromosome is determined considering the objective function that is a combination of residual energy of the CH, mean intracluster distance, and distance of the CH from the sink. For each possible clustering of the population, the fitness function is considered as the representative of the parameters of interest to balance the residual energy of the CH, mean intracluster distance, and distance of the CH from the sink. Since the scales of the distances between the nodes and energy of the sensor nodes is not the same, the values of the proposed method should be normalized to obtain a unit value as the fitness function; in the proposed method, MIN-MAX normalization, given in equation (2), is used [28].
(2)NX=Xi−minXmaxX−minX.where NX is the normalized data, Xi is the main data, minX is the minimum possible value of the data, and maxX is the maximum value of the data.The fitness function used to evaluate the given chromosomes using the proposed objective function is calculated based on equation (3).
(3)Fitness=min∑i=1M∑j=1nDi,j+∑i=1MDSi−∑i=1MEresi,subject to
(4)∑i=1MEresi>Emini,(5)∑i=1MDSi≤DSfaresrj,∑i=1M∑j=1nDi,j≤∑j=1nDSj,Mi≥0,DSi≥0,Di,j≥0,Considering the fitness function given in equation (3), the proper chromosomes are selected from the initial population and other chromosomes are transmitted to the mutation and crossover operators to diversify the population and generate new superior chromosomes. Each chromosome of the new offspring population is checked to see if it is a possible solution for the problem or not (does it minimize the fitness function and satisfy the given constraints or not). The impossible chromosomes that violate the existing constraints are penalized considering their fitness value such that they have a lower probability to be selected for generation and conversion to new chromosomes. The most proper chromosome that represents the nearly optimal clustering solution is preserved at each iteration and sorted based on its optimality. This process continues until the termination condition is met.


### 3.2.3. The Crossover Operator

The crossover operator is an essential step of the GA to diversify the population and generate new chromosomes. To increase the search domain and public feasible solutions, the GA should apply the crossover operator between two chromosomes (parents) and generate new offspring as the new population. The crossover operator is performed as a random replacement of a number of genes of the first chromosome with the second chromosome. Thus, the parameter that is essential in the crossover operator is called the crossover probability orP-crossover, which is defined as follows for random crossover.
(6)P−crossover=roundk∗Gmax−Gmin,kisarandin0,1,in which Gmax is the maximum number of genes and Gmin is the minimum number of genes of the chromosome. The parameter k is considered as a random number in the range of 0 and 1. The value of P-crossover is considered as a part of the chromosome that should be exchanged between the first chromosome and the second chromosome; the beginning and ending points are called the crosspoints. The beginning crosspoint might be selected from the beginning of the chromosome or any other part of the chromosome, and the ending crosspoints are added to the P-crossover. Figure 3 shows the crossover operator.Figure 3
An example of crossover of two chromosomes.As shown in Figure3, each gene, Ti, represents a CH node and Ri represents the cluster of each gene for any of the solutions.


### 3.2.4. Mutation Operator

The mutation operator, like the crossover operator, also plays a significant role in generating a new population and diversifying the chromosomes. This operator can increase the search domain and the possible solutions and generate new offspring as the new population. Thus, in this operator, the probability parameter is of great importance that is considered as a chromosome that should mutate. TheP-mutate parameter or the mutation probability can be calculated.
(7)P−mutate=roundk∗Gmax−Gmin,kisarandin0,1.TheP-mutate parameter represents the mutation probability, and the parameter k can be considered as a value between zero and one; zero or one can be considered as the first or the last gene of the chromosome. The difference of the mutation and the crossover operators is that the crossover operator changes several genes of a chromosome with another chromosome but the mutation operator only changes the value of one gene to generate a new chromosome. Figure 4 shows the mutation operator.Figure 4
An example of population diversity of the chromosomes.As shown in Figure4, there are two chromosomes with different genes that change at i+1 and N−2, independently. At i+1, the value of the gene changes from R2 to R4. Similarly, the value of the gene mutates from R5 to R2 at N−2. The gene mutation might yield excellent results. Sometimes the results might not be satisfactory. However, the gene mutation is essential to preserve population diversity.


### 3.2.5. Selection Operator

The selection operator, after the crossover and the mutation operators, selects the chromosomes with maximum fitness or the nearly optimal solution among the new population and the chromosomes generated as the next generation for the clustering problem to reduce energy consumption in the WSN. In this case, the CHs assigned to each cluster with maximum residual energy, minimum mean intracluster distance, and minimum distance to the CH are examined to balance the energy consumption of each cluster. Therefore, the efficiency of the clustering algorithm is optimized to balance the energy consumption of the WSN.


## 3.2.1. Chromosome Encoding

The proposed GA receives an initial set of CHs as input and initiates by generating an initial population of the chromosomes, where each chromosome represents a possible solution for the clustering problem. Therefore, a chromosome is a vector of genes and the numbers inside each chromosome represent the index of a CH node. In Figure2, an example of the chromosomes of the proposed method is given.Figure 2
Chromosomes of the proposed method.As shown in Figure2, the chromosomes of the proposed method include a vector of genes where each gene represents an index of a CH node. The numbers inserted in each gene represent the CH selected randomly in the initial step. At the beginning, each chromosome is considered as the probabilistic clustering in the WSN that changes by applying the fitness function and mutation and crossover operators. Finally, the chromosome with maximum fitness is selected as the nearly optimal cluster.


## 3.2.2. Fitness Function of the GA

The fitness function of each chromosome is determined considering the objective function that is a combination of residual energy of the CH, mean intracluster distance, and distance of the CH from the sink. For each possible clustering of the population, the fitness function is considered as the representative of the parameters of interest to balance the residual energy of the CH, mean intracluster distance, and distance of the CH from the sink. Since the scales of the distances between the nodes and energy of the sensor nodes is not the same, the values of the proposed method should be normalized to obtain a unit value as the fitness function; in the proposed method, MIN-MAX normalization, given in equation (2), is used [28].
(2)NX=Xi−minXmaxX−minX.where NX is the normalized data, Xi is the main data, minX is the minimum possible value of the data, and maxX is the maximum value of the data.The fitness function used to evaluate the given chromosomes using the proposed objective function is calculated based on equation (3).
(3)Fitness=min∑i=1M∑j=1nDi,j+∑i=1MDSi−∑i=1MEresi,subject to
(4)∑i=1MEresi>Emini,(5)∑i=1MDSi≤DSfaresrj,∑i=1M∑j=1nDi,j≤∑j=1nDSj,Mi≥0,DSi≥0,Di,j≥0,Considering the fitness function given in equation (3), the proper chromosomes are selected from the initial population and other chromosomes are transmitted to the mutation and crossover operators to diversify the population and generate new superior chromosomes. Each chromosome of the new offspring population is checked to see if it is a possible solution for the problem or not (does it minimize the fitness function and satisfy the given constraints or not). The impossible chromosomes that violate the existing constraints are penalized considering their fitness value such that they have a lower probability to be selected for generation and conversion to new chromosomes. The most proper chromosome that represents the nearly optimal clustering solution is preserved at each iteration and sorted based on its optimality. This process continues until the termination condition is met.


## 3.2.3. The Crossover Operator

The crossover operator is an essential step of the GA to diversify the population and generate new chromosomes. To increase the search domain and public feasible solutions, the GA should apply the crossover operator between two chromosomes (parents) and generate new offspring as the new population. The crossover operator is performed as a random replacement of a number of genes of the first chromosome with the second chromosome. Thus, the parameter that is essential in the crossover operator is called the crossover probability orP-crossover, which is defined as follows for random crossover.
(6)P−crossover=roundk∗Gmax−Gmin,kisarandin0,1,in which Gmax is the maximum number of genes and Gmin is the minimum number of genes of the chromosome. The parameter k is considered as a random number in the range of 0 and 1. The value of P-crossover is considered as a part of the chromosome that should be exchanged between the first chromosome and the second chromosome; the beginning and ending points are called the crosspoints. The beginning crosspoint might be selected from the beginning of the chromosome or any other part of the chromosome, and the ending crosspoints are added to the P-crossover. Figure 3 shows the crossover operator.Figure 3
An example of crossover of two chromosomes.As shown in Figure3, each gene, Ti, represents a CH node and Ri represents the cluster of each gene for any of the solutions.


## 3.2.4. Mutation Operator

The mutation operator, like the crossover operator, also plays a significant role in generating a new population and diversifying the chromosomes. This operator can increase the search domain and the possible solutions and generate new offspring as the new population. Thus, in this operator, the probability parameter is of great importance that is considered as a chromosome that should mutate. TheP-mutate parameter or the mutation probability can be calculated.
(7)P−mutate=roundk∗Gmax−Gmin,kisarandin0,1.TheP-mutate parameter represents the mutation probability, and the parameter k can be considered as a value between zero and one; zero or one can be considered as the first or the last gene of the chromosome. The difference of the mutation and the crossover operators is that the crossover operator changes several genes of a chromosome with another chromosome but the mutation operator only changes the value of one gene to generate a new chromosome. Figure 4 shows the mutation operator.Figure 4
An example of population diversity of the chromosomes.As shown in Figure4, there are two chromosomes with different genes that change at i+1 and N−2, independently. At i+1, the value of the gene changes from R2 to R4. Similarly, the value of the gene mutates from R5 to R2 at N−2. The gene mutation might yield excellent results. Sometimes the results might not be satisfactory. However, the gene mutation is essential to preserve population diversity.


## 3.2.5. Selection Operator

The selection operator, after the crossover and the mutation operators, selects the chromosomes with maximum fitness or the nearly optimal solution among the new population and the chromosomes generated as the next generation for the clustering problem to reduce energy consumption in the WSN. In this case, the CHs assigned to each cluster with maximum residual energy, minimum mean intracluster distance, and minimum distance to the CH are examined to balance the energy consumption of each cluster. Therefore, the efficiency of the clustering algorithm is optimized to balance the energy consumption of the WSN.


## 3.3. Using the Gravitational Search Algorithm to Find the Optimal Route

As shown in Figure1, in the third step of the proposed method, the gravitational search algorithm finds the best route based on the CHs selected by the proposed GA. In this step, considering the selected CHs, the information transmission routes from each cluster to the sink node are specified. Therefore, the CHs in each cluster are considered as particles of the gravitational search algorithm. Thus, at each information packet transmission step, the gravitational search algorithm measures the particles’ weight and leaves the particles that do not have sufficient quality and other particles are selected as proper solutions.The weight of the selected particles is determined based on the objectives. In other words, in the proposed method, at each information transmission step, the gravitational search algorithm checks if the route between the sensor nodes and the sink node that requires information transmission decreases the total energy consumption and the end-to-end delay and increases the data delivery rate and the network throughput or not. The routes that optimize these measures are selected as the optimal routes, and the routes that worsen even one of these measures are considered as the abandoned routes. Therefore, the fitness function of the proposed gravitational search algorithm is as given in equation (8).
(8)CSfitness=min∑i=1n∑j=1ndelayi,j+∑i=1nEcons−∑i=1nDDRi−∑i=1nthrouputi,subject to
(9)∑i=1n∑j=1ndelayi,j≥0,∑i=1nEcons<Einit,∑i=1nDDRi>0,∑i=1nthrouputi>0,where CSfitness is the fitness function value of the gravitational search algorithm, delayi,j is the end-to-end delay of nodes i and j, Econs is the total energy consumption of the network, Einit is the initial energy of the network, DDRi is the data delivery rate at each node, and throuput is the network throughput. According to the fitness function, each population that obtained the minimum fitness value can be selected as a practical solution for information transmission.


## 4. Implementation of the Proposed Method

To implement the proposed method, first, the WSN is configured based on the standard parameters. The proposed network is implemented in a100×100 environment. To implement this scenario, MATLAB 2021a is used. Other parameters of the proposed network are given in Table 2. Figure 5 also shows the initial configuration of the proposed WSN.Table 2
Initial parameters of the proposed WSN.
ParametersValueNetwork dimension100×100Number of sensor nodes100Coordinate of the sink node50,50Initial energy of the nodes0.5JInitial energy of the sink node50JEnergy consumption of data transmission5×108Energy consumption of data reception5×108Energy consumption of routing packet transmission1×1010Energy consumption of routing packet reception13×1013Energy consumption of data aggregation5×109Initial probability of selecting the sensor node as the CH0.01Maximum number of rounds3500Data packet length4000Number of packet transmissions at each hop10Routing packet length100Radio range5000Figure 5
Initial configuration of the proposed WSN.As shown in Table2 and Figure 5, the proposed WSN is simulated based on the initial parameters. This network is comprised of 100 sensor nodes that are distributed randomly in the network. The sink node is also at the center of the network that facilitates access to it.In the first step, the sink node collects information about the location of the network sensors and selects multiple CHs accordingly. The CHs are selected randomly, and the sensor nodes also join the CHs based on their distance and constitute clusters. After formation of the first cluster and transmitting data to the CH, the information about the initial energy and the intracluster distances and distance of the CH from the source can be calculated. In Figure6, the initial clustering of the WSN is shown. Table 3 represents the information of the initial CHs.Figure 6
Initial clustering of the nodes in a WSN.Table 3
Information of the initial CHs.
CH no.Node index11121531842053964775685896710801186128813951497Information of Table4 is given as the initial chromosome to the GA, and the second step of the proposed method is implemented. In the first step of the proposed GA, the initial population is evaluated considering the randomly selected CHs. To evaluate the input population of the proposed GA, the fitness function is applied to the initial population. Accordingly, the proposed GA evaluates the CHs in terms of the residual energy, mean intracluster distance, and distance from the sink node. Since no data is transmitted in the initial population, the initial energy of all CH nodes and MNs is the same. Thus, in the first step, the CHs are evaluated in terms of intracluster distance and distance from the sink node. In the following, since the optimal routes are found, information transmission, energy consumption, and residual energy affect the selection of the optimal CHs. To this end, Table 4 represents the fitness value of the initial population.Table 4
Fitness value of the initial population.
CH no.Node indexFitness value1110.88842150.84493180.80944200.80865390.86536470.80997560.74868580.61199670.801210800.560211860.607712880.483613950.580214970.0982As shown in Table4, the fitness value of each CH in the initial population is calculated. It is seen that some CHs have an excellent fitness but other are weak. Thus, in the next step, the new population is generated based on the crossover and mutation operators and the fitness value of the new population is examined. The new population of the proposed method is a combination of the CHs that have replaced the previous CHs, and their fitness is evaluated. Table 5 represents the expert population that have replaced the initial population considering their fitness.Table 5
Fitness values of the new population.
CH no.CH indexFitness valueCH indexFitness value1110.8884760.94852150.8449740.96783180.8094810.94384200.8686210.97215390.8653940.96316470.8099810.98447560.74865118580.6119280.94639670.8012550.998410800.560251111860.607751112880.483651113950.580270.974214970.9822970.9822As shown in Table5, the fitness values of the new population are calculated. The clusters of three CHs with indexes of 86, 80, and 80 are broke down, and they are integrated in a cluster with CH 51. Also, it is seen that CH 97 is transferred from the previous population to the new expert population. Figure 7 shows the replacement of the new CHs with the previous CHs.Figure 7
Replacement of the new CHs with previous CHs.As shown in Figure7, the previous CHs are represented with a black ×, the previous connections are represented in blue, and the connections with new CHs are represented in red. The new CHs are selected as the proposed solution for information transmission form sensor nodes, data aggregation, and data transmission to the sink node. Considering the distance of the CH nodes from the sink node, if a CH observes another CH along the direct route to the sink, the packet transmission is carried out in multihops between the CHs and the sink node.Now, the proposed method enters the third step in which the gravitational search algorithm examines the quality of the route based on the CHs obtained using the GA. Considering the global search capability of the gravitational search algorithm, it can find the optimal route in the whole network. This step determines if the selected route is optimal for information packet transmission or there might be a more optimal route and the GA is trapped in local optimum. Algorithm1 represents the output of the gravitational search algorithm for the routes proposed by the GA.Algorithm 1: The output of the gravitational search algorithm for finding the high-quality routes.
This solution of cluster heads as route must be abandoned51 37 61 76 76 79 61 79 76 76 21 53∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗This route is selected by probability 0.76915========================================76 21 59 79 51 37 10 29 41 25 69 87∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗This solution of cluster heads as route must be abandoned71 87 61 76 76 87 22 87 76 42 19 42∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗This solution of cluster heads as route must be abandoned22 87 42 87 76 76 76 76 76 71 87 51∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗This route is selected by probability 0.8945========================================67 76 21 62 71 57 17 79 73 37 25 38As shown in Table5, the optimal routing of the proposed method is carried out using the gravitational search algorithm. The gravitational search algorithm examines the quality of the routes proposed by the GA based on the fitness function given in equation (11), and the routes that improve the network objectives are returned with their fitness value. Figure 8 shows convergence of the gravitational search algorithm to the optimal point.Figure 8
Convergence of the gravitational search algorithm to the optimal point.As shown in Figure8, since the employed fitness function is a minimization function, the gravitational search algorithm reduces the objective function value at each step so that it converges to the optimal point. In the following, in Figure 9, the dead nodes of the WSN are represented.Figure 9
Death process of the sensor nodes by information transmission in the WSN.As shown in Figure9, the wireless sensor nodes run out of energy by information transmission and die. In Figure 9, small red dots show the dead nodes; as the information transmission steps increase, the number of dead nodes also increases until the network is interrupted. In the following, the proposed method is evaluated.


### 4.1. Evaluation of the Proposed Method

The proposed method is evaluated to examine its quality and improve the proposed method on the primary problem. Various measures have been presented in the literature to evaluate the WSNs, which are introduced considering the research objectives mentioned in the first section. In this section of the study, the proposed method is evaluated in terms of energy consumption, residual energy, message transmission delay, number of lost packets, data delivery rate, and network throughput. Thus, Figure10 shows the average energy consumption of the network. Figure 11 also shows the total residual energy as the data transmission steps increase.Figure 10
The average energy consumption in all nodes of the network.Figure 11
Total residual energy of the network nodes.As shown in Figures10 and 11, the slope of the energy consumption and residual energy curves is linear, indicating that energy consumption in the network nodes is symmetric. Thus, some nodes do not run out of energy earlier than other nodes and all nodes run out of energy almost the same. Thus, all nodes run out of energy gradually, indicating a long lifetime of the network. Figure 12 shows the death process of the sensor nodes of the network.Figure 12
Death process of the sensor nodes of the network.As shown in Figure12, the first node in the proposed WSN has died after 1470 iterations. In WSN routing methods, if a node dies, an alternative route might be found for information transmission but the information of that area cannot be aggregated. So, as long as a node’s death does not interrupt the network, its death can be handled. In the proposed method, this has occurred in the 3020th round in which about half of the nodes have run out of energy and the network is interrupted.Another measure used to evaluate the proposed method is the number of lost packets. The smaller is the number of lost packets in the information aggregation process, the quality of information collection and accuracy of the routing method are higher. Selecting nodes with congestion of transmitted packets that appear as the network bottleneck might be one of the main reasons of information packet loss. Figure13 shows the lost nodes in the proposed method.Figure 13
Lost packets in the proposed method.As shown in Figure13, the number of lost packets in the proposed method is about 70 packets, yielding a maximum of 0.02 lost packets considering the 35000 total transmitted packets during routing. Therefore, it can be concluded that the proposed method is able to find the optimal route and deliver the information packets correctly. To this end, the date delivery rate, which is the ratio of received data to the transmitted data in the whole network can be examined. Figure 14 shows the data delivery rate of the proposed method.Figure 14
The data delivery rate of the proposed method.As can be seen in Figure14, the data delivery rate of the proposed method is high and reaches 99.8% for 3500 rounds of the network. As the method, this large value indicates the ability of the proposed method to find the optimal route and deliver and the information packets correctly. After this measure, the network throughput can be examined. The throughput is the ratio of the transmitted packets per unit time to the bandwidth of the transmission medium. Since the bandwidth of WSNs is considered the same for all sensor nodes, the network throughput indicates the data delivery rate per unit time. Figure 15 shows the network throughput of the proposed method.Figure 15
Network throughput.As shown in Figure15, the network throughput has increased in an ascending order reaching 100% at the end.The last measure that is evaluated is the end-to-end delay of the network nodes. Since the transmission time factor of a packet is fixed for the nodes, the main reason of the delay in end-to-end transmission is the distance between the nodes. Since in the proposed method, information is transmitted between the sensor nodes and the CH, the shorter distance between the CH and other nodes indicates accurate clustering and shorter mean intracluster distance, which is one of the objectives of the proposed GA. Figure16 shows the cumulative effect of end-to-end delay of 100 nodes.Figure 16
The cumulative end-to-end delay of the nodes.As shown in Figure16, the proposed method has a 100 ms delay for 100 nodes and 3500 transmission rounds, demonstrating the high clustering accuracy of the proposed method.


### 4.2. Comparison of the Proposed Method with Previous Studies

Considering the importance of routing in WSNs for balancing the energy consumption of the nodes, the proposed method is compared with a previous method in terms of energy consumption and other evaluation measures. To this end, the proposed method is compared with [5, 11, 29] in terms of energy consumption and network lifetime. Figure 17 compares the proposed method with a previous method in terms of average energy consumption.Figure 17
Comparison of the proposed method and the previous methods in terms of energy consumption.As shown in Figure17, the proposed method has a lower average energy consumption for 100 nodes compared to the previous methods. Figure 18 also compares the proposed method and the previous methods in terms of lifetime and death of the first node.Figure 18
Comparison of the proposed method and the previous method in terms of lifetime.As shown in Figure19, the proposed method has a longer lifetime compared to the previous method and the first node in the proposed method dies later than other methods, indicating the balanced energy consumption of the proposed method. Figure 19 compares the proposed method and previous methods in terms of data delivery rate.Figure 19
Comparison of the proposed method and previous methods in terms of data delivery rate.As shown in Figure19, the proposed method has a higher data delivery rate compared to the previous methods, indicating the selection of the optimal route and avoidance of the bottlenecks and losing the minimum number of information packets.


## 4.1. Evaluation of the Proposed Method

The proposed method is evaluated to examine its quality and improve the proposed method on the primary problem. Various measures have been presented in the literature to evaluate the WSNs, which are introduced considering the research objectives mentioned in the first section. In this section of the study, the proposed method is evaluated in terms of energy consumption, residual energy, message transmission delay, number of lost packets, data delivery rate, and network throughput. Thus, Figure10 shows the average energy consumption of the network. Figure 11 also shows the total residual energy as the data transmission steps increase.Figure 10
The average energy consumption in all nodes of the network.Figure 11
Total residual energy of the network nodes.As shown in Figures10 and 11, the slope of the energy consumption and residual energy curves is linear, indicating that energy consumption in the network nodes is symmetric. Thus, some nodes do not run out of energy earlier than other nodes and all nodes run out of energy almost the same. Thus, all nodes run out of energy gradually, indicating a long lifetime of the network. Figure 12 shows the death process of the sensor nodes of the network.Figure 12
Death process of the sensor nodes of the network.As shown in Figure12, the first node in the proposed WSN has died after 1470 iterations. In WSN routing methods, if a node dies, an alternative route might be found for information transmission but the information of that area cannot be aggregated. So, as long as a node’s death does not interrupt the network, its death can be handled. In the proposed method, this has occurred in the 3020th round in which about half of the nodes have run out of energy and the network is interrupted.Another measure used to evaluate the proposed method is the number of lost packets. The smaller is the number of lost packets in the information aggregation process, the quality of information collection and accuracy of the routing method are higher. Selecting nodes with congestion of transmitted packets that appear as the network bottleneck might be one of the main reasons of information packet loss. Figure13 shows the lost nodes in the proposed method.Figure 13
Lost packets in the proposed method.As shown in Figure13, the number of lost packets in the proposed method is about 70 packets, yielding a maximum of 0.02 lost packets considering the 35000 total transmitted packets during routing. Therefore, it can be concluded that the proposed method is able to find the optimal route and deliver the information packets correctly. To this end, the date delivery rate, which is the ratio of received data to the transmitted data in the whole network can be examined. Figure 14 shows the data delivery rate of the proposed method.Figure 14
The data delivery rate of the proposed method.As can be seen in Figure14, the data delivery rate of the proposed method is high and reaches 99.8% for 3500 rounds of the network. As the method, this large value indicates the ability of the proposed method to find the optimal route and deliver and the information packets correctly. After this measure, the network throughput can be examined. The throughput is the ratio of the transmitted packets per unit time to the bandwidth of the transmission medium. Since the bandwidth of WSNs is considered the same for all sensor nodes, the network throughput indicates the data delivery rate per unit time. Figure 15 shows the network throughput of the proposed method.Figure 15
Network throughput.As shown in Figure15, the network throughput has increased in an ascending order reaching 100% at the end.The last measure that is evaluated is the end-to-end delay of the network nodes. Since the transmission time factor of a packet is fixed for the nodes, the main reason of the delay in end-to-end transmission is the distance between the nodes. Since in the proposed method, information is transmitted between the sensor nodes and the CH, the shorter distance between the CH and other nodes indicates accurate clustering and shorter mean intracluster distance, which is one of the objectives of the proposed GA. Figure16 shows the cumulative effect of end-to-end delay of 100 nodes.Figure 16
The cumulative end-to-end delay of the nodes.As shown in Figure16, the proposed method has a 100 ms delay for 100 nodes and 3500 transmission rounds, demonstrating the high clustering accuracy of the proposed method.


## 4.2. Comparison of the Proposed Method with Previous Studies

Considering the importance of routing in WSNs for balancing the energy consumption of the nodes, the proposed method is compared with a previous method in terms of energy consumption and other evaluation measures. To this end, the proposed method is compared with [5, 11, 29] in terms of energy consumption and network lifetime. Figure 17 compares the proposed method with a previous method in terms of average energy consumption.Figure 17
Comparison of the proposed method and the previous methods in terms of energy consumption.As shown in Figure17, the proposed method has a lower average energy consumption for 100 nodes compared to the previous methods. Figure 18 also compares the proposed method and the previous methods in terms of lifetime and death of the first node.Figure 18
Comparison of the proposed method and the previous method in terms of lifetime.As shown in Figure19, the proposed method has a longer lifetime compared to the previous method and the first node in the proposed method dies later than other methods, indicating the balanced energy consumption of the proposed method. Figure 19 compares the proposed method and previous methods in terms of data delivery rate.Figure 19
Comparison of the proposed method and previous methods in terms of data delivery rate.As shown in Figure19, the proposed method has a higher data delivery rate compared to the previous methods, indicating the selection of the optimal route and avoidance of the bottlenecks and losing the minimum number of information packets.


## 5. Conclusion

The wireless sensor network is one of the most recent environments monitoring and controlling networks that collect information from the environment and aggregate data for network applications autonomously without any infrastructure. Thus, the popularity of these networks has resulted in various challenges, among which the unbalanced energy consumption can be mentioned. Considering the limited energy of the sensor nodes, unbalanced energy consumption might affect all performance measures of the network. Thus, in this study, a novel optimization approach using the multiobjective genetic algorithm and the gravitational search algorithm has been presented for WSN clustering. In this study, the multiobjective genetic algorithm based on reducing the intracluster distances and the energy consumption of the member nodes is used to select the cluster heads and the nearly optimal routing based on the gravitational search has been used to transmit information between the cluster heads and the sink node. The implementation results of the proposed method show that considering the capabilities of the multiobjective genetic algorithm and the gravitational search algorithm, the proposed method has improved the average energy consumption, data delivery rate, and network lifetime significantly compared to the previous methods.



---

*Source: 2292580-2021-12-07.xml*