A QoS-driven Service Selection Optimization Algorithm for Internet of Things

Currently, the smart devices have been widely deployed in Internet of Things (IoT). With the scale of IoT continues to increase, it brings big challenges for service composition in a large-scale IoT. For solving this problem, a QoS-driven service selection method based on the enhanced Genetic algorithm (EGS~QoS) is proposed in this paper. To decrease the scale of service composition, we use the lexicographic optimization approach and QoS constraint relaxation technique to find the candidate service with height QoS. Then, the IoT service composition problem is transformed into a single-objective optimization problem adopting a simple weighting method, and the final composite service meeting the user's QoS needs is found from the candidate service. Compared with the related algorithm, the simulation results show that EGS~QoS can efficiently and quickly select a composite service satisfying user's QoS needs, and is more suitable for solving the service composite problem in large-scale IoT services.


Introduction
Internet of Things (IoT) is an emerging technology, which is widely used in many fields such as smart homes, intelligent logistics, and so on. It also changes people's lifestyles and promotes a series of industrial revolutions. The essence of IoT is allowing smart components, such as smartphones, with certain computing and storage capabilities, to interconnect. Meanwhile, these smart devices can communicate, interact, and cooperate with other components to generate new smart services [1][2]. Moreover, with the continuous popularization of IoT technology, the number of smart devices deployed on IoT is increasing exponentially every year [3]. In IoT, each smart device provides its own functional services, which are called and provided to users through standard Web services. Therefore, service-oriented computing (SoC) and serviceoriented architecture (SoA) are regarded as the key to the development of IoT technology.
At present, due to the continuous improvement of user needs, a single service, which provided by smart devices, cannot meet the user's needs in IoT. IoT services composition based on SoC and SoA has successfully solved this problem. Compared with traditional service composition, the characteristic of today's IoT service composition is that all IoT services run directly in smart devices with limited power, storage capacity, and computing resources [4]. Therefore, the non-functional attributes, also call QoS, of IoT composite services are crucial factors, which will directly affect the user experience. However, as the scale of the Internet of Things continues to increase, there are many services with the same function and different QoS. How to quickly integrate these services into comprehensive composite services and applications satisfying user QoS requirements has become a major challenge.
In this article, to solve the service composition problem concerning QoS needs in the large-scale IoT, we propose a QoS-driven service selection method based on the enhanced genetic algorithm (EGS~QoS).
This algorithm mainly consists of two parts: First, for reducing the scale of service composition, the QoS~driven service selection problem is modeled as a multi-attribute decision-making problem, and we use the lexicographic optimization method and QoS constraint relaxation technology to select candidate services with higher QOS within users' QoS preferences [5][6].Finally, the simple linear weighting method [7] is used to convert the service composite problem into a single-objective optimization problem, and the elitist genetic algorithm [8] is used to search the service composition way with the greatest fitness from the candidate services.
Simulation experiments are carried with matlab2014a on a 64-bit Windows operating system. We compared our proposed EGS~QoS algorithm with realated algorithms. The simulation results indicate that the proposed algorithm performs better. It can efficiently and accurately find the optimal composite service with higher QoS.
The remaining parts are organized as follows in this paper. Section 2 summarizes related work for IoT service composition. Section 3 introduces the model of IoT service. Section 4 details the EGS~QoS algorithm. Section 5 presents the simulation results and evaluation. Section 6 gives conclusions in this work.

Related work
Now, SOA and SOC are some of the most commonly used structures to solve service composition. Based on this structure, the multiple services with similar functions and different QoS can be combined into a complex and comprehensive composite service within QoS constraints. Thus, the essence of QoS~drien service composition problem is NP-hard problem. Many scholars have solved this problem in the past.
Kouicem et al. [9] and Yachir et al. [10] use the Simple Additive Weighting (SAW) technique to calculate the QoS utility of the service, then use the service with the largest utility value as the final composite service. L. Zeng Et al. [12] use Integer linear programming to successfully solve the problem of service composition, then propose two-step QoS~driven services composition methods. First, regardless of global QoS constraints, a local selection strategy is implemented for each service class, and candidate services that meet the requirements are selected. Then, using the ILP method finds the final composite service form candidate service for each service class based on the global QoS constraints and user's preferences. Y. Ngoko et al. [13] apply a mixedinteger linear programming method to solve service composition problems and take energy consumption as a QoS attribute to optimize the process of composition. However, as the problem scale increases, the efficiency of algorithm selection will decrease, which is not suitable for large-scale service composite problems. X. Jin et al. [14] adopts the concept of Pareto optimality to deal with the problem of service composition and proposes a service model that uses four QoS attributes to describe the characteristics of IoT services. Through a single QoS rating function (fitness function), the candidate service is evaluated and the composition service that meets the requirements is selected.
Different from previous studies, in this article, we combined the lexicographic optimization method [17] and threshold relaxation technology [6] to preselect candidate services with higher QoS, and then use the genetic algorithm to search for the final combination of services from the candidate service according to fitness value.

Models description and optimization goal
In the process of service composition for IoT, there are mainly two types of services: the concrete services and the abstract service classes . The abstract service class, also known as abstract service, is defined as a service function that includes multiple concrete services with the same function and different QoS. The concrete services, also known as atomic services, are provided by the smart device in IoT [15]. As shown in Figure 1, the essence of QoS-driven service composition is: First, integrate the existing service classes into a new comprehensive class. Then, find the optimal concrete service form each abstract service to composite service for new service class [16]. Figure.1 the model of QoS-driven service composition

The service models in IoT
In this article, the concrete service , also known as invocable service, is provided by IoT components and can be called through standard web services. (1) Where is the QoS attribute of the concrete service , and represents the function of the concrete service . The abstract service class consists of concrete services which have the same functions but different QoS levels, it can be expressed as follows. (2)

the QoS model 3.2.1 the concrete service QoS model
In the IoT environment, the QoS attributes of services are almost the same as those of web services. The QoS attributes usually have two types: qualitative attributes and quantitative attributes.Qualitative attributes include privacy, security, and so on.Quantitative attributes include cost, response time, reliability, and reputation [6].
According to the impact of QoS attributes on services, the attribute is divided into the positive attribute and the negative attribute. The positive attribute means that, as the value of the QoS attribute increasing, the service QoS increases. The negative attribute means that, with the value of the QoS attribute growing, the service QoS decreases.
The QoS attributes of the concrete service are as follows: Where represents the QoS attribute in the concrete service . The QoS model of the concrete is as follows: Where and are the QoS aggregation values for the positive and negative attributes in the specific service , respectively, and represents the weight of the user's preference for each QoS attributes.

(5)
Where is the QoS aggregation value for the concrete service . The with larger the QoS aggregation value shows that with the upper QoS level of the service in abstract service class .

The composite service QoS model
The QoS of the composite service in IoT is affected by its own structure. The commonly used service composite structures are sequential, parallel, conditional, and loop, respectively. All composite services can be combined with the above four basic structures. Since any complex structure can be transformed into a sequential structure through a certain technology, so the composite service in this article adopts a sequential structure [6].

The optimization goal
In this work, the service composition problem is finally transformed into a singleobjective optimization problem, and the enhanced genetic algorithm is used to find a composite service meeting the user's QoS requirements. In the composition process, we will choose the final composite service based on the fitness of the composition service. The optimization goal in this paper is as follows. (6) Where is the fitness value of the composite service, is the size of the composite service, and represents the concrete service contained in the composite. 4、EGS~QoS：an QoS-driven service selection method based on enhanced Genetic optimization algorithm The EGS~QoS algorithm proposed in this paper consists of two steps. First, lexicographic optimization and threshold relaxation technology are used to preselect candidate services with higher QoS.

service preselection concerning QoS levels and user's QoS needs
In this article, we model the service preselection concerning QoS levels and user's Qos needs' as a multi-attribute decision-making problem, then use lexicographic optimization technology and threshold relaxation technique to preselect candidates that In this article, we innovatively regard the aggregate value of the IoT service QoS, the positive QoS or the negative QoS for each abstract service class as the suboptimization problem to be solved in the lexicographic optimization technology. Therefore, the service pre-screening steps are as follows: 1) ranking QoS aggregation value attributes and the positive or the negative QoS aggregation value according to the sum of user's preference weights for QoS. 2) For each abstract service class with concrete service , each QoS aggregation value is processed, whether negative or positive, according to the previous order. A) Discover the optimal QoS aggregation value in the abstract service class . B) Using threshold relaxation technology [6], calculate the threshold of each QoS attribute aggregation value, based on the optimal QoS aggregation value and tolerance factor .
3) The concrete service that is not within the threshold will be deleted from the candidate service sets of the abstract service class . This reduces the composite scale and search time to a certain extent. The pseudocode of the service preselection stage based on lexicographic optimization and threshold relaxation technology is shown in Algorithm 1.
Algorithm 1-service preselection concerning QoS levels and user's QoS needs Input： abstract service class containing concrete service. : the tolerance factor for QoS aggregation value.
Step 1: the QoS aggregation values, positive or negative, are ranked according to the user's preference weight for QoS Attribute. The rank is 1 or 2. The rand of Qos aggregation values with I has the highest priority.
Step 2: Step 3: for rank=1 to 2 do Step 4: discover from Step 5: compute according to (8) Step 6: compute according to (7) Step 7: Update as follows: Step 8: if current QoS aggregation value is positive then Step 9： Step 10： else Step 11： Step Step 13：end for Outputs：the pre-selecting candidate service sets for each abstract service class .

Final composition service selection based on enhanced genetic algorithm
In this paper, concrete services with relatively low QoS are deleted through service preselection for each abstract service class , which reduces the search domain to a certain extent. The service composition in IoT is an NP-hard problem. The Genetic algorithm is a common method to solve this problem. To speed up efficiency, we use an enhanced genetic algorithm [8] to find the final composite service. The flow chart of the enhanced genetic algorithm is shown in Figure.2.

Figure. 2 The process of enhanced genetic algorithm
For the enhanced genetic algorithm, the current population is generated according to the number of concrete services contained in the candidate service set of each abstract class . In order to ensure the complete evolution of the population, the evolution iterations change adaptively according to the scale of the composite service, as shown below.

(9)
Where is the total number of abstract service classes, and is the number of concrete services for abstract service classes.

the population selection operation
Commonly used methods of population selection are roulette wheel selection [18], stochastic universal sampling [19], and tournament selection method [20]. To ensure

the Individual coding method in Evolutionary operation
In this article, the coding method of population individuals adopts integer coding. As shown in Figure.3, the individual length is the total number of abstract service classes participating in service composition. The locus of an individual is the serial number of the concrete service included in the preselected candidate service sets for the abstract service class . Figure.3 individual coding method

the Individual crossover method in Evolutionary operation
To speed up the evolution, we use the single-point crossover to perform the individual crossover operation.

the Individual mutation method in Evolutionary operation
for ensuring the integrity of the individual, this paper uses the small disturbance mutation method to perform mutation operations for the individual as shown below: Step 1：select a mutation point to form individual randomly.
Step 2：chose a serial number for the candidate service Sets for abstract service to replace the serial number in .

the Population updating strategy
To ensure that population evolution does not undergo evolutionary recession, we use the coverage method to update the population.
Step1: Arrange the individuals of the current population in descending order according to their fitness.
Step2: According to the order, the top individuals in the current population replaced the elitist individual.
Where is the population replacement rate and is the current population size.

The simulation and result analysis
For verifying the performance of EGS~QoS, we use matlab2014a on a 64-bit Windows operating system, Intel Core i3-9100F, 3.60GHz, and 8GB RAM to conduct

The individual
The pre-selecting candidate service CAS for each abstract service class.

CAS1 CASi CASn
Size simulation experiments. In the simulation, EGS~QoS will be compared with traditional genetic algorithms(TGA) [22] in terms of the maximum fitness of individuals.

Simulation settings
In this paper, we consider five common QoS attributes for the IoT service, and all QoS attributes are uniform distribution in a certain interval as shown in Table 1. Meanwhile, the user's preference weight for reliability, reputation, security, cost, and response time are 0.3, 0.25,0.2, 0.15, 0.1, respectively.
In this work, we set various abstract service class numbers and concrete service numbers for each abstract service class to evaluate the performance of EGS~QoS. The setting of abstract service class and concrete service number is shown in Table 2.

The results analysis
In the simulation, we show the performance of the EGS~QoS algorithm in terms of maximum fitness of individuals. We set various number of abstract service classes and concrete service for each abstract service class, which is as shown in table 2.

Maximum fitness of individual versus evolutionary iteration
For the first simulation, the number of abstract service classes and the number of concrete services for each abstract service class are set to 10 and 500, respectively, the number of evolutionary iterations is 500, for the EGS~QoS and TGA algorithms, and the tolerance factor is set to 0.4, 0.5 and 0.6 respectively. From Figure.4, it is easy to see that, compared withTGA, the EGS~QoS algorithm converges to the global optimal solution before 50 generations on average. Therefore, the convergence speed of EGA~QoS is higher than that of TGA, and its global optimization ability is greater than TGA. For the second simulation, the number of abstract service classes and the number of concrete services for each abstract service class are set to 50 and 100, respectively. The number of evolutionary iterations is 500, and the tolerance factor is set to 0.4, 0.5 and 0.6 respectively. From Figure. 5, it is can be seen that, compared with TGA, the EGS~QoS algorithm converges to the global optimal solution before 300 generations on average. Therefore, the convergence speed of EGA~QoS is higher than that of TGA, and its global optimization Ability is greater than TGA. For the third simulation, the number of abstract service classes and the number of specific services are consistent with condition 2 in table 2, and the tolerant factor is 0.5. From Figure. 6, it is very obvious that as the number of abstract classes increases, the maximum individual fitness also increases, which is due to the fact that as the number of abstract service classes increases, the scale of composite services also increases.  Figure.7, it is not difficult to find that as the number of concrete services increases, the maximum individual fitness also increases, which is due to the fact that as the number of concrete services increases, the probability of choosing the service with the highest fitness also increases.

Results and Discussion
In this paper, for dealing with the service composition problem in the IoT environment within QoS constraints and user's needs for QoS, we propose an QoSdriven service selection method based on enhanced genetic algorithm. The simulation results indicate that the global search ability and convergence speed of the proposed algorithm are better than the related algorithm. Meanwhile, the proposed algorithm can efficiently and accurately find the optimal composite service, which has higher QoS and meets the user's needs. However, in this study, we donot take the energy computation into account.It is should be futher studied that how to quickly combine the services provided by IoT components into a comprehensive composition service to balance energy and quality of service(QoS).Also, how to design more efficient algorithm is a key issue.

Availability of data and materials
Data sharing is not applicable to this article as no datasets were generated or analyzed during the current study. There are mainly two types of services: the concrete services and the abstract service classes.The essence of QoS-driven service composition is: First, integrate the existing service classes into a new comprehensive class. Then, find the optimal concrete service form each abstract service to composite service for new service class.

Figure. 2 The process of enhanced genetic algorithm
The Genetic algorithm is a common method to solve this problem. To speed up efficiency, we use an enhanced genetic algorithm to find the final composite service. The flow chart of the enhanced genetic algorithm is shown in Figure.2.

Figure.3 individual coding method
In this article, the coding method of population individuals adopts integer coding. As shown in Figure.3, the individual length is the total number of abstract service classes participating in service composition. The locus of an individual is the serial number of the concrete service included in the preselected candidate service sets for the abstract service class .

Figure.4 maximum fitness of individual for n=10 and m=500
From Figure.4, it is easy to see that, compared withTGA, the EGS~QoS algorithm converges to the global optimal solution before 50 generations on average. Therefore, the convergence speed of EGA~QoS is higher than that of TGA, and its global optimization ability is greater than TGA.

The individual
The pre-selecting candidate service CAS for each abstract service class. From Figure. 5, it is can be seen that, compared with TGA, the EGS~QoS algorithm converges to the global optimal solution before 300 generations on average. Therefore, the convergence speed of EGA~QoS is higher than that of TGA, and its global optimization Ability is greater than TGA.  Figure. 6, it is very obvious that as the number of abstract classes increases, the maximum individual fitness also increases, which is due to the fact that as the number of abstract service classes increases, the scale of composite services also increases.  Figure.7, it is not difficult to find that as the number of concrete services increases, the maximum individual fitness also increases, which is due to the fact that as the number of concrete services increases, the probability of choosing the service with the highest fitness also increases.