1 Introduction

Wireless sensor networks (WSNs) are composed of a large number of energy-limited and disposable sensor nodes that can be deployed in the target area for monitoring various events such as fire, intrusions, etc. (Masdari et al. 2013). Likewise, they can be integrated with other emerging technologies such as the Internet of Things (Atzori et al. 2010; Gubbi et al. 2013), Fog computing (Stojmenovic and Wen 2014; Vaquero and Rodero-Merino 2014), and cloud computing (Masdari et al. 2016a, b) in order to provide a comprehensive monitoring and processing infrastructure.

However, the sensor nodes suffer from limited battery power, limited processing capabilities, and low wireless communication bandwidth (Sert et al. 2015; Zhen et al. 2013). Clustering is an effective energy management technique that can be applied in the WSN as a means to organize the sensor nodes and improve their energy efficiency (Wang et al. 2011). It is also a well-studied field in the WSNs context. As indicated in Fig. 1, a clustered WSN benefits from several clusters and in each cluster a node acts as a cluster head (CH) to receive the sensor nodes’ data, combine them, and forward the final result to the sink node (Shankar et al. 2016). Clustering allows cluster members to sleep and only operate in their own schedule (Mehmood et al. 2015). Correspondingly, it improves the scalability and lifetime of WSNs by mitigating the contention for the wireless channel among sensor nodes (Lung and Zhou 2010). In a clustered WSN, data traffic can be categorized as inter-cluster and intra-cluster traffic (Lakhlef 2015).

Fig. 1
figure 1

Clustering in the WSNs

Nevertheless, due to the long distance between the CHs and sink nodes, the inter-cluster traffic consumes more energy than intra-cluster traffic in the WSNs with a large number of nodes. To mitigate this problem, the hierarchical clustering methods apply multiple levels of clusters in the WSNs (Farouk et al. 2014). Applying these methods, reduces the distance among the CHs and the sink nodes and distributes the power usage of inter-cluster communication among some of the sensor nodes (Darabkh et al. 2012). As a result, hierarchical clustering can deal with the scalability issue and lifetime improvement in WSNs.

Due to NP-Completeness of the clustering problem, it is widely investigated in the literature (Cacciagrano et al. 2019; Gaber et al. 2018; Mittal et al. 2018; Preeth et al. 2018; Vijayalakshmi and Anandan 2019; Wang et al. 2019c). Numerous metaheuristic-based clustering schemes are provided to deal with this problem in WSNs. Meta-heuristic algorithms are capable of solving NP-Completeness problems in a reasonable time and with sufficient accuracy (Barshandeh and Haghzadeh 2020). For example, a series of state-of-the-art algorithms are proposed for the WSNs (Azharuddin and Jana 2016; Kuila and Jana 2014a, b; Lalwani et al. 2018; Saha and Chaki 2012; Yuan et al. 2017) based on particle swarm optimization (PSO) (Kennedy and Eberhart 1995), artificial bee colony (Karaboga and Basturk 2008), differential evolution (Qin et al. 2008), harmony search algorithm (Geem et al. 2001), etc. TLBO is an interesting population-based optimization algorithm, which was recently proposed by Rao et al. (2011; Rao and Patel 2012). It mimics the teaching–learning process of the teacher and students in the class. This algorithm simulates the learning process of students using the teacher and the learning process by learners interacting with one another. In the teacher phase, the best solution is regarded as the teacher, and it is used to increase the mean of the class. In the second phase, each learner should learn new information from other learners who are better than him/her. However, TLBO is designed to solve continuous optimization problems and it cannot be directly applied to discrete problems such as network clustering. Consequently, in this paper, a novel discrete version of the TLBO (DTLBO) algorithm is presented, which employs genetic operators such as mutation and crossover operators to produce discrete values. Furthermore, DTLBO was exploited to provide a centralized hierarchical clustering scheme for WSNs in order to diminish the power usage of the sensor nodes and improve the lifetime of the network. Additionally, it tries to mitigate the power usage of the intra-cluster and inter-cluster communications in each clustering level. Besides, to postpone the death of the sensor nodes, an energy-aware local search algorithm is presented, which can change the CH selected by the DTLBO to the nearest node with higher energy than the cluster’s average. Extensive simulations indicate the effectiveness of the proposed clustering approach in terms of the network lifetime, power usage, and death of sensor nodes. The contributions in this paper are as follows:

  • Presenting DTLBO, a novel discrete version of the TLBO algorithm.

  • Providing a hierarchical energy-aware clustering algorithm using DTLBO.

  • Presenting an energy-aware local search algorithm to improve the first node die time (FND) in the WSN.

  • Comprehensive simulation and comparison of the proposed clustering algorithm to illustrate its effectiveness against other clustering frameworks.

The paper is organized as follows: Sect. 2 describes the existing clustering approaches for the WSNs. Section 3 briefly introduces the TLBO algorithm, and Sect. 4 presents the proposed Discrete TLBO (DTLBO), and the hierarchical clustering based on this algorithm for WSNs. Section 5 provides the results of the extensive simulations of the DTLBO-based clustering, and finally, Sect. 6 presents the concluding remarks and future research suggestions.

2 Related works

Numerous hierarchical clustering schemes have been proposed in the literature (Sabet and Naji 2016; Wang et al. 2019b; Wang et al. 2018a, b). This section seeks to analyzes some of the proposed hierarchical clustering schemes.

In Wang et al. (2018b), a clustering method denoted as EC-PSO was provided to prevent the energy holes in the WSN as well as search power centers for CHs selection. In this scheme, at first, the CHs are selected using the geometric method, and then, EC-PSO is used for clustering. Afterwards, low power nodes are prevented from becoming the forwarder, and a mobile data node is used to collect the data.

In Wang et al. (2019a), a data gathering and fusion method named IDGS-DF was propositioned, in which a neural network is used for data fusion to enhance WSN’s performance. They use virtual grids for dividing WSN into subdomains and select CHs based on the score of nodes and data fusion.

In Elhabyan and Yagoub (2014), Elhabyan et al. proposed PSO-HC, a PSO-based scheme for hierarchical clustering, which decreases power consumption by mitigating the number of CHs. It improves the WSN scalability using two-hop communications among the nodes and their CHs.

Furthermore, the hierarchical routing method proposed in Sabet and Naji (2015), applied a clustering-based algorithm which decreases the control packets. Power usage, adjustment degree, and the distance of data transmissions are considered in the CH selection process.

In Yan et al. (2008), the authors presented a power-aware clustering scheme to reduce the number of relays nodes in its routing tree. Moreover, it can distribute the power usage among all network nodes by the rotation of the CH task. This scheme employs a spanning tree with minimal relay set and maximal weight for communication in WSN. In addition, nodes can join or detach automatically, leading to improvements in the robustness of the virtual infrastructure.

The proposed clustering and routing protocol in Meenakshi and Kumar (2012), partitioned the WSN into annular rings based on the power levels. In the first phase, the sink transmits a level-1 signal, and all nodes that receive it set their level to one. Thenceforth, the sink transmits a level-2 signal and nodes, which are not in the first level and receives it, set their level to two, etc.

In Banerjee and Khuller (2001), the authors introduced a clustering method to create a layered hierarchical structure for the multi-hop WSNs. In this scheme, a minimum and maximum size constraint are defined for clusters and a node in any layer of the hierarchy belongs to a constant number of clusters in that layer.

A gossip-based hierarchy maintenance protocol is presented in Iwanicki and Van Steen (2009), that decouples its operation from its hierarchy topology. It declines the power usage of the exchanged messages by using local updates and periodic gossiping.

In Kuila and Jana (2014a), Kuila et al. presented two PSO-based algorithms for the routing and clustering in WSNs, which was balanced the power usage of the CHs and the delay in forwarding data packets. To reduce power consumption, it selects the shortest routes from the CHs to the sink.

In Lalwani et al. (2018), the authors proposed two harmony search-based algorithms for CH selection and routing in WSNs. In the clustering step, it considers energy, distance, and node degree and in the routing step the same parameters are used to provide routing from the CHs to the sink.

In Masdari et al. (2019), the authors provided a chaotic and discrete artificial bee colony algorithm, named CDABC and exploited it to create a new clustering protocol to organize the sensor network into several hierarchical levels. This scheme is able to improve WSN’s lifetime by selecting better nodes to be CHs in the various levels and reduces the energy costs of the WSN’s communications.

In addition, an ant colony optimization (ACO) based hierarchical clustering scheme, called ACOHC, was proposed by Mondal et al. (2016). In this scheme, the deployment area is divided into an optimal number of clusters by the K-means algorithm. Moreover, the nodes in each cluster form a chain using the ACO algorithm.

Similarly, Tarhani et al. (2014), presented a distributed clustering algorithm called SEECH, which tried to select CHs and relay based on the degree of the nodes.

3 The teaching–learning-based optimization

In the TLBO algorithm, each solution is represented as Xj,k,i where j denotes the jth dimension and j = 1, 2,…, m; k specifies the kth population member or learner, k = 1, 2,, n and i indicates the ith iteration, i = 1, 2,, Gmax which Gmax specifies a maximum number of iterations. The first requirement in a discrete optimization algorithm is to have an initial discrete population. For this purpose, a simple procedure is applied to produce the initial population. In this pseudocode, the Dim parameter indicates the dimension of the population and the Population_Count specifies the number of solutions in the population. In this phase, the best solution or teacher tries to increase the knowledge of the students as well as the mean result of the class based on his/her capabilities. This phase starts by finding the best solution is represented by Xkbest. The next step is to calculate the mean result Mj,i of the learners in the jth dimension. The increase in the mean result of each student by the teacher can be computed as follows:

$$Difference\_Mean_{j,k,i} = \, r_{j,i} \left( {X_{j,kbest,i} - \, T_{F} M_{j,i} } \right)$$
(1)

In which, TF is the teaching factor to decide the mean value to be changed, and rj,i is the random number in the range [0, 1]. The TF can be randomly 1 or 2 and is chosen with an equal probability:

$$T_{F} = round[1 + rnd\left( {0, \, 1} \right)\{ 2 - 1\} ]$$
(2)

According to the Difference_Meanj,k,i achieved using Eq. 1, the value of \(X^{\prime}_{j,k,i}\) should be computed according to the following expression:

$$X^{\prime}_{j,k,i} = X_{j,k,i} + Difference\_Mean_{j,k,i}$$
(3)

TLBO uses a greedy method to update its population, and when the fitness value of the \(X^{\prime}_{j,k,i}\) is better than the \(X^{\prime}_{j,k,i}\) then the existing solution should be updated. In the learner phase, the learners can increase their knowledge by interacting with each other. For this purpose, at the ith iteration, each learner randomly selects two learners denoted as P and Q such that

X’P,i ≠ X’Q,i, which are updated at the teacher phase. When the fitness of the X’P, i is better than the X’Q, i, the Eq. 4 will be applied to compute the new solution, otherwise, the Eq. 5 should be utilized for this purpose.

$$X^{\prime\prime}_{j,P,i} = X^{\prime}_{j,P,i} + r_{j,P,i} (X^{\prime}_{j,P,i} - X^{\prime}_{j,Q,i} )$$
(4)
$$X_{j,P,i}^{''} = X_{j,P,i}^{'} + r_{j,i} (X_{j,Qi}^{'} - X_{j,P,i}^{'} )$$
(5)

In these equations, rj, i is the random number in the range [0, 1]. All the accepted function values at the end of the learner phase are used as the input to the teacher phase.

4 The proposed solution

The contributions, which will be discussed in this section, are as follows:

  • Presenting DTLBO, a discrete version of the TLBO optimization algorithm for clustering in WSNs.

  • Design and evaluation of a hierarchical energy-aware clustering scheme based on the DTLBO for organizing large WSNs.

4.1 The proposed DTLBO algorithm

To apply TLBO for discrete problems such as network clustering, this algorithm should be modified. Figure 2 indicates the flowchart of the DTLBO algorithm. This subsection presents the proposed Discrete TLBO (DTLBO) algorithm and provides the required modification to convert the continuous TLBO algorithm to a discrete one. For this purpose, firstly, it is required to have a discrete initial population and secondly, there should be equations that receive discrete solutions and modifies them to produce other discrete solutions. To convert the TLBO into a discrete optimization algorithm, the TLBO’s equation is being modified by applying genetic operators such as mutation and crossover. For this purpose, the Eq. 1 is being changed as follows:

Fig. 2
figure 2

Teacher phase of the proposed DTLBO

$$Difference\_Mean_{j,k,i} = \, r_{j,i} (X_{j,kbest,i} {-}Temp1_{j,k,i} )$$
(6)
$$Temp1_{j,k,i} = T_{F} M_{j,i}$$
(7)

To compute the Temp1j,k,i in Eq. 7, Eq. 8 is applied, which produces discrete values.

$${\text{Temp}}1_{k,i} = \left\{ {\begin{array}{*{20}l} {{\text{M}}_{j,i} } \hfill & {i{\text{f}}\;Rnd > {\text{T}}_{\text{F}} } \hfill \\ {\text{Mutation}} \hfill & {\text{else}} \hfill \\ \end{array} } \right\}$$
(8)

In Eq. 8, the Rnd parameter denotes a random number between [0, 1] and Mutation selects a random node ID between the [1, NLive], which NLive denotes the number of live sensor nodes in WSN. After Temp1j,k,i is computed using Eq. 8, it can be utilized in Eq. 9, which replaces the Eq. 1 in the DTLBO. In Eq. 9, \(Difference\_Mean_{jki}\) and \(X_{jki}\) are applied based on their fitness values. Using the \(Difference\_Mean_{jki}\) achieved from Eq. 9, the Eq. 10 can be computed.

Figure 2 exhibits the flowchart of the teacher phase. To convert Eq. 4 of the TLBO algorithm, it is considered to be as shown in Eqs. 11 and 12.

Thenceforth, they are replaced by Eqs. 13 and 14. In addition, Fig. 3 depicts the flowchart of the learner phase in the proposed DTLBO algorithm. To convert the Eq. 5 of the TLBO, for discrete operation, Eqs. 15 and 16 should be used.

Fig. 3
figure 3

Learners phase of the proposed DTLBO

Equation 17 was applied to compute the Temp3j,Q,i in Eq. 16, and to compute the X’’j, P, i in Eq. 15, Eq. 18 is used, which applies the fitness value in their computation.

$$Difference\_Mean_{\text{j,k,i}} = \left\{ {\begin{array}{*{20}l} {X_{j,kbest,i} } \hfill & {if rij < \frac{{Fitness\left( {Temp1_{k ,i} } \right)}}{{Fitness\left( {X_{kbest ,i} } \right) + Fitness\left( {Temp1_{k,i} } \right)}}} \hfill \\ {Temp1_{j,k,i} } \hfill & { else } \hfill \\ \end{array} } \right\}$$
(9)
$$X^{\prime}_{jki} = \left\{ {\begin{array}{*{20}l} {X_{j,k,i} } \hfill & {if\,Rnd < \frac{{Fitness\left( {X_{k,i} } \right)}}{{Fitness\left( {X_{ki} } \right) + Fitness\left( {Difference\_Mean_{k,i} } \right)}}} \hfill \\ {Difference\_Mean_{j,k,i} } \hfill & {else} \hfill \\ \end{array} } \right\}$$
(10)
$$X^{\prime}_{j,P,i} = X^{\prime}_{j,P,i} + Temp2_{j,P,i}$$
(11)
$$Temp2_{j,P,i} = r_{j,i} (X^{\prime}_{j,P,i} - X^{\prime}_{j,Q,i} )$$
(12)
$$Temp2_{j,P,i} = \left\{ {\begin{array}{*{20}l} {Mutation} \hfill & \quad {if Rnd > rij} \hfill \\ {X^{\prime}_{j,P,i} } \hfill & \quad{Else\,if\,Rnd < \frac{{Fitness\left( { X^{\prime}_{Q,,i} } \right)}}{{Fitness\left( {X^{\prime}_{P,i} } \right) + Fitness\left( { X^{\prime}_{Q,i} } \right)}}} \hfill \\ {X^{\prime}_{j,Q,i} } \hfill &\quad {else} \hfill \\ \end{array} } \right\}$$
(13)
$$X^{\prime\prime}_{j,P,i} = \left\{ {\begin{array}{*{20}l} {X^{\prime}_{j,P,i} } \hfill &\quad {if\,Rnd < \frac{{Fitness\left( { Temp2_{j,P,i} } \right) }}{{Fitness\left( {X^{\prime}_{P,i} } \right) + Fitness\left( { Temp2_{P,i} } \right)}}} \hfill \\ {Temp2_{j,P,i} } \hfill &\quad {else} \hfill \\ \end{array} } \right\}$$
(14)
$$X^{\prime\prime}_{j,P,i} = X^{\prime}_{j,P,i} + Temp3_{j,Q,i}$$
(15)
$$Temp3_{j,Q,i} = r_{j,i} (X^{\prime}_{j,Q,i} - X^{\prime}_{j,P,i} )$$
(16)
$$Temp3_{j,Q,i} = \left\{ {\begin{array}{*{20}l} {Mutation} \hfill &\quad {if\,Rand > r_{ij} } \hfill \\ {X^{\prime}_{j,P,i} } \hfill &\quad {Else\,if\,Rand < \frac{{Fitness\left( { X^{\prime}_{Q,i} } \right)}}{{Fitness\left( {X^{\prime}_{P,i} } \right) + Fitness\left( { X^{\prime}_{Q,i} } \right)}}} \hfill \\ {X^{\prime}_{j,Q,i} } \hfill &\quad {else} \hfill \\ \end{array} } \right\}$$
(17)
$$X^{\prime\prime}_{j,P,i} = \left\{ {\begin{array}{*{20}l} {X^{\prime}_{j,P,i} } \hfill &\quad {if\,R\,and < \frac{{Fitness\left( {X^{\prime}_{P,i} } \right) }}{{Fitness\left( {X^{\prime}_{P,i} } \right) + Fitness\left( { Temp3_{Q,i} } \right)}}} \hfill \\ { Temp3_{j,Q,i} } \hfill &\quad { else } \hfill \\ \end{array} } \right\}$$
(18)

4.2 Hierarchical clustering by DTLBO

This subsection provides the details of the proposed centralized hierarchical energy-aware clustering algorithm for WSNs. In this scheme, the following items are assumed about the network model:

  • Sensor nodes are placed randomly in the WSN, and they are fixed.

  • Sensor nodes may have GPS sensors, but without GPS, the distance among nodes can be computed by the received signal strength.

  • Sensor nodes are homogeneous.

  • WSN utilizes only one fixed sink node, which does not have any energy limitations.

4.2.1 Radio model

A radio model, depicted in Fig. 4 and described in Soro and Heinzelman (2005) was applied for communications between sensor nodes and the sink node. In this model, \(E_{tx} \left( {d,L} \right)\) is the power usage for sending a packet with the size of L bits to the distance specified by d. This power usage can be computed by Eq. 19:

$$E_{{tx}} \left( {d,L} \right) = \left\{ {\begin{array}{*{20}l} {L*\left( {E_{{elec}} + E_{{fs}} d^{2} } \right)} & {if\quad d < d_{0} } \\ {L*\left( {E_{{elec}} + E_{{amp}} d^{4} } \right)} & {if\quad d \ge d_{0} } \\ \end{array} } \right.$$
(19)

where Eelec denotes the amount of power usage to run the transmitter or receiver circuitry for each bit. Besides, Efs and Emp are the amounts of energy per bit dissipated in the RF amplifier according to the distance d0 which can be obtained from Eq. 20:

Fig. 4
figure 4

Applied energy model

$$d0 = \sqrt {\frac{{E_{fs} }}{{E_{amp} }}}$$
(20)

Furthermore, \(E_{rx} \left( L \right)\) indicates the power usage required for receiving a packet with L bits that can be calculated using Eq. 21:

$$E_{rx} \left( L \right) = L*E_{elec}$$
(21)

4.2.2 Clustering algorithm

Because of the following reasons, once the size of the WSN increases, the effectiveness of the single level clustering schemes reduces:

  • The distance between sensor nodes and their CHs increases, which leads to an increase in the sensor nodes’ power usage.

  • The distance between CHs and the sink nodes increases and this intensifies the power usage of the CHs.

  • The number of cluster members increases and this increases the power usage of the CHs. This problem also is encountered in the non-uniformly distributed WSNs, which some section of the network has more nodes than the others.

$$N_{node} = \mathop \sum \limits_{i = 1}^{Level} N_{CHLi} + \, N_{nonCH}$$
(22)
$$The \, objective \, in \, the \, i^{th} level{:} \, Minimize \, Fitness = \left( { \, E_{Intraclusteri} + E_{Interclusteri} } \right)$$
(23)
$$E_{Intracluster1} = \mathop \sum \limits_{i = 1}^{NchL1} (\mathop \sum \limits_{j = 1}^{Nclusteri} \left( {E_{tx} \left( {Dis\left( {Member_{j} ,CH_{i} } \right),L} \right)} \right) + E_{rx} \left( L \right)$$
(24)
$$E_{Intracluster1} = \mathop \sum \limits_{i = 1}^{NchL1} (E_{tx} \left( {Dis\left( {CH_{i} ,Sin_{k} } \right),L} \right)$$
(25)
$$E_{Intracluster1} = \mathop \sum \limits_{i = 1}^{NchLi} (\mathop \sum \limits_{j = 1}^{Nclusteri} \left( {E_{tx} \left( {Dis\left( {Member_{j} ,CH_{i} } \right),L} \right)} \right) + E_{rx} \left( L \right)$$
(26)
$$E_{Intracluster1} = \mathop \sum \limits_{i = 1}^{NchLi} (E_{tx} \left( {Dis\left( { CH_{i} ,CH\left( {i - 1} \right)} \right),L} \right) + \mathop \sum \limits_{i = 1}^{{NchL\left( {i - 1} \right)}} E_{rx} \left( L \right)$$
(27)
$$Dis\left( {S_{i} ,S_{j} } \right) = \sqrt {\left( {X_{i} - X_{j} } \right)^{2} + \left( {Y_{i} - Y_{j} } \right)^{2} }$$
(28)

To mitigate these problems, hierarchical clustering schemes produce multiple layers of clusters in large-scale WSNs. This section provides the proposed Discrete TLBO (DTLBO)-based energy-aware hierarchical clustering algorithm for the WSNs. As exhibited in Fig. 5, based on the number of nodes, the proposed solution provided in this paper, dynamically produces multiple layers of nested clusters for WSN. In this figure, CHL1 denotes the first level CHs, CHL2 denotes the second level CHs, and, etc. When several levels of clusters are created, the Eqs. 2228 can be considered about the CHs and cluster member nodes.

Fig. 5
figure 5

DTLBO-based energy-aware hierarchical clustering, a one level clustering, b two-level clustering, and c three-level clustering

In these equations, Nnode is the number of WSN nodes. Equation 23 exhibits the fitness functions exploited for the ith level of clustering, which consists of the energy required for communications performed inside the clusters and among the clusters. Thus, in this scheme, the objective is to minimize the power usage of each clustering level by minimizing the power usage of both intra-cluster and inter-cluster communications. Equation 24 computes the energy required for communications inside the 1st clustering level. Moreover, Eq. 25 computes the energy required for inter-cluster communications in the first clustering level. Equation 26 computes the energy required for intra-cluster communications in the ith clustering level. Moreover, Eq. 27 computes the energy required for inter-cluster communications in the first clustering level. Additionally, once the position of sensor nodes is available, their distance can be calculated using Eq. 28. Whilst the position data of sensor nodes are not available, their distance can determine using the Received Signal Strength (RSS), as indicated in Eq. 29:

$$Dist\left( {S_{i} ,S_{j} } \right) = s.\left( {P^{r} } \right)^{ - 1/2}$$
(29)

where \(Dist\left( {S_{i} ,S_{j} } \right)\) denotes the distance of the ith and jth sensor nodes, ƒ is the communication frequency, c is the speed of light, \(P^{r}\) is the received signal strength, and Ps is the sender signal strength. In addition, the s parameter can be calculated as follows:

$$s = c \times \left( {P^{s} } \right)^{1/2} / 4\pi f$$
(30)

In this hierarchical clustering scheme, time is organized as rounds and each round is composed of setup and steady-state phases. As depicted in Fig. 6, the first step of this scheme is the initialization phase, in which each sensor node should send its location data to the sink node. GPS may achieve this data using some localization techniques or using RSS. Subsequently, the sink node runs the proposed DTLBO-based hierarchical clustering algorithm with the received data. As outlined before, it considers energy costs in selecting some sensor nodes as CHs. Then, the sink node broadcasts the list of the CH nodes in the WSN. Later, in the steady-state phase, each non-CH node connects to the nearest CH. In the proposed scheme, the steady-state phase consists of N sub-phases and in each sub-phase, sensor nodes send their data to the CH in their TDMA schedule. After sensors in the Nth level transmit data to their CH nodes, the CHs located in the (N-1)th level collect these data and after aggregation, send them to their parent CH. This operation is being maintained until data reaches the sink. Figure 7 indicates a sample solution applied in the so-called scheme. As shown in this figure, the value of each dimension indicates the index of a CH node, and according to this index, the location of the CH can be determined. Figure 8 indicates two sample particles in the proposed scheme. However, in each solution, the location of each value is not essential, and as a result, both solutions shown in this figure are the same, since they contain the same values.

Fig. 6
figure 6

Phases of the proposed DTLBO-based hierarchical clustering algorithm for WSNs

Fig. 7
figure 7

A sample encoding in the DTLBO-based clustering

Fig. 8
figure 8

Two sample particles

Fig. 9
figure 9

Computing the live sensor nodes set

Fig. 10
figure 10

Pseudocode of the local search for the DTLBO-based hierarchical clustering algorithm

As a result, in the DTLBO algorithm swap operation is not used, and only mutation and crossover operators are benefited.

To lessen the total power usage of sensor nodes in forwarding the sensed data to the sink node, the proposed DTLBO-based clustering solution tries to select the most appropriate sensors nodes as CHs.

However, this greedy CH selection approach depletes the energy of the CH nodes and results in the decrease of the first node die time (FND). Consequently, to increase the FND, it is better to change a CH after the energy of this node becomes less than the average energy of the cluster members. For this purpose, in the proposed scheme, a local search algorithm has been proposed to improve the CH selection process, by rotating the CH role between the cluster members according to the remaining power of the sensor nodes and the distance from the node to the CH selected by the TLBO-based clustering method. It is important to note that, because this local search algorithm may change the CH selected by the DTLBO algorithm, the resulted configuration may consume more energy. Therefore, the FND of the network improves at the cost of a decrease in the LND or last node die time.

Figure 11 presents the pseudo-code of the DTLBO-based clustering algorithm for WSNs. As shown in Fig. 9, in each round, this algorithm first computes the set of live sensor nodes. Afterwards, DTLBO-based clustering is performed based on the objectives specified in Eq. 23. Later, each selected CH is analyzed by the local search algorithm, and it may be replaced by a close node with more energy (see Fig. 10). When a created cluster has more members than a specific threshold, this cluster should be further clustered and this process continues until all large clusters are clustered and a hierarchy of clusters is formed.

Fig. 11
figure 11

The proposed DTLBO-based clustering algorithm for WSNs

5 Simulation results

This section is trying to present the results of the extensive simulation of the performance evaluation of the DTLBO-based hierarchical clustering scheme. For this purpose, the proposed scheme is compared against several recently proposed clustering schemes. These experiments are conducted in the MATLAB 2016 software, and results are averaged from 40 executions of each simulation scenario. The performance evaluation of this scheme is conducted concerning the following metrics:

  • Power usage in the WSN.

  • Inactive/dead sensor nodes in the WSN.

  • Difference between the FND (First Node Die) time and LND (Last Node Die) times.

  • The received data packets at the sink.

  • Residual energy in the WSN.

5.1 Comparison with the clustering scheme proposed by Kuila et al.

This subsection puts forward results of the comparison of the proposed DTLBO-based scheme, mainly with the Kuila’s scheme (Kuila and Jana 2014a). Table 1 shows the applied parameters in the first simulation scenario. The simulations are conducted in a 500*500-m area when the sink is assumed to be at the center. Besides, 200 nodes are placed randomly in the simulation area aimed at forwarding their sensed data to the sink node. These nodes are distributed randomly in the WSN and have 2 J initial battery power. These simulations are conducted in three simulation scenarios, in which different positions are considered for the sink node, and a different number of nodes with different amounts of the initial energy are assumed. Figure 12 illustrates the amount of power usage in the WSN in the compared schemes. As depicted in this figure, the proposed scheme can better preserve the nodes’ battery power. Figure 13 exhibits the number of inactive nodes in the WSN. As this figure indicates, the proposed DTLBO-based scheme is able to improve the WSN’s lifetime. The reason for this improvement is that the proposed scheme uses more nodes in the data forwarding process. Moreover, as the nodes send their data to the near destinations, they consume less energy. The difference between FND and LND times is illustrated in Fig. 14. By using the energy-aware local search algorithm, the so-called difference between FND and LND times is lower in the proposed scheme.

Table 1 Simulation parameters
Fig. 12
figure 12

The amount of power usage in the WSN

Fig. 13
figure 13

Number of inactive nodes in the WSN

Fig. 14
figure 14

The amount of difference between the FND and LND times

5.2 Comparison with the clustering scheme proposed by Lalwani et al.

This subsection provides the comparison of the DTLBO-based hierarchical clustering algorithm results against the harmony search-based clustering and routing scheme proposed by Lalwani et al. (2018). Table 2 shows the values of the parameters used in these simulation scenarios.

Table 2 Simulation parameters

Figure 15 indicates the number of received packets at the sink node. These results indicate that the DTLBO-based clustering algorithm outperforms the other clustering methods. To this end, the amount of data sent to the sink is based on the following items:

Fig. 15
figure 15

The number of data packets received at the base station

  • The alive nodes

  • The number of clusters

  • Data aggregation ratio

Therefore, more data packets will be sent to the sink node when WSN entails more of the live nodes.

In a WSN, a sensor node consumes its energy for data transmission, data receiving, and data aggregation operations. The amount of residual energy in the network can be calculated as follows:

$$\begin{aligned} E_{Residual} = \mathop \sum \limits_{i = 1}^{{N_{Live} }} E\left( {Si} \right) \hfill \\ 0 < N_{Live} \le N_{Sensor} \quad and \quad E\left( {S_{i} } \right) > 0 \hfill \\ \end{aligned}$$
(31)

where \(E_{Residual}\) denotes the residual energy of the WSN, and \(E\left( {S_{i} } \right)\) denotes the remaining energy of the ith node. Correspondingly, NLive shows the number of live nodes in the WSN and, NSensor is the total number of nodes in the WSN. Figure 16 shows the amount of residual energy in the WSN when the sink node is positioned in the (100,100). In this simulation, DTLBO-based clustering is compared with schemes such as CRHS, ERP, DHCR, EADC, and HF.

Fig. 16
figure 16

Residual energy in the WSN when the sink node is positioned in (100,100)

Another analysis of the remaining energy of WSN has been provided in Fig. 17. In this simulation scenario, the sink node is positioned in the (200,200). As it is observed in this figure, the DTLBO-based energy-aware scheme outperforms the existing schemes. Figure 18 exhibits the residual energy of WSN when the sink node is located at the (250, 250). Since the proposed scheme consumes less energy in each round, it can better save the network’s energy than the other compared schemes.

Fig. 17
figure 17

Residual energy in the WSN when the sink is located at the (200, 200)

Fig. 18
figure 18

Residual energy in the WSN when the sink is located at the (250, 250)

Since, the distance of the first level CHs to the sink node is considered in the cost function of the first level of clustering. As shown in Fig. 19, the proposed scheme can be energy efficient when the sink node is placed in different positions.

Fig. 19
figure 19

Residual energy in the WSN

As exposed in Figs. 16, 17, 18, 19, the proposed scheme significantly outperforms the compared schemes in preserving the energy of the nodes.

Table 3 provides the comparison of the data packets received at the sink node in the DTLBO-based scheme and other clustering schemes such as PSO-C, LA2D-GA, GA-based, PSO-SD, and HSA-based scheme. Moreover, in these comparisons, the sink node is placed in locations such as (100*100), (200,200), and (250,250).

Table 3 Data packets received at the sink

Table 4 provides the comparison of residual energy in the DTLBO-based clustering as well as series of other clustering schemes such as LA2D-GA, PSO-C, PSO-SD, GA-based, and HSA-based scheme.

Table 4 Residual energy in WSN

5.3 Comparison with the clustering scheme proposed by Mondal et al.

This subsection presents the results of the comparison against the ACOHC (Mondal et al. 2016). Table 5 specifies the parameters applied in these experiments. In these simulations, a 100*100 area is considered for WSN, in which 100 nodes are used. Correspondingly, the sink node is positioned in the (50,175) and 1 J energy is considered for the battery of nodes

Table 5 Simulation parameters

Figure 20 provides the comparison of the FND, HND (Half Node Die), and LND times in the LEACH (Soro and Heinzelman 2005), LEACH-C, PEGASIS (Lindsey and Raghavendra 2002), KLEACH, ACOHC, and the DTLBO-based clustering schemes. As shown in this figure, the proposed scheme can achieve better results than other schemes.

Fig. 20
figure 20

Comparison of the FND, HND, and LND

Figure 21 indicates the number of alive nodes in the WSNs throughout the network lifetime in the LEACH, LEACH-C, PEGASIS, KLEACH, ACOHC, and the DTLBO-based clustering schemes. As shown in this figure, the DTLBO-based clustering is more successful in keeping the nodes alive. These improvements are due to the centralized clustering method, which consumes less energy than the distributed schemes.

Fig. 21
figure 21

Number of alive nodes in the WSN

5.4 Comparison with the clustering scheme proposed by Tarhani et al.

This section presents the experimental results against the SEECH clustering scheme proposed in (Tarhani et al. 2014). Table 6 specifies the metrics applied for comparison of the proposed scheme with the SEECH.

Table 6 Simulation parameters

These simulations are conducted in two simulation scenarios. In the first scenario, 1000 nodes were applied in a 200*200 meters square area, and in the second scenario, 400 nodes were applied in a 100*100 meters square area. Moreover, in the first simulation scenario, 1 J energy was considered for the WSN, and the sink was positioned in the (100,350). In addition, in the second simulation scenario, a sink node was positioned in the (50,200), and 0.5 J battery power was used for all nodes in the WSN.

Figure 22 exhibits the comparison of the alive nodes when the sink is located at (100,350). In addition, Fig. 23 depicts the comparison of the alive nodes when the sink is located at (50,200). In both comparisons, the DTLBO-based clustering scheme was compared against the schemes such as SEECH, LEACH, and TCAC. As shown in Figs. 22 and 23, the DTLBO-based hierarchical clustering outperformed other schemes in terms of alive nodes in the WSN.

Fig. 22
figure 22

Comparison of the alive nodes when the sink is located at (100,350)

Fig. 23
figure 23

Comparison of the alive nodes when the sink is located at (50,200)

Figures 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23 indicate the proposed scheme can outperform some of the existing clustering schemes. The reasons for these improvements can be outlined as follows:

  • Centralized clustering requires disseminating a few control packets, which reduces the power usage of the nodes and preserves their battery power.

  • Since the DTLBO-based clustering scheme is hierarchical, it exploits multiple levels of clusters to mitigate the distance to next-hop, and this decreases the power usage of nodes.

  • The DTLBO-based clustering scheme applies a cost function that considers the power usage for intra-cluster and inter-cluster communications.

5.5 The effect of the local search algorithm on network lifetime

The DTLBO algorithm can select the best node to reduce the power usage for communications conducted inside and outside of the clusters. However, the local search algorithm changes this cluster node when its remaining energy is less than the average energy of the cluster members. As a result, the selected node by the local search algorithm is not the best node. To find a near-optimal node as a CH, distance to the best node (selected by DTLBO) is considered in this algorithm, which provides better results than other CH selection frameworks, as revealed in the previous subsection. In this subsection, the simulation results are being provided to indicate the effect of the local search algorithm on the network lifetime.

In these experiments, three simulation scenarios with 300, 400 and, 500 nodes and with 2 J battery power are considered. Table 7 lists the exploited parameters in the conducted experiments.

Table 7 Simulation parameters

Figure 24 indicates the number of dead sensor nodes in the first simulation scenario, in which WSN has 500 nodes, and the proposed algorithm runs with and without its local search algorithm. As shown in this figure, the local search algorithm improves the FND time of the proposed solution by selecting near-optimal nodes as CHs. However, since in most applications such as network coverage, the correct operation of all nodes is required, enhancement of the FND is significant, and the results of the local search algorithm can be beneficiary. Figure 25 indicates the number of the dead sensor nodes in each round of the second simulation scenario when 400 nodes are used in the network. Once more, in this simulation scenario, the proposed hierarchical scheme is executed with and without using the local search algorithm.

Fig. 24
figure 24

Number of dead sensor nodes in the first simulation scenario

Fig. 25
figure 25

Number of the dead sensor nodes in the second simulation scenario

Figure 26 depicts the number of dead sensor nodes in the third simulation scenario, in which WSN has 500 nodes. The results of the proposed scheme indicated with and without the local search algorithm. Figure 27 indicates the FND times in the three simulation scenarios with 300, 400, and 500 nodes. As indicated in the figure, the proposed scheme is able to improve the FND time by using the local search algorithm.

Fig. 26
figure 26

Number of dead sensor nodes in the third scenario

Fig. 27
figure 27

Comparison of the FND times

Figure 28 shows the LND times in the three simulation scenarios, which WSN utilizes 300, 400, and 500 nodes. As indicated in this figure, the LND time will be diminished by using the local search algorithm in the proposed scheme. However, in order to call for the importance of the FND, the LND reduction is the price that should be paid in exchange for the enhancement of FND.

Fig. 28
figure 28

Comparison of LND times

6 Conclusion

The limited resources and battery power of the sensor nodes are some of the critical constraints, which should be considered in the WSNs. The clustering of sensor nodes is one of the widely used approaches to deal with these issues in the literature.

In this paper, it is aimed to introduce a discrete version of the TLBO algorithm for energy-aware clustering in the WSNs. This scheme can be utilized to organize the large-scale WSNs into the nested clusters and is able to improve the network scalability. It considers the power usage of the intra-cluster and inter-cluster communications in its objective function in order to finds the best to be CH set of nodes. In addition, so as to improve the FND of WSNs, an energy-aware local search algorithm is provided, which changes the CH selected by DTLBO, when its power is less than the average of the cluster. The DTLBO-based hierarchical clustering scheme was simulated intensively in various simulation scenarios, and the achieved results were evaluated regarding the several performance metrics against some of the recently proposed well-known clustering schemes. The experimental results demonstrated that the proposed clustering approach outperforms other schemes in terms of the network lifetime, the data delivered to the sink, the remaining power of WSN, FND, and LND.

Although hierarchical clustering is energy efficient, they are more susceptible to the failures than the single level clustering. In addition, centralized clustering is less fault-tolerant than distributed clustering, since the failure of the sink can fail the clustering process. Consequently, in future studies, a new endeavor is going to be put into practice to deal with this limitation of the proposed scheme, while keeping its energy efficiency. In this process, sink nodes will be multiplied in order to improve the fault tolerance of the centralized clustering. A multi-objective version of DTLBO of the proposed algorithm will also be provided to deal with these conflicting objectives in the WSN clustering process. Furthermore, conducting auto-clustering to find the optimum number of clusters in the WSN can be investigated in the subsequent studies.