Optimal Base Station Location for Network Lifetime Maximization in Wireless Sensor Network

: Wireless sensor networks have attracted worldwide attention in recent years. The failure of the nodes is caused by unequal energy dissipation. The reasons that cause unequal energy dissipation are, ﬁrst and foremost, the distance between the nodes and the base station, and secondly, the distance between the nodes themselves. In wireless sensor networks, the location of the base station has a substantial impact on the network’s lifetime effectiveness. An improved genetic algorithm based on the crossover elitist conservation genetic algorithm (CECGA) is proposed to optimize the base station location, while for clustering, the K-medoids clustering (KMC) algorithm is used to determine optimal medoids among sensor nodes for choosing the appropriate cluster head. The idea is to decrease the communication distance between nodes and the cluster heads as well as the distance among nodes. For data routing, a multi-hop technique is used to transmit data from the nodes to the cluster head. Implementing an evolutionary algorithm for this optimization problem simpliﬁes the problem with improved computational efﬁciency. The simulation results prove that the proposed algorithm performed better than compared algorithms by reducing the energy use of the network, which results in increasing the lifetime of the nodes, thereby improving the whole network.


Introduction
The advancement of digital technology during the third industrial revolution combined with power-efficient electronic devices has brought about wireless sensor network (WSN) technology.WSN refers to a network of several low-cost, efficient, and multifunctional sensor nodes working together to monitor or investigate an area of interest (AoI).These sensors generate data from the area of interest and send them to a base station (BS) to be processed into useable information.Some of the WSN applications include monitoring the environment [1,2], military surveillance and tracking [3], human-centric applications and robotics [4], agriculture [5], health monitoring [6,7], etc.The type of information acquired by the sensor nodes may include position, temperature, pressure, humidity, vibration, or even the presence of certain chemicals.
Despite the popularization of WSN, the challenges encountered when implementing sensor nodes can be broadly categorized into three main issues: node deployment, data handling (includes acquisition and transfer), and power efficiency.Node deployment density is critical because it affects the overall performance and energy consumption in the network [8,9].If the nodes are sparsely deployed, the sensing accuracy would be compromised, while a dense deployment would result in a high power requirement and cost of the system.This has led to the research into techniques to improve deployment [10], which could be either planned [9], where all the nodes are organized in a grid, random [11], which is more suitable for large-scale AoI, or dynamic [12], where the nodes can be redeployed after the initial deployment.
Data acquisition and transmission are the key functions of WSN, and a growing number of applications require the network to perform various tasks concurrently.This can be achieved by fitting the nodes with multiple sensors, but this plurality of sensors is often associated with invalid data and low-quality data, resulting in high power consumption and latency.Tomovic et al. [13] proposed a weighted task allocation algorithm that avoids sending multiple data through the same path, while authors in [14] proposed an algorithm for multiple tasks scheduling such that only the data from the required sensors are acquired during the task, thereby reducing invalid data and delay and improving the quality of the data, which maximizes the network lifespan.Depending on the application, the network lifetime can be defined in a variety of ways.For example, in clustering methods, the network lifetime is defined as the time when all sensor nodes deplete their energy and stop functioning.Data transmission to the base station is performed in hops.Traditionally, data are transferred from the nodes in a single hop, but the distance between the nodes and the based station and their varying data rates resulted in a power inequality between the nodes; some nodes were found to extinguish too early, while others were still full of power.The clusters and multi-hop were used to improve the energy inequality and reduce the distance problem, thereby improving the lifetime of the nodes.In these techniques, the data in the distant nodes hop onto several nodes before arriving at the cluster head.The problem associated with the data hopping technique is that sometimes some nodes are ill-positioned, such that there are no other nodes around it for data hopping.
The types of nodes implemented in WSN can be classified into homogeneous nodes and heterogeneous nodes.Homogeneous sensor nodes refer to a situation where the sensors in a network have similar power and data rates, while heterogeneous sensor nodes refer to a situation where the sensors in a network have varying power and data rates.The heterogeneous WSN was shown to have better performance indices compared to the homogeneous networks [15].
Optimizing the position of the BS was also found to reduce the effects of ill-positioned nodes [16].Because the energy consumed by cluster heads to send data to the base station is dependent not only on the data bit rate but also on the physical distance between cluster heads and the base station, the location of the base station plays an essential role in the lifetime of wireless sensor networks.As a result, it is critical to comprehend the impact of the base station's location on the performance of wireless sensor networks so that we can optimize the topology throughout the network deployment stage.Direct transmission requires more energy if the base station is located far from the cluster heads because the distance from border to border is sufficiently large, causing the energy in cluster heads to drain faster and the overall lifetime of the wireless sensor network to shorten.On the other hand, if the base station is close to the center of the WSN field, the distance between CHs and the BS is reduced compared to the current assumption, and the CH's energy consumption can be improved.However, locating the BS in the center of a large network area is usually impractical.It would be a practical suggestion to design a better WSN if we could obtain an estimate for some practical cost to locate the BS inside the network to some degree and the results that we can obtain from that expense.
Various researchers have used the clustering of sensor nodes to optimize the energy use of sensor nodes [17].Clustering is used in wireless sensor networks to divide nodes into distinct sets known as clusters with their cluster heads (CHs).The CH then must collect data and forward the data to the base station from its cluster members.Clustering can be divided into several forms, including partition clustering [18], hierarchical clustering [19], and grid clustering [20].These partition-based clustering methods have already demonstrated their effectiveness in increasing the network lifetime and overall scalability of wireless sensor networks [21].
Unlike in paper [16] and other different works that have conducted the optimization of the base station location, the main contributions and innovations of this paper include the following aspects: 1.
To optimize the location of the base station, an efficient energy-saving technique called the crossover elitist conservation genetic algorithm (CECGA) was suggested, where in the crossover phase, we apply the elitist conservation of individuals to replace others in the second generation.To avoid the loss of the best chromosome after mutation, elitism is used to copy some of those chromosomes for the next generation.This optimal location helps reduce the distance from nodes to the base station, which results in saving energy used by nodes.

2.
Data transmission from nodes to the base station consume a high amount of energy that can cause the network to stop working early; to solve this problem, the K-medoids algorithm for nodes clustering is proposed for choosing the appropriate cluster head to acquire the perfect outcome of the cluster, to prevent the adverse effect of outliers, and to calculate the optimum medoids among the sensor nodes.

3.
After forming clusters, a multi-hop data routing is used among sensor nodes inside the cluster to send sensed data to their cluster heads from node to the nearest node, which results in reducing energy use in the cluster.
Our proposed algorithm can improve energy efficiency and efficiently increase the network lifetime by balancing the network workload.The abbreviations used in this paper can be found in Abbreviations.
The remaining sections of this work are organized as follows: Section 2 describes the work's related history.Section 3 outlines the steps of the system and the energy model.Section 4 explains the proposed algorithms.In Section 5, the simulations are carried out, and the results are delivered, and finally, Section 6 concludes the work and expresses the future aspirations of this research.

Literature Review
The evolutionary programming methods proposed by [22], their tactics developed by [23], and developed evolutionary strategies [24] have given rise to what is known as genetic algorithms.These are strategies based on biological mechanisms such as Mendel's laws and Charles' fundamental concept of selection [25].They have been disclosed in [26] to allow computers to emulate biological creatures to solve problems.There are a lot of interesting approaches to dealing with WSN problems, but one of the most powerful metaheuristic approaches is related to GA [27] for solving optimization problems [26], obtaining more information, and understanding the genetic algorithm [28,29].Chen et al. [30] established an innovative protocol (GAEEP) based on genetic algorithms for maximizing lifetime and improving WSN stability.The protocol goals were to extend the lifetime of the wireless sensor network by determining the best number of cluster heads and their best positions based on the sensor node's energy consumption minimized by a genetic algorithm.The protocols must be energy efficient to maximize the network lifetime.Cluster head (CH) selection in the Low-Energy Adaptive Clustering Hierarchy (LEACH) protocol is based on a random probability equation, which has limitations such as unequal cluster and energy distribution, as well as random CH selection.A method for improving CH selection and reducing CH energy degradation [31] is proposed to address these limitations.The proposed algorithm LEACH-CHGA protocol improves CH selection over the existing protocol while lowering the network's energy consumption.In comparison to conventional CH selection, optimal CH selection based on a genetic algorithm improves the network lifetime and energy consumption.
Tamandani et al. [16] proposed an algorithm that identifies the geometric median of all positions connected to the SN to place the BS within the network.They compared the optimal position of their algorithm with different positions, such as the field center, and their performance evaluation showed that the proposed position for the base station would extend the network life of the sensor nodes.However, their network throughput was good at the central location compared to the optimal position of the base station.
Tamandani et al. [32] located the sink at different locations in the network, and the results showed that both the center and the center of the quarter of the network have the maximum density of nodes, making better choices for the position of the base station.
The NP-hard problem's P-median was used in [33,34] to determine the optimal location of the base station, and in [34], the simulations carried out show that a good optimal location of the BS would be the center of the field.In [35], the LEACH protocol was used to improve WSN performance through finding the optimal base station position, and the simulation results showed that the distance between cluster heads and the BS is an important cause that affects the death of cluster heads in wireless sensor networks.To achieve improved performance, Li et al. [36] explored ways to deploy 802.15.4 and NB-IoT-equipped base stations in existing wireless sensor networks.Based on the traditional model, two types of major problems were considered, and then their structure was implemented and evaluated in realistic wireless network sensor topologies.Shah et al. [37] proposed an algorithm for the optimum position of the base station in the cluster WSN.Bogdanov et al. [38] selected the base station's location to maximize the WSN's energy consumption, and the simulation results demonstrated that data rates can be increased with different algorithms to enhance the configuration of the base station position.
Most routing systems are designed to reduce energy consumption [39] without taking into account the importance of the location of the BS or which method is best to reduce energy use done by routing strategies GM [16].Different from the above conservative models and to the best of our understanding, our paper model maximizes WSN lifetime by combining the optimization of the location of the BS and optimization of cluster head for clusters and additionally using a multi-hop data routing inside the cluster for reducing energy use in the cluster.

The Proposed Network Model
In this part, the proposed network model in Figure 1 will be described based on the position of the BS and the clustering strategy routing method.We calculated the location of the base station based on the distance between the nodes, their initial energy, and data rates.The optimal base station location is found while deploying the sensor nodes.After optimizing the base station location, the number of clusters is calculated, and we select the cluster heads.The next step is to send a message from the base station location to all cluster heads in the network; this message carries the optimal base station location.When the message reaches CHs, the cluster heads extract the information from the message and store it in their memories for later use at the data transmission stage.
Electronics 2021, 10, x FOR PEER REVIEW 4 of 20 would extend the network life of the sensor nodes.However, their network throughput was good at the central location compared to the optimal position of the base station.Tamandani et al. [32] located the sink at different locations in the network, and the results showed that both the center and the center of the quarter of the network have the maximum density of nodes, making better choices for the position of the base station.
The NP-hard problem's P-median was used in [33,34] to determine the optimal location of the base station, and in [34], the simulations carried out show that a good optimal location of the BS would be the center of the field.In [35], the LEACH protocol was used to improve WSN performance through finding the optimal base station position, and the simulation results showed that the distance between cluster heads and the BS is an important cause that affects the death of cluster heads in wireless sensor networks.To achieve improved performance, Li et al. [36] explored ways to deploy 802.15.4 and NB-IoT-equipped base stations in existing wireless sensor networks.Based on the traditional model, two types of major problems were considered, and then their structure was implemented and evaluated in realistic wireless network sensor topologies.Shah et al. [37] proposed an algorithm for the optimum position of the base station in the cluster WSN.Bogdanov et al. [38] selected the base station's location to maximize the WSN's energy consumption, and the simulation results demonstrated that data rates can be increased with different algorithms to enhance the configuration of the base station position.
Most routing systems are designed to reduce energy consumption [39] without taking into account the importance of the location of the BS or which method is best to reduce energy use done by routing strategies GM [16].Different from the above conservative models and to the best of our understanding, our paper model maximizes WSN lifetime by combining the optimization of the location of the BS and optimization of cluster head for clusters and additionally using a multi-hop data routing inside the cluster for reducing energy use in the cluster.

The Proposed Network Model
In this part, the proposed network model in Figure 1 will be described based on the position of the BS and the clustering strategy routing method.We calculated the location of the base station based on the distance between the nodes, their initial energy, and data rates.The optimal base station location is found while deploying the sensor nodes.After optimizing the base station location, the number of clusters is calculated, and we select the cluster heads.The next step is to send a message from the base station location to all cluster heads in the network; this message carries the optimal base station location.When the message reaches CHs, the cluster heads extract the information from the message and store it in their memories for later use at the data transmission stage.The BS and sensor nodes will be static after deployment, and all sensor nodes are homogenous with limited energy.The base station has enough power and recognizes the position of all SNs.Sensor nodes in a WSN are typically powered by batteries.As a result, we will need an energy model to estimate the sensor node's energy consumption during various functions.

Energy Model
The location of the BS not only helps extend the life of a single sensor node but also the life of the entire wireless sensor network.This paper studies a stable SN made up of N sensor nodes spread out over a 2-dimension field.We fixed the position of each SN as well as the initial energy at each sensor node i.Each SN generates data at a rate of Ri.Static nodes and a single mobile base station are used in the field.The energy consumption caused by the communication between nodes and the base station is the main key this paper is focusing on.
Our goal is to figure out which base station position is the best position to collect data in a WSN so that the network lifetime (T) can be extended.Assuming that a sensor node i transmits data to a sensor node j at a rate of W ij (b/s) and transmits data to the base station at a rate of W iB (b/s), we can construct the following transmission energy model for a sensor node i where V ij and V iB are costs associated with the transmission of data between nodes and BS, respectively, and can be demonstrated as follows: Here, β 1 and β 2 are constant parameters, d ij is the distance between nodes i and j, and α is the path-loss index, respectively, where 2 ≤ α ≤ 4. From Equation (1), we have a non-linear function of the base station position (X B , Y B ) expressed as follows: The flow balance limitations and energy were considered to maximize T by following the power consumption model shown in this equation: where W ki (b/s) represents the bit rate coming from node k to i, and ρ is the constant coefficient.Assign P i as the rate of energy consumption at sensor node i.We have: Let us assume that the BS is at point p with coordinates X B and Y B , we define T as the network lifetime.A reasonable flow routing solution should achieve the flow stability and energy constraints to achieve this network lifetime T. The flow rates W ij and W iB represent rates from sensor node i to j and from sensor node i to the BS, respectively, as mentioned above.The flow balance for each sensor node is expressed as follows: This means that adding the incoming flow rate to the self-generated data rate equals the total ongoing flow rate.The goal of this paper is to maximize T while preserving flow balance and energy constraints, that is: Max T Subject to This optimization problem is a nonconvex programming problem, which is, in general, NP-hard [40].

Proposed Approaches 4.1. Crossover Elitist Conservation Genetic Algorithm (CECGA)
In our work, we used a meta-heuristic algorithm called the crossover elitist conservation genetic algorithm (CECGA).Certainly, a large part of genetic algorithms processes is random.Many publications give a good introduction to the genetic algorithm [39,[41][42][43].GA is a combination of the principles behind artificial intelligence in computer science and natural evolution in biology.Optimizing GAs is based on the fitness function of the individual environment.Applying the crossover and mutation of the old generation to a new generation is produced [44], then new genes that tip to the best fitness have more chance of life, and after some generations, the optimal solution will be reached.The steps of our modified GA are as follows: 1.
Population Initialization: Firstly, random N individuals (chromosomes) are produced, and the evolutionary generation begins with iteration 0. The distance threshold (communication radius) is initialized.

2.
Fitness Calculation: To evaluate if the particular chromosome increases or decreases the lifetime of WSN, we calculate its fitness function.The algorithm conserves the historically obtained best chromosome; that is, with the highest fitness value, this is called elitism.The fitness of a chromosome controls how much energy is consumed and how much coverage is provided.Our algorithm fitness is a cluster-based distance (CD), which is the sum of the distances between the calculated member nodes and their cluster leaders, as well as the total CHs and BS distances, and is calculated as follows: where n and m denote the number of clusters and related members, respectively; d ij is the distance between a node and its CH; and D CB denotes the distance between the CH and the BS.The solution is best suited for networks with a high number of widely separated nodes.A greater cluster distance results in higher energy usage.This measurement is used to manage the density of the clusters, where density is the number of nodes in each cluster.
Standard derivation measures the cluster's distance changes.Cluster-based distance standard is determined by the location of the sensor nodes.Clusters of varying sizes are randomly placed so that an SD within a defined variance in cluster distance is acceptable.
If this is the case, the variances in the cluster distance are not zero, and the variation must be adopted based on information deployment.In any case, cluster distance change must be minimized under deterministic placement with a uniform distribution of node placements.Changes in uniform cluster-based distances, in general, indicate that the network is weak, which is not the case when nodes are put randomly: The symbol µ in Equation ( 12) represents the average of the cluster distances, which is the conventional SD formula for calculating cluster distance variation.
Transfer energy (E): this is the amount of energy consumed in transferring all of the acquired data to the BS.Let m denote the number of related nodes in a cluster; then, E is calculated as follows: where e jm is the amount of energy necessary to transport data from a node to the matching CH.Thus, the first term in the sum of i represents the total energy consumed for the transfer of aggregated data to CHs.Furthermore, the second term in the summation "i" represents the total required energy to collect data from members, and the last term in the summation e i represents the required energy for transmission from the cluster head to the BS.

3.
Selection: The selection step chose the best individuals according to the selection operator, whereby a mating pool of individuals with above-average fitness values is conserved and two parents become selected randomly for crossover.

4.
Crossover: CECGA is used to obtain better parameters.In the crossover phase, we apply the elitist conservation of individuals to replace others in the second generation.
To avoid the loss of the best chromosome after mutation, elitism is used to copy some of those chromosomes in the next generation.
This method improves the GA and allows the best solutions to be saved.In CECGA, the first population consists of n chromosomes indicating the best possible base station position.The structure of the proposed algorithm is summarized as follows: In our approach, B1 symbolizes the elitist individual, A1 symbolizes the elitist individual's father, and A2, the mother, symbolizes the elitist individual's mother.If the present solution is better than the previous solution, the current one is defined as B1, then A1 and A2 are retained.In the first generation, CECGA randomly generates eight individuals: A1 to A8.In the next generation, eight new individuals are formed by a crossover gene algorithm operator, such as A1 and A2 cross to generate B1.If the present optimal solution is individual B1, the parents of the elitist individual A1 and A2 shall be retained.Each individual is the combination of the distance and energy of the sensor nodes.For example, our first individuals were generated randomly, as shown in Figure 1, then in the second generation, two individuals are chosen at random from the remaining seven as B2 and B3, and replaced with A1 and A2, as shown in Figure 2, where generations are B1, A1, A2, B4, B5, B6, B7, and B8.
The elitist individual's parents and the current generation's population are combined using the CECGA to improve the gene quality of the population, ensuring that good genes are not discarded during the selection process.Maintaining the ability to pass down the genes of the population's best individuals to the next generation is essential for evolution.Except for the elitists, the parents of the elitists are saved and replace some members of the current generation.The elitist individual's parents and the current generation's population are combined using the CECGA to improve the gene quality of the population, ensuring that good genes are not discarded during the selection process.Maintaining the ability to pass down the genes of the population's best individuals to the next generation is essential for evolution.Except for the elitists, the parents of the elitists are saved and replace some members of the current generation.

Mutation:
The new individuals are produced in this mutation to keep the diversity in the population.Here the node is selected randomly from the best chromosome obtained in the past generation.
Elitist individuals with good genes are reproduced in the second generation, and the parents of these elitist individuals are conserved.By extending the sampling space, the crossover elitist conservation strategy can increase individual competition.Competition among the elitists of the newly formed generation makes it easier to find a better solution.This cycle will continue until a predetermined end condition is met.The preceding steps ensure that the best genes are conserved and that the algorithm evolves to the best solution.The pseudo-code and block diagram of CECGA are shown in Algorithm 1 and Figure 3, respectively.

Mutation:
The new individuals are produced in this mutation to keep the diversity in the population.Here the node is selected randomly from the best chromosome obtained in the past generation.
Elitist individuals with good genes are reproduced in the second generation, and the parents of these elitist individuals are conserved.By extending the sampling space, the crossover elitist conservation strategy can increase individual competition.Competition among the elitists of the newly formed generation makes it easier to find a better solution.This cycle will continue until a predetermined end condition is met.The preceding steps ensure that the best genes are conserved and that the algorithm evolves to the best solution.The pseudo-code and block diagram of CECGA are shown in Algorithm 1 and Figure 3, respectively.

Proposed Routing Based K-Medoids Clustering
Our K-medoids-based clustering (KMC) algorithm reduces energy consumption and extends the network lifetime.Cluster head nodes collect data from all nodes via a base station in our proposed scheme.This is followed by a calculation of K of the cluster number.The iteration time is reduced by computing the central circle mean points and remaining energy.Here are the steps of the algorithm: Step 1: Sensor nodes are distributed into clusters, and the cluster head nodes are located during the first phase.The number of clusters is calculated during this phase, and the cluster head nodes are selected.Initialize greedy select K of the N-data points as medoids to minimize the cost.Equation ( 14) can be used to calculate K, the number of clusters.
N represents the number of nodes.
Step 2: Calculation of the CH of the cluster as the center point of the initial mean points.Nodes should be centered around point (O).Equation ( 15) allows for the calculation of O.
where Xi is the coordinate of node i.Let d be the average distance between O and all nodes.d is calculated by Equation ( 16) Step 3: Associate each node to the closest center (medoids).While the distance decreases: The cost (distance) change is computed for each medoid O and non-medoid m.O and m should be used together if cost changes are at their highest level.Perform the best swap of m and O if the cost function decreases.Otherwise, the algorithm ends.

Proposed Routing Based K-Medoids Clustering
Our K-medoids-based clustering (KMC) algorithm reduces energy consumption and extends the network lifetime.Cluster head nodes collect data from all nodes via a base station in our proposed scheme.This is followed by a calculation of K of the cluster number.The iteration time is reduced by computing the central circle mean points and remaining energy.Here are the steps of the algorithm: Step 1: Sensor nodes are distributed into clusters, and the cluster head nodes are located during the first phase.The number of clusters is calculated during this phase, and the cluster head nodes are selected.Initialize greedy select K of the N-data points as medoids to minimize the cost.Equation ( 14) can be used to calculate K, the number of clusters.
N represents the number of nodes.
Step 2: Calculation of the CH of the cluster as the center point of the initial mean points.Nodes should be centered around point (O).Equation ( 15) allows for the calculation of O.
where X i is the coordinate of node i.Let d be the average distance between O and all nodes.d is calculated by Equation ( 16) Step 3: Associate each node to the closest center (medoids).While the distance decreases: The cost (distance) change is computed for each medoid O and non-medoid m.O and m should be used together if cost changes are at their highest level.Perform the best swap of m and O if the cost function decreases.Otherwise, the algorithm ends.
Step 4: Earlier we mentioned that, while other works use single hop when nodes transmit data to their cluster heads [16], in our approach, we use a multi-hop data routing where we divided our field into layers according to the number of nodes we have.Then, those nodes send data to their closest node to reduce the distance and energy used among nodes in the cluster.We use the path construct used in Hamidouche et al. [45], where a few layers of cluster space are created by dividing the cluster space into several layers.This selects the next hop based on distance and energy then divides each layer into regions (northeast, northwest, southeast, southwest) until this grouping is complete.Their genetic algorithm can be applied in Figure 4.
where we divided our field into layers according to the number of nodes we have.Then, those nodes send data to their closest node to reduce the distance and energy used among nodes in the cluster.We use the path construct used in Hamidouche et al. [45], where a few layers of cluster space are created by dividing the cluster space into several layers.This selects the next hop based on distance and energy then divides each layer into regions (northeast, northwest, southeast, southwest) until this grouping is complete.Their genetic algorithm can be applied in Figure 4.This paper made some improvements also to the approach in [45] as follows: 1.They fixed the number of layers to 4, whereas in our approach.we set 10 nodes in one layer, which means if we used 100 nodes, then we will obtain where L represents the number of layers and N is the number of nodes in the field.2 In their work where 4 layers are used, nodes in layer number 4 must only communicate with nodes in layer number 3 and so on, and finally, nodes in layer 1 connect directly to the base station.Here it does not make sense because nodes in layer 4 can be closer to the node in layer 2, thereby assuming that the number of nodes in each layer is set to 10, a total of 100 nodes, then divided into ten layers.For layer 10 nodes, we traverse all nodes in layers 1-9 and find a connection to the nearest node.For layer 9 nodes, we traverse all the nodes in layers 1-8 to find the closest node to connect sequentially.3 In their approach for nodes in layer 4, for example, there is one common closer node in the next layer, and if all these nodes send data to its closest node, then that node will be down fast because it is using more energy to receive data, so its life is very short.Here the improvement is to impose a penalty when calculating the distance between nodes, and the specific formula is: This paper made some improvements also to the approach in [45] as follows: 1.
They fixed the number of layers to 4, whereas in our approach.we set 10 nodes in one layer, which means if we used 100 nodes, then we will where L represents the number of layers and N is the number of nodes in the field.

2.
In their work where 4 layers are used, nodes in layer number 4 must only communicate with nodes in layer number 3 and so on, and finally, nodes in layer 1 connect directly to the base station.Here it does not make sense because nodes in layer 4 can be closer to the node in layer 2, thereby assuming that the number of nodes in each layer is set to 10, a total of 100 nodes, then divided into ten layers.For layer 10 nodes, we traverse all nodes in layers 1-9 and find a connection to the nearest node.For layer 9 nodes, we traverse all the nodes in layers 1-8 to find the closest node to connect sequentially.

3.
In their approach for nodes in layer 4, for example, there is one common closer node in the next layer, and if all these nodes send data to its closest node, then that node will be down fast because it is using more energy to receive data, so its life is very short.Here the improvement is to impose a penalty when calculating the distance between nodes, and the specific formula is: where d(i, j) denotes the distance between nodes i and j.K i represents the number of nodes connected to sensor node i.After constructing the routing from nodes to their cluster heads, these cluster heads send data corrected to the optimal base station calculated above.

Experimental Results Assessment and Discussions
In this section, we compared our proposed CECGA with the algorithm (GM) used in [16] and with simple genetic algorithm (SGA) and Strengthen elitist genetic algorithm (SEGA) protocols.Table 1 gives the location of each node and its data rate for a 100 nodes network.The experiment was conducted on an Intel i5-5257U at 2.70 GHz, with 8 GB of RAM.We ran the GA algorithms implemented using the PYTHON language (PyCharm Community Edition 2021.1.2x64).Table 2 lists the parameters used in this experiment.We consider WSNs with 100 randomly generated nodes.The following metrics were used to assess the proposed algorithm's performance.

1.
Energy Consumption-The total energy consumed during a round can provide a good estimate of the algorithm's energy efficiency, and the total energy consumed increases as the number of generations increases.

2.
Network Lifetime-The network lifetime is defined as the time when all sensor nodes stop functioning.We first calculate the optimal base station location using CECGA with 100 nodes.As we discussed above, we used multi-hop routing for data transmission and reception.Figure 5 shows cluster heads after the deployment of nodes and calculation of clusters.Figure 6 shows the multi-hop routing from nodes to their cluster heads and from CHs to the optimal base station location.
6 shows the multi-hop routing from nodes to their cluster heads optimal base station location.
After finding the location of the optimal base stations using ou with a different number of nodes, we calculated the maximum netw ent algorithms with the same nodes number for each.Figure 7 show work lifetime of CECGA, GA, and SEGA for 100 nodes.
In three different scenarios, Figure 7 depicts the convergence of CECGA with the variation of evolutionary generations.The CECGA the other two algorithms, as shown in Figure 8.The optimal solution and SEGA, and the performance difference between the two is not in Table 3. Figure 7 depicts the results, which show that (CECGA) ou After finding the location of the optimal base stations using our proposed technique with a different number of nodes, we calculated the maximum network lifetime of different algorithms with the same nodes number for each.Figure 7 shows the maximum network lifetime of CECGA, GA, and SEGA for 100 nodes.In three different scenarios, Figure 7 depicts the convergence of the SGA, SEGA, and CECGA with the variation of evolutionary generations.The CECGA converges faster than the other two algorithms, as shown in Figure 8.The optimal solution outperforms the SGA and SEGA, and the performance difference between the two is not significant, as shown in Table 3.   (20,60) 121.01 Location2 (30,45) 153.76 Location3 (50, 20) 131.18 The crossover elitist conservation genetic algorithm is better with the maximum work lifetime of sensor nodes, as shown in the above figure and table.In our model, CECGA protocol not only reduced energy consumption for data transmission to the b station but also the distribution among nodes.Figure 8 represents the total energy c sumption of nodes that directly affect the stability of the WSN.The results show that proposed algorithm consumes low energy compared to others.
We also compared the different positions of the base stations to check which is be for energy consumption reduction, and the results in Figures 9 and 10 show that the o mal location of the BS is the best one to reduce the energy consumption of SNs.The m  The crossover elitist conservation genetic algorithm is better with the maximum network lifetime of sensor nodes, as shown in the above figure and table.In our model, the CECGA protocol not only reduced energy consumption for data transmission to the base station but also the distribution among nodes.Figure 8 represents the total energy consumption of nodes that directly affect the stability of the WSN.The results show that our proposed algorithm consumes low energy compared to others.
We also compared the different positions of the base stations to check which is better for energy consumption reduction, and the results in Figures 9 and 10 show that the optimal location of the BS is the best one to reduce the energy consumption of SNs.The more nodes that send data to the base station, the more they finish their energy, and after several rounds, they start dying until they all run down.As previously stated, our goal is to maximize the network lifetime of sensor nodes, which we define as either the time until any sensor node runs out of energy or the time until the last node in the network dies.Figures 11 and 12 show the results of the death of the first node and last node, respectively.When they are sending data to different base station locations, the results still show that our optimal position of BS is better than other positions.These results show the importance of optimal base station position in the network for lifetime maximization.Table 4 compares the ability of these three algorithms for solving energy consumption problems in wireless sensor networks.The algorithms are run ten times, and the parameters considered in the algorithms are the following: (Gen) is used to set how many generations to record information in the evolution process.The key value of (Eval) is a list, which is used to store the number of evaluations of the evolutionary algorithm.The key value of (f_opt) is a list, which stores the value of the objective function of the optimal individual of each generation of the population.The key value of (f_avg) is a list, which stores the average objective function value of all individuals in each generation of the population and the standard deviation, abbreviated as "f_std", and the minimum and maximum of the function are also abbreviated as f_min and f_max.Table 4 compares the ability of these three algorithms for solving energy consumption problems in wireless sensor networks.The algorithms are run ten times, and the parameters considered in the algorithms are the following: (Gen) is used to set how many generations to record information in the evolution process.The key value of (Eval) is a list, which is used to store the number of evaluations of the evolutionary algorithm.The key value of (f_opt) is a list, which stores the value of the objective function of the optimal individual of each generation of the population.The key value of (f_avg) is a list, which stores the average objective function value of all individuals in each generation of the population and the standard deviation, abbreviated as "f_std", and the minimum and maximum of the function are also abbreviated as f_min and f_max.Table 4 compares the ability of these three algorithms for solving energy consumption problems in wireless sensor networks.The algorithms are run ten times, and the parameters considered in the algorithms are the following: (Gen) is used to set how many generations to record information in the evolution process.The key value of (Eval) is a list, which is used to store the number of evaluations of the evolutionary algorithm.The key value of (f_opt) is a list, which stores the value of the objective function of the optimal individual of each generation of the population.The key value of (f_avg) is a list, which stores the average objective function value of all individuals in each generation of the population and the standard deviation, abbreviated as "f_std", and the minimum and maximum of the function are also abbreviated as f_min and f_max.The running time used after 150 generations for CECGA is 897 s, SGA is 32,488 s, and SEGA is 1224 s.The proposed algorithm produces statistically better results than the other algorithms.Furthermore, CECGA takes less time than other algorithms.As a result, CECGA can obtain more optimal solutions.

Conclusions and Future Work
This paper studied the base station location problem for a multi-hop clustering sensor network to conserve energy consumption for network lifetime maximization in WSN.The formulation of the first part of our work was to find the proper optimal position of the BS using CECGA to maximize the network lifetime of sensor nodes.The second part of the work is concerned with clustering, where the K-medoids clustering (KMC) algorithm is used to select optimal CHs and their cluster nodes.The last part of the work investigates the way nodes send data to their cluster heads, where they use multi-hop routing to reduce energy use among sensor nodes.The calculation of the BS' position depends on the nodes' initial energy, data rates, and the distance among nodes and the BS, respectively.The numerical experiments and simulated results showed that among algorithms that were compared, the crossover elitist conservation genetic algorithm (CECGA) is the best in terms of the best positioning of the BS station for energy conservation.Additionally, our tests have been estimated, and the results achieved dramatically boost the network's lifespan, reduce energy consumption, and increase its stability.As a future task, by implementing smarter algorithms, the WSN architecture can be improved to make it more intellectual in terms of its organization.

Figure 2 .
Figure 2. Eight individuals of first-generation (the green sign means the current optimal solution).

Algorithm 1
Crossover Elitist Conservation Genetic Algorithm Input: (1) Population size N, (2) Number of generation NG, (3) Elitists e 1.Initial the current population P 2⸦ Next P // End of Crossover Elitist Conservation Mechanism (CEC) 14.Mutation 15.Evaluation of the population P

Figure 2 .
Figure 2. Eight individuals of first-generation (the green sign means the current optimal solution).

Algorithm 1 Figure 3 .
Figure 3. New individuals after CECGA (Red stars are preserved parents, green is the current optimal solution).

Figure 3 .
Figure 3. New individuals after CECGA (Red stars are preserved parents, green is the current optimal solution).

Figure 3 .
Figure 3. New individuals after CECGA (Red stars are preserved parents, green stars are the current optimal solution).

3 .
First Node Death-Our work plots the first node death by showing which round the first node dies by comparing different BS locations in different networks.4.Last Nodes death-Our work plots the last node death by showing which round the first node dies by comparing different BS locations in different networks.

Figure 10 .
Figure 10.Energy consumption for different locations.

Figure 10 .
Figure 10.Energy consumption for different locations.Figure 10.Energy consumption for different locations.

Figure 10 .
Figure 10.Energy consumption for different locations.Figure 10.Energy consumption for different locations.

Table 1 .
Position and data rate of our 100-node network.

Table 3 .
Lifetime performance

Table 4 .
The solution results from three algorithms under different generations.