[0043] The purpose, advantages and characteristics of the present invention will be illustrated and explained through the following non-limiting description of preferred embodiments. These embodiments are only typical examples of applying the technical solutions of the present invention, and any technical solutions formed by equivalent substitutions or equivalent transformations fall within the protection scope of the present invention.
[0044] The present invention discloses a computing migration method based on task dependency in a mobile cloud environment. The method firstly expresses the computing capabilities of different microclouds in detail on the basis of subdivision of task types, and then provides The utility function calculation method of the migration scheme is proposed; then based on the general genetic algorithm idea, an improved algorithm is proposed to reduce the data transmission between tasks as much as possible under the constraints of timing and data dependence, and improve the parallelism of tasks; finally, the response time and An overall better migration solution for terminal energy consumption.
[0045] In the present invention, the processing location of the computing task only considers the terminal local and the micro cloud, and there is a dual dependency relationship between time sequence and data between the computing tasks. In this scenario, how to migrate and process computing tasks in order to obtain better response time and terminal energy consumption, that is, a lower effect value, is the main problem we will solve.
[0046] Specifically, the method includes the following steps:
[0047] S1: Established a computing task model based on the subdivision of task types;
[0048] A weighted directed acyclic graph G(V, ξ) is used to represent a set of calculation tasks generated, and a four-tuple v i =(d i , W i , R i , Ty i ) To represent computing tasks, which can be divided into different types according to their purpose;
[0049] S2: Establish a computing resource model in the computing migration system;
[0050] Such as figure 1 As shown, the computing resources in the mobile cloud computing environment mainly include the local resources of the mobile terminal and the micro-cloud resources. Through a four-tuple To represent the local resources of the mobile terminal, through f k ty To represent the micro-cloud resources, the local resources of the mobile terminal and the micro-cloud resources communicate through the local area network;
[0051] S3: Give a mathematical description of the migration problem based on the system model;
[0052] The computing tasks generated by the mobile terminal can be processed locally or migrated to the micro-cloud for processing; use a one-dimensional vector S=(s 1 , S 2 , S 3 ,...,S n ) To represent the migration plan, and the utility function U to represent the final optimization result. The smaller the effect function U, the closer the migration plan is to the optimal, and the corresponding migration plan S at this time is the final migration plan;
[0053] S4: Propose an improved algorithm based on the general genetic algorithm;
[0054] According to the steps S1~S3, combined with the genetic algorithm, a multi-task migration method based on task dependence is proposed, in order to obtain a migration plan with overall better response time and terminal energy consumption. The genetic algorithm simulates the genetic law of organisms, starting from the initial individual, through selection, crossover and mutation operations to produce new individuals, and so on, continue to evolve until the stopping conditions are met;
[0055] S5: Get the final migration plan;
[0056] When the number of iterations reaches the set value, it will stop, and then output the individual with the best adaptability U, and the migration plan S is the final migration plan.
[0057] In the S5 step, when the number of iterations reaches the set value, it will stop. Each iteration will save the current optimal fitness value and the individual of that value. After the iteration stops, the adaptability U is optimal. The individual output of the migration plan S is the final migration plan.
[0058] The S1 step specifically includes:
[0059] A weighted directed acyclic graph G(V, ξ) is used to represent a set of calculation tasks generated, where V={v 1 , V 2 , V 3 ,..., v n } Represents the set of computing tasks in this group, n represents the number of computing tasks in this group, ξ={h(v i , V j )|v i , V j ∈V} represents the set of dependencies between computing tasks, when h(v i , V j )=0, it means task v i And task v j There is no dependency relationship, when h(v i , V j )=1, it means task v i And task v j There is only timing dependence between, when h(v i , V j )=2, it means task v i And task v j There is a dual dependence on timing and data;
[0060] Use a quadruple v i =(d i , W i , R i , Ty i ) To represent computing tasks, where d i Means v i The amount of data of the task itself, in MB; w i Indicates the amount of calculation required to process the task, in MB; r i Represents task v i The data amount of the processing result, the unit is MB; ty i Indicates the type of computing task; computing tasks can be divided into different types according to their respective goals; assuming there are four different task types, represented by TY={A, B, C, D}, ty i ΕTY, due to different instruction sets and other reasons, it is believed that local or micro-cloud has different processing capabilities for different types of computing tasks.
[0061] In the S2 step,
[0062] The computing resources in the mobile cloud computing environment in this technical solution are mainly composed of the local resources of the mobile terminal and the micro cloud resources. The local resources of the mobile terminal and the micro cloud resources can communicate through a local area network.
[0063] Pass a quad To represent the local resources of the mobile terminal, where, Represents the amount of data that can be processed per unit time, in GHz, ty∈TY represents the computing power of the mobile terminal for different types of tasks, P local Indicates the local calculated power, the unit is w;
[0064] P send Represents the power of sending data locally, the unit is w, P rec Represents the power of the local received data; the unit is w, through f k ty Represents the microcloud resource, where k represents the number of the microcloud, k=1, 2,..., m, Indicates the different computing capabilities of Weiyun, the unit is GHz, ty∈TY; mobile terminals and Weiyun generally communicate through a local area network, the bandwidth of the local area network is uniformly expressed by Bc, and the unit of Bc is MB/ms.
[0065] In the S3 step,
[0066] In the mobile cloud computing environment, the computing tasks generated by the mobile terminal can be processed locally or migrated to the micro-cloud for processing; use a one-dimensional vector S=(s 1 , S 2 , S 3 ,...,S n ) To represent the migration plan, where s i ∈{0,1,...,k,...,m}, m represents the number of micro clouds;
[0067] When s i =0, it means task v i Processing locally, at this time, the response time and terminal energy consumption can be calculated separately;
[0068] When s i =1,...,k,...,m, it means task v i Will be migrated to the microcloud for processing, at this time the response time and terminal energy consumption can also be calculated separately.
[0069] When task v i Predecessor mission v j With task v i When there are data dependencies and different processing locations, tasks need to be considered v j To task v i Data transfer between, if task v i If there are multiple such precursors, multiple data transfers need to be calculated.
[0070] For a set of tasks with timing and data dependence, the migration method combines the considerations of response time and mobile terminal energy consumption, in order to achieve better application performance while saving energy consumption. In the present invention, the utility The function U represents the final optimization result.
[0071] Because the ultimate goal is to minimize the response time and the terminal energy consumption, the smaller the effect function U, the closer the migration plan is to the optimal, and the corresponding migration plan S at this time is the final migration plan.
[0072] In the S4 step, as figure 2 As shown, the improved algorithm includes the following steps:
[0073] S41: First perform a population initialization operation, that is, initialize the processing position of the calculation task;
[0074] For a task v i Processing position, randomly generated s i = {0,...,m} random integer, traverse all computing tasks in the same way, you can get the initial position set S as the chromosome 0 In the present invention, the population is represented by the matrix pop.
[0075] S42: On the basis of the step S41, the fitness value is then calculated;
[0076] Each chromosome represents a solution, and the individual meeting the optimal fitness value is the optimal solution, and the objective function (5) is the fitness function, and the value calculated by this function is called the fitness value.
[0077] S43: Perform a selection operation on the basis of the step S42 to select part of the chromosomes with a better fitness value, use the roulette method to perform the selection operation, the number of repetitions is popsize, and the obtained individual performs the next operation.
[0078] S44: On the basis of the step S43, the individual obtained after the selection operation performs a crossover operation. First, according to the crossover probability p c Select two individuals who are about to perform the crossover operation as the parent individuals, and then select an intersection point at the same position of the two parent individuals. The calculation task corresponding to the first gene after the intersection point meets the following conditions: After the crossover point, the genes of the two parent individuals are exchanged to obtain two new offspring individuals.
[0079] S45: On the basis of the step S44, perform a mutation operation after the crossover operation. First, according to the mutation probability p m Select a chromosome that will undergo mutation operation, and then select a gene s in the chromosome i , The computing task corresponding to this gene satisfies the following conditions: Mutate the gene to make the new gene s i ’=s j , And then you can get a new individual.
[0080] S46: Repeat steps S1 to S5 until the stop condition is met.
[0081] The system model and problems of the present invention are described as follows:
[0082] (1) Computing task model
[0083] A computing task represents a module or a section of program that can achieve a certain purpose in a mobile application. A mobile application may generate a set of computing tasks within a period of time, and there are timing or data dependencies between tasks. In the present invention, a weighted directed acyclic graph G(V, ξ) is used to represent a set of calculation tasks generated, where V={v 1 , V 2 , V 3 ,..., v n } Represents the set of computing tasks in this group, n represents the number of computing tasks in this group, ξ={h(v i , V j )|v i , V j ∈V} represents the set of dependencies between computing tasks, when h(v i , V j )=0, it means task v i And task v j There is no dependency relationship, when h(v i , V j )=1, it means task v i And task v j There is only timing dependence between, when h(v i , V j )=2, it means task v i And task v j There is a dual dependence on timing and data.
[0084] In the present invention, a four-tuple v i =(d i , W i , R i , Ty i ) To represent computing tasks, where d i (The unit is MB) means v i The amount of data of the task itself, w i (The unit is MB) represents the amount of calculation required to process the task, r i (Unit is MB) means task v i The data volume of the processing result, ty i Indicates the type of calculation task. Computing tasks can be divided into different types according to their purpose, such as videos, pictures, games, etc. In the present invention, it is assumed that there are four different task types, represented by TY={A, B, C, D}, ty i ∈TY. Due to different instruction sets and other reasons, it is believed that local or microcloud has different processing capabilities for different types of computing tasks.
[0085] (2) Computing resource model
[0086] According to the above scenario description, the present invention assumes that the computing resources in the mobile cloud computing environment are mainly composed of the local resources of the mobile terminal and the micro-cloud resources, and the two can communicate through the local area network, such as figure 1 Shown. Since the ordinary cloud is often far away, it will cause excessive delay, so it will not be considered for the time being.
[0087] The local resource of the mobile terminal can pass a quadruple Means, where (The unit is GHz, which means the amount of data that can be processed per unit time, ty∈TY) means the mobile terminal’s computing power for different types of tasks, P local (The unit is w) represents the local calculated power, P send (The unit is w) represents the power of sending data locally, P rec (The unit is w) represents the power of the local received data.
[0088] Weiyun resources are available through f k ty Means, where k represents the number of the micro cloud, k = 1, 2, ..., m, (Unit: GHz) represents the different computing capabilities of Weiyun, ty∈TY. In addition, communication between the mobile terminal and the microcloud is generally through a local area network, and the local area network bandwidth can be uniformly expressed by Bc (unit: MB/ms).
[0089] (3) Problem description
[0090] In the mobile cloud computing environment, computing tasks generated by mobile terminals can be processed locally or migrated to micro-cloud for processing. The present invention uses a one-dimensional vector S=(s 1 , S 2 , S 3 ,...,S n ) To represent the migration plan, where s i ∈{0,1,...,k,...,m}, m represents the number of micro clouds. When s i =0, it means task v i Processing locally, at this time, the response time can be expressed by formula (1):
[0091]
[0092] At this time, the energy consumption of the mobile terminal can be expressed by formula (2):
[0093] e(i,0)=t(i,0)*P local (2)
[0094] When s i =1,...,k,...,m, it means task v i Will be migrated to Weiyun for processing. At this time, its response time can be expressed by formula (3):
[0095]
[0096] At this time, the energy consumption of the mobile terminal can be expressed by formula (4):
[0097]
[0098] Among them, L LAN Indicates the time delay in the transmission process when the task is migrated from the mobile terminal to the micro cloud through the local area network; L wait Indicates the waiting time of a computing task in the microcloud, that is, if multiple parallel tasks migrate to the same microcloud for processing, these tasks need to be processed in sequence, and the tasks in the queue need to wait for the processing of the previous tasks to be completed. When task v i Predecessor mission v j With task v i When there are data dependencies and different processing locations, tasks need to be considered v j To task v i Data transfer between, if task v i If there are multiple such precursors, multiple data transfers need to be calculated.
[0099] Aiming at a set of tasks with time sequence and data dependence, the migration method in the present invention mainly integrates the two considerations of response time and mobile terminal energy consumption, so as to achieve better application performance while saving energy.
[0100] In the present invention, a utility function is used to express the final optimization result, as shown in formula (5):
[0101]
[0102] with Respectively represent the sum of the response time and the sum of the terminal energy consumption when all tasks in this group of tasks are processed. Divide it by the response time and energy consumption of all computing tasks processed locally, in order to obtain the migration solution of the present invention relative to all local processing The ratio reduced by the solution.
[0103] Among them, α and β represent the weight of response time and terminal energy consumption respectively, and meet the following conditions:
[0104] α+β=1, 0≤α≤1, 0≤β≤1 (6)
[0105] Because the ultimate goal is to minimize the response time and the terminal energy consumption, the smaller the effect function U, the closer the migration plan is to the optimal, and the corresponding migration plan S at this time is the final migration plan.
[0106] Based on the above description and combined with the genetic algorithm, the present invention proposes a multi-task migration method based on task dependence, in order to obtain a migration scheme with overall better response time and terminal energy consumption. Genetic algorithm is a random search method designed with reference to the laws of biological evolution, and is widely used to solve this type of problem of seeking global optimal solutions. The genetic algorithm simulates the genetic law of organisms, starting from the initial individual, through selection, crossover and mutation operations to produce new individuals, and so on, continue to evolve until the stopping conditions are met.
[0107] First, you need to set the parameter values corresponding to the population size, chromosome length, etc. based on the number of tasks in the application, and then generate the primary population based on the parameter values. Each chromosome in the population corresponds to a migration plan, and each gene in the chromosome Corresponding to the processing position of the task, the fitness value of each individual in the population can be obtained according to formula (5), that is, the utility function U. Then, the selection operation is performed according to the individual fitness value, and the individuals with better adaptability perform crossover and mutation operations according to the dual dependency between the computing tasks, and the new individuals generated after the operation are inherited to the next generation population. Such non-stop iterations until the stopping conditions are met, and results are produced.
[0108] Part of the steps will be described in detail below:
[0109] (1) Population initialization
[0110] The population initialization operation is to initialize the processing position of the computing task. For a task v i Processing position, randomly generated s i = {0,...,m} random integer, traverse all computing tasks in the same way, you can get the initial position set S as the chromosome 0 , And the length of the chromosome, the number of genes, is determined by the number of all computing tasks. Since the population is composed of multiple chromosomes, in the present invention, the population is represented by the matrix pop.
[0111] (2) Calculation of adaptability value
[0112] In the genetic algorithm, each chromosome represents a solution, and the individual that meets the optimal fitness value is the optimal solution. In order to measure the excellence of each individual in the selection process, it is necessary to design a fitness function that can directly reflect the individual performance. In the present invention, the objective function (5) is the fitness function, which is calculated by the function The value obtained is called the fitness value.
[0113] Before calculating the fitness value of an individual, input the specific description of each calculation task and the dependencies between the tasks. In order to obtain the fitness value of an individual, we must first traverse each gene value of the individual, and use formula (1) or formula (3) to obtain the response of each calculation task according to the task processing position represented by its gene value Time, among them, if multiple parallel tasks migrate to the same microcloud for processing, there will be a waiting phenomenon. At this time, tasks with less processing time need to be processed first to reduce the waiting time; then according to formula (2) or Equation (4) can be used to obtain the terminal energy consumption for processing each computing task.
[0114] Then find the sum of the response time and the sum of terminal energy consumption when all tasks in this group of tasks are processed. At this time, it is necessary to combine the dependency between the two computing tasks and whether they can be migrated jointly, which will save the response time and terminal energy. Deplete. Finally, the fitness value of the individual is obtained according to formula (5). The fitness values of other individuals in the population can be calculated in the same way.
[0115] (3) Select operation
[0116] The selection operation is to select part of the chromosomes with better adaptability values, and perform crossover and mutation operations to produce next-generation chromosomes with better adaptability. The present invention uses the roulette method to perform the selection operation: first, the probability that the j-th individual is selected is calculated by formula (7), U j Indicates the fitness value of the jth individual;
[0117]
[0118] Then, calculate the cumulative probability of individual k to construct a roulette, as shown in formula (8):
[0119]
[0120] Finally, roulette is selected, and a random number ms is generated in the interval [0, 1], if ms meets the following conditions: q k-1 k , Then select individual k to enter the offspring population. Repeat the last two steps above, the number of repetitions is popsize, and the obtained individual will proceed to the next step.
[0121] The selection operation algorithm is as follows:
[0122]
[0123] (4) Cross operation
[0124] The crossover operation is to interact part of the genes of two chromosomes in order to obtain the next generation of chromosomes with better fitness value. First, according to the cross probability p c Select two individuals who are about to perform the crossover operation as the parent individuals, and then select an intersection point at the same position of the two parent individuals. The calculation task corresponding to the first gene after the intersection point meets the following conditions: After the intersection point, the genes of the two parent individuals are exchanged to obtain two new offspring individuals.
[0125] For example, select two parent individuals S who are about to crossover p And S q , And randomly select the intersection point:
[0126] S p =(s 1 , S 2 , S 3 , S 4 , S 5 , S 6 , |s 7 , S 8 , S 9 , S 10 ),
[0127] S q =(s 1 ’, s 2 ’, s 3 ’, s 4 ’, s 5 ’, s 6 ’,|s 7 ’, s 8 ’, s 9 ’, s 10 ’).
[0128] Among them, "|" represents the intersection point, gene s 5 The corresponding computing task is gene s 7 The precursor task of the corresponding computing task, there is a data dependency between the two, s 5 ≠s 7 And s 5 ’≠s 7 ’, cross the genes after "|" to get the following two new offspring individuals:
[0129] S p *=(s 1 , S 2 , S 3 , S 4 , S 5 , S 6 , |s 7 ’, s 8 ’, s 9 ’, s 10 ’),
[0130] S q *=(s 1 ’, s 2 ’, s 3 ’, s 4 ’, s 5 ’, s 6 ’,|s 7 , S 8 , S 9 , S 10 ).
[0131] The crossover operation algorithm is as follows:
[0132]
[0133]
[0134] (5) Mutation operation
[0135] The mutation operation is to change the value of a certain gene in the chromosome. First, according to the mutation probability p m Select a chromosome that will undergo mutation operation, and then select a gene s in the chromosome i , The computing task corresponding to this gene satisfies the following conditions: Mutate the gene to make the new gene s i ’=s j , And then you can get a new individual.
[0136] For example, select a parent individual S who will undergo mutation operation p , And select variant genes:
[0137] S p =(s 1 , S 2 , S 3 , S 4 , S 5 , S 6 , S 7 , S 8 , S 9 , S 10 ),
[0138] Where s 6 Indicates a variant gene, gene s 3 Corresponding computing tasks and genes 6 There is data dependence between the corresponding computing tasks, and s 3 ≠s 6. Mutate it to get the following new individual:
[0139] S p *=(s 1 , S 2 , S 3 , S 4 , S 5 , S 6 ’, s 7 , S 8 , S 9 , S 10 ).
[0140] At this time, s 6 ’=s 3.
[0141] The new individual obtained by the above mutation operation has better adaptability and can effectively improve the convergence speed of the algorithm.
[0142] The mutation operation algorithm is as follows:
[0143]
[0144]
[0145] (6) Get the result
[0146] There are generally two ways to stop the iteration conditions: the first is to set a limit for the expected result, when the result reaches this limit, the iteration stops; the second is to set the limit of the number of iterations, when the number of iterations reaches the limit, The iteration stops.
[0147] The second iteration stop method is used in the present invention. First, set a maximum number of iterations, and stop when the number of iterations reaches the set value, and then output the individual with the best adaptability U to obtain the migration plan S, which is For the final migration plan.
[0148] The present invention aims at the problem of multi-task computing migration with dependencies in the mobile cloud environment, and then proposes an improved algorithm based on the general genetic algorithm idea, thereby obtaining a migration scheme with overall better response time and terminal energy consumption. Based on the subdivision of task types, the computing capabilities of different microclouds are expressed in detail, computing task models and computing resource models are given, and there is a dual dependency on timing and data between computing tasks. Under the constraints of data dependence, the data transmission between tasks is reduced as much as possible, and the parallelism of tasks is improved. On this basis, the utility function calculation method of the migration plan is given, which is expressed in mathematical form; then, using the improved genetic algorithm, Find the final migration plan, which has better response time and terminal energy consumption.
[0149] The present invention still has many implementation modes, and all technical solutions formed by equivalent transformations or equivalent transformations fall within the protection scope of the present invention.