Task scheduling method, device, electronic device and storage medium
By using ant colony algorithm in the cloud computing system to optimize task scheduling and combining the objective function of time cost and resource cost, the problem of poor task scheduling effect in the existing technology is solved, and the operation efficiency of the cloud computing system is improved.
Patent Information
- Application Number
- CN202010802972.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-08-11
- Publication Date
- 2024-12-31
- Estimated Expiration
- 2040-08-11
AI Technical Summary
When scheduling tasks, a single scheduling indicator leads to poor task scheduling results, thereby reducing system operation efficiency.
By determining the task completion cost of the task to be scheduled, the objective function is generated, and the ant colony algorithm is used to set parameters, optimize the task allocation results, comprehensively consider time and resource costs, and improve the utilization rate of virtual machines and task execution efficiency.
It realizes better task scheduling strategies, improves the utilization rate of server resources and task execution efficiency, and improves the overall operating performance of cloud computing systems.
Smart Images

Figure CN114077475B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of cloud computing technology, and in particular to a task scheduling method, device, electronic device and storage medium. Background Art
[0002] At present, in the implementation process of cloud computing, the task scheduling strategy determines the operating efficiency of the cloud computing system. In related technologies, when performing task scheduling, the task scheduling strategy is formulated based on a single scheduling indicator, which makes the task scheduling effect poor, thereby reducing the operating efficiency of the cloud computing system. Summary of the invention
[0003] In view of this, the embodiments of the present invention provide a task scheduling method, system, electronic device and storage medium to at least solve the problem that the task scheduling effect of related technologies is poor, thereby reducing the operating efficiency of the cloud computing system.
[0004] The technical solution of the embodiment of the present invention is achieved as follows:
[0005] An embodiment of the present invention provides a task scheduling method, including:
[0006] Determine a set of tasks to be scheduled, wherein the set of tasks to be scheduled includes at least one task to be scheduled;
[0007] Determine the task completion cost of the to-be-scheduled task set; the task completion cost includes at least time cost and resource cost;
[0008] generating an objective function according to the task completion cost;
[0009] The parameters of the ant colony algorithm are set based on the objective function and the task completion cost, and the candidate allocation result with the smallest function value of the objective function among at least two candidate allocation results corresponding to the task set to be scheduled is output as the allocation result corresponding to the task set to be scheduled by the ant colony algorithm with the parameter setting completed;
[0010] According to the allocation result corresponding to the set of tasks to be scheduled, each task to be scheduled in the set of tasks to be scheduled is respectively allocated to at least one virtual machine.
[0011] In the above solution, generating an objective function according to the task completion cost includes:
[0012] Normalizing the task completion cost;
[0013] According to the normalized task completion cost, a linear weighted sum method is used to generate an objective function; the objective function includes a first coefficient and a second coefficient; wherein the first coefficient represents the weight of the time cost, and the second coefficient represents the weight of the resource cost.
[0014] In the above solution, when the allocation result corresponding to the set of tasks to be scheduled is obtained by using the ant colony algorithm, the method further includes:
[0015] Determining a computing capability of each of the at least one virtual machine;
[0016] Determining an average computing capacity of all virtual machines in the at least one virtual machine;
[0017] Determine the pheromone initial value corresponding to at least one mapping path according to the computing power of each virtual machine in the at least one virtual machine and the average computing power; wherein,
[0018] Each mapping path in the at least one mapping path represents allocation of a task to be scheduled in the set of tasks to be scheduled to a virtual machine in the at least one virtual machine.
[0019] In the above solution, when the allocation result corresponding to the set of tasks to be scheduled is obtained by using the ant colony algorithm, the method further includes:
[0020] Determining an elapsed execution time of each of the at least one virtual machine;
[0021] Determining an average execution time of all virtual machines in the at least one virtual machine;
[0022] Determining a load balancing factor of the corresponding virtual machine according to the corresponding executed time of the corresponding virtual machine and the average execution time;
[0023] Determine a heuristic function corresponding to the virtual machine; the heuristic function includes the load balancing factor; the value of the heuristic function increases as the load balancing factor increases.
[0024] In the above solution, when the allocation result corresponding to the set of tasks to be scheduled is obtained by using the ant colony algorithm, the method further includes:
[0025] When an ant completes a solution search, the allocation result corresponding to the ant is obtained;
[0026] Determine the local pheromone concentration according to the set parameters in the ant colony algorithm and the value of the pheromone; the local pheromone concentration is the updated value of the pheromone concentration after an ant completes a solution search;
[0027] The pheromone concentration corresponding to the mapping path is updated according to the local pheromone parameter and the allocation result corresponding to the one ant.
[0028] In the above solution, when the allocation result corresponding to the set of tasks to be scheduled is obtained by using the ant colony algorithm, the method further includes:
[0029] When all ants have completed one solution search, a first allocation result is calculated according to the allocation result corresponding to each ant;
[0030] Randomly select two tasks to be scheduled from the set of tasks to be scheduled as target tasks;
[0031] When the virtual machines corresponding to the two target tasks in the first allocation result are different, exchanging the virtual machines corresponding to the two target tasks in the first allocation result to obtain a second allocation result;
[0032] When the function value of the objective function corresponding to the first matching result is greater than the function value of the objective function corresponding to the second allocation result, determining the second matching result as a global allocation result;
[0033] When the function value of the objective function corresponding to the first matching result is less than or equal to the function value of the objective function corresponding to the second allocation result, if the set rules are met, the second allocation result is determined as the global allocation result; if the set rules are not met, the first allocation result is determined as the global allocation result;
[0034] According to the maximum number of cycles set in the ant colony algorithm, the global allocation result determined by the last cycle of the ant colony algorithm is determined as the allocation result corresponding to the task set to be scheduled; wherein,
[0035] The global allocation result is the allocation result obtained after completing one cycle of the ant colony algorithm.
[0036] In the above solution, when the allocation result corresponding to the set of tasks to be scheduled is obtained by using the ant colony algorithm, the method further includes:
[0037] When one cycle of the ant colony algorithm is completed, the function value of the objective function corresponding to the global allocation result is obtained according to the corresponding global allocation result; the global allocation result is the allocation result obtained after one cycle of the ant colony algorithm is completed;
[0038] Determine the global pheromone concentration according to the function value of the objective function; the global pheromone concentration is the updated value of the pheromone concentration after completing one cycle of the ant colony algorithm;
[0039] According to the global pheromone concentration and the global allocation result, the pheromone concentration corresponding to the mapping path is updated.
[0040] The embodiment of the present invention further provides a task scheduling device, comprising:
[0041] A first determining unit, configured to determine a set of tasks to be scheduled, wherein the set of tasks to be scheduled includes at least one task to be scheduled;
[0042] A second determining unit is used to determine the task completion cost of the to-be-scheduled task set; the task completion cost at least includes time cost and resource cost;
[0043] A first generating unit, configured to generate an objective function according to the task completion cost;
[0044] A second generating unit is used to set the parameters of the ant colony algorithm based on the objective function and the task completion cost, and output the candidate allocation result with the smallest function value of the objective function among at least two candidate allocation results corresponding to the task set to be scheduled as the allocation result corresponding to the task set to be scheduled by the ant colony algorithm after completing the parameter setting;
[0045] The allocation unit is used to allocate each task to be scheduled in the set of tasks to be scheduled to at least one virtual machine according to the allocation result corresponding to the set of tasks to be scheduled.
[0046] An embodiment of the present invention further provides an electronic device, including:
[0047] a processor and a memory for storing a computer program capable of being executed on the processor,
[0048] Wherein, the processor is used to execute the steps of any of the above methods when running the computer program.
[0049] An embodiment of the present invention further provides a storage medium on which a computer program is stored. When the computer program is executed by a processor, the steps of any of the above methods are implemented.
[0050] In an embodiment of the present invention, by determining the task completion cost of each task set to be scheduled, wherein the task completion cost includes time cost and resource cost, an objective function is generated according to the task completion cost, and the parameters of the ant colony algorithm are set based on the objective function and the task completion cost. By completing the parameter setting of the ant colony algorithm, the candidate allocation result with the smallest function value of the objective function among at least two candidate allocation results corresponding to the task set to be scheduled is output as the allocation result corresponding to the task set to be scheduled. According to the allocation result corresponding to the task set to be scheduled, each task to be scheduled in the task set to be scheduled is allocated to the corresponding virtual machine. The task completion cost of the task set to be scheduled can be comprehensively considered, and a task scheduling strategy can be formulated according to the resource cost and the time cost, thereby improving the utilization rate of server resources and the efficiency of task execution. BRIEF DESCRIPTION OF THE DRAWINGS
[0051] Figure 1 A schematic diagram of an implementation flow of a task scheduling method provided in one embodiment of the present invention;
[0052] Figure 2A schematic diagram of an ant colony algorithm according to an embodiment of the present invention obtaining an allocation result corresponding to a set of tasks to be scheduled;
[0053] Figure 3 A schematic diagram of an implementation flow of a task scheduling method provided by another embodiment of the present invention;
[0054] Figure 4 A schematic diagram of an implementation flow of a task scheduling method provided by another embodiment of the present invention;
[0055] Figure 5 A schematic diagram of an implementation flow of a task scheduling method provided by another embodiment of the present invention;
[0056] Figure 6 A schematic diagram of an implementation flow of a task scheduling method provided by another embodiment of the present invention;
[0057] Figure 7 A schematic diagram of an implementation flow of a task scheduling method provided by another embodiment of the present invention;
[0058] Figure 8 A schematic diagram of determining a second allocation result provided by an embodiment of the present invention;
[0059] Fig. 9 A schematic diagram of an implementation flow of a task scheduling method provided in one embodiment of the present invention;
[0060] Fig.10 A flowchart of a task scheduling method provided by an application embodiment of the present invention;
[0061] Fig.11 A schematic diagram of the structure of a task scheduling device for an application provided by an embodiment of the present invention;
[0062] Fig.12 The figure is a schematic diagram of the hardware structure of the electronic device according to the embodiment of the present invention. DETAILED DESCRIPTION
[0063] The present invention will be further described in detail below with reference to the accompanying drawings and specific embodiments.
[0064] In the following description, specific details such as specific system structures, technologies, etc. are provided for the purpose of illustration rather than limitation, so as to provide a thorough understanding of the embodiments of the present invention. However, it should be clear to those skilled in the art that the present invention may be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, and methods are omitted to prevent unnecessary details from obstructing the description of the present invention.
[0065] It should be noted that the technical solutions described in the embodiments of the present invention can be arbitrarily combined without conflict.
[0066] Figure 1 The implementation process of the task scheduling method provided by the embodiment of the present invention is shown. Figure 1 As shown, the method includes:
[0067] S101: Determine a set of tasks to be scheduled, where the set of tasks to be scheduled includes at least one task to be scheduled.
[0068] Here, the to-be-scheduled task set is composed of at least one to-be-scheduled task, and the to-be-scheduled task refers to a task that is not assigned to a virtual machine. In practical applications, each to-be-scheduled task in the to-be-scheduled task set may be independent of each other, without any dependencies.
[0069] S102: Determine the task completion cost of the to-be-scheduled task set; the task completion cost includes at least time cost and resource cost.
[0070] Here, the task completion cost of the task set to be scheduled is determined by the attributes of the task set to be scheduled and the attributes of the virtual machine, wherein the task completion cost includes at least time cost and resource cost. Time cost refers to the time required to execute the task set to be scheduled. The attributes of the virtual machine include the computing power of a single PE of the virtual machine, the number of CPUs, the communication bandwidth and other related parameters. Resource cost refers to the resources of the virtual machine required to execute the task set to be scheduled. In practical applications, the time cost includes task execution time and task transmission time. The specific calculation process of the task execution time is: by calculating the execution time of each task to be scheduled in the task set to be scheduled, the task execution time of the task set to be scheduled is determined. Among them, the execution time of a task to be scheduled is related to the length of the code of the instruction to be executed by the task to be scheduled and the computing power of the virtual machine that executes the task to be scheduled. Specifically, it can be calculated by the formula Calculate the execution time of each task to be scheduled, where et ij represents the execution time of the scheduled task i on virtual machine j, t length_i Indicates the size of instructions that a scheduled task i needs to execute, vm comp_j represents the speed at which virtual machine j processes scheduled task i. comp_j =vm mips_j ×vm penum_j , vm mips_j Represents the computing power of a virtual machine j per unit, vm penum_j Represents the number of CPUs of a virtual machine j. Through the above calculation formula, the execution time of each task to be scheduled in the task set to be scheduled can be obtained, and the execution time of each task to be scheduled in the task set to be scheduled is represented by the matrix ET:
[0071]
[0072] Among them, the matrix et mn Indicates the execution time of the task m to be scheduled in the task set to be scheduled on the virtual machine n.
[0073] The calculation formula for the transmission time of the task to be scheduled is: Among them, er ij represents the time for the scheduled task i to be transferred to the virtual machine j, t inputfilesize_i represents the amount of data to be transferred from task i to virtual machine j, vm bw_j Represents the communication bandwidth of virtual machine j. Through the above calculation formula, the transmission time of each task to be scheduled in the task set to be scheduled can be obtained, and the transmission time of each task to be scheduled in the task set to be scheduled is represented by the matrix ER:
[0074]
[0075] Among them, the matrix er mn It indicates the transmission time of the scheduled task m in the scheduled task set to be transmitted to the virtual machine n.
[0076] Therefore, the completion time of a scheduled task can be determined by the execution time and transmission time of the scheduled task. Specifically, TaskRunTime ij =et ij +er ij , where TaskRunTime ij represents the completion time of the scheduled task i assigned to virtual machine j, et ij represents the execution time of the scheduled task i assigned to virtual machine j, et ij represents the transmission time of the scheduled task i assigned to virtual machine j. Then the completion time of virtual machine j can be obtained by the sum of the completion times of all tasks assigned to the virtual machine. The specific calculation expression is: Among them, vm completetime_j represents the completion time of virtual machine j, Indicates the sum of the completion times of all tasks assigned to the virtual machine. In practical applications, when the tasks to be scheduled in the task set to be scheduled are assigned to each virtual machine for execution, since each virtual machine executes the assigned tasks in parallel, the completion time of the task set to be scheduled is the execution time of the last virtual machine to complete the task, that is, the completion time of the task set to be scheduled can be represented by the end time of the virtual machine that finishes the task execution the latest. Specifically, the completion time of the task set to be scheduled can be expressed as: C_Time(I)=max(vm completetime_j ), j∈[1,n], where C_Time(I) is the completion time of the task set to be scheduled, max(vm completetime_j) refers to the end time of the virtual machine that finishes the task execution the latest.
[0077] The resource cost of the task set to be scheduled may include the execution cost of the task set to be scheduled on the virtual machine and the transmission cost of the task set to be scheduled to the virtual machine. The execution cost of the task to be scheduled on the virtual machine can be obtained by the execution time of the task to be scheduled on the virtual machine and the calculation cost per unit time of the virtual machine. The specific algorithm for the execution cost of the task to be scheduled is: Cost_run ij =et ij ×Cost_mips j , where Cost_run ij represents the execution cost of the scheduled task i on virtual machine j, et ij Cost_mips represents the execution time of task i on virtual machine j. j Represents the computational cost per unit time of virtual machine j. The computational cost per unit time of a virtual machine can be obtained through the properties of the virtual machine. The specific algorithm can be expressed as: Cost_mips j =Cost_per_mips×pe_num j ×pe_mips j , where Cost_per_mips represents the cost of processing single-word fixed-point instructions per second by virtual machine j, and pe_num j Indicates the number of CPUs of virtual machine j, pe_mips j Represents the computing power of a single CPU of virtual machine j. The transmission cost of a scheduled task to a virtual machine can be obtained by the transmission time of the scheduled task and the communication cost per unit time of the virtual machine. The specific algorithm can be expressed as: Cost_trans ij =er ij ×Cost_bw j , where Cost_trans ij represents the transmission cost of the scheduled task i to virtual machine j, er ij Cost_bw represents the transmission time of scheduled task i to virtual machine j. j represents the transmission communication cost per unit time of virtual machine j. The algorithm for calculating the communication cost per unit time of a virtual machine can be expressed as: Cost_bw j =Cost_per_bw×bw j , where Cost_per_bw represents the unit bandwidth cost of virtual machine j, bw j represents the communication bandwidth of virtual machine j. Therefore, the resource cost of executing a scheduled task on a virtual machine is: Cost ij=Cost_run ij +Cost_trans ij By obtaining the resource cost of each task to be scheduled on the corresponding virtual machine, the resource cost required for all virtual machines to complete the set of tasks to be scheduled can be determined. The specific calculation expression is: Total_Cost(I) is the resource cost of executing the scheduled tasks in the scheduled task set on all virtual machines. ij It is the sum of the resource costs of each task to be scheduled in the task set to be scheduled when it is executed on the corresponding virtual machine.
[0078] S103: Generate an objective function according to the task completion cost.
[0079] Here, the objective function is generated based on the task completion cost of the task set to be scheduled. The objective function contains all the task completion costs. The objective function contains weight coefficients, and the weight coefficients can be used to select the object measured by the objective function. When a weight coefficient in the objective function is zero, it means that the objective function is only used to measure the cost of one task.
[0080] S104: Setting the parameters of the ant colony algorithm based on the objective function and the task completion cost, and outputting the candidate allocation result with the smallest function value of the objective function among at least two candidate allocation results corresponding to the task set to be scheduled as the allocation result corresponding to the task set to be scheduled through the ant colony algorithm that completes the parameter setting.
[0081] Here, the allocation result of the task set to be scheduled refers to the result of allocating the task set to be scheduled to the virtual machine. The parameters of the ant colony algorithm are set based on the objective function and the task completion cost. The ant colony algorithm that completes the parameter setting outputs the candidate allocation result with the smallest function value of the objective function among at least two candidate allocation results corresponding to the task set to be scheduled as the allocation result corresponding to the task set to be scheduled, wherein the candidate allocation result refers to all allocation combinations of each task in the task set to be scheduled and different virtual machines. The ant colony algorithm is a probabilistic algorithm used to find an optimization path. When running the ant colony algorithm to find an optimization path, it is necessary to set the relevant parameters in the ant colony algorithm. The relevant parameters in the ant colony algorithm are necessary parameters for finding the optimization path through the ant colony algorithm. In practical applications, the relevant parameters include at least the initial concentration of pheromones on the mapping path between the task to be scheduled and the virtual machine, the updated concentration of pheromones, and the parameters for determining the virtual machine that matches the task to be scheduled. Thus, the ant colony algorithm that completes the parameter setting can determine the candidate allocation result with the smallest function value of the objective function among at least two candidate allocation results, and output the candidate allocation result with the smallest function value of the objective function as the allocation result corresponding to the task set to be scheduled. Figure 2 As shown, Figure 2 The schematic diagram shows the allocation result of the task set to be scheduled obtained by the ant colony algorithm. T is the task set to be scheduled, V is the virtual machine set. E is the allocation path of each task to be scheduled in the task set to be scheduled, expressed as E = {e ij |i=1,2,……,m,j=1,2,……,n},where e ij is the allocation path selected by an ant in the ant colony algorithm, indicating that task Ti is allocated to virtual machine Vj. Figure 2 As shown, the connection relationship between the task set T and the virtual machine set V represents the allocation path. For example, T1 in the task set T is allocated to Vm1 in the virtual machine set V for processing, then the mapping path between T1 and Vm1 can be expressed as e11. In practical applications, the ant colony will find an allocation result through multiple cycles of calculation, so that the function value of the objective function corresponding to this allocation result is the smallest. The minimum function value of the objective function means that the corresponding allocation result has the best load balancing effect among at least two candidate allocation results, indicating that the task completion cost required by the virtual machine when completing the task is the smallest. In practical applications, when the objective function only contains time cost, the function value of the objective function composed of time cost corresponding to the output allocation result is the smallest among all candidate allocation results. When the objective function only contains resource cost, the function value of the objective function composed of resource cost corresponding to the output allocation result is the smallest among all candidate allocation results. When the objective function contains time cost and resource cost, the function value of the objective function composed of time cost and resource cost corresponding to the output allocation result is the smallest among all candidate results.
[0082] S105: Allocate each task to be scheduled in the set of tasks to be scheduled to at least one virtual machine according to the allocation result corresponding to the set of tasks to be scheduled.
[0083] Here, after obtaining the allocation result corresponding to the task set to be scheduled, each task to be scheduled in the task set to be scheduled is allocated to the corresponding virtual machine according to the allocation result corresponding to the task set to be scheduled. In practical applications, each task to be scheduled in the task set to be scheduled has a corresponding task number, and the virtual machine also has a corresponding virtual machine number. The allocation result can be represented by combining the task number with the corresponding virtual machine number. According to the task number in the allocation result and the corresponding virtual machine number, each task to be scheduled in the task set to be scheduled can be allocated to the corresponding virtual machine, and each virtual machine can independently process the assigned task.
[0084] In the above embodiment, by obtaining the task set to be scheduled, the task completion cost of the scheduled task set is determined, the objective function is generated according to the task completion cost, and the parameters of the ant colony algorithm are set based on the objective function and the task completion cost. By completing the parameter setting of the ant colony algorithm, the candidate allocation result with the smallest function value of the objective function among at least two candidate allocation results corresponding to the task set to be scheduled is output as the allocation result corresponding to the task set to be scheduled. According to the allocation result corresponding to the task set to be scheduled, the tasks to be scheduled are allocated to the corresponding virtual machines. A scheduling strategy can be formulated according to one or more scheduling goals to obtain a better allocation result, thereby improving resource utilization and task execution efficiency.
[0085] In one embodiment, if Figure 3 As shown, the objective function is generated according to the task completion cost, including:
[0086] S301: normalizing the task completion cost.
[0087] Here, the task completion cost is normalized, and the deviation normalization method can be used to normalize the task completion cost. The conversion function of the deviation normalization method is max refers to the maximum value of the sample that needs to be normalized, and min refers to the minimum value of the sample that needs to be normalized. Specifically, according to the conversion function, the algorithm corresponding to the time cost normalization process is Among them, C_Time(I) represents a sample in the time cost without normalization, C_Time min C_Time refers to the smallest sample in the unnormalized time cost, which indicates the running time of all the tasks to be scheduled in the task set when they are run in parallel on the virtual machine with the best performance. max It refers to the largest value of the unnormalized time cost, which represents the running time of all the tasks to be scheduled in the task set when they are run in parallel on the virtual machine with the worst performance. The smallest value of the unnormalized time cost can be obtained by j∈[1,n] is calculated, where It represents the total execution time of all scheduled tasks on the virtual machine with the best performance. represents the transmission time of all scheduled tasks to the virtual machine, m represents the number of tasks, and n represents the number of virtual machines. The maximum value of the unnormalized time cost can be obtained by j∈[1,n] is calculated, where It represents the total execution time of all scheduled tasks on the virtual machine with the worst performance. The calculation expression for normalizing resource cost is: Wherein, C_Cost(I) represents the value of the resource cost after normalization, TotalCost(I) represents a value of the resource cost without normalization, and TotalCost min TotalCost refers to the value of the minimum resource cost that has not been normalized, indicating the minimum resource cost required when the scheduled tasks are executed in parallel on the virtual machine. max It refers to the value of the maximum resource cost without normalization, which indicates the maximum resource cost required when the scheduled task is executed in parallel on the virtual machine. The minimum resource cost without normalization can be calculated by the minimum execution cost and the minimum transmission cost. The specific algorithm can be expressed as: in, It represents the product of the average execution time of all scheduled tasks on the best-performing virtual machine and the minimum unit execution cost, that is, the theoretical average minimum execution cost. It represents the product of the average minimum transmission time of all tasks to be scheduled and the average minimum unit transmission cost, that is, the theoretical average minimum transmission cost of the task. The maximum value of the resource cost without normalization can be calculated by the maximum execution cost and the maximum transmission cost. The specific algorithm is: in, It represents the product of the average execution time of all scheduled tasks on the virtual machine with the worst performance and the maximum unit execution cost, that is, the theoretical average maximum execution cost. It represents the product of the maximum average transmission time of all tasks to be scheduled and the maximum unit transmission cost, that is, the theoretical maximum average transmission cost. Based on the above algorithm corresponding to the normalization of time cost and the algorithm corresponding to the normalization of resource cost, the normalization of time cost and resource cost is completed.
[0088] S302: Generate an objective function using a linear weighted sum method based on the normalized task completion cost; the objective function includes a first coefficient and a second coefficient; wherein the first coefficient represents the weight of the time cost, and the second coefficient represents the weight of the resource cost.
[0089] Here, after the normalization of the task completion cost of the task set to be scheduled is completed, the objective function can be generated according to the normalized task completion cost. In practical applications, the objective function can be constructed by the linear weighted sum method. The linear weighted sum method is an evaluation function method that assigns corresponding weight coefficients according to the importance of each goal and then optimizes the linear combination of each goal to solve the multi-objective programming problem. The objective function generated by the linear weighted sum method is L=w1Time_cf+w2C_Cost, where Time_cf represents the time cost in the objective function, C_Cost represents the resource cost in the objective function, w1 is the weight coefficient of the time cost, w2 is the weight coefficient of the resource cost, and the relationship between w1 and w2 is w1+w2=1. In practical applications, the weight coefficient of the time cost and the weight coefficient of the resource cost can be adjusted according to the actual situation. When w1=0 and w2=1, the objective function is an objective function related only to the resource cost. Then, when the ant colony algorithm is used to determine the allocation result of the task set to be scheduled, only the resource cost of the task set to be scheduled is considered as a factor. When w1=1,w2=0,the objective function is the objective function related only to time cost. When the ant colony algorithm is used to determine the allocation result of the task set to be scheduled, only the time cost of the task set to be scheduled is taken into consideration. When w1=0.5,w2=0.5,the time cost and resource cost in the objective function have the same weight. When the ant colony algorithm is used to determine the allocation result of the task set to be scheduled, the influence of the time cost and resource cost of the task set to be scheduled will be considered comprehensively. When the weight of time cost is greater than the weight of resource cost, when the ant colony algorithm is used to determine the allocation result of the task set to be scheduled, the influence of the time cost of the task set to be scheduled will be considered.
[0090] In the above embodiment, by normalizing the task completion cost of the task set to be scheduled, an objective function containing a time cost weight coefficient and a resource cost weight coefficient is generated according to the normalized task completion cost of the task set to be scheduled. The weight coefficient can be adjusted according to the needs of actual conditions to achieve flexible adjustment of the relative importance of multiple scheduling objectives, and a task scheduling strategy that is more in line with actual conditions can be formulated.
[0091] In one embodiment, if Figure 4 As shown, when the allocation result corresponding to the task set to be scheduled is obtained by using the ant colony algorithm, the method further includes:
[0092] S401: Determine the computing capability of each virtual machine in the at least one virtual machine.
[0093] Here, the computing capability of each virtual machine in the at least one virtual machine is determined by determining the attributes of the virtual machine.
[0094] S402: Determine the average computing capacity of all virtual machines in the at least one virtual machine.
[0095] Here, by determining the computing power of each virtual machine in at least one virtual machine and obtaining the number of virtual machines, the average computing power of all virtual machines in at least one virtual machine can be determined. The specific calculation expression is: Among them, vm avgcomp represents the average computing power, It represents the sum of the computing capabilities of all virtual machines, and n represents the number of virtual machines.
[0096] S403: Determine the pheromone initial value corresponding to at least one mapping path according to the computing power of each virtual machine in the at least one virtual machine and the average computing power; wherein,
[0097] Each mapping path in the at least one mapping path represents allocation of a task to be scheduled in the set of tasks to be scheduled to a virtual machine in the at least one virtual machine.
[0098] Here, the pheromone initial value corresponding to at least one mapping path is determined according to the computing power and average computing power of each virtual machine in at least one virtual machine. Determine the initial pheromone value of at least one mapping path, where τ0 represents the initial pheromone value on a mapping path, vm comp_j Indicates the computing power of the corresponding virtual machine, vm avgcomp Represents the average computing power in the above text. According to the above formula, the pheromone initial value corresponding to at least one mapping path can be determined, wherein a mapping path refers to allocating a task to be scheduled in the task set to be scheduled to a virtual machine in at least one virtual machine, that is, an allocation path for allocating a task to be scheduled to a virtual machine. In practical applications, the pheromone initial value obtained by the ratio of the computing power of a virtual machine to the average computing power of a virtual machine will not be too large or too small, so that the pheromone initial value will not be too small to be conducive to the early search of the ant colony algorithm, nor will it cause the pheromone initial value to be too large, causing the ant colony algorithm to cause drastic changes in pheromone concentration in the subsequent search process.
[0099] In the above embodiment, by determining the computing power of each virtual machine in at least one virtual machine and determining the average computing power, the initial value of the pheromone on at least one mapping path is determined according to the computing power of at least one virtual machine and the average computing power. According to the properties of each virtual machine, the pheromone initialization on different mapping paths can be appropriately performed, so that the search of the ant colony algorithm in the initial stage can be guided by certain distinctions to obtain more accurate allocation results.
[0100] In one embodiment, if Figure 5 As shown, when the allocation result corresponding to the task set to be scheduled is obtained by using the ant colony algorithm, the method further includes:
[0101] S501: Determine the elapsed execution time of each virtual machine in the at least one virtual machine.
[0102] Here, the main work of the virtual machine is to execute the tasks assigned to the virtual machine. The execution time of each virtual machine in at least one virtual machine refers to the time from the start of the task execution to the current time, that is, the working time of the virtual machine.
[0103] S502: Determine the average execution time of all virtual machines in the at least one virtual machine.
[0104] Here, the elapsed execution time of each virtual machine in the at least one virtual machine is determined, and the number of virtual machines is determined, so that the average execution time of each virtual machine in the at least one virtual machine can be determined.
[0105] S503: Determine a load balancing factor of the corresponding virtual machine according to the corresponding executed time and the average execution time.
[0106] Here, the load factor of a virtual machine can be determined based on the executed time and average execution time of the virtual machine. Specifically, the load factor of the virtual machine is: Among them, E j is the elapsed execution time of a virtual machine j, E avg The average execution time of all virtual machines.
[0107] S504: Determine a heuristic function corresponding to the virtual machine; the heuristic function includes the load balancing factor; the value of the heuristic function increases as the load balancing factor increases.
[0108] Here, after determining the load balancing factor, the heuristic function is determined, wherein the heuristic function can represent the probability of a task to be scheduled in the set of tasks to be scheduled being executed on a virtual machine. The heuristic function can be determined based on the load balancing factor and the execution time of a task to be scheduled on a virtual machine. Here, the heuristic function is: Among them, Load j Indicates the load balancing factor of the virtual machine, et ij represents the execution time of the scheduled task i on virtual machine j. According to the heuristic function, we know that without considering Load j , when et ij The smaller η is, the ijThe larger the value, the greater the probability that the task to be scheduled will be executed on the current virtual machine. The influence of the load balancing factor of the virtual machine on the heuristic function is as follows: when the E in the load balancing factor of virtual machine j is j When the load is large, j The corresponding value will be relatively small, indicating that the load of the virtual machine j is large and the execution time is long, then η ij The corresponding value is relatively small, and the probability of the scheduled task being executed on virtual machine j is relatively small. Similarly, when E in the load balancing factor of virtual machine j is j When the load is small, j The corresponding value will be relatively large, indicating that the load of the virtual machine j is small and the execution time is short, so η ij The corresponding value is relatively large, and the probability of the task to be scheduled being executed on virtual machine j is relatively high.
[0109] In the above embodiment, the executed time and the average execution time of at least one virtual machine are determined, and the load balancing factor of the virtual machine is determined based on the executed time and the average execution time of at least one virtual machine. The heuristic function containing the load balancing factor is determined, which can realize dynamic adjustment of the load of the virtual machine, thereby better performing task scheduling.
[0110] In one embodiment, if Figure 6 As shown, when the allocation result corresponding to the task set to be scheduled is obtained by using the ant colony algorithm, the method further includes:
[0111] S601: When an ant completes a solution search, an allocation result corresponding to the ant is obtained.
[0112] Here, the ant colony algorithm is to search for solutions through multiple ants. When an ant completes a search, it can determine a corresponding allocation result. The search process of an ant mainly includes calculating the allocation probability of each task in the task set to be scheduled to each virtual machine, and determining the allocation result corresponding to an ant according to the allocation probability. In practical applications, the probability of the current task being assigned to each virtual machine in at least one virtual machine is mainly calculated by the pseudo-random probability transfer formula. The specific expression of the pseudo-random probability transfer formula is:
[0113]
[0114] Where q0 is a set parameter whose value range is (0, 1), and q is a random number in the value range [0, 1]. When an ant selects a virtual machine for a task to be scheduled, it first generates a random number q and compares the random number q with the set parameter q0. If q≤q0, then the probability of an ant assigning a task to be scheduled to each virtual machine is calculated. Where α represents the pheromone heuristic factor, β represents the expected heuristic factor, and τ iS (t) represents the pheromone concentration on the mapping path between the task to be scheduled and a virtual machine at time t, η iS represents the heuristic function of the virtual machine. According to the above parameters, the probability of an ant allocating a task to be scheduled to each virtual machine in at least one virtual machine is calculated when q≤q0. When q>q0 occurs, the probability of an ant allocating a task to be scheduled to each virtual machine in at least one virtual machine is S, where the specific arithmetic expression of S is:
[0115]
[0116] Among them, τ ij (t) represents the pheromone concentration on the mapping path between the scheduled task i and the virtual machine j at time t, η ij Represents the heuristic function of virtual machine j. According to the above parameters, the probability S of an ant assigning a task to be scheduled to each virtual machine in at least one virtual machine is calculated. In practical applications, the value of q0 can be set according to the actual needs. After obtaining the allocation probability, the roulette method is used to select the virtual machine to be assigned for a task to be scheduled. The specific process is that a roulette wheel is divided into n sectors, one sector corresponds to a virtual machine, and the area of the sector is determined according to the allocation probability calculated by an ant through a pseudo-random probability transfer rule. The larger the value of the allocation probability, the larger the corresponding sector area on the roulette wheel, that is, the larger the allocation probability, the greater the probability of the virtual machine being assigned to the task to be scheduled. After determining the area of each sector on the roulette wheel, rotate the roulette wheel. When the roulette wheel stops rotating, the sector where the roulette wheel pointer stops represents the virtual machine assigned to the task to be scheduled. The allocation probability corresponding to each task in the task set to be scheduled is obtained by an ant, and the roulette method is used to finally determine the virtual machine corresponding to each task in the task set to be scheduled, so as to obtain the allocation result corresponding to an ant.
[0117] S602: Determine the local pheromone concentration according to the set parameters in the ant colony algorithm and the value of the pheromone; the local pheromone concentration is an updated value of the pheromone concentration after an ant completes a solution search.
[0118] Here, when an ant completes a solution search, that is, when the distribution result corresponding to an ant is obtained, the local pheromone concentration needs to be re-determined. The local pheromone concentration update rule is mainly related to the current residual pheromone concentration and the increased pheromone concentration. According to the pheromone value and the signal setting parameters in the ant colony algorithm, the local pheromone concentration can be obtained. The local pheromone concentration update rule is: τ ij (t+1)=(1-ρ)τ ij (t)+ρΔτ ij (t), where ρ ranges from (0,1], representing the pheromone volatility factor, (1-ρ) ranges from (0,1], representing the residual degree of pheromone, ρ is the setting parameter in the ant colony algorithm, Δτ ij (t) represents the increase in pheromone concentration on the mapping path between the scheduled task i and the virtual machine j at time t. The increase in local pheromone concentration is calculated by the following formula:
[0119]
[0120] Among them, L represents the function value of the objective function of the distribution result corresponding to an ant, T k (t) represents the kth ant seeking a solution in the tth ant colony algorithm cycle, which is mainly used to determine whether the ant is in the cycle of the ant colony algorithm. When the ant is not in the cycle of the ant colony algorithm, the increase in pheromone concentration is zero. According to the arithmetic expression of the increase in pheromone concentration, it can be known that when the function value of the objective function is larger, the increase in pheromone concentration is smaller. Conversely, when the function value of the objective function is smaller, the increase in pheromone concentration is larger. Among them, the smaller the function value of the objective function is, the corresponding allocation result is a better allocation result, thereby increasing the probability of the better allocation result being selected. According to the arithmetic expression of the increase in pheromone concentration and the local pheromone update rule, the local pheromone concentration can be calculated.
[0121] S603: updating the pheromone concentration corresponding to the mapping path according to the local pheromone concentration and the allocation result corresponding to the one ant.
[0122] Here, after determining the local pheromone concentration, the corresponding pheromone concentration is updated according to the determined local pheromone concentration and the allocation result corresponding to an ant. The allocation result corresponding to an ant indicates the allocation of tasks to be scheduled and virtual machines. Through the mapping path, a task to be scheduled is allocated to a virtual machine. Therefore, when updating the pheromone concentration, the corresponding mapping path is obtained according to the allocation result corresponding to an ant, the pheromone concentration on the mapping path is updated, and the pheromone concentration on the mapping path is set as the local pheromone concentration.
[0123] In the above embodiment, by obtaining the allocation result corresponding to an ant, determining the local pheromone concentration according to the pheromone setting parameters and pheromone values in the ant colony algorithm, and updating the pheromone concentration on the mapping path in the allocation result, the phenomenon of excessively large differences in pheromone concentrations on different mapping paths can be avoided, thereby increasing the probability of the ant colony algorithm finding a better allocation plan.
[0124] In one embodiment, if Figure 7 As shown, when the allocation result corresponding to the task set to be scheduled is obtained by using the ant colony algorithm, the method further includes:
[0125] S701: When all ants have completed one solution search, a first allocation result is calculated according to the allocation result corresponding to each ant.
[0126] Here, when all ants complete a solution search, that is, complete an ant colony algorithm cycle, the first allocation result is calculated according to the allocation result corresponding to each ant, wherein the function value of the objective function of the first allocation result is the minimum function value of the objective function among the allocation results corresponding to all ants.
[0127] S702: Randomly select two tasks to be scheduled from the set of tasks to be scheduled as target tasks.
[0128] Here, after the first allocation result is determined, two tasks to be scheduled are randomly selected from the set of tasks to be scheduled, and the two tasks to be scheduled are used as target tasks.
[0129] S703: When the virtual machines corresponding to the two target tasks in the first allocation result are different, the virtual machines corresponding to the two target tasks in the first allocation result are exchanged to obtain a second allocation result.
[0130] Here, after determining the first allocation result and the target task, it is determined whether the virtual machines corresponding to the two target tasks are the same according to the first allocation result. Figure 8 As shown, Figure 8A schematic diagram for determining the second allocation result is shown. The first task T1 and the second task T2 are selected from the task set T as target tasks. The virtual machine corresponding to the first task and the virtual machine corresponding to the second task are searched from the first allocation result. When the virtual machine corresponding to the first task is Vm1 and the virtual machine corresponding to the second task is Vm2, it can be determined that the virtual machine corresponding to the first task and the virtual machine corresponding to the second task are different, and the virtual machine corresponding to the first task is exchanged with the virtual machine corresponding to the second task. That is to say, after the exchange, the virtual machine corresponding to the first task is Vm2, and the virtual machine corresponding to the second task is Vm1, and the second allocation result is obtained. The virtual machine corresponding to the target task in the first allocation result is different from the virtual machine corresponding to the second allocation result, and the virtual machine corresponding to any other task to be scheduled in the first allocation result and the second allocation result is the same.
[0131] S704: When the function value of the objective function corresponding to the first allocation result is greater than the function value of the objective function corresponding to the second allocation result, the second matching result is determined as a global allocation result.
[0132] Here, the function value of the objective function corresponding to the first allocation result is calculated and compared with the function value of the objective function corresponding to the second allocation result. If the function value of the objective function corresponding to the first allocation result is greater than the function value of the objective function corresponding to the second allocation result, it means that when the scheduling task set is allocated according to the second allocation result, the load balancing effect of the virtual machine is better. Then the second allocation result is determined as the global allocation result. The global allocation result can be regarded as the allocation result obtained after completing an ant colony algorithm cycle.
[0133] S705: When the function value of the objective function corresponding to the first matching result is less than or equal to the function value of the objective function corresponding to the second allocation result, determine whether the second allocation result is a global allocation result according to a preset rule.
[0134] Here, when the function value of the objective function corresponding to the first matching result is less than or equal to the function value of the objective function corresponding to the second allocation result, it is determined according to the preset rules whether to accept the second allocation result as a global allocation result. In practical applications, the Metropolis criterion can be used to determine whether the second allocation result is a global allocation result. Before making a Metropolis criterion judgment, it is also necessary to obtain the current temperature T. Temperature T is a calculation parameter in the Metropolis criterion. When the current temperature T is less than Tmin, the Metropolis criterion cannot be used for judgment. In practical applications, when the current temperature T is less than Tmin, the second matching result is determined as a global allocation result. When the current temperature T is greater than Tmin, the Metropolis criterion can be used for judgment, where Tmin is a preset value. In practical applications, Tmin can be set to 10. The current temperature T can be calculated by T(t+1)=cT(t), where c is a constant, which is generally set to 0.995 in practical applications. The initialization temperature is T0, which can be set to 1000. The Metropolis criterion mainly determines whether the second allocation result is a global allocation result by probability. The specific algorithm is Where p represents the probability that the second allocation result is the global allocation result, exp represents the natural exponent, and T represents the current temperature. The ΔT in the formula can be expressed by ΔT = T n -L′ best Calculated, where Tn is the function value of the objective function corresponding to the second allocation result, L′ best is the function value of the objective function corresponding to the first allocation result. Through the calculation formula of the Metropolis criterion, the probability P that the second allocation result is the global allocation result can be obtained. After the probability P is obtained, a uniformly distributed random number is generated from the set [0, 1]. When the probability value P is greater than the random number, the second allocation result is the global allocation result. If the probability value P is less than the condition of the random number, the second allocation result is not the global allocation result, and the first allocation result is determined as the global allocation result.
[0135] S706: According to the maximum number of cycles set in the ant colony algorithm, the global allocation result determined by the last cycle of the ant colony algorithm is determined as the allocation result corresponding to the task set to be scheduled; wherein,
[0136] The global allocation result is the allocation result obtained after completing one cycle of the ant colony algorithm.
[0137] Here, after determining the global allocation result corresponding to each cycle of the ant colony algorithm, according to the maximum number of cycles set in the ant colony algorithm, it is determined whether the maximum number of cycles set has been completed. If the required number of cycles of the ant colony algorithm has been completed, the global allocation result determined by the last cycle of the ant colony algorithm is output as the allocation result corresponding to the task set to be scheduled. In the ant colony algorithm, in the same time, the number of times the ants walk on the shorter path will be more than the number of times they walk on the longer path, so the pheromone concentration left on the shorter path will be higher than the pheromone concentration on other paths. Through multiple cycles of all ants to find solutions, the result obtained in the last cycle is the final allocation result. Therefore, when scheduling tasks through the ant colony algorithm, the shorter path in the ant colony algorithm is equivalent to a better task scheduling strategy, and the longer path is equivalent to a poor task scheduling strategy. Therefore, the global allocation result obtained by the last cycle of the ant colony algorithm is actually the final allocation result, so the global allocation result obtained by the last ant colony algorithm can be output as the allocation result corresponding to the task set to be scheduled.
[0138] In the above embodiment, a first allocation result is calculated according to the allocation result corresponding to each ant, and two target tasks are arbitrarily selected from the set of tasks to be scheduled. When the virtual machines corresponding to the two target tasks in the first allocation result are different, the virtual machines corresponding to the two target tasks are exchanged in the first allocation result to obtain a second allocation result. The global allocation result is determined by comparing the function value of the objective function of the first allocation with the function value of the objective function of the second allocation result. According to the set maximum number of loops, the allocation result is output after the loop ends. By making certain disturbances to the first allocation result, the ant colony algorithm can be prevented from falling into a local solution, which is conducive to the ant colony algorithm to seek more allocation results and improves the scientific nature of the allocation result.
[0139] In one embodiment, if Fig. 9 As shown, when the allocation result corresponding to the task set to be scheduled is obtained by using the ant colony algorithm, the method further includes:
[0140] S901: when one cycle of the ant colony algorithm is completed, according to the global allocation result determined by the one cycle of the ant colony algorithm, a function value of the objective function corresponding to the global allocation result is obtained.
[0141] Here, after completing one ant colony algorithm cycle, that is, obtaining the global allocation result corresponding to one ant colony algorithm cycle, the function value of the objective function of the global allocation result corresponding to the ant colony algorithm cycle is obtained.
[0142] S902: Determine the global pheromone concentration according to the function value of the objective function; the global pheromone concentration is an updated value of the pheromone concentration after completing one cycle of the ant colony algorithm.
[0143] Here, after obtaining the function value of the objective function of the global allocation result corresponding to an ant colony algorithm cycle, the global pheromone concentration is determined according to the function value of the objective function. The global pheromone concentration update rule is mainly related to the pheromone setting parameters in the ant colony algorithm and the function value of the objective function of the global allocation result. According to the pheromone value, the setting parameters in the ant colony algorithm and the function value of the objective function of the global allocation result, the global pheromone concentration can be obtained. The update rule of the global pheromone concentration is: τ ij (t+1)=(1-ρ1)τ ij (t)+ρ1Δτ ij (t), where ρ1 is a parameter with a value range of (0,1), which refers to the pheromone volatility factor, indicating the degree of pheromone volatility per unit time, and 1-ρ1 indicates the residual degree of pheromone. The larger ρ1 is, the faster the pheromone evaporates. ρ1 is a setting parameter in the ant colony algorithm, and the value of ρ1 can be the same as ρ. Δτ ij (t) represents the increase in pheromone concentration on the mapping path between the task i to be scheduled and the virtual machine j at time t.
[0144] The increase in global pheromone concentration is:
[0145]
[0146] Among them, L best It refers to the function value of the objective function of the global allocation result. According to the update rule of the global pheromone concentration, the size of the global pheromone concentration after completing an ant colony algorithm cycle can be obtained.
[0147] S903: According to the global pheromone concentration and the global allocation result, update the information concentration on the mapping path between each task to be scheduled and the corresponding virtual machine.
[0148] Here, after determining the size of the global pheromone concentration, the corresponding pheromone concentration on the mapping path is updated according to the global allocation result. The pheromone concentration on the mapping path can be updated by obtaining the global allocation result and according to the mapping path recorded in the global allocation result, and the pheromone concentration on the mapping path is set to the global pheromone concentration. Since the updated pheromone concentration is the mapping path corresponding to the global allocation result, the global allocation result represents the mapping path with better load balancing effect, and the mapping path outside the global allocation result represents the mapping path with general load balancing effect, then the difference between the pheromone concentration on the mapping path corresponding to the global allocation result and the pheromone concentration on other mapping paths will be increased, making ants more inclined to choose mapping paths with high pheromone concentrations, resulting in the ants' solution search being able to be concentrated near the mapping path with better load balancing effect, thereby improving the solution search efficiency of the ant colony algorithm.
[0149] In the above embodiment, by obtaining the global allocation result determined by an ant colony algorithm cycle, obtaining the function value of the objective function corresponding to the global allocation result, determining the global pheromone concentration according to the function value of the objective function, and updating the pheromone concentration on the mapping path between each task to be scheduled and the corresponding virtual machine according to the global allocation result, it is beneficial to guide the solution-finding of the ant colony algorithm when performing multiple ant colony algorithm cycles, improve the solution-finding efficiency of the ant colony algorithm, and efficiently obtain the allocation result.
[0150] The present invention also provides application examples, such as Fig.10 As shown, Fig.10 A flowchart of a task scheduling method is shown.
[0151] S1001: Initialize the relevant parameters of the ant colony algorithm, including the initial value of pheromone, pheromone heuristic factor, expected heuristic factor, volatility factor, number of ants, q0 in pseudo-random transition probability, the first coefficient and the second coefficient of the objective function, and the maximum number of cycles.
[0152] S1002: Obtain the serial number of the ant currently searching for a solution. When the ant colony algorithm is performed, multiple ants are used to search for a solution, and the solutions of the multiple ants are combined to obtain the final result. Therefore, it is necessary to obtain the serial number of the ant currently searching for a solution.
[0153] S1003: Randomly generate q. Before each ant searches for a solution, it randomly generates a value q, where the value range of q is (0, 1).
[0154] S1004: Determine whether q≤q0 is established. If q≤q0 is established, go to S10041; if q≤q0 is not established, go to S10042.
[0155] S10041: Allocate according to the first preset rule. Here, the first preset rule means that an ant The probability of each task to be scheduled in the task set to be scheduled being assigned to at least one virtual machine is calculated, and a corresponding virtual machine is selected for each task to be scheduled in the task set to be scheduled according to the calculated allocation probability.
[0156] S10042: Allocate according to the second preset rule. Here, the second preset rule means that an ant The probability of each task to be scheduled in the task set to be scheduled being assigned to at least one virtual machine is calculated, and a corresponding virtual machine is selected for each task to be scheduled in the task set to be scheduled according to the calculated allocation probability.
[0157] S1005: Determine whether all the tasks to be scheduled have been assigned. If all the tasks to be scheduled in the task set to be scheduled have not been assigned, go to S1003. If all the tasks to be scheduled in the task set to be scheduled have been assigned, go to S1006.
[0158] S1006: Record the allocation result corresponding to an ant.
[0159] S1007: Update local pheromone concentration. Here, after an ant has completed the allocation of each task to be scheduled in the task set to be scheduled, the local pheromone concentration is updated according to the local pheromone concentration update rule.
[0160] S1008: Determine whether the current ant number is greater than or equal to the number of ants. When the current ant number is less than the number of ants, go to S1002. When the current ant number is greater than or equal to the number of ants, go to S1009. Here, by comparing the current ant number with the number of ants, it is to determine whether all ants have completed the solution.
[0161] S1009: Calculate a first allocation result. Here, the first allocation result is determined according to a cycle of the ant colony algorithm.
[0162] S1010: Randomly generate a second allocation result. Here, two tasks to be scheduled are randomly selected from the set of tasks to be scheduled, and the virtual machines corresponding to the two selected tasks to be scheduled are determined according to the global matching result. When the virtual machines corresponding to the two selected tasks to be scheduled are different, the virtual machines corresponding to the two selected tasks to be scheduled are exchanged based on the global matching result to obtain a new global matching result.
[0163] S1011: Determine whether the function value of the objective function of the second allocation result is greater than that of the first allocation result. When the function value of the objective function of the second allocation result is greater than that of the first allocation result, go to S10111. When the function value of the objective function of the second allocation result is less than or equal to that of the first allocation result, go to S10112.
[0164] S10111: Determine the second allocation result as the global allocation result.
[0165] S10112: Determine whether the second allocation result is the global allocation result according to the Metropolis criterion.
[0166] S1012: Determine whether T is less than Tmin. When T is less than Tmin, go to S1013. When T is greater than or equal to Tmin, go to S1010. Here, T < Tmin is the condition for ending the loop of determining the global allocation. Among them, T is a calculation variable in the Metropolis criterion, representing the current temperature, and Tmin is a parameter in the Metropolis criterion. Here, after determining whether the second allocation result is the global allocation result, a new round of experiments is carried out to obtain a better allocation result.
[0167] S1013: Update the global pheromone concentration. Here, when a cycle of the ant colony algorithm is completed, the global pheromone concentration is updated according to the global pheromone concentration update rule.
[0168] S1014: Determine the current number of cycles.
[0169] S1015: Determine whether the current number of cycles is greater than the maximum number of cycles. When the current number of cycles is greater than the maximum number of cycles, go to S1016. When the current number of cycles is less than the maximum number of cycles, go to S1002.
[0170] S1016: Output the allocation result.
[0171] To implement the task scheduling method of the embodiments of the present invention, the embodiments of the present invention also provide a task scheduling device, as Fig.11 shown. The task scheduling device includes:
[0172] The first determination unit 1101 is used to determine the set of tasks to be scheduled, and the set of tasks to be scheduled includes at least one task to be scheduled;
[0173] The second determination unit 1102 is used to determine the task completion cost of the set of tasks to be scheduled; the task completion cost at least includes time cost and resource cost;
[0174] A first generating unit 1103 is used to generate an objective function according to the task completion cost;
[0175] The second generating unit 1104 is used to set the parameters of the ant colony algorithm based on the objective function and the task completion cost, and output the candidate allocation result with the smallest function value of the objective function among at least two candidate allocation results corresponding to the task set to be scheduled as the allocation result corresponding to the task set to be scheduled by the ant colony algorithm after completing the parameter setting;
[0176] The allocating unit 1105 is configured to allocate each task to be scheduled in the set of tasks to be scheduled to at least one virtual machine according to the allocation result corresponding to the set of tasks to be scheduled.
[0177] In one embodiment, the first generating unit generates an objective function according to the task completion cost, including:
[0178] Normalizing the task completion cost;
[0179] According to the normalized task completion cost, a linear weighted sum method is used to generate an objective function; the objective function includes a first coefficient and a second coefficient; wherein the first coefficient represents the weight of the time cost, and the second coefficient represents the weight of the resource cost.
[0180] In one embodiment, when the second generation unit obtains the allocation result corresponding to the to-be-scheduled task set by using an ant colony algorithm, it also includes:
[0181] Determining a computing capability of each of the at least one virtual machine;
[0182] Determining an average computing capacity of all virtual machines in the at least one virtual machine;
[0183] Determine the pheromone initial value corresponding to at least one mapping path according to the computing power of each virtual machine in the at least one virtual machine and the average computing power; wherein,
[0184] Each mapping path in the at least one mapping path represents allocation of a task to be scheduled in the set of tasks to be scheduled to a virtual machine in the at least one virtual machine.
[0185] In one embodiment, when the second generation unit obtains the allocation result corresponding to the to-be-scheduled task set by using an ant colony algorithm, it also includes:
[0186] Determining an elapsed execution time of each of the at least one virtual machine;
[0187] Determining an average execution time of all virtual machines in the at least one virtual machine;
[0188] Determine a load balancing factor of a corresponding virtual machine according to the corresponding executed time and the average execution time;
[0189] Determine a heuristic function corresponding to the virtual machine; the heuristic function includes the load balancing factor; the value of the heuristic function decreases as the load balancing factor increases.
[0190] In one embodiment, when the second generation unit obtains the allocation result corresponding to the to-be-scheduled task set by using an ant colony algorithm, it also includes:
[0191] When an ant completes a solution search, the allocation result corresponding to the ant is obtained;
[0192] Determine the local pheromone concentration according to the set parameters in the ant colony algorithm and the value of the pheromone; the local pheromone concentration is the updated value of the pheromone concentration after an ant completes a solution search;
[0193] The pheromone concentration corresponding to the mapping path is updated according to the local pheromone concentration and the allocation result corresponding to the one ant.
[0194] In one embodiment, when the second generation unit obtains the allocation result corresponding to the to-be-scheduled task set by using an ant colony algorithm, it also includes:
[0195] When all ants have completed one solution search, a first allocation result is calculated according to the allocation result corresponding to each ant;
[0196] Randomly select two tasks to be scheduled from the set of tasks to be scheduled as target tasks;
[0197] When the virtual machines corresponding to the two target tasks in the first allocation result are different, exchanging the virtual machines corresponding to the two target tasks in the first allocation result to obtain a second allocation result;
[0198] When the function value of the objective function corresponding to the first matching result is greater than the function value of the objective function corresponding to the second allocation result, determining the second matching result as a global allocation result;
[0199] When the function value of the objective function corresponding to the first matching result is less than or equal to the function value of the objective function corresponding to the second allocation result, if the set rules are met, the second allocation result is determined as the global allocation result; if the set rules are not met, the first allocation result is determined as the global allocation result;
[0200] According to the maximum number of cycles set in the ant colony algorithm, the global allocation result determined by the last cycle of the ant colony algorithm is determined as the allocation result corresponding to the task set to be scheduled; wherein,
[0201] The global allocation result is the allocation result obtained after completing one cycle of the ant colony algorithm.
[0202] In one embodiment, when the second generation unit obtains the allocation result corresponding to the to-be-scheduled task set by using an ant colony algorithm, it also includes:
[0203] When one cycle of the ant colony algorithm is completed, the function value of the objective function corresponding to the global allocation result is obtained according to the corresponding global allocation result; the global allocation result is the allocation result obtained after one cycle of the ant colony algorithm is completed;
[0204] Determine the global pheromone concentration according to the function value of the objective function; the global pheromone concentration is the updated value of the pheromone concentration after completing one cycle of the ant colony algorithm;
[0205] According to the global pheromone concentration and the global allocation result, the pheromone concentration on the mapping path between each task to be scheduled and the corresponding virtual machine is updated. Based on the hardware implementation of the above program module, and in order to implement the method of the embodiment of the present invention, the embodiment of the present invention also provides an electronic device, Fig.12 FIG. 1 is a schematic diagram of the hardware structure of an electronic device according to an embodiment of the present invention. Fig.12 As shown, the electronic equipment includes:
[0206] Communication interface 1, capable of exchanging information with other devices such as network devices;
[0207] The processor 2 is connected to the communication interface 1 to implement information exchange with other devices and is used to execute the task scheduling method provided by one or more technical solutions when running a computer program. The computer program is stored in the memory 3.
[0208] Of course, in actual application, the various components in the electronic device are coupled together through the bus system 4. It can be understood that the bus system 4 is used to realize the connection and communication between these components. In addition to the data bus, the bus system 4 also includes a power bus, a control bus and a status signal bus. However, for the sake of clarity, Fig.12 Various buses are labeled as bus system 4.
[0209] The memory 3 in the embodiment of the present invention is used to store various types of data to support the operation of the electronic device. Examples of such data include: any computer program used to operate on the electronic device.
[0210] It can be understood that the memory 3 can be a volatile memory or a non-volatile memory, and can also include both volatile and non-volatile memories. Among them, the non-volatile memory can be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), a magnetic random access memory (FRAM), a flash memory, a magnetic surface memory, an optical disc, or a compact disc read-only memory (CD-ROM); the magnetic surface memory can be a disk memory or a tape memory. The volatile memory can be a random access memory (RAM), which is used as an external cache. By way of example and not limitation, many forms of RAM are available, such as static random access memory (SRAM), synchronous static random access memory (SSRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDRSDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous link dynamic random access memory (SLDRAM, SyncLink Dynamic Random Access Memory), and direct RAM bus random access memory (DRRAM, Direct Rambus Random Access Memory).The memory 2 described in the embodiments of the present invention is intended to include but is not limited to these and any other suitable types of memories.
[0211] The method disclosed in the above embodiment of the present invention can be applied to the processor 2, or implemented by the processor 2. The processor 2 may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by the hardware integrated logic circuit in the processor 2 or the instruction in the form of software. The above processor 2 can be a general-purpose processor, a DSP, or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components, etc. The processor 2 can implement or execute the methods, steps and logic block diagrams disclosed in the embodiment of the present invention. The general-purpose processor can be a microprocessor or any conventional processor, etc. In combination with the steps of the method disclosed in the embodiment of the present invention, it can be directly embodied as a hardware decoding processor to execute, or it can be executed by a combination of hardware and software modules in the decoding processor. The software module can be located in a storage medium, which is located in the memory 3. The processor 2 reads the program in the memory 3 and completes the steps of the above method in combination with its hardware.
[0212] When the processor 2 executes the program, the corresponding processes in the various methods of the embodiments of the present invention are implemented, which will not be described here for the sake of brevity.
[0213] In an exemplary embodiment, the embodiment of the present invention further provides a storage medium, namely a computer storage medium, specifically a computer readable storage medium, for example, including a memory 3 storing a computer program, and the above-mentioned computer program can be executed by a processor 2 to complete the steps of the above-mentioned method. The computer readable storage medium can be a memory such as FRAM, ROM, PROM, EPROM, EEPROM, Flash Memory, magnetic surface storage, optical disk, or CD-ROM.
[0214] In the several embodiments provided in the present application, it should be understood that the disclosed devices, terminals and methods can be implemented in other ways. The device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as: multiple units or components can be combined, or can be integrated into another system, or some features can be ignored or not executed. In addition, the coupling, direct coupling, or communication connection between the components shown or discussed can be through some interfaces, and the indirect coupling or communication connection of the devices or units can be electrical, mechanical or other forms.
[0215] The units described above as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units; some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.
[0216] In addition, all functional units in the embodiments of the present invention may be integrated into one processing unit, or each unit may be separately used as a unit, or two or more units may be integrated into one unit; the above-mentioned integrated units may be implemented in the form of hardware or in the form of hardware plus software functional units.
[0217] A person of ordinary skill in the art can understand that: all or part of the steps of implementing the above-mentioned method embodiment can be completed by hardware related to program instructions, and the aforementioned program can be stored in a computer-readable storage medium, which, when executed, executes the steps of the above-mentioned method embodiment; and the aforementioned storage medium includes: various media that can store program codes, such as mobile storage devices, ROM, RAM, disks or optical disks.
[0218] Alternatively, if the above-mentioned integrated unit of the present invention is implemented in the form of a software function module and sold or used as an independent product, it can also be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the embodiment of the present invention can be essentially or partly reflected in the form of a software product that contributes to the prior art. The computer software product is stored in a storage medium and includes several instructions for an electronic device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the methods described in each embodiment of the present invention. The aforementioned storage medium includes: various media that can store program codes, such as mobile storage devices, ROM, RAM, magnetic disks or optical disks.
[0219] The above is only a specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any person skilled in the art can easily think of changes or substitutions within the technical scope disclosed by the present invention, which should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention should be based on the protection scope of the claims.
Claims
1. A task scheduling method, characterized in that: include: Determine a set of tasks to be scheduled, wherein the set of tasks to be scheduled includes at least one task to be scheduled; Determine the task completion cost of the set of tasks to be scheduled; The task completion cost includes at least time cost and resource cost; generating an objective function according to the task completion cost; The parameters of the ant colony algorithm are set based on the objective function and the task completion cost. Through the ant colony algorithm with parameter setting, the candidate allocation result with the smallest function value of the objective function among at least two candidate allocation results corresponding to the set of tasks to be scheduled is output as the allocation result corresponding to the set of tasks to be scheduled; wherein, when all ants complete a solution search, a first allocation result is calculated according to the allocation result corresponding to each ant; two tasks to be scheduled are arbitrarily selected from the set of tasks to be scheduled as target tasks; when the virtual machines corresponding to the two target tasks in the first allocation result are different, the virtual machines corresponding to the two target tasks are exchanged in the first allocation result to obtain a second allocation result; when the first allocation result corresponds to When the function value of the objective function is greater than the function value of the objective function corresponding to the second allocation result, the second allocation result is determined as the global allocation result; when the function value of the objective function corresponding to the first allocation result is less than or equal to the function value of the objective function corresponding to the second allocation result, if the set rules are met, the second allocation result is determined as the global allocation result; if the set rules are not met, the first allocation result is determined as the global allocation result; according to the maximum number of cycles set in the ant colony algorithm, the global allocation result determined by the last cycle of the ant colony algorithm is determined as the allocation result corresponding to the task set to be scheduled; wherein the global allocation result is the allocation result obtained after completing one cycle of the ant colony algorithm; According to the allocation result corresponding to the set of tasks to be scheduled, each task to be scheduled in the set of tasks to be scheduled is allocated to at least one virtual machine.
2. The task scheduling method according to claim 1, characterized in that: Generating an objective function according to the task completion cost includes: Normalizing the task completion cost; According to the normalized task completion cost, an objective function is generated using a linear weighted sum method; the objective function includes a first coefficient and a second coefficient; wherein the first coefficient represents the weight of the time cost, and the second coefficient represents the weight of the resource cost.
3. The task scheduling method according to claim 1, characterized in that: When the allocation result corresponding to the set of tasks to be scheduled is obtained by using the ant colony algorithm, the method further includes: Determining a computing capability of each of the at least one virtual machine; Determining an average computing capacity of all virtual machines in the at least one virtual machine; Determine the pheromone initial value corresponding to at least one mapping path according to the computing power of each virtual machine in the at least one virtual machine and the average computing power; wherein, Each mapping path in the at least one mapping path represents allocation of a task to be scheduled in the set of tasks to be scheduled to a virtual machine in the at least one virtual machine.
4. The task scheduling method according to claim 1, characterized in that: When the allocation result corresponding to the set of tasks to be scheduled is obtained by using the ant colony algorithm, the method further includes: Determining an elapsed execution time of each of the at least one virtual machine; Determining an average execution time of all virtual machines in the at least one virtual machine; Determine a load balancing factor of a corresponding virtual machine according to the corresponding executed time and the average execution time; Determine a heuristic function corresponding to the virtual machine; the heuristic function includes the load balancing factor; the value of the heuristic function increases as the load balancing factor increases.
5. The task scheduling method according to claim 1, characterized in that: When the allocation result corresponding to the set of tasks to be scheduled is obtained by using the ant colony algorithm, the method further includes: When an ant completes a solution search, the allocation result corresponding to the ant is obtained; Determine the local pheromone concentration according to the set parameters in the ant colony algorithm and the value of the pheromone; the local pheromone concentration is the updated value of the pheromone concentration after an ant completes a solution search; The pheromone concentration corresponding to the mapping path is updated according to the local pheromone concentration and the allocation result corresponding to the one ant.
6. The task scheduling method according to claim 1, characterized in that: When the allocation result corresponding to the set of tasks to be scheduled is obtained by using the ant colony algorithm, the method further includes: When one cycle of the ant colony algorithm is completed, the function value of the objective function corresponding to the global allocation result is obtained according to the corresponding global allocation result; the global allocation result is the allocation result obtained after one cycle of the ant colony algorithm is completed; Determine the global pheromone concentration according to the function value of the objective function; the global pheromone concentration is the updated value of the pheromone concentration after completing one cycle of the ant colony algorithm; According to the global pheromone concentration and the global allocation result, the pheromone concentration on the mapping path between each task to be scheduled and the corresponding virtual machine is updated.
7. A task scheduling device, characterized in that: include: A first determining unit, configured to determine a set of tasks to be scheduled, wherein the set of tasks to be scheduled includes at least one task to be scheduled; A second determining unit, used to determine the task completion cost of the to-be-scheduled task set; The task completion cost includes at least time cost and resource cost; A first generating unit, configured to generate an objective function according to the task completion cost; A second generating unit is used to set the parameters of the ant colony algorithm based on the objective function and the task completion cost, obtain at least two candidate allocation results corresponding to the set of tasks to be scheduled by the ant colony algorithm that completes the parameter setting, and output the candidate allocation result with the smallest function value of the objective function among the at least two candidate allocation results as the allocation result corresponding to the set of tasks to be scheduled; wherein, when all ants complete a solution search, a first allocation result is calculated according to the allocation result corresponding to each ant; two tasks to be scheduled are arbitrarily selected from the set of tasks to be scheduled as target tasks; when the virtual machines corresponding to the two target tasks in the first allocation result are different, the virtual machines corresponding to the two target tasks are exchanged in the first allocation result to obtain a second allocation result; When the function value of the objective function corresponding to the first allocation result is greater than the function value of the objective function corresponding to the second allocation result, the second allocation result is determined as the global allocation result; when the function value of the objective function corresponding to the first allocation result is less than or equal to the function value of the objective function corresponding to the second allocation result, if the set rules are met, the second allocation result is determined as the global allocation result; if the set rules are not met, the first allocation result is determined as the global allocation result; according to the maximum number of cycles set in the ant colony algorithm, the global allocation result determined by the last cycle of the ant colony algorithm is determined as the allocation result corresponding to the set of tasks to be scheduled; wherein the global allocation result is the allocation result obtained after completing one cycle of the ant colony algorithm; The allocation unit is used to allocate each task to be scheduled in the set of tasks to be scheduled to at least one virtual machine according to the allocation result corresponding to the set of tasks to be scheduled.
8. An electronic device, characterized in that: comprising a processor and a memory for storing a computer program capable of being executed on the processor, Wherein, when the processor is used to run the computer program, it executes the steps of the method described in any one of claims 1 to 6.
9. A storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.