Abstract
To a wireless sensor network, cooperation among multiple sensors is necessary when it executes applications that consist of several computationally intensive tasks. Most previous works in this field concentrated on energy savings as well as load balancing. However, these schemes merely considered the situations where only one type of resource is required which drastically constrains their practical applications. To alleviate this limitation, in this article, we investigate the issue of complex application allocation, where various distinctive types of resources are demanded. We propose a heuristic-based algorithm for distributing complex applications in clustered wireless sensor networks. The algorithm is partitioned into two phases, in the inter-cluster allocation stage, tasks of the application are allocated to various clusters with the purpose of minimizing energy consumption, and in the intra-cluster allocation stage, the task is distributed to appropriate sensor nodes with the consideration of both energy cost and workload balancing. In so doing, the energy dissipation can be reduced and balanced, and the lifetime of the system is extended. Simulations are conducted to evaluate the performance of the proposed algorithm, and the results demonstrate that the proposed algorithm is superior in terms of energy consumption, load balancing, and efficiency of task allocation.
Keywords
Introduction
In the last decade, with the development in technology of micro-electronics, digital electronics design, as well as advances in low-power wireless communication and network technique, a new type of network, wireless sensor network (WSN), has emerged. 1 In general, a WSN is composed of a large number of sensor nodes which are endowed with detection, computation, and communication capabilities. The emergence of WSN has greatly extended the application areas over traditional sensors. In fact, by grouping numerous sensors into a connected network, the end-users can obtain much more accurate data of a target that is in a remote and/or hostile environment. Therefore, WSNs have been widely used in many applications such as object detection and tracking, 2 privacy and security protection, 3 natural disaster rescue, 4 health care, 5 and so on.
In many real-world scenarios, a WSN will face applications which may require large amount of information collection, considerable computation operations, and intensive communication overhead. In contrast, as a tiny, low-cost and battery-powered device, a single sensor node usually has limited resource and can perform relatively simple action. Consequently, in order to successfully execute a complicated application, various sensors should work cooperatively. In particular, by task decomposition and allocation, a difficult task can be divided into several uncomplicated parts, and each sub-task is assigned to a sensor node which can handle it independently. A typical example is the Third Generation Surveillance System (3GSS) where a number of cameras are connected with a network. 6 To such a system, a common application is to detect, classify, localize, and recognize an object; it involves computationally intensive operations which can hardly be performed by a single sensor node. A promising way to resolve this problem is to decompose the complicated application into simple tasks and distribute them among specific sensors. In such a way, various cameras can collaboratively accomplish the complex application. Thus, task allocation has a vital influence on the overall performance of a WSN, and the development of efficient strategies for collaborative task distribution has attracted much attention in recent research.
Although the issue of task allocation has been widely studied and well addressed in conventional distributed systems, including multiprocessor systems, 7 cloud computing, 8 social networks, 9 and so on, the problem has distinctive features in WSNs. As sensor nodes in WSNs are usually powered by batteries and the power is irreplaceable, they may be prone to be invalid due to energy exhaustion. If the energy of some sensor nodes is depleted in short term, critical data cannot be collected in the sensing area which may seriously weaken the function of a WSN. A more disastrous effect is that if too many nodes are dead, the communication link will become collapsed and the whole network may be out of work. On the other side, the sensor nodes in a WSN should consume the energy uniformly, and a poor workload balancing may lead to some sensor nodes deplete their energy much earlier than others. Therefore, how to reduce and balance energy consumption becomes a desirable design goal to WSNs.10,11 The issue should also be taken into account for task allocation in WSNs. In fact, numerous studies have been conducted in this field.12–14 Most existing works focus on distributing computation and communication tasks rationally among sensor nodes with the purpose of extending network lifetime by load balancing and energy conservation. These approaches model task allocation as a multi-objective optimization problem which has been proved to be NP-hard; thus, heuristic-based algorithms are widely presented to solve this problem in polynomial time.
In general, a WSN is considered to be an application-oriented network, that is it is created and deployed to implement a specific application. In real practice, an application normally requires detecting and gathering various types of information. In this article, this kind of applications is referred to as complex applications. Formally, a complex application is composed of multiple tasks each of which can be executed if some specific information is collected and processed. Actually, most real-world applications to WSNs are complex applications, one typical example is the environment monitoring system. In the scenario of an environment monitoring system, sensor nodes are deployed in the target area to detect environmental conditions. Considering an application that starts running on such a WSN to determine whether the environmental status is normal in a particular region, different sorts of data including temperature, humidity, pressure, and so on should be detected and sent back to the sink node for further analysis. Consequently, to perform such a complex application, various types of information are required. For a WSN, it should have the capacity to collect, process, and transmit distinctive kinds of data. As a limited resource and low-cost unit, a sensor node is usually equipped with only one sensing device, thus the whole WSN comprises a great deal of sensor nodes which are integrated with multiple sensing elements of different types. This kind of WSN is referred to as a heterogeneous WSN, a typical example of a heterogeneous WSN is shown in Figure 1, where sensor nodes with distinctive sensing devices are marked by different notations. Compared with homogeneous WSNs in which sensor nodes have identical or similar functionalities, heterogeneous WSNs have their unique characteristics. On one hand, all the nodes in a heterogeneous WSN can share underlying protocols or standards, such as the structure of a frame, the implementation of modulation and demodulation, and data transmission protocol. On the other hand, to high-level applications, such as task allocation, heterogeneous WSNs are quite different from homogeneous WSNs. Previous studies mainly focus on distributing tasks in a homogeneous WSN. Nevertheless, these methods cannot be directly adopted to solve the problem of assigning complex applications in heterogeneous WSNs. The challenge stems from the fact that to distribute a complex application in a heterogeneous WSN, sensor nodes with particular resources must be determined. To this end, an allocation algorithm should consider not only the conventional optimization metrics, such as energy consumption and latency, but also the sensing capability of a node. The node that has the required sensing capability can be regarded as the candidate for the task, otherwise it cannot undertake corresponding task even if it has superior properties in energy conservation or computation speed. In summary, as a common issue in practice, complex application allocation in heterogeneous WSNs is different from traditional task allocation problem in WSNs and should be concerned with.

An example of heterogeneous WSN.
To WSNs, one core issue is energy conservation and/or network lifetime extension; it is not an exception to complex application allocation in heterogeneous WSNs. Since communication is the most energy costly operation in WSNs, and the communication energy expenditure is proportional to the distance (normally second power) between the two nodes, a node is usually constrained to communicate directly with other nodes within a limited range. In order to send the collected data to the sink node with low power, a hierarchical communication network should be formed—the most popular and effective method is clustering.15–17 By dividing the whole WSN into small parts and clustering multiple nodes into a group, a sensor node can communicate with the sink node through the cluster head (CH) in a multihop manner, which can significantly reduce power dissipation. Therefore, the complex application allocation should be considered in a clustered WSN.
With this background, in this article, we design a complex application allocation mechanism in heterogeneous clustered WSNs, which is claimed as a main contribution of this article. In comparison with previous works, the presented mechanism assumes that a complex application can be divided into various tasks and each task requires various kinds of resources, and accordingly, a sensor node is endowed with a sensing resource that enables it to accomplish a corresponding action. Meanwhile, the WSN has a hierarchical structure and all the sensor nodes are grouped into clusters and each cluster has a leader. The goal is to find an optimal scheme that can distribute the complex application to proper sensor nodes with the purpose of minimizing energy dissipation and balancing the workload while meeting the application’s requirement for multiple resources. A two-stage application allocation algorithm is presented to achieve the goal. First, a dynamic programming (DP)-based algorithm is developed to assign the partitioned application to clusters according to the aim of decreasing energy consumption. Then, inside each cluster, an algorithm which considers both the energy dissipation and the workload balancing is developed to distribute the task to sensor nodes. In addition, the algorithm provides parameters for end-users to adjust the importance of distinctive objectives. Finally, extensive simulations are conducted and the results demonstrate that the proposed algorithm is feasible and efficient.
Related work
As an event-driven system, a WSN is designed and deployed to accomplish specific applications. As a tiny and resource limited unit, a sensor node can hardly execute a complicated application independently, an effective method to resolve this problem is to divide the application into small parts and assign them to appropriate sensors. Thus, task allocation has attracted a great deal of interests and becomes a hot spot in WSN.
As mentioned above, the issue of task allocation in WSN is NP-hard which makes it infeasible to be solved optimally within limited time, and therefore, heuristic-based approaches are essential to handle this problem in polynomial time. Yu and Prasanna 18 studied the problem of allocating an epoch-based real-time application in a homogeneous WSN in which each sensor node was equipped with discrete dynamic voltage scaling (DVS). They first proposed an Integer Linear Programming (ILP) formulation which can obtain the optimal solution with intensive computation. Furthermore, they presented a three-phase heuristic which can be adopted to large-scale systems. One feature of this method is that the voltage levels of tasks can be adjusted with the goal to maximize the system lifetime. Abdelhak et al. 19 proposed an energy-balancing task scheduling and allocation heuristic with the aim of prolonging the network lifetime (EBSEL). This approach is divided into two phases. In phase 1, the tasks are grouped in order to reduce communication traffic, and in phase 2, the task group which requires the highest computational energy is distributed to the nodes with the highest remaining energy. In so doing, energy balancing is achieved and the lifetime is extended. Shen et al. 20 are concerned with a specific application—digital signal processing (DSP) application—in WSNs which is defined as the energy-driven partitioning (EDP) problem. They formulated the EDP problem as a synchronous dataflow (SDF) graph and developed an algorithm that can minimize the overall energy consumption by analyzing the pattern of internal data exchange rates in the application. Similarly, Yu et al. 21 also modeled the workload distribution problem in a WSN as an SDF graph partition problem. They proposed an optimal online task allocation algorithm to maximize the network lifetime by taking the energy cost of sensing, computing, communicating, and sleeping into account. They proved that for each sensor node, by using at most two of the important partition cuts with proper weights, it can obtain the optimal solution. Li et al. 22 investigated scheduling tasks with a predefined deadline. A three-phase task scheduling (TPTS) scheme is presented that takes into account an integrated goal including overall energy dissipation reduction, workload balance, and latency constraint. First, the whole deadline of all tasks is divided into subdeadlines and each task is endowed with a subdeadline. Then, an energy-load tunable graph partitioning algorithm is developed to decompose the task graph into several disjoint partitions and distribute them to distinct clusters. Finally, a contention-aware scheduling scheme is employed to allocate tasks to appropriate sensors. One common flaw of these approaches is that they only consider homogeneous WSNs and thus cannot be utilized to address our case.
Another category of popular approaches exploits bio-inspired meta-heuristic algorithms. Compared with the aforesaid traditional heuristic approaches, these methods adopt bionic swarm intelligence which allows them to obtain good-quality solutions with high efficiency. Jin et al. 23 investigated task mapping and scheduling in multihop wireless networks (MHWNs). They designed a hybrid function that takes both network lifetime and schedule length into account, then an adaptive intelligent scheme that is based on genetic algorithm (GA) is proposed to provide real-time guarantees. Compared with GA, the particle swarm optimization (PSO) algorithm has the advantage of simplicity of implementation and the capability to converge to a reasonably good solution quickly. As a consequence, it has been widely applied in task allocation in WSNs. Guo et al. 24 considered the case that when some sensors become out of work, how to transfer the remaining tasks on these nodes to other sensors. They proposed a self-adapted task scheduling strategy which is inspired by the multi-agent system theory; in this strategy, they developed an effective discrete PSO algorithm with a well-designed particle position code and a hybrid fitness function that takes into account the task execution time, the energy expenditure, and network balance. Furthermore, in Guo et al., 25 they proposed a real-time fault-tolerant task allocation algorithm (FTAOA). Likewise, to maximize the network lifetime, a discrete PSO algorithm is adopted. Various metrics, involving task execution time, energy dissipation, load balance, and the reliability cost of the network, are integrated into the fitness function. Compared with other similar work, the main difference of FTAOA is that it uses primary/backup technology to achieve fault tolerance in task allocation which makes WSNs sustain functionalities even when some nodes are failed or out of power. In addition, passive backup copies overlapping technology is employed to further improve the performance. One shared defect of these bio-inspired approaches is that they would easily get stuck in local optimum and the computational complexity may grow exponentially with the size of the problem which makes them not suitable for large-scale systems.
All the aforementioned works focus on improving the applicability and performance of task distribution in homogeneous WSNs where a WSN is dedicated for a single sensing task. However, due to the difficulty and high cost of deployment, for example, establishing a WSN in a hostile environment to collect information, WSNs are preferred to have the ability of performing various kinds of tasks. Many researchers begin to concern about this issue in recent years, one promising solution is the software-defined wireless sensor networks (SD-WSNs). 26 A typical SD-WSN is composed of a number of sensor nodes whose functionalities can be dynamically configured by running different programs. Specifically, such software-defined sensor nodes are able to conduct different sensing tasks according to the software that is activated. In comparison with conventional WSNs, SD-WSNs is more versatile, flexible, and easy to manage. Following the line, Zeng et al. 27 studied the minimum energy sensor activation problem with the consideration of guaranteed quality of sensing tasks in SD-WSNs. They formulated the problem as a mixed-integer with quadratic constraints programming model and linearized it into a mixed-ILP problem to further lower the computation complexity. Then an efficient online algorithm is proposed to deal with the problem. Although SD-WSNs are capable of performing multiple distinctive types of tasks, each individual node becomes more complicated and costly as it requires larger storage space and a control procedure that can coordinate different functions of the node.
Problem statement
The goal of distributing a complex application is to find out a scheme of allocating all the tasks in the application to appropriate sensor nodes while extending the network lifetime. The network lifetime has diverse definitions by taking into account the number of died nodes, sensing coverage, connectivity, and so on.
28
Although these definitions are concerned with distinctive metrics, they are all related to two elements: energy consumption and workload balancing. Therefore, in this article, the purpose of our scheme is to minimize energy dissipation as well as balance workload. To a regular sensor node
where
In addition, load balancing plays a key impact on the network lifetime. Since the load of a sensor node
where
According to the above descriptions, the problem of
where
Problem formulation
The network model
In general, a WSN is composed of a number of sensor nodes that are connected by wireless links. All the nodes are randomly dispersed in the target region to detect or monitor the occurrence of specific events. Accordingly, the network can be modeled by a connected undirected graph
The application and the node model
In fact, the problem of task allocation has been widely discussed in WSNs, most of existing works do not consider the characteristics of the allocated tasks. They all assume that only computation and communication resources are required to execute a task. Therefore, a task can be distributed to any sensor nodes, the difference between distinctive allocation solutions is the different energy cost. However, in many real-world scenarios, to complete an application, various types of resources may be required. Here, we name this kind of applications as complex applications. In particular, when allocating a complex application, we need to consider not only the computation and energy features at each sensor node but also the matching between the resource available at each node and the resources required by the application. In our work, a complex application is composed of several tasks, these tasks are independent and have no precedent constraints, that is, all the tasks can be assigned and executed simultaneously. To a task, it requires various types of resources. We assume that only when all of the required resources are fulfilled, the task is deemed to be successfully accomplished. Formally, a complex application can be denoted as a set of tasks

Application model.
Another notable feature to our framework is the characteristics of individual sensor nodes. Most previous works assume that the nodes in a WSN are similar with respect to functionalities; they all can perform computation and communication tasks. Thus, they concentrate on how to assign computation and communication load among sensors. On the other side, although the term “Heterogeneity” has been introduced in some existing literatures, they merely referred to that the nodes had distinct initial energy state and computation capacity. In practice, to distribute a complex application, the sensor nodes in a WSN are endowed with various types of resources that can be used for detecting and collecting information of the target. In this work, this kind of WSN is regarded as a heterogeneous WSN. In particular, in a heterogeneous WSN, each sensor node is equipped with a specific type of sensing device, such as ultrasonic sensor and photoelectric sensor. As a consequence, a sensor node
The proposed algorithm
Since the task allocation issue has been proven to be an NP-complete problem, in this article, we provide a heuristic algorithm to solve it in polynomial time. The algorithm can be briefly divided into two stages, namely, inter-cluster distribution and intra-cluster distribution. The first scheme is run on the sink node and its aim is to allocate the tasks in an application to cooperative clusters with minimum power cost. After this, in each cluster, the CH is responsible for distributing the task to proper sensor nodes under the condition that the task can be successfully executed while reducing energy consumption as well as balancing workload.
The inter-cluster application allocation algorithm
In our case, a WSN has a hierarchical structure and all the sensor nodes are grouped into multiple clusters. A complex application consists of various tasks each of which requires distinctive resources, and only when all of the tasks are executed successfully, the complex application is deemed to be finished. For a task, it can be assigned to any cluster that will provide the required resources; thus, the possible solutions of distributing the complex application to clusters are numerous. Among these solutions, the one with the minimum energy consumption is preferred. We name this problem as inter-cluster application allocation.
To a cluster, if it is assigned with a task
The first component of Algorithm 1 (lines 1–10) is initialization. In this part, the resources of a cluster are calculated, and they are equal to the sum of resources of all sensor nodes in the cluster. To a task
The intra-cluster task allocation algorithm
Through inter-cluster application allocation, all tasks in an application have been allocated to multiple clusters with the least energy expenditure. Then, the CH which is associated with a task is responsible for distributing the task to variable sensor nodes in the cluster. Thus, the CH plays an important role in the process of intra-cluster task allocation. However, in this article, we are concerned with task allocation and the selection of the CH is beyond our scope. On the other side, as there is no specific requirement for the CH, any previous method can be adopted to determine the CH in our approach. In our model, a task can be partitioned into several parts, each of which demands for a specific type of resource; the selected nodes should have one type of the required resource and therefore the task can be guaranteed to perform. Our global purpose of allocating a complex application is extending network lifetime; it can be achieved from two aspects: energy reduction and load balancing. In previously described stage, the main metric is the energy consumption of different allocation schemes; in this phase, both the energy cost and workload balancing are taken into account.
To reduce the power consumption of distributing a task inside a cluster, it is important to minimize the energy cost for communication between each pair of allocated nodes and the CH. This is due to the fact that in our case, each normal sensor node with the identical type of resource will consume equal energy when undertaking the same amount of computation, that is, from the viewpoint of computation energy consumption, there is no difference among the nodes that can provide the same type of resource. On the other side, the communication energy cost is highly related to the distance between a sensor node and the CH, the larger the distance, the more energy needed. Consequently, to minimize the total energy expenditure of allocating a task inside a cluster, the nodes that are closest to the CH are preferred. However, if these nodes are always chosen out to execute tasks, their power will be overused and they die quickly. In such a case, the system lifetime will be significantly shortened. Therefore, it is hard to find a coherent solution that can simultaneously optimize energy dissipation and workload balancing, although there may be an optimal solution for each one of the individual objectives. Even worse, as mentioned above, to prolong the network lifetime, these two objectives are a pair of contradictory metrics to a certain extent, and a solution that provides good performance for one target may worsen the performance for another one. Thus, some trade-offs between the two metrics must be made to achieve the global optimization. Here, we develop an effective method to handle the issue. The main idea is that to each sensor node which has the demanded type of resource, it is associated with a probability which indicates its possibility to be selected as a member for performing the task. Obviously, the probability is determined by two elements where one is energy related and the other is load related. To achieve a good load balance among sensor nodes, the workload assigned to a node should match the remaining energy of it. In general, the lower residual energy of a node, the smaller probability of it to be selected. By integrating these two factors, we can adopt the following equation to evaluate the probability of a node to contribute its resource
where
In Algorithm 2,
Computational complexity analysis
To the inter-cluster application allocation algorithm, its computational complexity is the same as that of policy iteration algorithm of DP, that is,
Experimental results
In this section, extensive experiments are conducted to objectively evaluate the performance of our two-phase complex application allocation algorithm in heterogeneous hierarchical WSNs, which is referred to as TP-CAA-HH. Since no similar works (dealing with the issue of complex application allocation algorithm in heterogeneous hierarchical WSNs) have been proposed so far, we develop an intuitive method as well as modify an existing method to solve the problem, namely, greedy-based distribution method and binary PSO-based method, and compare our approach with these two methods.
Greedy-based method (G-CAA-HH). To this approach, the complex application is first distributed to clusters randomly, that is, for all clusters that own the required resources of a specific task, they have the same probability to be selected out to perform the task. Afterward, a task is allocated to various sensor nodes within a cluster by a greedy heuristics; in more detail, the CH computes the energy dissipation of each sensor node that can match the demanded resources of the task, the ones with the minimum cost will cooperatively execute the task.
Binary particle swarm optimization–based method (BPSO-CAA-H). To compare with the state-of-the-art, we modify the BPSO-based task allocation method proposed in Yang et al. 31 The original approach is capable of allocating tasks in a homogeneous nonhierarchical WSN, we do a few modifications to make this scheme suitable for our situation. In particular, all the sensor nodes are partitioned into several groups according to their resource type, in each group, a sensor node is determined by using BPSO algorithm with the consideration of both the energy consumption and load balancing. Note that in this framework, the WSN has a flat structure and all nodes communicate directly with the sink node.
Experimental setup
In our simulation, the WSN is composed of 400 sensor nodes that are uniformly distributed in a circular area with a radius of 500 m, the sink node is located at the center. We assume there are six distinctive types of resources in the system. To a task, the number of the type of required resources is generated randomly; similarly, a sensor node is endowed with a random resource. To energy consumption model, several popular parameters are adopted32,33 as follows:
To comprehensively evaluate the performance of TP-CAA-HH, the following metrics are measured:
Energy consumption. It is the energy dissipation for executing the applications. In addition, the energy consumption for performing each task in an application is also recorded for comparison.
Stand deviation of residual energy. It is the stand deviation of residual energy of all nodes, as defined by equation (4). It indicates the load balancing of the system.
Number of unallocated task. It is the number of tasks that cannot be successfully allocated for the lacking of some specific resources. This is due to the fact that with the running of WSN, some nodes may deplete the power and their resources become unavailable.
Number of living nodes. It is the number of nodes that do not exhaust their energy. In the simulation, we regard this metric as a measurement of network life since in most existing literatures, network lifetime is defined as the proportion of alive nodes to all nodes in the WSN.
Effect of parameters
The first set of experiments is conducted to investigate the effect of parameter

Performance with parameters: (a) energy consumption and (b) standard deviation of residual energy.
Performance comparison
Effect of the number of applications
To further illustrate the efficiency of the proposed algorithm, we compare it with two benchmarks. Here, we focus on the effect of the number of complex applications which varies from 1 to 350, the parameter

Performance comparison with the number of applications: (a) energy consumption and (b) standard deviation of residual energy.
In our configuration, some applications may not be successfully allocated due to the lack of some specific types of resources, as the corresponding sensor nodes deplete their energy and die. Thus, we compare the performance of the three methods in terms of unallocated task number, the results are shown in Figure 5. From Figure 5(a), we observe that with the application distribution, G-CAA-HH is the first approach where the case of unallocated tasks occurs, followed by BPSO-CAA-H, while TP-CAA-HH is capable of allocating all the applications with no failure. This can be explained by the fact that to G-CAA-HH, it assigns tasks with greedy heuristics which will lead to the overuse of some nodes. If these nodes exhaust their power prematurely, the tasks that demand the corresponding resources can no longer be executed. In contrast, TP-CAA-HH considers both energy cost and workload balancing which significantly defer the death of the nodes; thus, all the tasks are allocated successfully. It should be noted that BPSO-CAA-H can select the desired sensor nodes from the whole WSN that makes it predominant on the possibility of task assignment. However, the presented approach is better which provides a further verification of the superior performance of TP-CAA-HH. Figure 5(b) shows the average energy dissipation of a task in an application, the result seems a little strange. To G-CAA-HH, it allocates task to nodes with the least energy cost and therefore should have better performance. Nevertheless, the simulation exhibits opposite result. We attribute this to the fact that in TP-CAA-HH, it distributes all tasks in an application to various clusters by Algorithm 1, which aims at minimizing energy consumption, whereas to G-CAA-HH, it allocates an application randomly which consumes more power. Consequently. the proposed inter-cluster allocation algorithm is certified to be efficient again.

Performance comparison with the number of applications: (a) number of unallocated tasks and (b) energy cost of each task.
The last experiment is conducted to investigate the performance with respect to the number of living nodes which provides an indirect illustration of the network lifetime. The result is shown in Figure 6. As expected, with the increase of application number, the amount of living nodes of BPSO-CAA-H descends drastically while only very few nodes die of TP-CAA-HH, G-CAA-HH achieves a medium performance. This can easily be explained by the fact that TP-CAA-HH adopts the technology of both reducing energy consumption and balancing workload which is significantly beneficial to prolong the lifetime of individual sensor nodes. In contrast, to BPSO-CAA-H, nodes transmit information directly to the sink node that expends the power of sensor nodes seriously. Therefore, a great deal of nodes die within a short period. To G-CAA-HH, although sensor nodes communicate with the CHs, it neglects load balance and the overused nodes deplete their energy quickly.

Number of living sensor nodes.
Effect of cluster size
In this set of experiments, we investigate the performance of various algorithms with changing the cluster size. The cluster size is the number of nodes in a cluster; here, it is varied from 16 to 30 with a step 2. In the simulations, the number of applications is 200; each application contains five tasks, and the radius of the area is set to 2000 m. From Figure 7(a), we observe that the energy dissipation of the WSN increases when the network size gets larger. The explanation is that, when the quantity of sensor nodes increases in a cluster, more tasks can be successfully allocated which will inevitably lead to more energy consumption. TP-CAA-HH and G-CAA-HH dissipate much less power than BPSO-CAA-H; this situation comes from two aspects. On one side, to a single task allocation, BPSO-CAA-H consumes much more energy than TP-CAA-HH and G-CAA-HH because it searches appropriate nodes in the whole WSN, while TP-CAA-HH and G-CAA-HH assign a task within a cluster. On the other side, when the sensing resources of a WSN are limited, that is, only few tasks can be completed, BPSO-CAA-H can allocate more tasks than the other two methods and the energy consumption will improve accordingly. Figure 7(b), CAA-HH, shows the best performance even compared with G-CAA-HH, which allocates tasks with a energy-greedy strategy within a cluster. In summary, if the number of tasks is large and the WSN is resource constrained, BPSO-CAA-H can be adopted to allocate tasks as much as possible, while if the network size is large, TP-CAA-HH is preferred to achieve good performance in task allocation as well as energy conservation.

Performance comparison with cluster size: (a) energy consumption and (b) energy cost of each task.
Figure 8 shows the performance of the three algorithms with regard to the number of unallocated task and the number of living nodes. As illustrated in Figure 8(a), the number of unallocated tasks decreases as there is an increase in cluster size. This is due to the fact that more sensor nodes in a cluster indicates a higher possibility for distributing a task; hence, less tasks will not be allocated. BPSO-CAA-H achieves the best performance because all the nodes in WSN can be used for executing tasks, whereas to TP-CAA-HH and G-CAA-HH, only the nodes in the cluster can be allocated with a task. However, it should be noted that with the increase in the cluster size, the gap between BPSO-CAA-H and TP-CAA-HH is narrowed down which implies that when the cluster size is large, TP-CAA-HH can allocate almost the same number of tasks as BPSO-CAA-H while costs much less energy. Figure 8(b) shows that when the cluster size becomes larger, the number of living nodes increases proportionally, yet TP-CAA-HH outperforms the other two methods. This can be ascribed to the fact that TP-CAA-HH makes a good tradeoff between energy consumption and load balance, which can prolong the lifetime of nodes significantly.

Performance comparison with cluster size: (a) number of unallocated tasks and (b) number of living nodes.
Conclusion
In this work, we discussed the issue of complex application distribution in a heterogeneous clustered WSN. Unlike most previous studies that assume all sensor nodes in WSN are homogeneous, in our system all nodes are associated with distinctive kinds of resources each of which can be utilized to perform a specific action. Accordingly, a complex application is composed of several tasks and each task demands various types of resources. Our objective is to distribute the complex application to appropriate sensor nodes with the purpose of prolonging the system lifetime while ensuring that the required resources of each tasks can be covered by the resources of the nodes. To achieve this goal, a two-phase-based application allocation algorithm is proposed. First, a DP-based scheme is employed to distribute all tasks in the complex application to multiple clusters which aims at minimizing the energy dissipation. Then, inside a cluster, the task is further assigned to sensor nodes by a feedback mechanism which prevents the overuse of individual nodes. In particular, a parameter µ is provided to allow end-users to tune the importance between energy conservation and workload balancing. Experimental results show that compared with approaches based on Greedy and BPSO, the proposed algorithm achieves superior performance in terms of energy consumption as well as load balancing.
In this article, an application can be allocated with no time constraints. However, in some scenarios, an application is required to be distributed and performed within limited time. In the future, we will extend our approach to take application deadline into account which can provide real-time guarantees. Meanwhile, in recent years, the technology of mobile sink has emerged as a promising method to further reduce energy consumption of WSNs;34,35 therefore, another interesting future direction is to address the problem in a WSN with mobile sink.
Footnotes
Handling Editor: Mohamed Elhoseny
Declaration of conflicting interests
The author(s) declared no potential conflicts of interest with respect to the research, authorship, and/or publication of this article.
Funding
The author(s) disclosed receipt of the following financial support for the research, authorship, and/or publication of this article: This work is supported in part by the National Natural Science Foundation of China under Grant No. 61472344, 61772454, 6171101570, the Natural Science Foundation of Jiangsu Province under Grant No. BK20150460.
