Task scheduling algorithm based on fireworks algorithm

To give full play to the high efficiency and parallelism of multi-processor systems, the fireworks algorithm (FWA) is improved, and a multi-processor task scheduling algorithm based on improved FWA, named IMFWA, is proposed. IMFWA maps continuous space to discrete space by designing the fireworks location coding method, improves the Gaussian mutation process, and sets adaptive dimensions to accelerate the convergence speed of the algorithm. At the same time, in order to reduce the time complexity of the algorithm and shorten the time finding the optimal task scheduling sequence, the fitness-based tournament selection strategy is used instead of the rule based on Euclidean distance. Finally, IMFWA is compared with the basic fireworks algorithm and the genetic algorithms on the Matlab platform for performance analysis. The results show that the IMFWA has advantages in the convergence speed, and the negative impact of the number of tasks is also lower than the fireworks algorithm and genetic algorithm.


Introduction
The task scheduling problem belongs to the combinatorial optimization problem and cannot be solved within the polynomial time complexity [1]. It has been proved to be an NP-hard problem [2,3]. It is easy for multiple independent tasks to be scheduled on homogeneous multiprocessors, by only scheduling the task with the shortest completion time to the processor. The representative task scheduling scheme on heterogeneous multi-processors is more complex. The performance parameters, such as execution efficiency and total time of completion, need to be considered [4][5][6][7]. Research on task scheduling strategies for heterogeneous multi-processors has drawn much attention in recent years [8][9][10]. At present, the combination optimization algorithm, which is widely used in task scheduling problem, is genetic algorithm (GA) [11][12][13]. Nevertheless, the parameters of genetic algorithm are complicated to configure, and the effectiveness of the crossover and mutation operations decreases when the number of tasks increases, and the "premature" phenomenon can be easily triggered by the population initialization of the individuals [12,[14][15][16][17][18]. The fireworks algorithm (FWA) is a swarm intelligence optimization algorithm based on non-living population proposed by Ying Tan in 2010 [1,19,20]. The fireworks algorithm can provide the global optimal solution for complex problems [1,20,21] and has low definition for solving the problem. Since proposed, it has been widely applied to non-negative matrix factorization calculation, directional characteristic matrix measure, group robot multi-target search, fertilization problem, traveling salesman, among others [20].
Based on the above literature and background, a heterogeneous multi-processor task scheduling algorithm, IMFWA, is proposed, for making the fireworks algorithm suitable for the discrete multi-processor task scheduling problem and for efficiently and quickly obtaining the optimal task scheduling sequence. Compared with the basic fireworks and genetic algorithm on the Matlab simulation platform, it is proved that IMFWA has noticeable advantages in convergence speed, and the impact on the number of tasks is also significantly lower than genetic algorithm.
The paper is organized as follows: Section 1 introduces the research background for the problem. Section 2 describes the basic task scheduling problem. Section 3 presents the fireworks algorithm and its improvement strategy. The proposed algorithm is presented in

Description of task scheduling problem
Task scheduling is to obtain the optimal solution of the task sequence according to an algorithm, and tasks are assigned to the corresponding multi-processor according to the optimal solution order, so that the task completion time is the shortest [22][23][24]. For convenience, the system contains n heterogeneous multi-processors, denoted by P = {P 1 , P 2 , . . . , P n }. Divide any application into m independent tasks, represented by T = {T 1 , T 2 , . . . , T m }. n ≥ m means there are more processors than tasks to be scheduled. The next task is scheduled to an idle processor which has the shortest execution time according to the first-come-first-service mechanism. When n ≺ m, the number of processors is smaller than the number of tasks, and the tasks need to be assigned following the scheduling scheme. This paper only considers the case of n ≺ m. exet ij is the execution time of task T i on processor P j . The execution time of all tasks under the scheduling scheme is CP(s). min(CP(s)) indicates the time used to execute all tasks under the optimal scheduling scheme f. The task scheduling problem can be expressed as Eq. (1).

The fireworks algorithm
The fireworks algorithm is a parallel explosive optimization algorithm proposed by Tan Ying, inspired by the natural fireworks exploding behavior [20]. In the fireworks algorithm, the sparks generated by fireworks and their explosions and mutations resemble feasible solutions, and the explosion process simulates the process of optimizing in the current feasible solution domain [25,26]. In nature, high-quality fireworks explosions produce more and more sparks, while the inferior fireworks explosions produce much fewer sparks. The fireworks algorithm follows the natural rules: the fitness value is good, the fireworks quality is excellent, the explosion range is small, and the sparks generated are in large quantity. On the other hand, when the fitness value is not good, the fireworks quality is inferior, the explosion range is large, and the sparks generated are limited [1,20,21,27]. The fireworks algorithm includes explosive sparks, mutation sparks, mapping rules, selection strategies, and other elements [20]. The explosion operator produces explosion sparks, which play a key role in the fireworks algorithm, whose metrics include explosion intensity, explosion amplitude, and displacement operation [28,29]. The explosion intensity is the core of the explosion operator, indicating the quantity of sparks generated during the explosion [30,31].
The fireworks based on better fitness value can produce more sparks and avoid them swinging around the optimal value during optimization. The calculation method for the number of sparks is shown in Eq. (2).
S i indicates the number of subgeneration sparks in the ith fireworks. S represents the maximum number of sparks in the fireworks subgeneration. F max indicates the worst fitness value of this generation. f (X i ) represents the fitness value of the ith fireworks. is a minimal constant, avoiding the divide-by-zero error.
In order to control the number of subgeneration sparks of high quality fireworks and inferior fireworks, fireworks i is limited, as shown in Eq. (3).
a and b are given constants. round is the integral function, following the principle of rounding. The explosion amplitude is set to explore the optimum value within a certain range around this generation of fireworks [32,33]. The fireworks with poor fitness value can produce sparks in a wider range and avoid "premature" phenomenon [34,35]. The calculation method of explosion amplitude is shown in Eq. (4).
R i indicates the range of the explosion amplitude of the ith fireworks. R shows the maximum range of the fireworks explosion. F min represents the best fitness value of the current generation of fireworks. The displacement operation is performed on each dimension of the fireworks i according to the explosion intensity and the explosion amplitude [36,37], as shown in Eq. (5).
X k i indicates the value of the location vector of fireworks i in the kth dimension. X k i represents the value of the location vector of the sparks generated by fireworks i explosion in the kth dimension. rand(0, R i ) indicates the random number between 0 and R i .
In the fireworks algorithm, the diversity of the population is further improved by the mutation spark. The Gauss distribution is used to preform Gauss mutation on any dimensions of fireworks in the population [38][39][40]. The calculation method is shown in Eq. (6).
∇X k i indicates the value of the location vector of the sparks produced by fireworks i Gauss mutation in the kth dimension. n obeys the Gauss distribution of the mean value of 1 and the variance of 1, as shown in Eq. (7).
If fireworks i is near the boundary of the feasible domain, it may produce sparks across the boundary. Therefore, we use the rule of modular operation to map it back to the feasible domain, as shown in Eq. (8).
X k max and X k min indicate the upper and lower bounds of the location vector of fireworks i in the kth dimension, respectively.
According to the explosion operator and Gauss mutation operator, the current population contains this generation of fireworks, the explosion sparks, and the Gauss mutation sparks. The individuals with the best fitness values are retained to the next generation with probability 1. Then, the rest N − 1 individuals are selected according to the Roulette rule with the probability in Eq. (9).
P i indicates the probability that fireworks i is selected. K is a set of fireworks, explosion sparks, and Gauss mutation sparks. D ij represents the Euclidean distance between fireworks i and fireworks j, as shown in Eq. (10):

The process of adaptive Gaussian mutation
The basic fireworks algorithm increases the diversity of the population through Gauss mutation and uses Gauss distribution to mutate any of the multiple dimensions of the fireworks in the population [20]. The actual effect of Gauss mutation can be easily influenced by the selected Gauss mutation fireworks and mutation dimensions. Therefore, for having a good fireworks population diversity and short convergence time, the process of Gauss mutation is redesigned. With a poor fitness value of Gauss mutation, the contribution of the poor fireworks to the mutant becomes too large, thereby reducing the convergence speed of the algorithm. According to Pareto's rule, the most important part of anything is only 20%, and the remaining 80% are secondary, although they are the majority [41]. Therefore, in order to ensure that the algorithm has a fast convergence speed, the improved fireworks algorithm randomly selects one of the fireworks for Gauss mutation among the top 20% of the fitness value.
When the fireworks with better fitness value are selected for Gauss mutation, if the mutation dimension constantly remains large, despite the improved diversity of the fireworks population, the contribution of fireworks with better fitness value to the population is reduced, thereby slowing down the convergence speed of the algorithm. In contrast, if the mutation dimension constantly remains small, although the information of the fireworks with better fitness value is retained, the diversity of the fireworks population is also reduced and consequently makes the algorithm fall into the local optimum. Therefore, to guarantee a fast convergence speed while not falling into the local optimal, the adaptive Gauss mutation dimension is presented. The value of the dimension is shown in the Eq. (11).
w is a nonlinear function that decreases by the iterations t, as shown in Eq. (12). Considering that the value of Gauss mutation dimension should be a positive integer, the value of z(t + 1) is rounded up to w(t) × z(t) .
At the beginning of iteration, w is relatively large, and the corresponding mutation dimension z is also large, which helps improve the diversity of fireworks population and enhances the algorithm with global search. In the later stage of the iteration, the value of w decreases gradually along with the iterations. The corresponding mutation dimension z decreases, the Gauss mutation dimension decreases gradually, and the information of the fireworks with better fitness value is preserved, so that the algorithm achieves optimization in the later stage of the iterations. The improved fireworks algorithm fully plays the role of Gauss mutation, avoiding the waste of resources caused by improper selection of the mutation fireworks and the improper determination of the mutation dimension. Meanwhile, the algorithm improves the ability of global search and convergence speed.

Coding strategy
Fireworks algorithm is an explosive optimization algorithm for continuous space, and task scheduling is a discrete problem. Therefore, according to the characteristics of heterogeneous multi-processor task scheduling, IMFWA encodes every generation of fireworks and maps the continuous search space to the discrete search space, so that fireworks algorithm can be applied to the task scheduling problem.
The fireworks or spark in the population represents a possible way of task scheduling. The processors and tasks are numbered respectively: the processor numbers are 1, 2, . . . , n, and the task numbers are 1, 2, . . . , m. Let the location vector of fireworks or sparks be an mdimensional vector X i , as shown in Eq. (13). 2, 3, . . . , m}, and rand(1, n) indicates a random value between 1 and n, then: (1) The j th task is distributed to the x j processor.
(2) The requirements of task scheduling for heterogeneous multi-processors are met. (3) Each task can and can only be executed by one processor. (4) Each processor can execute multiple tasks.
In this coding scheme, the fireworks or spark location vector is retained as a multi-dimensional vector, and only the meaning and value represented by each dimension are limited. In order to apply the coding scheme to the heterogeneous multi-processor task scheduling problem, the displacement operation formula Eq. (5) is updated to Eq. (14).
When applying Eq. (14) to the execution of displacement operation, the value of x j may be beyond the range, and the mapping rule Eq. (8) needs to be updated to Eq. (15).
The coding scheme has four features and, therefore, is suitable for heterogeneous multi-processor task scheduling: (1) The encoded mode is simple and clear and easy to understand and implement. (2) The requirements of task scheduling for heterogeneous multi-processors are met. (3) Contains all possible task scheduling schemes. (4) The unique mapping of location vector and task scheduling sequence for fireworks or sparks.

Fitness value
In the fireworks algorithm, the quality of each generation of fireworks and their offspring is evaluated by the fitness value. IMFWA uses CP(s), the time used to execute all tasks under the task scheduling sequence s, as the fitness evaluation standard. A smaller value of CP(s) indicates faster task execution, and a smaller fitness value presents better quality of the fireworks or sparks. On the contrary, a larger value of CP(s) indicates slower task execution, and a higher fitness value presents worse quality of the fireworks or sparks. According to the coding scheme, CP(X i ) is the completion time of the task scheduling sequence corresponding to fireworks i or spark, and the fitness value calculation method is as shown in Eq. (16).
The fitness value calculation method is shown in Eq. (18).

Tournament selection strategy
The basic fireworks algorithm uses the Roulette rules based on Euclidean distance to select the next generation of fireworks; the higher the distance from the other fireworks or sparks, the higher the probability of being selected. Although this selection strategy allows the algorithm to avoid the local optimal solution, the time overhead increases greatly when the dimension of the location vector X i of the fireworks increases. This leads to long execution time of the algorithm in actual applications [1]. Therefore, IMFWA improves the basic fireworks algorithm and adopts the fitness-based tournament selection strategy instead of the Roulette rule based on Euclidean distance [1,20,21]. This reduces the time cost of the algorithm on the basis of ensuring the population diversity. Fitness-based tournament selection strategy first selects a certain number of fireworks or sparks from the population to form the next generation fireworks candidate set in each iteration. Then, it chooses the best fireworks or sparks in the candidate set to enter the next generation according to the fitness value. The specific process is as follows: (1) To determine the percentage of fireworks or sparks in the next generation of fireworks candidates out of the total number of fireworks or sparks in the contemporary population. (2) In accordance with the percentage determined in (1), the contemporary fireworks population is randomly selected to form the next generation of fireworks candidates set. (3) According to fitness values, the best fireworks or sparks are retained in the next generation within the candidate set determined in (2).
Based on the above, the selection strategy of IMFWA ensures that the individuals with the optimal fitness value still remain in the next generation with the probability of 1. Then the remaining N − 1 individuals are selected according to the fitness-based tournament strategy. The probability of each fireworks or spark being selected is shown in Eq. (19).
Q represents the next generation of fireworks candidates selected according to a certain percentage of r. F max indicates the maximum fitness value of an individual in set Q. IMFWA adopts this fitness-based tournament selection strategy to reduce the computational cost of selecting each generation of fireworks and shorten the actual execution time of the algorithm.

The process of IMFWA
The process of the IMFWA scheduling algorithm is as follows: (1) Initialize the number of fireworks N, the basic explosion spark number S, the basic explosion amplitude R, the number of tasks m, the multi-processors number n, and the maximum iteration number I. (2) Initialize the fireworks location and convert the fireworks location into a task scheduling sequence according to the encoding scheme in Section 4.1.

Experimental methods
For evaluating the performance of IMFWA algorithm, this research designed the comparative experiments with the basic fireworks algorithm and genetic algorithm which is widely used in task scheduling. The fireworks algorithm is distributed and parallel. Compared with the chromosome information sharing mechanism of genetic algorithm, the fireworks algorithm adopts a distributed information sharing mechanism. The population is not Fig. 1 The process of IMFWA uniformly to the optimal region, but the explosion and sparks are determined according to the fitness value of the fireworks distributed in different regions. Although the selection strategy of fireworks algorithm and genetic algorithm both introduce the idea of immune concentration, the fireworks algorithm has more mechanisms to avoid falling into the local optimal solution. The experimental platform is Matlab R2014b and the operating system is Windows 10. In order to objectively analyze the performance of the algorithms, several comparative experiments are set up to test the performance of the three algorithms under the conditions of eight processors and 50, 100, 150, 200, and 250 tasks.
To eliminate the contingency of random data, the total task completion time obtained is the average of 20 experiments. The specific parameter settings of IMFWA, GA, and FWA are shown in Table 1. Parameter N indicates the initial quantity of fireworks per generation of the population in IMFWA and FWA. In GA, it indicates the quantity of initial individuals per generation with the value of 100. The maximum number of iterations I is 500. Figure 2 shows the scenario when m = 200 and n = 8, where the average performance curve of all task completion time-iteration times after 200 tasks are executed on eight heterogeneous processors. In Fig. 2, among the three algorithms, IMFWA has the least number of iterations and the fastest convergence speed. As the number of iterations increases, the task completion time of IMFWA is consistently shorter than that of FWA and GA. It can be seen that the accuracy of IMFWA and FWA is superior to that of the genetic algorithm. This is because the crossover and mutation operations of genetic algorithm increase the time complexity of the algorithm, and it tends to miss the optimal solution. While the iterative process of IMFWA is relatively simple, the search speed is faster and the precision is higher. Figure 3 shows the algorithm execution time-task number curve for different task numbers when there are eight processors. In Fig. 3, with the increased number of tasks, IMFWA still maintains lower task execution time when compared with FWA and genetic algorithm. It can be seen that IMFWA is less affected by the number of tasks than FWA, and both algorithms are less affected by the number of tasks than genetic algorithm. This is because the cross-mutation operation of genetic algorithm reduces its effectiveness in large dimensions and is most affected by the dimension. IMFWA reduces the time complexity of the algorithm by improving the Gauss mutation and the selection strategy.

Results and discussion
The experimental results and analysis show that IMFWA has the feasibility and efficiency in solving the task scheduling problem. It retains the characteristics of  the basic fireworks algorithm's accuracy in finding the optimal or suboptimal task scheduling sequence. Meanwhile, it shortens the overall completion time of tasks on multi-processor, where its parallelism and heterogeneity can be fully utilized.

Conclusions
To exploit the parallelism and efficiency of heterogeneous multi-processor systems, a task scheduling algorithm based on improved fireworks algorithm is proposed. By setting the coding method of the fireworks location, the solution space of the fireworks algorithm is converted from continuous to discrete, so that it is suitable for task scheduling problem. At the same time, IMFWA improves the Gauss mutation process of the basic fireworks algorithm, effectively accelerating the convergence speed of the algorithm. The algorithm introduces a fitness-based tournament selection strategy, which reduces the time complexity of the algorithm. On the Matlab simulation platform, compared with the basic fireworks algorithm and genetic algorithm applied to the task scheduling problem, it is proved that IMFWA can find the optimal solution within fewer iteration times. The convergence speed is faster, and the execution time of the algorithm is also shorter. When the number of tasks increases, IMFWA can still maintain a good optimization speed and solution accuracy.

Availability of data and materials
The authors declare that all the data and materials in this manuscript are available.