Parallel processor scheduling method with preemption granularity limitation
By proposing mathematical planning formulas in parallel processor scheduling and using Gurobi optimizer, the problem of difficult to solve the optimal solution in medium and large-scale scheduling is solved, and efficient solution efficiency is achieved when the number of tasks and execution time increases.
Patent Information
- Application Number
- CN202411016639.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Priority Date
- 2024-04-19
- Filing Date
- 2024-07-29
- Publication Date
- 2024-11-22
- Estimated Expiration
- 2044-07-29
AI Technical Summary
The prior art cannot ensure the output optimal solution in medium-to-large parallel processor scheduling, especially when the number of tasks or task execution time increases, the time required to solve the optimal solution increases dramatically, making it difficult to output within a limited time. Question solution result.
Seven mathematical planning formulas are proposed, and the Gurobi mathematical optimizer is called through Python's gurobipy library to calculate the optimal solution to obtain the optimal scheduling scheme, ensuring the minimization of the scheduling target's maximum completion time and preemption of the granularity limit.
When dealing with large-scale problems, the optimal solution can be effectively obtained, which significantly improves the solution efficiency and has higher practical application value on larger problem scales than the existing optimal algorithms.
Smart Images

Figure CN119003154A_ABST
Abstract
Description
Technical Field
[0001] The invention belongs to the technical field of computer application, and in particular, relates to a parallel processor scheduling method with preemption granularity limitation. Background Art
[0002] Preemption is a key factor in improving task schedulability. It allows resources to be released to tasks that need to be processed immediately by suspending the execution of the current task. In order to reduce preemption overhead while maintaining task schedulability, the scheduling model needs to constrain the preemption timing, number of preemptions or preemption granularity, so as to avoid the waste of system resources caused by frequent preemption. Common restrictive preemptive scheduling models include preemption models with fixed time points and scheduling models with preemption granularity restrictions. The restrictive preemptive scheduling problem with a fixed time point fixes the preemption timing at a pre-set time point. Although this method can control the overhead caused by unlimited preemption, it lacks flexibility. This patent introduces a parameter k to characterize the "granularity" of preemption for a scheduling model with preemption granularity restrictions, requiring that preemption must occur after the task has been executed continuously for at least k time units, thereby avoiding the problem of resource waste caused by excessive preemption while ensuring the flexibility of the preemption timing.
[0003] The parallel processor scheduling problem with preemption granularity restrictions is an NP-hard problem. In practical applications, heuristic algorithms are often used to obtain feasible solutions. These algorithms can obtain optimal solutions in special cases, but the approximate solutions obtained in general cannot stably approach the optimal solutions. Considering that accurate scheduling algorithms can not only predict benefits and avoid risks in the early stage of system design, but also play a guiding role in the evaluation of approximate algorithms, some accurate algorithms have been proposed to study how to solve the optimal solution of the parallel processor scheduling problem with preemption granularity restrictions, such as SAT (Boolean Satisfiability) and PMS (Partial Maximum Satisfiability) methods. However, the scale of problems that these optimal scheduling algorithms can solve is very small. As the number of tasks or the execution time of tasks increases, the time required to solve the optimal solution of the problem increases sharply, making it difficult to output the problem solution results within a limited time. Therefore, it is of great theoretical significance and practical value to design a deterministic method that can be applied to medium and large-scale processor-restricted preemption scheduling. Summary of the invention
[0004] The purpose of the present invention is to provide a parallel processor scheduling method with preemption granularity limitation, mainly to solve the problem that the prior art cannot ensure the output of the optimal solution.
[0005] In order to achieve the above object, the technical solution adopted by the present invention is as follows:
[0006] A parallel processor scheduling method with preemption granularity limitation comprises the following steps:
[0007] (S1) According to the restrictive preemption attribute constraints of the scheduling problem and the scheduling goal of minimizing the maximum completion time, seven mathematical programming formulas are proposed;
[0008] (S2) calling the Python gurobipy library and passing the mathematical programming formula obtained in step (S1) into the Gurobi mathematical optimizer of gurobipy;
[0009] (S3) The optimal solution to the problem is calculated by calling the Gurobi mathematical optimizer to obtain the optimal scheduling solution.
[0010] Furthermore, according to the restrictive preemption attribute constraints of the scheduling problem and the scheduling goal of minimizing the maximum completion time, seven mathematical programming formulas are proposed; the rules are as follows:
[0011] Rule 1: The task slices of each task are executed sequentially. This property is encoded as a formula:
[0012]
[0013] Among them, Γ is the task set, T j represents the jth task in the set Γ, Represents task T j The i-th task slice of Represents task slicing The start time of execution, Represents task slicing The execution time of L max is the maximum completion time of a feasible scheduling solution calculated by any heuristic algorithm (e.g., LPT improved algorithm [1], 2RS algorithm [2]), p j It is task T j Execution time of
[0014] [1]K.Ecker and R.Hirschberg.Task scheduling with restrictedpreemptions.PARLE In 1993Parallel Architectures and Languages Europe,pages464-475,Berlin,Heidelberg,06 1993.Springer.
[0015] [2]K.Pie_nkosz and A.Prus.Task scheduling with restricted preemptionson two parallel processors.In 2015 20th International Conference on Methods and Models in Automation and Robotics(MMAR),pages 58-61,Poland,08 2015.IEEE.
[0016] Rule 2: If two task slices from different tasks are scheduled to the same machine, then the two task slices must be executed sequentially. This property is encoded as a formula:
[0017]
[0018] Among them, Μ represents the machine set, M u represents the u-th machine of M, is the decision variable, Represents task slicing On machine M u Execute on, Represents task slicing Not on machine M u ∧ represents the logical AND operation, ∨ represents the logical OR operation, represents the implication operation;
[0019] Rule 3: Except for the last task slice, the execution time of each task slice is either not less than k or equal to 0. This property is encoded as the formula:
[0020]
[0021] Among them, k is the preemption granularity. When a task is preempted, it must be executed continuously for k time units, otherwise it cannot be preempted. j It is task T j The execution time of It is task T j The last task slice of ;
[0022] Rule 4: If the execution time of a task slice is 0, it cannot be assigned to any machine for execution. Encode this property as a formula:
[0023]
[0024] Rule 5: If the execution time of a task slice is greater than 0, it should be assigned to a machine for execution. Encode this property as a formula:
[0025]
[0026] Rule 6: When a task is preempted and multiple task slices are formed, the sum of the execution time of all its task slices is equal to the execution time of the task. This property is encoded as a formula:
[0027]
[0028] Rule 7: The scheduling goal is to minimize the maximum completion time of all tasks. This goal constraint is encoded as the formula:
[0029]
[0030] (S2) writing the hard clauses and soft clauses obtained in step (S1) into a file with a suffix of .wcnf to obtain a PMS problem;
[0031] (S3) The optimal solution to the PMS problem is calculated by calling the LSUPlus solver to obtain the optimal scheduling plan.
[0032] Furthermore, in the step (S2), the gurobipy library is imported using the Python code import gurobipy as gp, a mathematical programming model is created using the code m=gp.Model('mp'), and then the mathematical programming formula obtained in (S1) is passed into the created mathematical programming model m;
[0033] Furthermore, in the step (S3), the Python code m.optimize() is used to call the Gurobi mathematical optimizer to obtain the optimal solution of the model m.
[0034] Compared with the prior art, the present invention has the following beneficial effects:
[0035] (1) The present invention encodes the task attributes and scheduling objectives into mathematical programming formulas, and then uses the mathematical optimizer Gurobi to find the optimal scheduling solution. The formalization of the formula and the call of the mathematical optimizer are both completed through the third-party Python library gurobipy, and the method is easy to understand and implement;
[0036] (2) Compared with the existing optimal algorithm, the present invention can handle larger problems and therefore has higher practical application value. BRIEF DESCRIPTION OF THE DRAWINGS
[0037] Figure 1 It is the work flow chart of the present invention.
[0038] Figure 2 Comparison results of the success rate of different optimal scheduling methods in finding the optimal solution within 300 seconds under different numbers of tasks.
[0039] Figure 3 Comparison results of running time of different optimal scheduling methods under different number of tasks.
[0040] Figure 4 The comparison results of the success rate of different optimal scheduling methods in finding the optimal solution within 300 seconds under different task execution times.
[0041] Figure 5 Comparison results of the running time of different optimal scheduling methods under different task execution durations. DETAILED DESCRIPTION
[0042] The present invention is further described below in conjunction with the accompanying drawings and examples. The embodiments of the present invention include but are not limited to the following examples.
[0043] Example
[0044] like Figure 1 As shown, a parallel processor scheduling method with preemption granularity limitation includes the following steps:
[0045] (S1) According to the restrictive preemption attribute constraints of the scheduling problem and the scheduling goal of minimizing the maximum completion time, seven mathematical programming formulas are proposed; the rules are as follows:
[0046] Rule 1: The task slices of each task are executed sequentially. This property is encoded as a formula:
[0047]
[0048] Among them, Γ is the task set, T j represents the jth task in the set Γ, Represents task T j The i-th task slice of Represents task slicing The start time of execution, Represents task slicing The execution time of L max is the maximum completion time of a feasible scheduling solution calculated by any heuristic algorithm (e.g., LPT improved algorithm [1], 2RS algorithm [2]), p j It is task T j Execution time of
[0049] [1]K.Ecker and R.Hirschberg.Task scheduling with restrictedpreemptions.PARLE In 1993Parallel Architectures and Languages Europe,pages464-475,Berlin,Heidelberg,06 1993.Springer.
[0050] [2]K.Pie_nkosz and A.Prus.Task scheduling with restricted preemptionson two parallel processors.In 2015 20th International Conference on Methods and Models in Automation and Robotics(MMAR),pages 58-61,Poland,08 2015.IEEE.
[0051] Rule 2: If two task slices from different tasks are scheduled to the same machine, then the two task slices must be executed sequentially. This property is encoded as a formula:
[0052]
[0053] Among them, Μ represents the machine set, M u represents the u-th machine of M, is the decision variable, 1 indicates task sharding On machine M u Execute on, Represents task slicing Not on machine M u ∧ represents the logical AND operation, ∨ represents the logical OR operation, represents the implication operation;
[0054] Rule 3: Except for the last task slice, the execution time of each task slice is either not less than k or equal to 0. This property is encoded as the formula:
[0055]
[0056] Among them, k is the preemption granularity. When a task is preempted, it must be executed continuously for k time units, otherwise it cannot be preempted. j It is task T j The execution time of It is task Tj The last task slice of ;
[0057] Rule 4: If the execution time of a task slice is 0, it cannot be assigned to any machine for execution. Encode this property as a formula:
[0058]
[0059] Rule 5: If the execution time of a task slice is greater than 0, it should be assigned to a machine for execution. Encode this property as a formula:
[0060]
[0061] Rule 6: When a task is preempted and multiple task slices are formed, the sum of the execution time of all its task slices is equal to the execution time of the task. This property is encoded as a formula:
[0062]
[0063] Rule 7: The scheduling goal is to minimize the maximum completion time of all tasks. This goal constraint is encoded as the formula:
[0064]
[0065] (S2) Use Python code import gurobipy as gp to import the gurobipy library, use code m = gp.Model('mp') to create a mathematical programming model, and then pass the mathematical programming formula obtained in (S1) into the created mathematical programming model m;
[0066] (S3) Use the Python code m.optimize() to call the Gurobi mathematical optimizer to obtain the optimal solution for model m.
[0067] The above embodiments are only preferred embodiments of the present invention and are not intended to limit the protection scope of the present invention. Any changes made by adopting the design principles of the present invention and performing non-creative work on this basis should fall within the protection scope of the present invention.
[0068] The following two simple examples illustrate the advantages of the method proposed in the present invention in dealing with medium-scale problems. For the convenience of description, MP is used to represent the method proposed in the present invention, and SAT and PMS are both methods proposed in the paper [1].
[0069] In the first application example, the number of tasks contained in each problem instance is set to n, and the value of n is enumerated from 10 to 30 in increments of 5 to test the performance of the three optimal algorithms when the number of tasks increases. These tasks need to be scheduled to 4 parallel identical machines for processing. The processing time of each task is randomly selected in the interval [10,20], and the value of the preemption granularity is set to 9 to ensure that each task can be preempted at least once. 10 problem instances are generated under each parameter, so a total of 50 instances are evaluated. Figure 2 The success rate of the three best algorithms in finding the optimal solution within the 300-second timeout limit under different numbers of tasks is shown. Figure 3 The figure shows the time it takes for the three methods to successfully find the optimal solution for different numbers of tasks. Figure 2 It can be clearly seen that as the number of tasks n increases, the performance of the SAT and PMS algorithms drops sharply, while the performance drop of MP can be controlled to a certain extent. Specifically, when the number of tasks reaches 20, the success rate of SAT and PMS in finding the optimal solution within 300 seconds drops to no more than 0.7; when the number of tasks reaches 25, the success rate of SAT and PMS in finding the optimal solution within 300 seconds drops to 0. In contrast, the MP method can still find the optimal solution of all problems with a 100% success rate when the number of tasks n reaches 30, and the running time is less than 40 seconds. Therefore, the MP method has a more significant performance advantage than SAT and PMS when the number of tasks increases.
[0070] In the second application example, each problem instance contains 10 tasks, which need to be scheduled to 4 parallel identical machines for processing. The processing time of each task is randomly selected in the interval [t, 2*t], and the preemption granularity is set to 0.9*t to ensure that each task can be preempted at least once. In this example, the t value is enumerated from 10 to 50 in increments of 10 to test the performance of different optimal algorithms when the t value increases. 10 problem instances are generated under each parameter, so a total of 50 instances are evaluated. Figure 4 The figure shows the comparison of the success rate of the three optimal scheduling methods in finding the optimal solution within 300 seconds under different task execution times. Figure 4 It can be clearly seen that as the task execution time t increases, both the MP and SAT algorithms can find the optimal solutions to all problems within the 300-second timeout period, while the PMS algorithm achieves a solution success rate of 0.7 when the task execution time interval is [30, 60], and the solution success rate drops to 0 in a larger task execution time interval. Figure 5The time it takes for the three methods to successfully find the optimal solution under different task execution times is shown. Obviously, when the t value increases, the running time of the SAT method increases significantly, while the running time of the MP method is almost unaffected. This is because the MP method treats the task execution time as an integer variable, while SAT and PMS use binary numbers to represent the task execution time. As the task execution time increases, the number of binary bits required also increases, causing the problem of expanding the scale of the problem to be solved.
[0071] The above application examples illustrate that the precise algorithm provided by the present invention can be used to obtain the optimal solution to the restrictive preemption problem, and when the number of tasks increases or the task execution time increases, the solution efficiency is higher than that of the existing optimal algorithm.
[0072] References:
[0073] [1]Xiaojuan Liao, Hui Zhang, Miyuki Koshimura, Rong Huang, Fagen Li, Solving Restricted Preemptive Scheduling on Parallel Machines with SAT andPMS, Journal of Universal Computer Science, 2023, vol.29, no.8, 911-937.
Claims
1. A parallel processor scheduling method with preemption granularity limitation, characterized in that: The steps include: (S1) According to the restrictive preemption attribute constraints of the scheduling problem and the scheduling goal of minimizing the maximum completion time, seven mathematical programming formulas are proposed; the rules are as follows: Rule 1: The task slices of each task are executed sequentially. This property is encoded as a formula: Among them, Γ is the task set, T j represents the jth task in the set Γ, Represents task T j The i-th task slice of Represents task slicing The start time of execution, Represents task slicing The execution time of L max is the maximum completion time of a feasible scheduling solution calculated by any heuristic algorithm, p j It is task T j Execution time of Rule 2: If two task slices from different tasks are scheduled to the same machine, then the two task slices must be executed sequentially. This property is encoded as a formula: Among them, Μ represents the machine set, M u represents the u-th machine of M, is the decision variable, Represents task slicing On machine M u Execute on, Represents task slicing Not on machine M u ∧ represents the logical AND operation, ∨ represents the logical OR operation, represents the implication operation; Rule 3: Except for the last task slice, the execution time of each task slice is either not less than k or equal to 0. This property is encoded as the formula: Among them, k is the preemption granularity. When a task is preempted, it must be executed continuously for k time units, otherwise it cannot be preempted. j It is task T j The execution time of It is task T j The last task slice of ; Rule 4: If the execution time of a task slice is 0, it cannot be assigned to any machine for execution. Encode this property as a formula: Rule 5: If the execution time of a task slice is greater than 0, it should be assigned to a machine for execution. Encode this property as a formula: Rule 6: When a task is preempted and multiple task slices are formed, the sum of the execution time of all its task slices is equal to the execution time of the task. This property is encoded as a formula: Rule 7: The scheduling goal is to minimize the maximum completion time of all tasks. This goal constraint is encoded as the formula: (S2) calling the Python gurobipy library and passing the mathematical programming formula obtained in step (S1) into the Gurobi mathematical optimizer of gurobipy; (S3) The optimal solution to the problem is calculated by calling the Gurobi mathematical optimizer to obtain the optimal scheduling solution.
2. A parallel processor scheduling method with preemption granularity limitation according to claim 1, characterized in that: In the step (S2), the Python code import gurobipy as gp is used to import the gurobipy library, the code m=gp.Model('mp') is used to create a mathematical programming model, and then the mathematical programming formula obtained in (S1) is passed into the created mathematical programming model m.
3. A parallel processor scheduling method with preemption granularity limitation according to claim 1, characterized in that: In the step (S3), the Python code m.optimize() is used to call the Gurobi mathematical optimizer to obtain the optimal solution of the model m.
Citation Information
Patent Citations
Double-layer scheduling method for precast concrete members in supply chain environment
CN111401616A
Workflow scheduling method with multiple timing constraints in hybrid cloud environment
CN115237593A
Distributed process planning and workshop scheduling integrated optimization method
CN116468137A
FJSP-AGV modeling method based on mixed integer programming model
CN116736819A
