Task Scheduling Algorithm Based on Improved Firework Algorithm in Fog Computing

As an emerging computing model close to the end-user, fog computing can move tasks from the cloud to the fog device to process, and make up for the lack of cloud computing in terms of mobile support, delay and location-aware. Due to the less computing resources and weak processing ability of fog devices, the lightweight computing has been the primary choice, higher requirements are imposed for time and load. Therefore, in the Cloud-fog computing architecture, a new task scheduling method(I-FASC) is proposed for the characteristics of tasks and resources, including an improved firework algorithm (I-FA) is proposed by introducing the explosion radius detection mechanism of fireworks. By two sets of experiments show this method can better reduce the processing time of the task and ensure better overall load balancing of fog devices in a cloud-fog computing system.


I. INTRODUCTION
Cloud computing is becoming more and more popular as a new distributed computing in the Internet era. By 2019, more than 70% of the calculations will be completed on the cloud server. Cloud computing provides users with efficient, secure computing and storage services, and it has been bringing huge economic benefits in many fields [1]- [4]. However, with the rapid development of smart devices, artificial intelligence and other Internet of things [5], the connectivity of objects are stronger and getting stronger, the number of devices connected to network is growing explosively, and lots of devices at the edge of the network need low latency and high reliability. Because the cloud data center is far away from the end user, the ultra-long distance transmission reduces the real-time performance and a large number of Internet of Things (IoT) applications are processed in the cloud data center, which increases the burden of the cloud [6]. In order to make up for the shortcomings of cloud computing in terms of delay, mobility support and enhance user experience. Cisco proposed fog computing in 2012 [7]. As an emerging computing model, fog computing extends the cloud computing paradigm from the network core to the network edge, The associate editor coordinating the review of this manuscript and approving it for publication was Guanjun Liu . providing compute, storage and network services between end-user and traditional clouds, and it can reduce latency and network congestion [8]- [10]. As a supplement to cloud computing, fog computing mainly deals with localized, realtime, and short-cycle data processing and analysis, for example: autopilot, telemedicine, mobile roaming, etc [11]- [13]. Therefore, combining fog computing with cloud computing is a hot topic in current technology research. As we all know, cloud computing, including hybrid cloud and public cloud is a computer and server connected by the Internet, and generally provide services to users in a large geographic area. Fog computing migrates data to a server near the terminal by managing certain applications or services at the edge of the network, usually providing services to users in a small local area network. When terminal data requires higher delay, fog computing can process data faster because of its location advantage. But the heterogeneity of the fog devices determines that different devices have different processing power, it is not as good as the data center, resulting in different time for the fog devices to handle tasks and the resource load will change frequently [14]- [17].
In the task scheduling of cloud computing, although there is a large-scale parallel processing architecture in cloud computing, there are still some phenomena such as low resource utilization and unbalanced load, which seriously affect the VOLUME 8, 2020 This work is licensed under a Creative Commons Attribution 4.0 License. For more information, see http://creativecommons.org/licenses/by/4.0/ work efficiency. On the one hand, large-scale data transmission will consume a lot of network bandwidth and increase the burden of cloud data center; On the other hand, due to the different terminal needs, the requirements for resources are also varied, and the long-distance data transmission will produce a large delay, unable to meet the time-delay sensitive user needs, at this time, the emergence of fog computing is very important. In the task scheduling of fog computing, the most basic problem is to match the requirements and resources. In iot scenarios, the user's needs are diverse, while fog computing service node performance is far inferior to cloud computing platform service node. Therefore, how to allocate the limited resources effectively in fog computing and allocate the resources according to users' needs to achieve the optimal scheduling goal is an urgent problem to be solved. Therefore, to meet the needs of future Internet applications and avoid wasting resources, we need to ensure the low processing time of the fog devices and the relatively balance of the overall load level according to user needs, which is becoming an important issue for users and operators. So, based on this situation, the contributions of this paper are summarized as follows: 1) An improved firework algorithm (I-FA) is proposed, which introduce the explosion radius detection mechanism of fireworks to avoid optimal solution disappears.
2) A task scheduling method(I-FASC) is presented, this method take into account the characteristics of tasks and resources, including an improved firework algorithm.

II. RELATED WORK
In recent years, fog computing has become a trend. As a novel paradigm, the core idea of fog computing is that the computation should be performed near to data source. Many researchers from home and abroad have begun studying in this field [18]- [22].
In the theoretical study of fog computing, Sarkar and Misra [23] modeled the fog computing structure in theory, comparing traditional cloud computing architecture and fog computing architecture from the service delay and energy consumption. Research shows that the service delay and energy consumption have more advantages in fog computing than cloud computing, but this article is limited to theoretical analysis. Stojmenovic [24] gave the fog computing structure in the smart grids, and they are connected to the software-defined network scenario, but they only considered the application of fog computing. Fan and Ansari [21] proposed the cost aware cloudlet placement in mobile edge computing strategy where both the cloudlet cost and average E2E delay are considered in the cloudlet placement. Yi et al. [25] analyzed the objectives and challenges of the fog computing platform, and designed a low-latency, high-efficiency and versatile fog computing platform, which did not involve the computational service problem of fog computing. Yang et al. [26] devised CUE, an intelligent EC framework based on ''cloud-user-edge'' cooperation by taking UGC features and resource heterogeneity into account. Yigitoglu et al. [27] proposed a framework, called Foggy, that facilitates dynamic resource provisioning and automated application deployment in Fog Computing architectures.
In terms of optimization strategy, Zeng et al. [28] researched a software-defined embedded system that supports fog computing to solve the problem of resource management in traditional embedded systems. They designed an efficient task scheduling and resource management strategy. For some nonlinear programming problems, they proposed an algorithm to minimize the task completion time. Pham and Euh [29] formulated the task scheduling problem in cloud-fog environment and then proposed a heuristic-based algorithm, whose major objective is achieving the balance between the makespan and the monetary cost of cloud resources. Bitam et al. [30] proposed a new bio-inspired optimization approach called Bees Life Algorithm (BLA) aimed at addressing the job scheduling problem in the fog computing environment, and this approach is based on the optimized distribution of a set of tasks among all the fog computing nodes. Sun et al. [31] proposed a two-level resource scheduling model and designed a resource scheduling scheme among fog nodes in the same fog cluster based on the theory of the improved non-dominated sorting genetic algorithm II (NSGA-II), which considers the diversity of different devices. Zhang and Zhou [32] proposed a method based on a two-stage strategy to maximize task scheduling performance and minimize nonreasonable task allocation in clouds, experimental results show that they can effectively improve the cloud's scheduling performance and achieve the load balancing of cloud resources. Li et al. [33] proposed a cloud task scheduling strategy based on clustering and improved SOS(Symbiotic Organisms Search) algorithm to solve the problems of some Quality of Service(QoS)-based scheduling algorithms in cloud computing environment.
Through careful study of the above studies, we find that they have advantages and limitations in many aspects: 1) many studies, e.g., [23]- [25], gave a sufficient introduction to the theoretical and platform of fog computing, and they were contributed to the research of optimization strategy. 2) various existing studies, e.g., [28], [30], [31], considered the optimization of time and energy consumption brought by fog computing, but they did not consider the problem between delay and device load according to tasks and resource types. It is easy to waste resources.

III. CLOUD-FOG COMPUTING WORKFLOW A. CLOUD-FOG COMPUTING ARCHITECTURE
The architecture of Cloud-fog computing is divided into the terminal layer, fog computing layer, and core layer, as shown in Fig. 1.
The terminal layer is mainly composed of terminal resource requestors, including fixed devices and mobile devices, such as sensors on the road, mobile phones, smart watches, computers and others. There are three types of task requests in the Cloud-fog computing architecture in present, one for time-sensitive requests, for example: games, autopilot and others, and one for storage requests, for example: data comparison and medical storage and others, and one for bandwidth requests, for example: drone, AR and others. All tasks are generated at this layer, and the processed results will return to this layer eventually.
The fog computing layer is mainly composed of fog resource providers, including fog devices and fog processor. The fog devices are located at the edge of the network and composed of devices with computing, storage and transmit ability, such as base station and micro servers. The fog processor is a hub connecting the core devices, fog devices and terminal devices, and it can send different requests to different locations. This layer can sense terminal requests in real time and provide various services such as device access and data processing. And this can solve the processing delay problem and alleviate pressure for the core layer.
The core layer is mainly composed of cloud resource providers, including server clusters with large storage capacity and strong computing ability. Servers are interconnected in the core layer, and the virtual machines can be moved back and forth between servers to handle complex computing tasks. The emergence of the fog computing layer facilitates the efficient use of cloud resources by the core layer and makes this layer to focus on large-scale storage and big data processing.

B. CLOUD-FOG COMPUTING WORKFLOW
The workflow of this architecture is shown in Fig. 2. And the following is the specific working process.
1) The terminal device sends the data request to the processing module of the fog computing layer.
2) In the fog computing layer, we establish a task clustering model and a resource integration model and determine the execution location of the task according to resource integration. 3) The controller sends tasks to different servers for processing.
4) The fog computing layer and core layer send the processed results to the terminal.

IV. PRETREATMENT A. TASK CLUSTERING
With the continuous development of artificial intelligence and big data, service experience has become more and more important. In the resource service of fog computing, the requirements of various tasks have different requirements for various resources in fog computing.
We can research tasks at the task level and use reasonable strategies to process the tasks. This way can facilitate the selection of different fog computing servers and reduce the size of candidate tasks during scheduling.
Assuming that K i represents the size of task T i (i = 1, 2, . . . , n), S i represents the expected storage space of task, D i represents the expected completion time of task, Y i represents the expected bandwidth of task.
We cluster the tasks according to expected storage space, expected time and expected bandwidth. In order to facilitate data processing, normalization processing is performed separately as follows: All tasks are classified into a cluster C, then we calculate distance between the different tasks: The two task T i , T j with the largest d ij values are classified into different clusters C 1 and C 2 . Then we calculate the Euclidean distance between other resources and these two center points, and select the task with the largest distance value as the center point of the cluster C 3 . And we determine the type of task by comparing the value of S i , D i and Y i , including time-sensitive requests, storage requests and bandwidth requests. Then we calculate the distance between the remaining tasks and this two tasks, they will be labeled as dist x , dist y and dist z . And we classify them according to distance, for example: if dist x > dist y > dist z , the task is assigned to cluster C 1 , otherwise it is assigned to others until these tasks divided into three different clusters. We can target resource scheduling based on task classification.

B. RESOURCE INTEGRATION
At present, the fog computing platform can be regarded as a virtualized resource pool, which is a cluster composed of many computers with different processing capabilities. Therefore, we integrate the different resources according to different index. In this article, we divide resources into three types: computing, storage, and bandwidth.
We assume that C j represents the processing power of fog device N j (i = 1, 2, . . . , m), M j represents the storage space of fog device, B j represents the bandwidth of fog device. Then we allocate resources based on processing power, bandwidth capacity and storage capacity, as shown in the following formula: C min and C max represent the maximum and minimum processing power of fog device, respectively, M min and M max represent the maximum and minimum bandwidth capacity of fog device respectively, B min and B max represent the maximum and minimum storage capacity of fog device respectively. And we determine the type of resource by comparing the value of this index, for example: if C * j > M * j > B * j , the resource belong to the type of computing resource. Then, we can perform task scheduling according to three task types.

C. CONSTRAINT
As we all know, the task data needs to be transmitted by the user to the edge server or cloud server for processing through the base station. When multiple tasks need to be offloaded to the fog server, the total transmission demand may exceed the transmission capacity of the base station. At this time, the edge controller is required to obtain the current resource occupation of the server and determine the offload location of the task.
We assume that Max connect i represents the maximum number of connections per device N j , and connect i represents the connections of the current fog server N j , at this time, we must ensure that the number of server connections cannot exceed the maximum number of current server connections, that is: At the same time, the following four constraints need to be met: 1) There is no priority constraint between tasks.
2) Tasks are not allowed to be preempted during execution. Each task can only be processed in one device, and one device can handle multiple tasks.
3) The completion time of a single task shall not exceed the expected completion time.
4) The number of tasks is greater than the number of devices.

V. OBJECTIVE MODEL
After clustering tasks and integrating resources, we begin targeted resource allocation. In fog computing, the fog devices are composed of heterogeneous network devices, so the latency of the service must be fully considered when scheduling tasks and the resource load often change. Therefore, we propose an objective model for time and load.

A. TIME MODEL
The fog computing is proposed to solve the problem of delay in cloud computing [30]. The processing speed of fog devices is different for different tasks, and the execution time will affect the service quantity for users. Therefore, the main goal is to efficiently reduce the completion time of task.
Assuming that K i represents the size of task T i , the time of fog device N j to execute task T i can be defined as follows: Since the resource requestors request n tasks, the time required for the last fog device to complete the task can be calculated as follows: When Totaltime is smaller, the entire devices have the least amount of completion time.

B. LOAD MODEL
In fog computing, there are many load factors to affect fog devices [34].We assume that C l j represents the CPU utilization of fog device N j , M l j represents the memory utilization of fog device N j , B l j represents the bandwidth utilization of fog device N j . In order to achieve the rationality of resource allocation, it is assumed that each fog device can normally receive the request of resource requestors and the load of each fog device is defined as follows: α represents the weight of the corresponding resource and α 1 + α 2 + α 3 = 1.
The average load of all fog devices is defined as L, and the formula can be expressed as follows: The load of each fog devices is expressed by the standard deviation by Eq. (6), and the calculation formula can be expressed as follows: When Load is smaller, the load of the entire device is more balanced.

VI. IMPROVED FIREWORK ALGORITHMS A. FIREWORK ALGORITHMS
The firework algorithm (FWA) is a new swarm intelligence optimization algorithm proposed by Tan and Zhu [35] and others in 2010. The algorithm is inspired by the phenomenon of fireworks exploding in the night sky and generating sparks. The fireworks and the sparks generated by the explosion together form the whole body.
The basic principle of the firework algorithm: the explosion radius and the number of explosion sparks of each firework are not similar, the poor fitness value of the firework has a large explosion radius and few sparks. So, it has global search capability; while the good fitness value of the firework has a small explosion radius and a large number of sparks. So, it has local search capability. Fireworks performs resource allocation and information interaction in accordance with the values of each adaptive degree, so that the entire population can achieve a balance between global search capabilities and local search capabilities [36], [37].
The typical firework algorithm is as follows: 1) Generate fireworks of the specified population size, and calculating the fitness value of each firework according to the fitness function.
2) Fireworks start to explode and calculate the explosion radius and number of sparks of each firework.
3) Generate explosion spark and gaussian mutation spark according to the explosion radius and the number of sparks. 4) Fireworks, explosive sparks and gaussian mutant sparks will constitute a new candidate population, and the current optimal value can be found out from this population.

5) Determine whether the termination condition is met.
If the output optimal value is met, stop iteration, otherwise enter step (6). 6) Find new fireworks according to the selection rules, and enter step (2).
For the research of firework algorithm, we analyze the explosion radius formula of the firework algorithm, and proposes an explosion radius detection mechanism in view of the possibility that the optimal spark radius may approach zero.

B. IMPROVED FIREWORK ALGORITHMS 1) ENCODING
In the swarm intelligence algorithm, the individual coding scheme is set according to the actual problem and the best solution is obtained by iterating to the optimal solution [38].
In this article, chromosome X j consisting of m genes represents the fog devices, each of gene represents a fog device, and each gene corresponds to the corresponding task code, as shown in Table 1: The chromosome is encoded as 3 , 0 , 1, 5 , 2 , .., 4 , indicating that task 3 is assigned to device 1, tasks 1 are assigned to device 3, task 2 is assigned to device 4, task 4 is assigned to device m, and device 2 is not assigned to task.
Each task can and can only be executed by one device, and each device can execute multiple tasks.

2) FITNESS FUNCTION
The fitness value is an important indicator for evaluating the individual's pros and cons. In the firework algorithm, the fitness value determines the number of sparks that are produced by each firework. Fireworks with good fitness values generate more sparks, otherwise generate fewer sparks.
We assume that the spark of the lth iteration of fireworks j is the solution. Since the magnitudes of time and load are quite different, it will produce large errors in directly processing. So, it is necessary for two goals to be numerically normalized separately.
Based on the normalization of the above goals, the fitness function is finally obtained by the summation method. The formula can be calculated by Eq. (19): α and β represent the weights of time and load respectively, its value reflects the emphasis of the optimization goal, and the center of gravity can be changed by adjusting the value, where 0 ≤ α,β ≤ 1, and α + β = 1. VOLUME 8, 2020

3) EXPLOSION DETECTION MECHANISM
The formula for calculating the number of explosion sparks and the radius of a firework explosion is: S i indicates the number of subgeneration sparks in the ith fireworks. A i represents the explosion radius of the ith fireworks. A max represents constant, which indicates the largest explosion radius. S represents the maximum number of sparks in the fireworks subgeneration. Y max indicates the worst fitness value of this generation. Y min indicates the fitness value of the fireworks with the best fitness value of the current population. f (x l i ) represents the fitness value of the ith firework. C represents the minimum number of machines.
The fitness value of the best fireworks is better, but it may (21) approximates to zero. Since the best fireworks can generate more sparks, if the radius of the sparks is zero, it is easy to be abandoned when the fireworks are finally selected, which waste computing time.
In response to the above problem, this article introduces a radius detection mechanism for fireworks. If the explosion radius of a firework is less than a certain threshold, we set its radius to this threshold: The threshold A min changes continuously with the number of iterations, the calculation formula is as follows: l represents the number of explosive searches, L represents the number of total searches.

4) GAUSSIAN MUTATION
In the fireworks algorithm, the diversity of the population is further improved due to mutation operation. The calculation method is shown in Eq. (23).
g obeys the Gauss distribution of the mean value of 1 and the variance of 1, x i k represents the value of the ith individual in the kth dimension.

5) SELECTION RULE
The individuals with the best fitness values are retained to the next generation from fireworks, explosive sparks and gaussian variation Sparks. And the rest N − 1 individuals are selected according to the following formula: k represents a set of fireworks, explosive sparks and gaussian variation Sparks. D(x i ) represents the Euclidean distance between fireworks i and fireworks j, if the firework is farther away from x i , the probability of being retained to the next generation is greater.
C. TASK SCHEDULING METHOD The task scheduling process of this article(I-FASC) is as follows: 1): Initialize parameters, including metrics for tasks, virtual machines, and algorithms.
2): Task clustering and resource integration, divided into three different types.
3): Initialize the number of fireworks N , and select specific resources to optimize, each firework represents a solution.
4): Calculate fitness function value for fireworks according to Eq. (19) and the number of sparks and explosion radius of fireworks. 5): Introducing explosion radius detection mechanism and determining the radius of the current spark.
8): If the maximum number of iterations is not reached, turn step 4, otherwise ends.

VII. SIMULATION A. EXPERIMENTAL ENVIRONMENT
This experiment uses Alibaba Cloud Server as the cloud server, a Core i5, 4G memory device is used as the fog controller, an 8-core smartphone with 4G memory is used as the edge device, and ten devices with different configurations are used as the fog server.
Task In this experiment, we deploy microservice architectures in different fog devices and containerize them in order to facilitate migration, and we use Dubbo and Thrift that is a transfer protocol to communication between services. Fog controller includes task cluster model, resource integration model and many algorithm model, it communicates with other servers through Dubbo, fog devices includes many services that deal with many task processing, fog device connects with the fog controller through Rest, the specific simulation architecture is shown in the following figure.

B. EXPERIMENTAL RESULTS
After all the parameters are configured, this paper has conducted two sets of experiments respectively for scheduling method and improved firework algorithm.

1) EXPERIMENT OF SCHEDULING METHOD
The experiments of task scheduling method include three sets of experiments: task clustering, task completion time, and edge server load.
When task scheduling started, we performed cluster experiments on 500 tasks. The experimental result is shown in the following figure 4, it can be seen from the figure that given tasks are divided into three different categories by our clustering strategy, which is convenient for scheduling in the next step. X, Y, and Z coordinates represent the expected storage of the task, the expected completion time of the task and the expected bandwidth of the task, respectively, the value is calculated as a percentage. The yellow task point is the bandwidth requests task, the blue task point is the storage requests task and the purple task point is the time-sensitive requests task.
For the task completion time, we compare the scheduling method in this paper(I-FASC) with first come first service(FSFC), an aco-based algorithm(Rank-ACO) [39] and a double-fitness genetic algorithm(DFGA) [40] under different optimization weights.
We set two different weights separately, one of which is 0.8 and 0.2 for α and β, and the other is 0.2 and 0.8 for α and β. Figure 5, 6 show the algorithm execution time line     shows that with the increased number of tasks, I-FASC maintains lower task execution time compared with other algorithms in different weights. This is because we take into account the characteristics of tasks and resources, select different devices with improved firework algorithm according to the characteristics of the task, this can greatly speed up processing efficiency. DFGA only considers the average completion time of the task, and does not preprocess the task scheduling, resulting in the overall efficiency reduction. Rank-ACO although utilizes an upward rank value along with an insertion-based policy to further guide the ants toward quality solutions, but, with the increase of data, the performance of the algorithm is still limited.
It can be seen from the figure 7, 8 that with the different number of tasks, when using different scheduling method to schedule tasks in different weights, the load of each method varies greatly. It can make the device's resource allocation more balanced by using I-FASC to schedule. It is beneficial to give full play to the performance of each device, thereby improving the performance of the entire system.
In addition, we will send all tasks to the cloud device to process and use the same algorithm to compare with I-FASC. Figure 9 show that I-FASC has lower task execution time in different fog devices compared with cloud device. The effect of data transmission time on the fog computing model can be ignored in total time, therefore, fog computing is much better in real-time than cloud computing models. On the contrary, when the data processing time is much longer than the data transmission time, cloud computing can make better use of its computing advantages.

2) EXPERIMENT OF ALGORITHM
In order to verify the optimization abilities of the improved firework algorithm in Cloud-fog computing architecture, the experiments of the improved firework algorithm include two sets of experiments: explosion radius, algorithm performance. Figure 10 shows the average of explosion radius of FW and I-FW after 200 tasks are executed, by comparison, as the number of iterations increases, the average explosion radius of fireworks of I-FA is smaller than FA, which means that each iteration of algorithm leaves more individuals with better fitness.
We compare different algorithm models under the same scheduling method and algorithm parameters, including DFGA, Rank-ACO and firework algorithm(FA), as shown in Fig.11 11. shows the average performance curve of all task completion time-iteration times after 200 tasks are executed on ten fog devices. Among the three algorithms, I-FA has the least number of iterations and the fastest convergence speed. As the number of iterations increases, the task completion time of I-FA is consistently shorter than that of other algorithms. This can be seen that I-FA is more accurate than DFGA, Rank-ACO and FA. This is because of the complexity of the Double-Fitness genetic algorithm, such as crossovers and mutations. Due to the lack of initial pheromone, Rank-ACO needs a long time to search, resulting in its slow convergence speed. While I-FA has accelerated the emergence of optimal solutions by introducing an explosion detection mechanism.

VIII. CONCLUSION
Fog computing is a kind of lightweight computing, a new task scheduling method(I-FASC) is proposed for the characteristics of tasks and resources in this article, and then an improved genetic algorithm(I-FA) is proposed by introduce the explosion radius detection mechanism of fire-works. Then, we simulate a cloud-fog computing system, and this method can achieve better execution time and ensure better load in a short time by two sets of experiments in this system.
With the widespread application of fog computing, more people will be attracted to study this field. In this article, the task scheduling is studied in the fog computing, and some research results have been achieved. However, in the actual application development, there are still many shortcomings. For example, in the modeling of the task processing time and load optimization, the energy consumption of the fog devices processing task is not considered and there are many service indicators in fog computing. So modeling the energy consumption and selecting other service indicators as optimization goals can be considered in the next step. SHANCHEN PANG received the degree in computer software and theory from Tongji University, Shanghai, China, in 2008. He is currently a Professor with the China University of Petroleum, Qingdao, China. His current research interests include theory and application of Petri net, service computing, trusted computing, and artificial intelligence.