Particle swarm optimization method and system integrating reverse learning and heuristic perception
Technical Field
The invention relates to the field of cloud computing task scheduling, in particular to a particle swarm optimization method and system integrating reverse learning and heuristic perception.
Background
The main idea of cloud computing is to use related technologies such as grid computing, distributed computing and parallel processing to fuse heterogeneous computer network resources dispersed in various places into a huge computer resource pool for users to use as required. After the user submits the tasks to the computer resource pool, the tasks are systematically distributed to all the computer resources in the resource pool, and the results are returned to the user after the tasks are executed by utilizing the powerful computing power of the tasks, so that people can obtain higher computing power with lower cost investment. In a cloud computing environment, task scheduling is one of the most important modules. The overall computing efficiency of resources in cloud computing and the satisfaction degree of user use are directly affected by the quality of a task scheduling result. How to efficiently and reasonably distribute tasks submitted by users to resources in cloud computing to execute becomes a hot issue of research of people. The essence of the problem is that on the premise of satisfying QOS (Quality of Service) or SLA (Service level Agreement), n mutually independent computer tasks submitted by a user are allocated to m heterogeneous computer resources in a cloud computing center, so that the execution time of the total task is minimized, and the computer resources are fully utilized.
The task scheduling problem in cloud computing is an NP difficult problem, and the objective of the task scheduling problem is to find an approximate optimal solution in a solution space of task scheduling, so that the execution time of a total task is minimum and the load is balanced. Many researchers at home and abroad propose different algorithms and improved algorithms. The Min-Min heuristic algorithm and the improved algorithm thereof are common. The Min-Min algorithm, which is a traditional algorithm, has a good performance in task scheduling, because Min-Min always allocates a small task to a resource with strong processing capability for processing in advance to achieve the minimum total execution time of the task, but because of this, the load of the task is unbalanced, that is, when the resource with strong processing capability is fully loaded to execute the task, the resource with poor processing capability in the resource is in an idle state, and an ideal result is not achieved.
With the development of intelligent algorithms, more and more students adopt intelligent algorithms based on the anti-biotic Algorithm, such as GA (Genetic Algorithm), ACO (Ant Colony Optimization), TS (Tabu Search Algorithm), particle swarm Algorithm and a hybrid Algorithm thereof, to solve the task scheduling problem in cloud computing and achieve certain results. The particle swarm optimization algorithm is a random parallel global search method, and has the advantages of being few in parameters, easy to implement, high in convergence speed and the like, so that the particle swarm optimization algorithm becomes a preferred algorithm for solving the problem of cloud computing task scheduling. However, the standard particle swarm optimization algorithm has the following disadvantages:
the method is sensitive to the initial particle swarm, the result of task scheduling has strong dependence on the quality of the initial particle swarm in the algorithm, the better the quality of the initial particle swarm generated by a random method is, the better the obtained result is, otherwise, the poor result is obtained. The particles in the algorithm may miss the local optimal solution by ignoring the possible "optimal solutions" around each particle when searching for the optimal solution in the "flying to" population.
Therefore, how to realize better optimization of the particle swarm becomes an urgent problem to be solved.
Disclosure of Invention
The invention aims to provide a particle swarm optimization method and system integrating reverse learning and heuristic perception so as to achieve better optimization of a particle swarm and further enhance the local optimization capability of an algorithm.
In order to achieve the purpose, the invention provides a particle swarm optimization method integrating reverse learning and heuristic perception, which comprises the following steps of:
s1: initializing original particles with the size of n, and forming an original population according to the original particles;
s2: generating n reverse particles of the original particles by adopting a reverse learning method, selecting a better one from the original particles and the reverse particles, and updating the original population to obtain an initial particle swarm;
s4: and sequentially generating q probes for sensing whether the positions of the probes are better than those of the current particles around each particle in the initial particle swarm, and optimizing each particle in the initial particle swarm according to the probes to obtain the optimal particle swarm.
Preferably, the method further comprises the step of:
s3: and calculating the fitness value of each particle in the initial particle swarm by adopting a fitness function, wherein the fitness value is used for judging the level of the position of the corresponding particle, and the larger the fitness value is, the better the position of the particle corresponding to the fitness value is.
Preferably, the S4 specifically includes the following steps:
s41: calculating the corresponding fitness value of each probe, selecting the optimal one to be compared with the fitness value of the current particle, and replacing the current particle with the probe if the optimal one is better than the current position;
s42: and updating the speed and the position of each particle in the initial particle swarm, judging whether a circulation condition is met, and if so, exiting the circulation to obtain an optimal particle swarm.
Preferably, the calculation formula of the fitness value is as follows:
in the formula, F (i) represents a fitness value corresponding to the ith particle, and Allexetime represents the total execution time of the task;
the smaller the total execution time Allexetime of the task is, the smaller the span of the task is, the larger the corresponding fitness value is, and the better the position of the particle is.
Preferably, the updated velocity V of each particle in the initial population of particlesj ikThe calculation formula of (2) is as follows:
Vj ik=ωvt ik+c1R1(Pbesti-xt ik)+c2R2(Gbest-xt ik);
R1=a-r1;
R2=b-r2;
wherein i represents the ith particle, j represents the jth probe, c1And c2All represent an acceleration factor, r1And r2Is represented by [0,1 ]]Random numbers in, a and b are represented as [0,1 ]]Interval constant, Pbesti represents that the optimal position searched by the ith particle so far is an individual extremum, Gesti represents that the optimal position searched by the whole particle swarm so far is a global extremum, omega represents inertia weight, xt ikRepresenting the current position of the particle.
Updating the position X of each particle in the initial population of particlesj ikThe calculation formula of (2) is as follows:
Xj ik=xt ik+Vj ik。
as a general technical concept, the present invention further provides a particle swarm optimization system incorporating reverse learning and heuristic perception, including a memory, a processor and a computer program stored on the memory and executable on the processor, wherein the processor implements the steps of the method when executing the program.
The invention has the following beneficial effects:
the invention provides a particle swarm optimization method and system integrating reverse learning and heuristic perception, wherein an initial particle swarm of a particle swarm is optimized by a reverse learning strategy, the quality of the initial particle swarm is improved, and the local optimization capability of an algorithm is enhanced by searching an individual optimal solution by adopting the heuristic perception method.
The present invention will be described in further detail below with reference to the accompanying drawings.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this application, illustrate embodiments of the invention and, together with the description, serve to explain the invention and not to limit the invention. In the drawings:
FIG. 1 is a flow chart of a particle swarm optimization method incorporating reverse learning and heuristic perception in accordance with a preferred embodiment of the present invention;
FIG. 2 is a model diagram of a heuristically-perceived search strategy of a preferred embodiment of the present invention;
FIG. 3 is a graph comparing the results of the PSO and OBL-TP-PSO algorithms for a preferred embodiment of the present invention with a 100 task count and a 100 population size;
FIG. 4 is a graph comparing the results of the PSO and OBL-TP-PSO algorithms for a preferred embodiment of the present invention with a task count of 200 and a population size of 200;
FIG. 5 is a graph comparing the results of the PSO and OBL-TP-PSO algorithms for 500 task counts and 500 population sizes in accordance with the preferred embodiment of the present invention;
fig. 6 is a schematic diagram of load balancing under different task numbers according to the preferred embodiment of the present invention.
Detailed Description
The embodiments of the invention will be described in detail below with reference to the drawings, but the invention can be implemented in many different ways as defined and covered by the claims.
Example 1
As shown in fig. 1, the present embodiment provides a particle swarm optimization method integrating reverse learning and heuristic perception, including the following steps:
s1: initializing original particles with the scale of n, and forming an original group according to the original particles;
s2: generating reverse particles of n original particles by adopting a reverse learning method, selecting a better one from the original particles and the reverse particles, and updating an original population to obtain an initial particle swarm;
s4: and generating q probes used for sensing whether the positions of the probes are better than those of the current particles around each particle in the initial particle swarm, and optimizing each particle in the initial particle swarm according to the probes to obtain the optimal particle swarm.
According to the particle swarm optimization method integrating reverse learning and heuristic sensing, the initial particle swarm of the particle swarm is optimized by using a reverse learning strategy, the quality of the initial particle swarm is improved, and the local optimization capability of the algorithm is enhanced by searching the individual optimal solution by using the heuristic sensing method.
In practical application, the embodiment of the present invention may further add the following steps to optimize:
s3: calculating a fitness value for each particle in the initial population of particles using a fitness function.
In fig. 2, assuming that q is 3, the s4 particle distributes probes { s41, s42, s43} in 3 random directions around the particle before the velocity and position update, i.e., "flying to" the group, and calculates their corresponding fitness values, selects the best probe, and if the fitness value corresponding to the probe is better than the fitness value corresponding to s4, replaces s4 with the position of the best probe, and then updates its velocity and position to the next cycle. If all probes are worse than s4, s4 remains unchanged and then updates its speed and position into the next round of the cycle. The algorithm is prevented from being missed in searching by heuristically sensing whether the surrounding of the particle has a better position than the surrounding. The search mode based on heuristic perception improves the local optimization capability of the particle swarm optimization algorithm and avoids the trapping of local optimization.
In this embodiment, the particles are first encoded in a sequential encoding manner. With N tasks, M resources, and N > M, the encoding and decoding process for the particles is as follows.
Where N is 10, M is 5, the task number is (1, 2, …,10), and the resource number is (1, 2, …,5), there is a code number: and A is (1, 3, 5, 2, 4, 5, 1, 3, 4, 3), wherein the sequence of numerical values in the code corresponds to the number of the task, and the numerical values in the code represent the number of the resource. At this time, consider a as a particle in the solution space, which corresponds to a scheme for task scheduling. The code is shown in table 1.
TABLE 1 coding
Task numbering
|
1
|
2
|
3
|
4
|
5
|
6
|
7
|
8
|
9
|
10
|
Resource numbering
|
1
|
3
|
5
|
2
|
4
|
5
|
1
|
3
|
4
|
3 |
As can be seen from table 1, a task numbered 1 is assigned to a resource numbered 1 and executed, a task numbered 2 is assigned to a resource numbered 3 and executed, and a task numbered 3 is assigned to a resource numbered 5 and executed.
What corresponds to the coding problem is decoding. The particles are first decoded to see the execution of the task on each resource. The results of decoding a are shown in table 2.
TABLE 2 decoding
Resource numbering
|
1
|
2
|
3
|
4
|
5
|
Task numbering
|
1 7
|
4
|
2 8 10
|
5 9
|
3 6 |
As can be seen from table 2, after decoding a, the result of task scheduling can be clearly obtained: the tasks allocated to the resources 1 to 5 are {1,7}, {4}, {2,8,10}, {5,9}, and {3,6}, respectively.
It should be noted that, both the particle swarm optimization and the improved particle swarm optimization need to determine the quality of the particle position through the fitness value, which is usually a multi-target optimization problem, but multi-target optimization is often contradictory and conflicting, so the best optimization can only balance each target according to the actual situation to obtain a relative extreme value. In the embodiment, the minimum total execution time of the task is taken as a main basis for the performance of the algorithm. Task scheduling means that tasks are completed in the shortest time and the highest efficiency, the smaller the task completion time is, the larger the objective function value is, and the better the fitness of particles in the population is.
Let T ═ { T ═ T1,T2,…,TrDenotes R mutually opposed tasks, R ═ R1,R2,…,RsDenotes s computing resources in the cloud data center, where r>And s. Let rxThe exeTime matrix of s represents the time required for the task queue to run to completion, T (T), on each computing resourcei) Representing a task TiSize of (2), Mips (R)j) Represents a resource RjThe time required for task i to complete execution on resource j is then expressed as:
assuming that the number of tasks allocated to the jth resource is n, the time for the resource j to complete all the tasks is:
where i denotes the execution of the ith task on the jth resource and n denotes the total number of tasks allocated on the jth resource. The total execution time of the tasks in the system is:
the fitness represents the quality of the position state of the particle, and in this embodiment, the network bandwidth in task scheduling, the performance of the task on the resource, the security and other requirements are not considered. Considering only the total time spent in task scheduling, the formula for calculating the fitness value is:
in the formula, F (i) represents a fitness value corresponding to the ith particle, and Allexetime represents the total execution time of the task;
the smaller the total execution time Allexetime of the task is, the smaller the span of the task is, the larger the corresponding fitness value is, and the better the position of the particle is.
Further, step S4 is performed, q probes for sensing whether there are better positions than the current particle are generated around each particle in the initial particle group, and each particle in the initial particle group is optimized according to the probes to obtain an optimal particle group. Which comprises the following steps:
s41: calculating the corresponding fitness value of each probe, selecting the optimal one to be compared with the fitness value of the current particle, and replacing the current particle with the probe if the optimal one is better than the current position;
s42: and updating the speed and the position of each particle in the initial particle swarm, judging whether a circulation condition is met, and if so, exiting the circulation to obtain the optimal particle swarm. In this embodiment, the cycle condition is a set number of times, and specifically, the set number of times is determined according to actual experience, which is not described herein in detail.
Specifically, it is assumed that in the solution space, there are 4 particles constituting a particle group for searching for an optimal solution of a certain problem. The current positions of the particles are { s1, s2, s3 and s4}, the speed is { v1, v2, v3 and v4}, each particle is supposed to virtualize q probes in random directions from the current position before updating the speed, the size of q is determined by the problem scale and the size of the initial population, and when the problem scale is fixed, the smaller the initial population is, the larger the q is. When the ith particle is in the t iteration loop, the velocity calculation formula of the jth probe in the kth dimension is as follows:
Vj ik=ωvt ik+c1R1(Pbesti-xt ik)+c2R2(Gbest-xt ik);
the calculation formula for the position in the k dimension of the jth probe is:
Xj ik=xt ik+Vj ik;
wherein R is1=a-r1,R2=b-r2;
According to the formula, the speed of the probe initialized by the ith particle also comprises three parts, wherein the first part represents the constraint of the speed of the original particle on the probe; the second part represents the constraint of the historical optimal solution of the individual on the probe; the third part represents the population-optimal solution to probe constraints. Wherein c is1,c2Denotes the acceleration factor, r1,r2Is represented by [0,1 ]]A, b are [0,1 ]]The constant of the interval can control the probability of the probe moving back to Pbest and Gbest in the primary particle state by setting the values of a and b.
Compared with a speed updating formula in a particle swarm optimization, the initialized probe has a wider motion space, and if the fitness value of the jth probe initialized by the ith particle is better than the Pbest of the particle, the jth probe is used for replacing the particle. And finally obtaining the optimal particle swarm.
Example 2
And (5) experimental verification. In this embodiment, the optimization effect of the particle swarm optimization method incorporating reverse learning and heuristic perception in embodiment 1 is verified through an experiment.
In the experiment, CloudeSim3.3.2 is used as a cloud computing simulation platform environment. The experimental test environment is Intel (R) Core (TM) i5 Dual-Core 3.4GHz, the memory is 4GB, the operating system is windows7, and the java virtual machine is jdk1.8 version. The particle swarm optimization method (OBL-TP-PSO) integrating reverse learning and heuristic perception provided by the invention is compared and analyzed with a Min-Min algorithm, a Max-Min algorithm and a particle swarm algorithm (PSO).
Multiple parameter adjustments of PSO found that PSO can obtain a more accurate solution more quickly when w is 0.5 and c1 is c2 is 1. At this time, the parameter setting of the BL-TP-PSO algorithm is consistent with the parameter setting of the PSO algorithm, and q is 3 and a is 0.5 in the BL-TP-PSO algorithm, which means that before flying to Pbest and Gbest, each particle can randomly generate 3 probe search from the original position to find whether there is a "better solution" than the current position, wherein each probe has half of the probability of searching in a direction away from the group optimal and the individual optimal.
In the experiment, the number of tasks is set to be 100,200 and 500 respectively, the size of the tasks is random number generated from the [100,1000000] interval, the number of virtual machines is 5, and the processing capacity of the single-core processor is {100,200,300,400 and 500} respectively. Under the same conditions, each random search algorithm was run 10 times and averaged. And finally, analyzing indexes of the algorithm in the aspects of total execution time of the tasks, convergence speed and load balance.
The total execution time of task scheduling at the particle swarm size 100 is shown in table 3, where the number of tasks and the number of resources are 100 and 5, respectively.
TABLE 3 Total execution time of tasks when the number of tasks is 100
When the number of tasks is 200 and the number of resources is 5, the total execution time of task scheduling with a particle swarm size of 200 is shown in table 4.
TABLE 4 Total execution time of tasks when the number of tasks is 200
When the number of tasks is 500 and the number of resources is 5, the total execution time of task scheduling with a particle swarm size of 500 is shown in table 5.
TABLE 5 Total execution time of tasks when the number of tasks is 500
As can be seen from comparison of the experimental data in tables 3, 4 and 5, when the improved particle swarm algorithm OBL-TP-PSO solves the task scheduling problem, the obtained solution has the minimum total execution time, i.e., the solution obtained by the OBL-TP-PSO algorithm is more accurate. The reason for this is that the total execution time of the tasks in the Min-Min algorithm or the Max-Min algorithm is based on the individual, and the total completion time of the tasks is the minimum when each task is scheduled, and the total execution time of the whole task group cannot be guaranteed to be the minimum. In addition, before each particle in the OBL-TP-PSO algorithm is optimal in a 'flying direction' group, the individual optimal value existing around the particle can be searched by using a heuristic perception method, and the probe of the particle has the probability of being optimal in a back-to-group mode and the individual optimal mode, so that the algorithm can be prevented from being trapped in local optimization, and the searching capability of each particle is enhanced. Therefore, the solution of the OBL-TP-PSO method provided by the invention is more accurate.
In terms of convergence rate, when the number of tasks is 100 and the population size is 100, a comparison graph of experimental results of the PSO and OBL-TP-PSO algorithms is shown in fig. 3. When the number of tasks is 200 and the population size is 200, a comparison graph of the experimental results of the PSO algorithm and the OBL-TP-PSO algorithm is shown in FIG. 4. When the number of tasks is 500 and the population size is 500, a comparison graph of the experimental results of the PSO algorithm and the OBL-TP-PSO algorithm is shown in FIG. 5.
It is worth to be noted that the Min-Min and Max-Min algorithms have single results, and iterative loop solution is not needed, so that the convergence of the algorithms is not considered, and the convergence of the OBL-TP-PSO algorithm and the convergence of the PSO algorithm are only compared. As can be seen from a comparison of fig. 3, 4, and 5, the OBL-TP-PSO algorithm converges faster than the PSO algorithm in the early stage. Under the same condition, after the same iteration times, the total execution time of the task of the former is reduced compared with that of the latter; in the later stage, the OBL-TP-PSO algorithm has better convergence and is closer to the optimal solution. That is, in the same case, the OBL-TP-PSO algorithm is higher in quality than the PSO algorithm initializing particle group, that is, the initializing particle is optimally closer to the population, and therefore Gbest is found more easily. In addition, the heuristic awareness strategy may precede each iteration loop, and the "probe" may also search for better Gbest and then enter the next iteration loop. Then, when the iterations are the same, the obtained Gbest of the OBL-TP-PSO algorithm is better, and the convergence speed is higher.
From the viewpoint of load balance, first, the load balance LB is defined as follows in this embodiment:
according to the above formula, as the task load on the resources in the cloud computing is more balanced, the LB is larger instead. The load balance of the experiment under different task numbers is shown in fig. 6, wherein the load balance of the PSO algorithm and the OBL-TP-PSO algorithm is an average of 10 solving.
As can be seen from FIG. 6, in terms of load balancing, the Min-Min algorithm and the Max-Min algorithm are inferior, and the OBL-TP-PSO algorithm and the PSO algorithm are superior. The traditional Min-Min algorithm always preferentially distributes the small tasks to the resources with strong processing capacity for execution, so that the load of the tasks on the resources is unbalanced, and the Max-Min algorithm preferentially distributes the large tasks to the resources with strong processing capacity for execution, so that the load imbalance of the Min-Min algorithm is effectively improved. However, the tasks are distributed to the system resources according to the sizes of the tasks in a hard-growing mode, and the combination optimization among the tasks is not considered, so that the Min-Min algorithm and the Max-Min algorithm are not good in load balance degree. And when the particle swarm optimization solves the task scheduling optimization problem, a better optimal span can be found and the load is more balanced.
In conclusion, the solution obtained by the OBL-TP-PSO algorithm is more accurate than the solution obtained by Min-Min, Max-Min and PSO algorithm, and the convergence of the OBL-TP-SPO algorithm is better than that of the PSO algorithm. In addition, the OBL-TP-PSO algorithm provided by the invention is better than Min-Min and Max-Min algorithms in terms of load balance.
Example 3
Corresponding to the above method embodiments, the present embodiment provides a particle swarm optimization system incorporating reverse learning and heuristic perception, including a memory, a processor, and a computer program stored on the memory and executable on the processor, where the processor implements the steps of the above method when executing the above program.
The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention, and various modifications and changes may be made by those skilled in the art. Any modification, equivalent replacement, or improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.