Disclosure of Invention
In order to overcome the defects and shortcomings in the prior art, the invention provides a cloud computing resource scheduling optimization method based on a dynamic target strategy, which can obtain a scheduling scheme with lower cost under the constraint of the same deadline and can still obtain a feasible scheduling scheme under the constraint of smaller deadline.
The invention further provides a cloud computing resource scheduling optimization system based on the dynamic objective strategy.
A third object of the present invention is to provide a storage medium.
It is a fourth object of the invention to provide a computing device.
In order to achieve the purpose, the invention adopts the following technical scheme:
a cloud computing resource scheduling optimization method based on a dynamic objective strategy comprises the following steps:
initializing a population: randomly generating a resource scheduling sequence for each chromosome in the population;
and (3) evaluating an adaptive value: evaluating an adaptive value by adopting the reciprocal of the task flow execution cost;
dynamic target policy: if the feasible solution meeting the final deadline requirement does not exist during the first-generation initialization, the task flow execution time is taken as an optimization target, the adaptive value of the chromosome is evaluated by the task flow execution time in a reciprocal manner, the chromosome with smaller TET and higher adaptive value is selected in each iteration until the solution obtained by the chromosome appearing in the population meets the final deadline requirement, and the adaptive value is evaluated by the reciprocal of the task flow execution cost again;
selecting an operator: selecting chromosome individuals entering the next generation by roulette according to the fitness value of the chromosomes;
crossover and mutation of chromosomes: each chromosome is provided with a cross probability and a variation probability, a random number is generated for each resource scheduling sequence, and if the random number is smaller than the cross probability, the resource scheduling sequence is selected as one of the male parents of the cross;
generating a random number for each task of each resource scheduling sequence, wherein if the random number is less than the variation probability, the resource number occupied by the task is varied;
optimal individual retention strategy: in each generation, if the adaptive value of a chromosome in the current generation is higher than that of the current optimal chromosome, taking the chromosome in the current generation as a new optimal chromosome; otherwise, replacing the chromosome with the minimum fitness value in the current generation with the current optimal chromosome individual;
and when a feasible solution cannot be found after the feasible solution is found out and the specified algebra is executed, outputting the solution of the generated optimal chromosome.
As a preferred technical solution, the randomly generating a resource scheduling sequence for each chromosome in the population includes:
the corresponding resources and tasks are represented by the numbers of the resources and the tasks, and the ith gene of each chromosome represents the task tiResource being executed, for chromosome x, xiJ denotes task tiIn resource rjIs executed.
As a preferred technical solution, the chromosome individuals entering the next generation are selected by roulette, and the probability of the resource scheduling sequence being selected is:
fitnessi=1/TECi
wherein TEC represents the task flow execution cost, fitnessiIndicates the fitness value, and i indicates the ith position of the chromosomal gene.
In the step of crossing and mutating chromosomes, each time 2 chromosomes are selected, a random number N ∈ [1, N-1], N ∈ [ Z ], is generated, and resource numbers of the first N tasks of the two resource scheduling sequences are correspondingly exchanged.
In order to achieve the second object, the present invention adopts the following technical solutions:
a cloud computing resource scheduling optimization system based on a dynamic objective strategy comprises: the system comprises a population initialization module, an adaptive value evaluation module, a dynamic target strategy construction module, a selection operator module, a chromosome crossing and mutation module, an optimal individual retention strategy construction module and an output module;
the population initialization module is used for initializing a population and randomly generating a resource scheduling sequence for each chromosome in the population;
the adaptive value evaluation module is used for evaluating an adaptive value by adopting the reciprocal of the task flow execution cost;
the dynamic target strategy construction module is used for constructing a dynamic target strategy, and specifically comprises the following steps: if the feasible solution meeting the final deadline requirement does not exist during the first-generation initialization, the task flow execution time is taken as an optimization target, the adaptive value of the chromosome is evaluated by the task flow execution time in a reciprocal manner, the chromosome with smaller TET and higher adaptive value is selected in each iteration until the solution obtained by the chromosome appearing in the population meets the final deadline requirement, and the adaptive value is evaluated by the reciprocal of the task flow execution cost again;
the selection operator module is used for selecting chromosome individuals entering the next generation through roulette according to the adaptive value of the chromosomes;
the chromosome crossing and mutation module is used for completing the crossing and mutation of chromosomes, each chromosome is provided with a crossing probability and a mutation probability, a random number is generated for each resource scheduling sequence, and if the random number is smaller than the crossing probability, the resource scheduling sequence is selected as one of the male parents of the crossing;
generating a random number for each task of each resource scheduling sequence, wherein if the random number is less than the variation probability, the resource number occupied by the task is varied;
the optimal individual retention strategy construction module is used for constructing an optimal individual retention strategy, and specifically comprises the following steps: in each generation, if the adaptive value of a chromosome in the current generation is higher than that of the current optimal chromosome, taking the chromosome in the current generation as a new optimal chromosome; otherwise, replacing the chromosome with the minimum fitness value in the current generation with the current optimal chromosome individual;
the output module is used for outputting an optimal solution, and outputting the generated optimal chromosome solution when a feasible solution cannot be found after a specified algebra is found.
In order to achieve the third object, the present invention adopts the following technical solutions:
a storage medium stores a program, and when executed by a processor, the program implements the above dynamic objective policy-based cloud computing resource scheduling optimization method.
In order to achieve the fourth object, the present invention adopts the following technical means:
a computing device comprises a processor and a memory for storing a processor executable program, and when the processor executes the program stored in the memory, the cloud computing resource scheduling optimization method based on the dynamic objective strategy is realized.
Compared with the prior art, the invention has the following advantages and beneficial effects:
(1) in the process of learning a certain dimension of particles in the existing particle swarm algorithm to the optimal particle, the tendency learning of resource numbers is not necessarily good and can lead to better results, and convergence is fast but premature convergence is easy.
(2) Because the genetic algorithm is not suitable for the optimization target with the constraint condition, the invention provides a dynamic target strategy, when a feasible scheduling scheme is not obtained (namely the deadline is exceeded) under the condition that the minimization cost based on the deadline constraint is taken as the optimization target, the task completion time is taken as the optimization target until the algorithm finds the feasible scheduling scheme, and then the minimization cost based on the deadline constraint is taken as the optimization target again, so that the applicability of the algorithm is stronger, and a feasible solution can still be found under the constraint of smaller deadline.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, the present invention is described in further detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.
Examples
A user has a series of tasks to be executed, and the cloud computing platform provides a series of running resources (virtual machines) which can be rented by the user as required, so how to allocate the tasks to the corresponding resources to run forms a resource scheduling problem. As shown in fig. 1, it can be seen that there are many tasks in a task group, and there is a topology between these tasks, i.e. there are parent-child relationships between the tasks. The value on each edge represents the transfer time of the data, namely when the parent task and the child task do not run on the same resource, the parent task needs to transfer the data required by the running of some child tasks to the child tasks. The time required for each task to execute on each resource is also known. For programming implementation, the embodiment adopts numbers to represent tasks and resources, and defines two matrixes of exetime and transit time, wherein the matrix represents the task tiIn resource rjRun time of (i)][j]Representing a task tiTransmitting data to tjWhen i is j or tiAnd tjTransfer time [ i ] when there is no direct dependency, i.e. there are no directly connected edges in the topology][j]0. As shown in fig. 2, an example of two matrices, exetime and transit time, is given, and as shown in fig. 3, a representation of the progress of a task flow scheduling scheme over time is shown.
In the present embodiment, the objective model to be optimized is to minimize the execution cost based on the deadline, and its mathematical expressions are shown as (1) and (2), where TEC and TET represent the cost of task completion and the time required for task completion, respectively.
Minimize TEC (1)
TET<deadline (2)
The TEC and TET calculation methods are shown by (3) and (4), where r is given to each resource
jDefine its lease start time
And rental end time
Representing a task t
iEnd time of execution; TET represents that the time of the task completed last in all the tasks of the resource is the time for completing the whole task flow; the cost is calculated by adding the price of each resource times the time it has been leased.
Last definitionA scheduling scheme for scheduling pos [ | T | ]]Denotes, pos [ i]The value of (b) represents the task tiRun on resource rpos[i]The above. Thus, TEC and TET can be calculated.
For each task t
iFrom the pos sequence, the resource r on which it runs can be obtained
pos[i]。t
iStart time of operation of
Is determined by two factors. If there is no parent, i.e. predecessor, then once resource r is available
pos[i]Is available then t
iOperation can begin and this value corresponds to resource r
pos[i]Lease end time LET of
rpos[i]. If t is
iHaving one or more parent tasks, except for waiting for resource r
pos[i]Available, yet can begin execution by waiting for all of its parent tasks to finish execution, this value corresponding to resource r
pos[i]And the maximum value of the rental end time of (c) and the execution end time of all parent tasks. And the running time of this task
Is composed of a running time exetime [ i ]][r
pos[i]]And data transfer time [ i ]][child(i)]And adding to obtain the final product. It should be noted that in practical applications, if the subtasks and t are used
iThe data does not need the time of data transfer when the data runs on the same resource. And task t
iEnd of run time of
Is its start time
Plus run time of tasks
If t is
iResource r in which to run
pos[i]Has not been selected by other tasks, then resource r
pos[i]LST (r)
rpos[i]Is the task t
iStart time of operation of
At the same time, r is also required to be
pos[i]To the set R of leased resources. The lease end time LET of the resource is then updated. Resource r
pos[i]LET (L)
rpos[i]Is task t
iThe end time of the run. From the data calculated above, TET and TEC can be calculated from formula (1) and formula (2) in the model definition.
As shown in fig. 4, the present embodiment provides a cloud computing resource scheduling optimization method based on a dynamic objective policy, including the following steps:
(1) initializing a population
Randomly initializing each chromosome in the population to generate a resource scheduling sequence; according to the population definition of the genetic algorithm, each chromosome in the population corresponds to a solution of the problem, so each chromosome corresponds to each scheduling scheme, i.e., a scheduling sequence. In this embodiment, the numbers of resources and tasks are used to represent the corresponding resources and tasks, and the ith gene of each chromosome represents task tiThe resource in which this is performed, specifically, this embodiment encodes chromosomes with integers, for chromosome x, xiJ denotes task tiIn resource rjIs performed where i e [0, | T | -1];
(2) Adaptive value evaluation
Evaluation formula of fitness value of each chromosome is as shown in (5), since the higher the fitness value in the genetic algorithm is, the better the chromosome is and the goal is to minimize the Cost, the reciprocal of the task flow Execution Cost TEC (TEC) is used as the fitness value of the chromosome. Due to the programming requirement, if the deadline of the solution obtained by the chromosome is not satisfactory, i.e. the task flow Execution Time (TET) of the solution exceeds the deadline, the TEC of the chromosome is defined as inf, a large number:
fitnessi=1/TECi (5)
(3) dynamic object policy
If the feasible solution meeting the demand of deadline does not exist during the first generation initialization, the execution time of the task flow, namely TET is used as an optimization target, the adaptive value of the chromosome is evaluated by using the reciprocal of TET, the chromosome with smaller TET and higher adaptive value is selected in each iteration of the algorithm until the solution obtained by one chromosome in the population can meet the demand of deadline, namely the TET of the chromosome is smaller than the deadline, and the adaptive value is evaluated again by using the reciprocal of TEC, namely the formula (5);
(4) selection operator
Selecting chromosome individuals entering the next generation by roulette according to the fitness value of the chromosomes; the probability that the resource scheduling sequence i is selected is shown in formula (6);
(5) crossover and mutation of chromosomes
Each chromosome has a crossover probability PcAnd a mutation probability Pm(ii) a As shown in FIG. 5, for each chromosome, i.e., each resource scheduling sequence, a random number r ∈ [0, 1] is generated]If r is<PcSelecting the sequence as one of the parents of the cross; each time 2 chromosomes are selected, a random number N e [1, N-1] is generated]N belongs to Z, and correspondingly exchanges the resource numbers of the first n tasks of the two sequences;
as shown in FIG. 6, for each chromosome, i.e., each task of each resource scheduling sequence, a random number r e [0, 1] is generated]If r is<PmIf the number of the resource occupied by the task is changed, xm=rand(0,N-1);
(6) Optimal individual retention strategy
In each generation, if the adaptive value of the chromosome in the current generation is higher than the optimal chromosome, the chromosome is used as the optimal chromosome, otherwise, the worst chromosome in the current generation, namely the chromosome with the minimum adaptive value is replaced by the optimal chromosome individual, and the optimal chromosome individual is stored by one variable in the embodiment; the optimal solution generated in the operation process of the algorithm can be ensured not to be discarded by reserving the optimal individual, so that the algorithm is accelerated to find the optimal scheduling scheme;
(7) end conditions
And when a feasible solution is found and then executed to a specified algebra (4000 generations) or the feasible solution cannot be found within 100000 generations, outputting the optimal solution generated by the algorithm and ending the whole process.
Aiming at the problem that the genetic algorithm is not suitable for the optimization target with constraint conditions, the embodiment provides a dynamic target strategy; when a feasible scheduling scheme is not obtained under the condition that the minimization cost based on the deadline constraint is taken as an optimization target, the task completion time is taken as the optimization target, the scheduling scheme with less task completion time is selected each time, the minimization cost based on the deadline constraint is taken as the optimization target again after the algorithm finds the feasible scheduling scheme, the scheduling scheme with less task scheduling cost is selected each time, and the operation is circulated continuously until the program operation is finished; this strategy makes the algorithm more adaptive and still finds a feasible solution under the constraint of a smaller deadline.
Example 2
The embodiment provides a cloud computing resource scheduling optimization system based on a dynamic objective policy, which includes: the system comprises a population initialization module, an adaptive value evaluation module, a dynamic target strategy construction module, a selection operator module, a chromosome crossing and mutation module, an optimal individual retention strategy construction module and an output module;
in this embodiment, the population initialization module is configured to initialize a population, and randomly generate a resource scheduling sequence for each chromosome in the population;
in this embodiment, the adaptive value evaluation module is configured to evaluate the adaptive value by using a reciprocal of the task flow execution cost;
in this embodiment, the dynamic target policy constructing module is configured to construct a dynamic target policy, and specifically includes: if the feasible solution meeting the final deadline requirement does not exist during the first-generation initialization, the task flow execution time is taken as an optimization target, the adaptive value of the chromosome is evaluated by the task flow execution time in a reciprocal manner, the chromosome with smaller TET and higher adaptive value is selected in each iteration until the solution obtained by the chromosome appearing in the population meets the final deadline requirement, and the adaptive value is evaluated by the reciprocal of the task flow execution cost again;
in the embodiment, the selection operator module is used for selecting chromosome individuals entering the next generation through roulette according to the fitness value of the chromosome;
in this embodiment, the chromosome crossing and mutation module is configured to complete crossing and mutation of chromosomes, each chromosome is provided with a crossing probability and a mutation probability, a random number is generated for each resource scheduling sequence, and if the random number is smaller than the crossing probability, the resource scheduling sequence is selected as one of male parents of the crossing;
generating a random number for each task of each resource scheduling sequence, wherein if the random number is less than the variation probability, the resource number occupied by the task is varied;
in this embodiment, the optimal individual retention policy construction module is configured to construct an optimal individual retention policy, and specifically includes: in each generation, if the adaptive value of a chromosome in the current generation is higher than that of the current optimal chromosome, taking the chromosome in the current generation as a new optimal chromosome; otherwise, replacing the chromosome with the minimum fitness value in the current generation with the current optimal chromosome individual;
in this embodiment, the output module is configured to output the optimal solution, and after finding a feasible solution, when the feasible solution cannot be found after the specified algebra is performed, output the solution of the generated optimal chromosome.
Example 3
The present embodiment further provides a storage medium, where the storage medium may be a storage medium such as a ROM, a RAM, a magnetic disk, an optical disk, and the like, and the storage medium stores one or more programs, and when the programs are executed by a processor, the cloud computing resource scheduling optimization method based on the dynamic objective policy in embodiment 1 above is implemented.
Example 4
The embodiment also provides a computing device, where the computing device may be a desktop computer, a notebook computer, a smart phone, a PDA handheld terminal, a tablet computer, or other terminal devices with a display function, the computing device includes a processor and a memory, the memory stores one or more programs, and when the processor executes the programs stored in the memory, the cloud computing resource scheduling optimization method based on the dynamic objective policy in embodiment 1 is implemented.
The above embodiments are preferred embodiments of the present invention, but the present invention is not limited to the above embodiments, and any other changes, modifications, substitutions, combinations, and simplifications which do not depart from the spirit and principle of the present invention should be construed as equivalents thereof, and all such changes, modifications, substitutions, combinations, and simplifications are intended to be included in the scope of the present invention.