1 Introduction

Wireless sensor network (WSN) is one of the leading technology trends since last few years. It has been used effectively for situation monitoring by using a number of sensor nodes [1,2,3]. WSNs have been employed in tough terrains to analyze data used for habitat monitoring, disaster relieves and target tracking etc. [4, 5]. Energy efficiency [6] and data robustness, integrity and confidentially of networks [4,5,6,7] are significant features to judge the quality of a WSN. Sensor nodes contribute in communication, signal processing, and self-organization in order to build a robust, scalable, energy efficient and long-lived WSN [8,9,10]. Though few constraints in WSNs, like developing multi-hop communication and autonomous aerial vehicle technology, routing in dense and difficult terrain, monitoring of resource limited systems, data management, collection and analysis, and optimization of energy consumption etc. need to be resolved [1,2,3]. Amongst these, energy consumption optimization is one of the key areas of research in WSN [11,12,13,14,15]. Moreover, the data communication in WSN consumes more energy than the sensing, data processing [16,17,18,19,20]. Consequently, effective energy optimization techniques are required to minimize the energy consumption in the communication process in WSN.

Some of the recent research reports in published literature describe energy optimization of WSN using nature inspired artificial intelligence (AI) methods [19,20,21,22,23,24,25,26], such as genetic algorithm (GA) is used to achieve an ideal set of parameters including lifetime and energy consumption for routing [19]; in another related study, a multi-objective GA method is proposed in the design of energy efficient WSNs by optimizing the network lifetime [20]; improved particle swarm optimization (IPSO) and virtual force algorithm (VFA) is implemented to solve the problem with sensor nodes positioning [21]; ant-based routing algorithm is proposed for minimizing energy efficiency (9%) [22]; performance of the GA, honey bees, and fireflies swarm intelligence algorithms is compared in optimization of energy cost, sensitivity area, and network reliability [23]; harmony search based energy efficient routing algorithm is developed [24]; artificial bee colony (ABC) algorithm is implemented for optimization of sensing data collection path with the objective to minimize the energy consumption [25]; a generic GA-based optimization is developed for fast and automatic energy management [26].

WSNs systems subjected to energy consumption constraints, besides extending the sensor node battery lifetime is of an utmost importance in ensuring the network autonomy [7]. Nature inspired AI methods based software approaches presents a reasonable and quick solution for performance optimization of WSNs [19, 20, 22,23,24,25,26]. Though the choice of an effective AI method is crucial that selects the best combination of parameters out of several possibilities. GA is a widely used and one of the fast and intelligent optimization methods which search and select the best combination of dependent parameters for the minimization of power consumption in WSNs [19, 20, 23, 26].

We hardly noticed few studies based on the application of GA method for optimization of energy related parameters during the receiving and transmission of data from the WSNs. This is the main motivation behind the present study to implement GA method on three different energy models (used to characterize the data transmission and receiving) of WSNs with the objective to calculate the least amount of energy spent by sensor nodes during data communications. More specifically, we considered two energy models [36, 37]; each of them describes the energy consumption in WSNs as a function of packet payload and header size, overhead symbol rate, circuit depletion of the sender and receiver, and amplifier coefficients. The details of energy models are discussed in the next section. The rest part of the paper is organized as follows. Energy optimization procedure in WSN using GA is briefed in Sect. 3 and Sect. 4 describes the analysis outcomes, and main findings of the study are concluded in Sect. 5.

2 Selected energy models of wireless sensor network

Energy minimization is one of the most critical considerations in the design of sensor nodes in WSN. Since energy is in a very limited supply, the design of sensor node should take into consideration for the maximization of battery lifetime [27]. Energy is consumed in such nodes through sensing, processing and power units [9]. Each of the power units has three states: idle, sleep and active, and the power consumption in each unit depend on the state [27]. Several energy conservation methods have been developed for WSNs like probabilistic model based on Petri nets to evaluate the energy consumption [28], a brief assessment of several methods with the objective to minimize the energy intake in hybrid WSN [29], and an energy model for WSNs using a simulator (IDEA1) [30].

The aforesaid methods have been implemented using the communication protocol stack model consisting of a physical layer, data link layer, network layer, transport, and application layer. The physical layer is responsible for carrier frequency generation, signal detection, modulation, and data encryption. Energy consumption models in the physical layer have been discussed in several research studies [31,32,33], by considering the energy consumption due to transmitting and receiving sensory data [31, 34]. Melodia et al. [35] detailed a model for energy consumption per bit at the physical layer as

$$\begin{aligned} E_b =E^{{\textit{trans}}}+\beta d^{\alpha }+\hbox {E}^{\mathrm{rec}} \end{aligned}$$
(1)

where \(E^{{\textit{trans}}}\) is a distance-independent term related to transmitter electronics and digital processing, \(E^{{\textit{rec}}}\) relates to receiver electronics, \(\beta d^{\alpha }\) is a distance-independent term that accounts for radiated power needed to transmit a bit over distance(d)between source and destination, \(\alpha \;(2\le \alpha \le 5)\) is path loss and \(\beta \, ({\text {J}/(\text {bit}\times \text {m}^{\alpha })})\)is a constant. In another related model, by Raghunathan et al. [36], energy cost for transmitting one bit of information has been formulated, as a function of packet payload size \(\hbox {(L)}\), header size \(\hbox {(H)}\), fixed overhead \(\hbox {(E}_{{\mathrm{start}}} )\) associated with the radio startup transient and symbol rate \((\hbox {R}_{\mathrm{s}} )\) for a M-ary modulation scheme. The energy model is denoted by Eq. 2.

$$\begin{aligned} E_{{\textit{bit}}} ={(E_{{\textit{start}}} }/{L+}{P_{{\textit{elec}}} )+(P_{RF} (M)}/{R_s }\log _2 M)(1{+}H/L)\nonumber \\ \end{aligned}$$
(2)

where \(P_{{\textit{elec}}}\) represents power consumption of electronic circuitry for frequency synthesis, filtering, and modulating, \(\hbox {E}_{\mathrm{start}} ={1}\,\upmu \hbox {J}\), \(\hbox {P}_{\mathrm{elec}} ={1}2\,{\text {mW}}\), \(\hbox {P}_{\mathrm{RF}} =1\,\text {mW}\), \(\hbox {R}S=1\,{\text {Mbaud}}\), \(H=16\,\text {bits}\) and \(\hbox {Modulation M}=1{-}8\). In another study [37], a low-energy adaptive clustering hierarchy (LEACH) algorithm is proposed for WSNs. It selects a few sensor nodes as cluster heads such that the distance between the cluster head and sink is greater than between the sink and the other sensor nodes in which the cluster head is located [37]. According to LEACH protocol, the energy cost increases as the distances between nodes increases [37]. The energy required to transmit and received k-bit of data is defined in Eq. 3 as

$$\begin{aligned} \left. {\begin{array}{l} E_{{\textit{rx}}} (k,d)={\begin{array}{ll} {\textit{kE}}_{{\textit{elec}}} +k\varepsilon _{fx} d^{2}&{}\quad d<d_0 \\ {\textit{kE}}_{{\textit{elec}}} +k\varepsilon _{fx} d4&{}\quad d\ge d_0 \\ \end{array} } \\ E_{RX} (k)={\textit{kE}}_{{\textit{elec}}} \\ \hbox {E}_{{\mathrm{DA}}} (k)={\textit{kE}}_{da} \\ \end{array}} \right\} \end{aligned}$$
(3)

where \(E_{{\textit{elec}}}\) represents circuit depletion of sender and receiver, \(\varepsilon _{fs}\) and \(\varepsilon _{mp}\) are amplifier coefficients of free-space and multi-path fading model respectively, and \(E_{da}\) is the energy consumption to compress unit data [37].

In a simulation study [38], associated parameters of Eq. 3 have following assumed values: \(E_{{\textit{elec}}} =50/\hbox {nJ}\,\hbox {bit}\), \(\varepsilon _{fs} =10\,\text {pJ}/\text {bit}/\text {m}^{2}\), \(\varepsilon _{mp} =0.0013\,\text {pJ}/{\text {bit}}/\text {m}^{4}\), \(E_{da} =5\,\hbox {nJ/bit}/{\text {signal}}\) and \(d_0 =87\,\hbox {m}\). The present research, analyses energy model described in Eqs. 2 and 3. Since Eqs. 2, and 3 define energy consumption in both micro and standard operation of WSN. Moreover, for easiness, the energy model described in Eq. 3 is parted into two sub-models according to the distance(d) between the sensor cluster head and the base station (i) \(d<87\,\hbox {m}\), and (ii) \(d\ge 87\,\hbox {m}\). Consequently, two new energy sub-models have been introduced as

$$\begin{aligned}&\left. {\begin{array}{l} E_{{\textit{rx}}} (k,d)={\textit{kE}}_{{\textit{elec}}} +k\varepsilon _{{\textit{fx}}} d^{2} \\ \hbox {E}_{{{\textit{RX}}}} (K)={\textit{KE}}_{{\textit{elec}}} \\ E_{{\textit{DA}}} (K)={\textit{KE}}_{{\textit{da}}} \\ \end{array}} \right\} d<d_0 \end{aligned}$$
(4)
$$\begin{aligned}&\left. {\begin{array}{l} E_{{\textit{rx}}} (k,d)=kE_{{\textit{elec}}} +k\varepsilon _{{\textit{mp}}} d^{4} \\ \hbox {E}_{\mathrm{RX}} (K)=KE_{{\textit{elec}}} \\ E_{{\textit{DA}}} (K)={\textit{KE}}_{{\textit{da}}} \\ \end{array}} \right\} d\ge d_0 \end{aligned}$$
(5)

Later, GA method is implemented on the three energy models represented in Eqs. 2, 4 and 5 with the objective to obtain the optimum conditions for the minimum consumption of energy in WSN.

3 Energy optimization in wireless sensor network using genetic algorithm

GA is a directed search algorithm based on the mechanics of biological evolution, developed to understand the adaptive processes of a natural system and to design artificial systems that hold the robustness of natural systems [39]. GA is an effective technique for optimization and machine learning applications. It is widely used at present in businesses, scientific and engineering applications [39,40,41] by using a random search approach to a decision through selection, mutation, and crossover operators [39]. The local optima can be escaped and global search is accomplished by using a different combination of parameters like crossover type, population size, mutation rate etc. [41]. Another advantage of using GA is that it is effective for both continuous and discrete variables.

Some of the basic operations of GA are as follows. GA operation starts with an initial population of chromosomes. Each chromosome consists of genes with each gene being an instance of a particular allele (e.g., 0 or 1) [39]. The selection operators were used to choose chromosomes in the population to reproduce. A new population is selected by two methods, namely steady state GA and generational GA [42]. In the steady state GA, one or two individuals of the population were replaced while the latter replaces all of the individuals at each generation. The second method is used in the present analysis. The fitness function in GA ranks chromosome, according to their qualification for the survival and further reproduction. It is decided according to the problem for which GA is implemented. E.g. energy models have been considered to decide the fitness function in the present analysis. The selection operator in GA selects individual chromosome in the population for reproduction [39]. Selection of chromosomes for reproduction is based on the fitness value. In the present study uniform, stochastic uniform, roulette, and tournament selection operator were inspected. Mutation operator flips, randomly some of the allele (bits) in the chromosome. A mutation can occur at each bit position in a string with some probability (usually very small, e.g., 0.001) [39]. Constraint dependent, uniform, and adaptive feasible based mutation function have been used in the present analysis. Crossover is the foremost step of producing a new population. It selects a pair of parents from the current population determined by the selection process to generate new children for the next generation [39]. This process continues until the desired size of the new population is achieved. A locus is selected and used to exchange the subsequences before and after the locus between the two chromosomes to produce two offspring [39, 42]. In the present study, constraints dependent, two points, single point, and heuristic crossover methods have been used. The details of GA are available in [39,40,41,42], though a simple illustration is shown in Fig. 1.

Fig. 1
figure 1

A simple schematic representation of GA

Table 1 Summary of GA methods used in energy optimization

Optimization methods have been recognized as significant tools to resolve the limited battery power issue in WSNs [20,21,22,23,24,25,26] in order to attain the optimum cost of network load, reliability, and energy efficiency. Though, amongst other optimization methods, GA results in better solutions as available in some studies [19, 20, 26]. Accordingly, based on the outcomes of past studies and basic assumption of GA like parallelism, efficient in working with the inconsistent and noisy fitness landscape, etc., it is implemented to handle the global optimization of energy in WSN in the present study, though this basis is not proven.

Table 2 GA outcomes for three energy models respectively

In order to find the optimum conditions for the minimum energy consumption, twenty different variations of GA have been designed and used in the analysis of energy models described in Eqs. (2), (4) and (5). For instance, the first GA model is based on constraint dependent mutation function with mutation probability \(P_m =0.05\), stochastic uniform selection method, constraint dependent crossover, and default values of the rest of the parameters. The details of other GA methods used in the analysis are summarized in Table 1.

GA models have been designed by using different combinations of operations (i) mutation, (ii) selection, and (iii) crossover. Specifically, three mutation functions, four selection functions, and four crossover functions have been used, more details are as follows. Three mutation functions have been used in the analysis include constraint dependent, uniform, and adaptive feasible. The constraint dependent mutation function uses a Gaussian distribution if there is no constraint; uniform mutation function chooses a segment of individual and thereafter interchanges it for mutation; while the adaptive feasible mutation function randomly generates directions that are adapted with respect to the last successful or unsuccessful generation [39,40,41,42].

Stochastic uniform, uniform, Roulette wheel, and tournament selection methods have been used in the analysis. The stochastic uniform selection method sets a line in which each parent corresponds to a section of the line of length proportional to its expectation; the uniform selection method selects parents at random from a uniform distribution using the expectations and the number of parents; Roulette wheel selection method simulates a roulette wheel with the area of each segment proportional to its expectation; and the tournament selection method selects each parent by choosing individuals at random, the number of which can be specified by tournament size, and then choosing the best individual to be a parent [39,40,41,42].

Four crossover functions have been used in the analysis include constraint dependent, single point, two point and heuristic. The constraint dependent crossover function chooses for non-linear constraints, and intermediates for linear constraints; single point crossover selects vector entries \({\le }n\) (random number between 1 and number of variable) from the first parent and \({>}n\) from the second parent to form the child; while two point crossover selects two random numbers m and n; and heuristic crossover method creates children that randomly lie on the line comprising the two parents [39,40,41,42]. Sixty independent simulations in MATLAB for twenty GA methods (Table 1) on three energy models for data communication in WSN have been accomplished. The analysis time for simulation is affected by the several factors, including the energy models, mutation, selection and crossover methods and their combination. In all the cases implemented GA methods results in an optimal solution in a few seconds. Though, sometimes crossover after the mutation results in less analysis time.

Fig. 2
figure 2

Fitness value representation of energy model 1 (Eq. 2) using the GA method no. 9

Fig. 3
figure 3

Fitness value representation of energy model 2 (Eq. 4) using the GA method no. 11

4 Analysis results

The analysis outcomes for sixty simulations have been summarized in Table 2. The best fitness functions for each of three energy models for data communication in WSNs (Eqs. 2, 4, 5) respectively are represented in Figs. 2, 3 and 4. Each of the Figs. plots a fitness value (value of the fitness function i.e. energy function) versus the number of generations. The best and mean parameters are the minimum and average values of energy used in data communication in WSNs. The minimum energy consumption for model 1 (Eq. 2) is \(-5.53\times 10^{-8}\) J, with a modulation (M) of 1 and packet size (L) of 1000 bits over 200 iterations using the GA method no. 9 (Table 1). The negative sign in the value shows that the system is bound unless it can acquire energy. GA method no. 9 is designed by using uniform mutation (mutation rate of 0.04), stochastic uniform selection, and two point crossover methods (Table 1).

Fig. 4
figure 4

Fitness value representation of energy model 3 (Eq. 5) using the GA method no. 9.

The variation of mean fitness and best fitness of the population over the generation for GA method no. 9 is shown in Fig. 2. It represents that the mean fitness values are always less than or equal to best fitness values, though the difference of two fitness values decreases over the generation and becomes zero once the best solution is achieved. The maximum energy consumption of the same energy model is −0.363 J with a modulation (M) of 0.99 and packet size (L) of 1000 bits over 51 iterations using the GA method no. 15 (Table 1). GA method no. 15 is designed by using adaptive feasible mutation (mutation rate of 0.06), stochastic uniform selection, and constraint dependent crossover methods (Table 1). Hence, the best performance is achieved in terms of minimum energy for energy model described in Eq. 2 using the GA method no. 9. The other GA methods result in average performance.

In the case of energy model 2 (Eq. 4), the minimum consumption of energy is 0.0002 J (Table 2) with a distance (d) of 87 meters and packet size (k) of 2000 bits over 51 iterations using the GA method no. 11 based on uniform mutation (mutation rate of 0.05), stochastic uniform selection, and heuristic crossover methods and a mutation rate of 0.05 (Table 1). Other GA methods, except GA method no. 1–5 result in the same value of energy consumption, though, the GA method no. 11 can be selected as the optimal method since it achieves the best solution in a minimum number of iterations (51) compared to other methods. The GA method no. 1–5 result in maximum energy consumption 0.0007 J (Fig. 3, Table 2) which is 3.5 times greater than the energy value achieved by rest of GA methods. Though amongst GA method no. 1–5, GA method no. 3 is ideal method due to a minimum number of iterations (51) to achieve the best solution while GA method no. 1 require a minimum number of iterations (85) to attain the comparable solution. Figure 3 shows the variation of mean and best fitness values of the population over the generation using the GA method no. 11 for the energy model 2 (Eq. 4). The difference of two fitness values decreases over the generation and becomes zero once the best solution is achieved similar to Fig. 2.

The minimum energy consumption for energy model 3 (Eq. 5) is equal to 0.000349 J (Table 2) with a distance (d) of 1 meter and packet size (k) to 2000 bits over 51 iterations using GA method no. 9. The other GA method used in analysis results in the same value of energy consumption, though, the GA method no. 9 is selected since it requires a minimum number of iterations (51) to achieve the best solution. Figure 4 demonstrates the variation of mean and best fitness values of the population over the generation using the GA method no. 9 for the energy model 3 (Eq. 5). Their difference decreases over the generation and turns into zero after the best solution have been accomplished. GA method no. 9, 11, and 9 results in the minimum energy consumption conditions for the three energy models respectively. Though the GA method no. 9 can be considered as the common method to search the energy optimization conditions for all three selected data communication energy models of WSN, since the GA method no. 9 require only 21 additional iterations to achieve the similar value of energy consumption than the GA method no. 11 for the energy model 2 (Eq. 4).

For the energy model 2 (Eq. 4) with distance \(d<87\,\hbox {m}\), the minimum energy obtained in the present study is equal to 0.0002 J which is 0.04% of the total energy in a sensor node (0.5 J) [38]. The minimum energy achieved in the present analysis, for energy model 3 (Eq. 5) is equal to 0.000349 J for distance \(d\ge 87\,\hbox {m}\), which is 0.0698% of the total energy in a sensor node. The comparison of minimum energy values obtained from the GA analysis of energy models 2 and 3 with real sensor node energy verifies the better performance of the GA in WSN energy optimization.

The scope of the present study is to propose an optimal GA method by selecting a proper combination of mutation, crossover and selection methods in searching the ideal set of parameters responsible for minimum energy consumption during data communication in WSN. The latter part is completed by selecting three recognized data communication energy model of WSN. Several published research reports in literature target the energy optimization of WSN [19, 20, 42] but we hardly noticed any of them covering energy models included in the present analysis. Therefore a direct comparison of analysis outcomes obtained in the present study with other studies is not possible. Though, the main findings of some of the study, based on the energy optimization of WSN using GA and other methods in a different way are as follows: in [19], an optimized GA method is used to obtain an optimal set of parameters of routing with the objective to improve several functioning stages of WSN; in [20], nested GA method based clustering method is implemented in lifetime optimization of WSN by searching competent topology. Better performance of the GA is noticed compared with the other GA and low energy adaptive clustering hierarchy (LEACH) methods; in another similar study [42], GA based clustering method is implemented in energy consumption optimization by creating clusters at the base station and performed better than LEACH.

The complexity of inter-cluster head communication is a significant issue of WSN. A summary of some significant studies covering inter-cluster head communication in WSN is as follows: prolong stable election protocol (P-SEP) is proposed for energy consumption in WSN, which assists in the cluster head selection, sensor node distribution, etc. [43]; a novel method using on cryptographic keys based cluster head to support inter-cluster head communication in WSN is designed [44]; Ahmadi et al. [45] have implemented an effective routing algorithm in WSN for stabilizing k-coverage; and a novel algorithm for minimum energy consumption in internet of thing (IoT) based on WSN is presented [46]. Inter-cluster head communication is not covered in the present study since energy modeling of WSN is not included in the scope of present analysis; rather established energy models of WSN have been used. Consequently, a direct evaluation of analysis outcomes with the LEACH and other related methods is not feasible. Future studies will target the inter-cluster head communication issue to develop optimization methods and their performance assessment with the other methods like LEACH, P-Sep, N-SEP, etc.

5 Conclusion

The problem of limited battery life in WSNs has been outlined and this challenge is explained by using the GA method and data communication energy models. Twenty varieties of GA methods have been applied on three recognized energy models of WSNs in order to find the minimum energy value during data communication. Uniform mutation function (mutation rate about 0.04), stochastic uniform based selection process and two point crossover in between 51 and 200 iterations results in a minimum value of energy consumption and the ideal set of parameters of selected energy models. The energy values obtained after the optimization signifies that the application of GA could extend the battery life of sensor nodes by using the ideal set of parameters during the data communication.