Energy-Aware Service Composition Algorithms for Service-Oriented Heterogeneous Wireless Sensor Networks

Wireless sensor networks are evolving with increasingly device heterogeneity, while the problem of effectively composing the platform-specific functionalities provided by heterogeneous sensor nodes to achieve specific goals still remains a challenge. Because of the constrained resources and unreliable communication in sensor networks, traditional service composition techniques in web services with adequate resources are insufficient. In this paper, focusing on the limited energy of sensor nodes, we propose an energy-aware service composition framework for developing various applications in heterogeneous wireless sensor networks. With both the energy-aware metrics: energy-aware load-balancing factor and overall energy consumption, we formulate the process of energy-aware sensor service composition into a combinatorial optimization problem; furthermore, an improved discrete particle swarm optimization (IDPSO) algorithm with inertia weights adjustment and extreme perturbation scheme is proposed to solve the combinatorial optimization problem. The experiment results have shown that the performance of the service route given by IDPSO is approximately equal to the best service route searched out by the exhaustive algorithm. Meanwhile, our proposed energy-aware service composition method is able to reduce the energy consumption and prolong the lifetime of the sensor network when providing stable service composition for various applications.


Introduction
In recent years, wireless sensor networks (WSNs) are evolving with new features such as larger scale, higher device heterogeneity and the capability of supporting multiple applications [1].For example, a WSN deployed for intelligent buildings contains a variety of different sensors, for example, video, audio, temperature, humidity, smoke, and light sensors, and it should be able to support video surveillance, accident location and tracking, environmental monitoring, and other applications.For example, as is shown in Figure 1, the target identification and tracking application is provided by combining acoustic sensing, target localization, target identification, and camera-based target tracking functionalities.In such environments, the device heterogeneity presents a great challenge for application programmers because it requires them to master the details of the underlying software and hardware platform [2,3].In order to develop diverse applications rapidly and efficiently, it is really necessary to provide programmers with adequate abstractions of the lowlevel platform-specific software and hardware details.
Existing service-oriented architecture (SOA) [4][5][6] has been considered as a promising means to provide higher level abstraction for the development of applications, and it helps enable applications to be platform-independent and adapt to network dynamics.Among the SOA technologies, service composition, that is, the process through which kinds of complex applications are developed by composing a set of primitive services with various restrictions (e.g., QoS [7], fault-tolerant [8]), has been well studied in the context of web services.
Service composition in wireless sensor networks is faced with more difficulties and has gradually gained attention.The existing service models and composition techniques for web services have limitations when directly applied to wireless sensor networks.The main reason is that the software-based web services are often supported with adequate resources.However, the service capabilities of the heterogeneous sensor nodes are affected by their intrinsic properties, such as the limited and dynamic computational ability, power supply, and residual memory and communication bandwidth.Meanwhile, too many service invocations in the same node will easily cause excessive computation and storage usage, energy consumption, and network traffic.More seriously, it will exhaust the battery of the involved service nodes and then create the energy holes that split the network into isolated islands.Therefore, it is critical to bind service requests to sensor nodes according to their available resources and current service load.
Considering that the network lifetime and energy spent at the node and system level are much important in WSNs, the objective of the work presented herein is to propose an energy-aware service composition framework for sensor services in the service-oriented heterogeneous wireless sensor networks.
With this service-oriented approach, nodes' sensing, data processing and transmission, and actuation capabilities are encapsulated as a collection of services.Conceptually, a service provided by a sensor node can be understood as a computational component that inherits the specific contexts of the related physical node.Meanwhile, a service can be provided by multiple different sensor nodes, although each service implementation may have different spatial, temporal, and QoS characteristics.
Then, based on resolving the application request into a workflow graph, we are able to develop new applications rapidly by combining a suitable set of available service nodes with service composition.Here, the process of choosing the appropriate set of service nodes is called service routing.Within the process of service routing, not only the service functionalities provided by the candidate node is concerned, but also its available energy is checked.We have exploited two different energy-aware metrics: energy-aware load-balancing factor and overall energy consumption.Based on both the metrics, we formulate the process of energy-aware sensor service routing into a combinatorial optimization problem.Considering that the traditional exhaustive algorithm suffers from the high computational complexity, we then propose an improved discrete particle swarm optimization algorithm to compute the optimal service route.In summary, we make the following contributions.
(1) In Section 3, we provide a framework to model the problem of energy-aware sensor service composition for developing sensor network applications.(2) In order to optimize for the energy balance and total energy minimization goals, we formulate the energy-aware sensor service composition process as a combinatorial optimization problem.(3) To deal with the high computational complexity of exhaustive algorithm, we propose an improved discrete particle swarm optimization algorithm to find out the approximately optimal service route effectively.
With our proposed methods, the workload of the service nodes is well balanced and the total energy cost is minimized as much as possible.Therefore, our proposal is able to reduce the energy consumption and prolong the lifetime of the sensor network when providing stable service composition for various applications.

Related Works
In recent years, service composition for pervasive computing such as distributed real-time system, MANETs, CPSs, and WSNs has been received more and more attention.In this section, we will discuss the related works on modeling and composition of services in these systems.

Related Works of Service Composition for Pervasive Computing.
Excepting for web services, service composition for pervasive computing has also been the subject of intense study over the past several years.Brønsted et al. [9] discussed that service composition mechanisms for pervasive computing should address the following four goals including context awareness, managing contingencies, leveraging heterogeneous devices, and empowering users.Their analysis suggests that there are indeed opportunities and reasons to focus on service composition for pervasive computing.
The work of Kalasapur et al. [10] presented a dynamic service composition mechanism in pervasive computing.They modeled and represented resources as services, maintained a repository of service graphs, and dynamically combined multiple basic services into complex services.However, the scheme of context-aware (e.g., residual energy and location) service selection for dependable service composition was not deeply studied in this paper.
The work of Estévez-Ayres et al. [11] presented a model for QoS-aware service composition in distributed systems with real-time and fault-tolerance requirements.However, they selected out the appropriate service nodes mainly based on their QoS properties, but it is not enough for dependable service provision in WSNs.The work developed by Wang [12] studied a dependable service composition problem in MANET.They proposed to achieve dependable service composition by taking the mobility prediction of the service providers into consideration.The work of Jiang et al. [13] proposed a new service composition and recovery framework designed to achieve minimum service disruptions for mobile ad hoc networks.However, the common WSNs do not have the mobility characteristics; moreover, energy issues should be more important for service composition because of the fewer available resources in sensor nodes.
In [14], the authors proposed OSGi-based service architecture for Cyber-Physical Home Control Systems, which supports service-oriented control methods.Users can control appliances in the physical environment by intuitive operation through a virtual home on the network.In [15], Huang et al. developed an ontology model for physical entity specification.Based on this model, OWL-S is extended to accurately model the characteristics of service providers in the context of cyber-physical worlds.These proposed SOAs in CPS are helpful for our studies in WSNs; however, the WS standards such as OWL and XML exploited in CPS are too much complex for the low-capacity sensor nodes.

Related Works of Service Composition for WSNs.
In recent years, some researchers have begun to focus on service composition for service-oriented wireless sensor networks.In order to handle the device heterogeneity, some kinds of service-oriented architectures and middleware have been proposed for a flexible service provision.In [5], the authors presented a service-centric WSN model, which focused on services provided by a WSN and viewed a WSN as a service provider.In [6], the authors presented a service-oriented, flexible, and adaptable middleware for QoS configuration and management of wireless sensor networks.Both proposed service-oriented models are meaningful for our studies; however, no details on automated service composition are studied in them.
Amundson et al. [16] have developed OASiS, which is an object-centric, service-oriented programming model and middleware for ambient-aware sensor network applications; however, it did not include automated composition with cost measures.In [17], the authors introduced the WSN-SOA suite which enables SOA-based communications in networks of low-capacity sensors.Service-oriented middleware TinySOA [18] allows programmers to access wireless sensor networks from their applications by using a simple service-oriented API via the language of their choice.However, both the studies did not address automatic composition construction.In [19], the authors presented a Distributed Operating System (DOS) based on the service-oriented architecture (SOA) to manage all embedded devices in a home network at high level of interoperability.Another service provision middleware, Servilla [20], enables applications to be both platform independent and energy efficient by facilitating in-network collaboration among heterogeneous devices.With Servilla, the available energy in the candidate nodes has been taken into account in the service binding process; however, the common service composition model and service selection algorithm had not been presented.
Few approaches have been proposed for modeling service composition problem and the related resolution algorithms.In [21], the authors provided service composition solutions during a persistent query's lifetime such that the involved routing update cost and transmission cost are minimized.Another approach [22] proposed a probabilistic context-free grammar (PCFG) based modeling technique to construct service compositions.In [23], the authors proposed a policyaware sensor service composition framework, which can automate the process of combining simple sensor services into larger ones with pre-specified policies.To the best of our knowledge, energy-aware automatic service composition in our study is novel in the sensor network domain.

Network and Application Model
3.1.1.Service Model Description in Sensor Networks.Currently, there are many modeling languages, protocols, and frameworks in web services, for example, OWL-S [24], WSDL [25], BPEL [26], and SOAP [27].However, these technologies are heavyweight for the limited resources of sensor nodes.Meanwhile, they view services as explicit entities and the resources that provide services as implicit entities.
In contrast with traditional resource-implicit web service description model, our proposed model is resource explicit, and the state of node services is affected by the dynamic properties of the sensor nodes.In addition, each heterogeneous node   has its own contexts, such as its location, residual battery, available storage, and computation ability and bandwidth.Note that these contexts will affect the service capability of the node, and we only concentrate on the residual battery in this paper.Then, a sensor service   in sensor networks can be described as follows: The service   is defined by the name, input data that it accepts, the operation function that it applies to its input, the output data that it produces, and the residual energy of the sensor node.The service functionality of   is defined by Input  , Output  , and Op  .Then, a service class   = { 1 ,  2 , . . .,   } is defined as a set of sensor services that provide the same functionality but differ in the energy attribute.
3.1.2.Network Model Description.Assume that  heterogeneous nodes  = { 1 ,  2 , . . .,   } are deployed in a specific area, and the topology of the whole sensor network can be described as  = {, }; here,  ⊆  ×  represents the connection set.The set of service classes provided by the whole sensor network is denoted by  = { 1 ,  2 , . . .,   }, and the syntactic parameters of a service class define service name, input, output, the operation function, and some additional information of service functionality.Assume that the set of service classes provided by a node   is denoted by   ⊆ .Therefore, we can use a  ×  matrix  to describe the service capability of each node, and   = 1 denotes that the node   is able to provide the service class   ∈ .Then, the service classes provided by   can be denoted by   = [, :] *   , and [, :] is the corresponding row vector of   .Meanwhile, for a service class   , the set of available service nodes can be denoted by   =  * [:, ], and [:, ] is the corresponding column vector of   .Then, a heterogeneous sensor network can be described as  = {, , }.

Application Model Description.
In a SOA environment, an assigned application   can be decomposed into a workflow graph, which contains a set of services with the control and data flow among them.Note that the service in the workflow graph refers to a service class rather than a specified service instance.Then we are able to describe the application as a workflow graph   = {  ,   }; here,   = { 1  , . . .,    } ⊆  represents the set of the requested service classes and the dependency relation   ⊆   ×   describes the dependencies between them.Make sure that the requested service classes should be covered by the whole sensor network.

Description of Service Composition
Problem.The service composition process can be achieved with a centralized or distributed method.In this paper, for simplicity, we use a centralized fashion.A sink node or a gateway can act as a central decision node receiving information from all service nodes and dispatch the service requests to the selected sensor nodes.The centralized fashion should be only suitable for service composition in small-scale sensor networks because of the dramatically increasing communication cost along with the scale of the wireless sensor network.
As is shown in Figure 2, we can implement a service composition for a given application   = {  ,   } by mapping the requested service classes in its workflow graph into the sensor nodes.An application can be constructed as a set of autonomous services that perform independent operations on the data stream passing through them.A service link between two service nodes is defined by   and it is an overlay link that may consist of several wireless links in the network.The communication path for a service link is built with the shortest path first routing method.Note that the arrow represents the direction of data flow,and   is the invocation times of each combined service, and   represents the amount of data transferred between both the services.Note that if the service capability of a node   can satisfy the requirements of a requested service class    , it will meet the following conditions: This formula denotes that certain service class provided by   should meet the functionality requirements specified by    .Now based on the wireless heterogeneous sensor network  = {, , } and the received application request   with the workflow graph   = {  ,   }, the key step of service composition for the application   is to select the appropriate service nodes to serve the service classes specified by the graph   , and the entire selection process is called service routing.The goal of our study is to find out an approximately optimal service route Gopt  such that (1) the total energy consumption should be minimized as much as possible and (2) the workload of the service nodes should be well balanced to avoid excessive energy consumption of certain service nodes.We then summarize the symbols used in our model in Table 1.service route, in order to evaluate its energy-aware performance, firstly we compute the overall communication and computation cost, as well as both the cost of each involved service node.

Calculate the Overall Communication and Computation
Cost of a Candidate Service Route.The overall communication cost contains not only the communication cost of each involved service node, but also the communication cost of the forwarding nodes within the communication paths for the service links.Note that the communication cost in this paper refers to the energy used to transmit and receive the data specified by the requested application.For two requested adjacent service classes    ,    which are connected by a service link in the workflow graph, two nodes   ,   ∈ G  are assumed to provide these two service classes, respectively.For simplicity, we exploit the shortest path network routing scheme when transferring data between two service nodes and then the communication cost from the service node    (  ) to    (  ) can be calculated as follows: for each   ∈    . ( Here,    denotes the shortest path between the service nodes   and   , and the residual energy of each node in the path should be greater than the necessary communication cost.  represents the energy spent by transmitting one unit of data, and   represents the energy spent by receiving one unit of data.The communication cost is proportional to the number of hops between both the involved service nodes.Meanwhile, there is no communication energy consumption when both the requested services are implemented in the same node.

The overall communication cost of the candidate service route G𝑡
is given by The overall computation cost of the candidate service route G  is given by Based on formula (5), we can conclude that the overall computation cost has no relation with the specific service routes.

Calculate the Communication and Computation Cost of
Each Involved Service Node.For each service node involved in a candidate service route G  , we first calculate its communication and computation cost.Note that a specific node may have the capabilities to serve multiple requested services, so we denote the set of requested services assigned to node   ∈ G  as follows: Here, G  (   ) =   represents that    is provided by   in the candidate service route G  .Then the computation cost for the service node is given by International Journal of Distributed Sensor Networks Then we compute the communication cost of the service node and before this, we assume that the amount of input and output data of a requested service    is given by input (   ) = ∑ Assume that there are no adjacent relationships among the services provided by node   ; then, the communication cost of   can be calculated by However, in some practical applications, a node may provide multiple services which are adjacent.For example, a specific node may provide perception and data fusion services at the same time, and these two services are usually adjacent since the perception data is directly sent to the data fusion service.Here, the data exchange between these two services is implemented within a node and there is no communication cost.Therefore, formula (10)

Service Routing with Two
Energy-Aware Metrics.As we mentioned above, the optimal service route should balance the workload on the service overlay network.Assume that   is the service node for    , without exhausting its energy; the residual energy in   should be more than the energy required for the service    .Meanwhile, if too many requested services are concentrated on a specific node, it will tend to consume the node's energy excessively and increase the response time of applications.To avoid these from happening, the service routing process should choose the appropriate service nodes by considering their residual energy and current service loads.
In this paper, we implement the service composition with two proposed energy-aware metrics.The first metric is energy-aware load-balancing factor, which we consider to be achieved when the maximal fraction of energy spent by any service node is minimized.With this goal, we define LBF( G  ) as the energy-aware load-balancing factor of the candidate service route G  , as follows: where LBF(  ) is the energy-aware load-balancing factor of node   .(  ) denotes the residual energy of the node   .
The second energy-aware metric is the total energy consumption for implementing the application.Although we believe that energy balance is a better metric to measure the service routes, it is also necessary to use the goal of minimize the total energy consumption to enhance our energy-aware service composition method.The total energy spent for a candidate service route is given by Our service routing algorithm then selects the smallest value of a weighted sum of total energy consumption ( G  ) and energy-aware load-balancing factor LBF( G  ) of the candidate G  .Note that the values of both the metrics are normalized in advance.Hence, the goal of service routing can be expressed as follows:

Exhaustive Algorithms for Service Routing
To formulate the problem, the candidate service route G  is denoted by a 1 −  dimensional matrix and G  [] denotes the selected service node providing the requested service    .Then, the process of searching out the optimal service route can be formulated into a combinatorial optimization problem, which is expressed as follows.
Evaluation Factor: Constraint: As is shown in Algorithm 1, according to the evaluation factor and constraint, we then propose an exhaustive algorithm to explore the optimal service route for a given application graph.A service route is constructed by selecting an available service node for each requested service class of the application graph.The exhaustive algorithm traverses all combinations with a depth first search algorithm (line (20)-( 23) of Algorithm 1).Each valid service route found by the algorithm is scored by calculating its evaluation factor (line (9)-( 11) of Algorithm 1).During the execution, the algorithm stores each valid service route and its value of evaluation factor and replaces them every time it finds a service route with a smaller value.
Algorithm 2 shows the whole process of calculating the evaluation factor.It mainly includes two steps: first, it calculates the expected communication and computation energy cost of every involved service node (line (5)-( 27) of Algorithm 2) and it should make sure that the candidate service route is valid by checking if the available energy of every involved service node is enough for providing the requested services (line (29)-(31) of Algorithm 2).Meanwhile, for the valid service node, the algorithm stores its value of loadbalancing factor and replaces it every time a service node with larger value of load-balancing factor is found (line (34)-(39) of Algorithm 2).Second, it calculates its evaluation factor by a weighted sum of its load-balancing factor and overall energy cost (line (43)-(46) of Algorithm 2).
Algorithm 3 shows the process of calculating the overall energy cost of each candidate service route, and it is called by Algorithm 2 (line (41) of Algorithm 2).This algorithm mainly contains two steps of calculating computation energy cost and communication energy cost of the whole service route.The latter is more complex, and it needs to obtain the hops of the shortest path between both the service nodes (line (10)-( 13) of Algorithm 3), which depends on the specific topology of the sensor network.

Computational Complexity.
The proposed exhaustive algorithm suffers from the relatively high computational complexity, because it evaluates all the candidate service routes.Given the  ×  matrix  described in Section 3, the number of associated service instances for each service   can be calculated as (  ) = sum((:, )), and the number of requested services of the application   is .The algorithm has to evaluate (  ) = ∏  =1 (  ) paths, and the computational complexity increases exponentially with the number of service nodes.

Improved Discrete Particle Swarm Optimization for Service Routing
Considering the high computational complexity of the exhaustive algorithm, we propose to adopt the evolutionary computing techniques which are more suitable to solve the combinatorial optimization problem.PSO [28] is an adaptive evolutionary computing technique proposed by Kennedy and Eberhart in 1995, which maintains and exploits both the position and velocity information in the evolution process, while other evolutionary algorithms only use the position information.In other words, PSO performs a kind of conscious mutation, which improves the convergence speed greatly.Meanwhile, existing studies show [29] that PSO has the merits of high speed, high quality solution, and good robustness in terms of multimodal optimization in multidimensional space and dynamic optimization.PSO has been widely applied in the complex optimization areas including multiobjective optimization, and pattern recognition.Therefore, we propose to use the PSO algorithm to solve the combinatorial optimization problem in this paper.

Basic Particle Swarm Optimization.
PSO is a populationbased optimization tool and inspired by the social behavior of natural individuals.It searches the optimal solution for a difficult optimization problem through the collaboration between the individuals.Assume that the size of swarm is , the coordinate position of each particle   ( = 1 ∼ ) at time  is denoted by   () = ( 1 (),  2 (), . . .,   ()), and the particle velocity is defined as the moving distance at each search iteration, which is represented by V  () = (V 1 (), V 2 (), . . ., V  ()).At each search iteration, the current position and velocity of each particle are updated by two best values: (1) , individual best position that has achieved so far, and (2) , another best value representing the global best position among all particles in the swarm.Then the particle   updates its th dimensional velocity and position according to the following formula: Here,  is the inertia weight factor which represents the impact of previous values of particle velocities on its current ones.A larger inertia weight factor is suitable for global exploration and a smaller inertia factor is suitable for fine tuning in the current search area.Parameters  1 and  2 are positive constants called acceleration coefficients; in general,  1 =  2 = 2. Parameters  1 and  2 are two random variables with range [0, 1].

Improved Discrete Particle Swarm Optimization for
Energy-Aware Service Composition.In this section, we present a formalized description for energy-aware service composition with an improved discrete particle swarm optimization (IDPSO) algorithm.end if (28) end if (29) end foreach (30) end if (31) return(success, Gopt  ,  opt ) (32) } Algorithm 1: Exhaustive composition algorithm.

Particle Representation.
As we defined in Section 3, a requested application   can be decomposed into a workflow graph containing a set of requested service classes   = { 1  , . . .,    } ⊆ .The candidate service route G  [] contains the set of involved service nodes.Each candidate service route can be viewed as a certain position of a particle   in the -dimensional space.Therefore, the particle position will change if any service node in the candidate service route is substituted.Then, the th particle can be represented as   = ( 1 ,  2 , . . .,   , . . .,   ), where   indicates the index of the allocated service node for the th requested service    in the application graph.The set of service node for    is   = { 1 , . . .,   , . . .,    },   represents a node   with the capability of providing the requested service class    , and   is the number of candidate service nodes.Each dimension of the particle has a discrete set of possible limit values {  : 1 ≤   ≤   }.

Fitness Function.
The fitness function (  ) measures to what extent the particle   satisfies the objective and constraints (which are defined by formula ( 14) and ( 15)) of the energy-aware service composition problem.According to the fitness function, the swarm evolution is navigated towards the optimal solution by the best particles.The fitness function (  ) at the th iteration is defined as follows: Constraint: Here,   () contains a set of service nodes providing services for the requested application and   () represents a service node.The objective function (  ()) measures the merit of the solution   () under the assumption that every service node in   () satisfies the constraint.However, if any service node in   () violates the constraint, the solution is infeasible.Meanwhile, the value of (  ) is invalid and set to infinity.output variable is the change in the inertia weight.The normalized CBPE (NCBPE) is used as an input variable between 0 and 1 and is defined as

Improved Discrete Particle Swarm Optimization
Here, the optimization problem to be solved is a minimization problem, and the estimated minimum is denoted by CBPE min , and the calculated value of from ( 14) at the first iteration may be used as CBPE max for the next iterations.Typical inertia weight value is between 0.2 and 1.1, and a range of −0.12 to +0.12 is chosen for the inertia weight correction (Δ).The specific fuzzy logic approach has been introduced in [30].
Then, we are able to update the value of  with the formula as follows: Here,  is the iteration times of the algorithm.The convergence performance of PSO algorithm can be improved based on this adjustment strategy of the inertia weight , because PSO algorithm can obtain better global exploration ability with a high  in prophase of the evolution process and accelerate the convergence speed with a low  in anaphase.However, for many complex combinatorial optimization problems, it is not enough to get rid of local optima and improve the exploration accuracy of PSO algorithm only by adjusting the inertia weight.Therefore, in addition to the adjustment of inertia weight, a swarm reoptimization method with extreme perturbation scheme is proposed.

Swarm Reoptimization with Extreme Perturbation Scheme.
When PSO algorithm falls into evolutionary stagnation, the phenomenon of particle accumulation happens, and the particles will scatter until the stagnation is broken.This phenomenon is theoretically explained well in [31].The definition of particle convergence is shown in formula (21), and () represents a particle's position at the th iteration.This definition describes that the particles will converge to a stable position  * finally, which is determined by the weighted sum of individual best position  and the global best position .If a position better than  is not found when all the particles are converging to the position  * , then the evolution will fall into stagnation and the particles gradually gather to  * , lim An extreme perturbation scheme is employed to break the stagnant state.The basic idea of this scheme is that we will randomly adjust the individual/global best position when the evolution of both the best positions is stagnant for several iterations.And the extreme perturbation operator is defined as follows: Here,  0 ,   represent the steps of evolutionary stagnation for individual and global best positions respectively, and  0 ,   represent the corresponding thresholds of triggering the extreme perturbation.And the random variables  3 and  4 are defined as follows: Then, based on formula (16), the improved PSO algorithm with dynamic adjustment of inertia weight and extreme perturbation is given as follows: Here, the values of  0 and   determine the activation delay of extreme perturbation, generally in the range of [3,8].

IDPSO Algorithm For Energy-Aware Service Routing.
With the iteration formula, we have presented the detailed optimization process with IDPSO algorithm for energyaware service routing, which is described as shown in Algorithm 4.
Computational Complexity.In the energy-aware service composition process with IDPSO algorithm, the size of swarm is , the number of requested service classes in the workflow graph is , and the number of iterations is .The computational complexity of the main steps in Algorithm 4 is given as follows: step 2.1: ( × ); step 2.4: (); step 2.5: ().Then the total computational complexity of IDPSO is expressed as ( ×  × ), which has no relation with the number of available service nodes for each requested service class.

Performance Evaluation
6.1.Simulation Environment.For evaluating the performance of our proposed energy-aware service composition algorithms, we apply them to the target identification and tracking application discussed in Section 1.The workflow graph of this application is shown in Figure 1.We build a sensor network in which there are  ( = 60 in this simulation) heterogeneous nodes spreading across a specific area with the size 0.5 km * 0.5 km, and each node can be attached to an acoustic sensor, a temperature sensor, or a video sensor that can identify and track the target within its surveillance area.The underlying physical topology is generated by GT-ITM using -node transit-stub models [32].For simplicity, we assume that this network provides five service classes, including acoustic sensing, temperature sensing, target localization, identification, and tracking services.Each service class may have multiple service instances, which are randomly distributed over the network.The number of service instances is set to 0.6 * , 0.6 * , 0.4 * , 0.2 * , 0.2 *  in turn, and the value will be rounded if it is not an integer.
Furthermore, the fire rate   of each service in the workflow graph is set as follows: for acoustic sensing service,   is set to 5; for localization service, it would be awaken only after it has received all the acoustic sensing data.Consider that the sensing data arrives asynchronously because of the different network transmission path and channel conditions.Therefore, the fire rate   of localization service is 13.Then, the target's location information will be sent to the following services.So the fire rate   of the following services in the workflow graph is set to 13 too.The amount of data   transferred between the services is assumed to be of unit size (  = 1).
A battery model simulates typical distributed embedded computing hardware, with a CPU and a radio module.For the parameters of our proposed IDPSO algorithm, the size of the swarm  is set to 15, the total number of iterations  is set to 150, and  1 =  2 = 2; (1) = 0.8;  0 = 3;   = 5.The weighting factors ,  in formula ( 14) are set to 0.5 if not specified differently.

Performance Evaluation for Our Proposed Algorithm.
Firstly, we evaluate the capability of searching the optimal service route for our proposed methods.As shown in Figure 3, the IDPSO algorithm was evaluated by comparing it with the basic PSO algorithm and exhaustive composition algorithm.In this experiment, given the same initialization parameters, the requested application is executed continuously with 80 times for each algorithm.For each time, the optimal service route is refreshed by running each algorithm, respectively, and the fitness of the optimal solution of each algorithm is recorded.It is shown that the exhaustive composition algorithm has gained the best performance with the lowest fitness, because it traverses all combinations of service nodes to find out the best one.The value of fitness increases stably because of the gradually increasing value of load-balancing factor.The basic PSO algorithm has the worst performance with the highest fitness, and the value of fitness fluctuates severely because the basic PSO algorithm easily falls into premature convergence and encounters local optimization.Our proposed IDPSO algorithm has gained better performance than the basic PSO algorithm.And it is able to search out a service route approximated with the best one, because the capability of global exploration of the IDPSO algorithm is enhanced with the extreme perturbation scheme.
Secondly, we measure the performance of our proposed methods on extending network lifetime, which is shown in Figure 4. Here, we also assume that all nodes started with an initial energy level and the requested application is executed continuously with 80 times for each algorithm.For the basic PSO algorithm, in Figure 4(a), we can notice that the variance of the residual energy of all the network nodes is the highest and increases most quickly; in Figure 4(b), the minimum residual energy is the lowest after the application is executed with 80 times.Therefore, some network nodes will run out of battery quickly with the basic PSO algorithm, and the network lifetime will be shortened because of the rapid emergence of energy hole.For our proposed IDPSO algorithm, it has gained better performance than the basic PSO algorithm on prolonging the network lifetime (lower variance of the residual energy and higher minimum residual energy), since it has searched out those service routes with better performance on load balancing.We can also notice that the performance of IDPSO approximates to the exhaustive composition algorithm.
With the proposed IDPSO algorithm, the performance of service composition is evaluated with using different energy-aware metrics, which is shown in Figure 5.Given the requested application above, we demonstrate the network   energy distribution after executing the service composition for 80 times under three circumstances: (a) only use the metric "overall energy consumption" with  = 1,  = 0 in formula ( 14); (b) use both the metrics with  = 0.5,  = 0.5; and (c) only use the metric "energy-aware load balancing factor" with  = 0,  = 1.From Figure 5(a), it is noticed that the energy of the sensor nodes in the central area with oxford blue has been consumed excessively.This is because that the sensor nodes in the central area are exploited repeatedly in the service composition process when only using the overall energy consumption metric.In Figure 5(c), we can notice that the energy of many sensor nodes in a larger area has been exhausted; in other words, the sensor network is fallen into "malignant load-balancing." When only the energy-aware load-balancing factor is concerned, the network routing paths will be too much long for many service routes.Further, the energy of many sensor nodes is exhausted just by forwarding data between the service nodes.
In Figure 5(b), a better performance on network energy distribution has been gained when using both the metrics, and only few sensor nodes have nearly run out of battery.Therefore, in order to improve the performance of service composition, it is very important to achieve the balance between both the energy-aware metrics.Further, to verify the experiment results in Figure 5, with different energy-aware metrics, we have monitored the number of total network transmission hops for the optimal service route of each execution of the requested application, which is shown in Figure 6.By the way, the number of total network transmission hops is obtained by accumulating the number of the network transmission hops between two adjacent service nodes in the service route; meanwhile, both the services nodes should have a service link specified by the workflow graph of the requested application.We notice that the number of total network transmission hops is 5 and remains almost unchanged while only using the overall energy consumption metric, and this is because the optimal service route is not refreshed until some involved sensor   nodes run out of power.When only using the energyaware load-balancing factor, the number of total network transmission hops for the optimal service route changes in a wide range mainly from 10 to 21; therefore, a greater number of sensor nodes in a larger area consume their battery quickly because of forwarding data frequently.By using both the metrics with  = 0.5 and  = 0.5, the number of total network transmission hops decreases significantly and changes between 5 and 9 and this is because the number of network transmission hops is limited by the optimization objective of minimizing the overall energy consumption.
International Journal of Distributed Sensor Networks   To analyze the global optimization capability of the IDPSO algorithm in depth, we then evaluate its performance on convergence of fitness function by comparing with the basic PSO algorithm.The convergence performance of both the algorithms for the 1st and 80th execution of the requested application is shown in Figure 7.In both the comparison experiments, the basic PSO algorithm has converged on local optimum quickly and fallen into evolutionary stagnation after a short iterative process, and the particles have to gather into the local optimum.For our proposed IDPSO, it has better global exploration ability because of the extreme perturbation scheme.Especially in Figure 7(b), IDPSO is able to search out better solutions at the 96th, 106th, and 139th iterations through a long-time global exploration.By adjusting the individual and global best position when the particle has fallen into evolutionary stagnation, the IDPSO algorithm can increase the particles' searching field and then improve the probability of finding out better solutions.
For the running time of IDPSO, as we have analyzed in the last paragraph in Section 5, the computation complexity of IDPSO has no relationship with the number of sensor nodes.As shown in Figure 8, with the increase in the number of atomic services, the running time for finding out an optimal service route with IDPSO maintained steady.For the exhaustive algorithm, the running time increases dramatically because it traverses all the combinations to find out the optimal one.
We then evaluate the convergence and optimization performance of IDPSO with different swarm size , which is shown in Figure 9.For each swarm size , the IDPSO algorithm is run for 20 times independently, and then we obtain the convergence curve with the average values.The best fitness value of the optimal service route obtained by IDPSO descends with the increase of swarm size.This is because a larger swarm size can enlarge the overall searching field and improve the probability of finding out better service routes.Meanwhile, when the swarm size exceeds a certain value, for example,  = 20 and  = 25, both the best fitness values are almost the same and there is no significant improvement in performance of IDPSO.Therefore, an excessively large swarm size has little impact on improving the performance of IDPSO.However, it will bring higher computational complexity and delay.

Conclusion
In this paper, we have presented an energy-aware service composition method for service-oriented heterogeneous wireless sensor network, and this framework takes into account both the energy-aware metrics including overall energy consumption and energy-aware load-balancing factor.Based on this framework, we propose the IDPSO algorithm, which is able to break the evolutionary stagnation and improve the global exploration capability of the PSO algorithm with the extreme perturbation scheme.Our experiment results have shown that the IDPSO algorithm is capable of searching out better service routes with smaller fitness than the basic PSO algorithm.Meanwhile, the energy-aware performance of the service routes obtained by IDPSO is close to those optimal service routes computed by the exhaustive composition algorithm.Based on the service routes with balancing between both the energy-aware metrics, the lifetime of the sensor network can be prolonged to provide stable service composition for various applications.

Figure 1 :
Figure 1: Collaboration among heterogeneous nodes for an application.

Figure 2 :
Figure 2: Service composition for a given application in wireless sensor networks.

Figure 3 :
Figure 3: The curve of fitness of the optimal solution along with the execution times of the requested application.
Execution times of the requested application

Figure 4 :
Figure 4: The residual energy changes along with the execution times of the requested application: (a) the curve of the variance of the residual energy; (b) the curve of the minimum residual energy.
Iteration times (for the 1st execution) Iteration times (for the 80th execution)

Figure 7 :
Figure 7: Comparison between IDPSO and Basic PSO algorithm on convergence of fitness function: (a) for the 1st execution of the requested application; (b) for the 80th execution of the requested application.

Figure 8 :
Figure 8: The running time versus the number of sensor nodes.

Figure 9 :
Figure 9: Convergence and optimization performance of IDPSO with different swarm size.

Table 1 :
Symbols used in our system model.  = {  ,   } Workflow graph of     = { 1  ,  2  , . . .,    } The set of service classes required by   and  is the number of required service classes   ⊆   ×   Edges in workflow graph   Amount of data transferred from    to    each time    is invocated NG = {, , },  = { 1 ,  2 , . . .,   }  ⊆  ×  Topology and service capability description of the heterogeneous sensor network  = { 1 ,  2 , . . .,   } The set of service classes provided by the whole network ER(  ) Residual energy of node rx Energy spent by receiving one unit of data  inv (   ) Energy spent per invocation to the service    ∈   in a physical node   Invocation times of each required service    ∈ : invocation times of each required service    ∈   ; (vi)  inv (   ): energy spent per invocation to the service    ; (vii)   ,   : energy spent by transmitting/receiving one unit of data.