Task scheduling method and device, computer equipment and storage medium
By constructing a genolocal and generating task scheduling scheme in the big data system, and determining the latest task completion time based on resource consumption and starting scheduling time, the problem of low task scheduling efficiency and poor effect in the big data system is solved, and efficient and timely task scheduling is achieved.
Patent Information
- Application Number
- CN202411669930.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-20
- Publication Date
- 2025-03-25
AI Technical Summary
In big data systems, when facing a large number of supervision and reporting tasks, the task scheduling efficiency is low and the effect is poor, making it difficult to ensure the timeliness of the task.
By obtaining multiple tasks to be dispatched, genota are constructed based on task priority, and task scheduling scheme is generated based on genota, combining resource consumption and starting scheduling time to determine the latest completion time of the task, performing fitness evaluation, and outputting a task scheduling scheme that meets the preset target scheduling conditions.
It significantly reduces scheduling time, improves scheduling efficiency, avoids resource conflicts between tasks, improves resource utilization, and ensures the timeliness of tasks, especially high-priority tasks can be completed on time.
Smart Images

Figure CN119690644A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of artificial intelligence and big data technology, and in particular to a task scheduling method, apparatus, computer equipment and storage medium. Background Art
[0002] The big data industry is developing rapidly and has played an important role in various fields. However, as the complexity and scale of big data systems increase, the amount of data continues to increase, and the number of tasks within the system increases. The resulting timeliness issues become more prominent. In order to more effectively utilize cluster resources, it is particularly important to reasonably schedule big data tasks. By optimizing scheduling, a large number of tasks can be completed at a lower cost.
[0003] However, when faced with regulatory reporting tasks, scheduling becomes even more difficult. These tasks are often numerous and complex, and downstream regulatory reporting projects have strict timeliness requirements. Simply optimizing certain individual tasks will usually affect the timeliness of other tasks in the queue, making it difficult to achieve overall optimization results.
[0004] Therefore, the current method of manual scheduling when faced with complex scheduling of a large number of tasks is both time-consuming and inefficient, and the optimization effect is difficult to guarantee. Summary of the invention
[0005] The purpose of the embodiments of the present application is to provide a task scheduling method, apparatus, computer equipment and storage medium to solve the problems of low task scheduling efficiency and poor scheduling effect in related technologies.
[0006] In order to solve the above technical problems, the present application provides a task scheduling method, which adopts the following technical solutions:
[0007] Get multiple tasks to be scheduled; each task includes resource consumption;
[0008] Constructing gene positions based on multiple tasks corresponding to the same task priority, and generating a task scheduling plan based on the multiple gene positions; wherein the gene positions include a starting scheduling time of the task;
[0009] Determine the latest completion time for each task based on resource consumption and starting scheduling time;
[0010] Based on the latest completion time of each task, the fitness of the task scheduling scheme is evaluated;
[0011] When the evaluation result meets the preset target scheduling conditions, the target task scheduling plan corresponding to the fitness is output.
[0012] Furthermore, resource consumption includes the total running time of each task and the total number of resources running in parallel. The steps of determining the latest completion time of each task based on resource consumption and the starting scheduling time specifically include:
[0013] Determine the execution time of the task based on the total running time and the total number of resources;
[0014] Determine the latest completion time of the task based on the starting scheduling time and execution duration.
[0015] Furthermore, the resource consumption includes the current remaining resource quantity. Based on the total running time and the total resource quantity, the steps of determining the execution time of the task specifically include:
[0016] Compare the total resource quantity with the current remaining resource quantity;
[0017] If the total number of resources is less than or equal to the current number of remaining resources, the ratio of the total running time to the total number of resources is used as the execution time.
[0018] Furthermore, after the step of comparing the total resource quantity with the current remaining resource quantity, the method further includes:
[0019] If the total resource quantity is greater than the current remaining resource quantity, the remaining resource quantity is compared with the preset value;
[0020] If the current number of remaining resources is greater than the preset value, the ratio of the total running time to the current number of remaining resources is used as the execution time.
[0021] Furthermore, resource consumption includes task loading time. Based on the total running time and the total number of resources, the steps of determining the execution time of the task specifically include:
[0022] If the current number of remaining resources is equal to the preset value, the ratio of the total running time to the current number of remaining resources is used as the addend;
[0023] The sum of the addend and the task loading duration is taken as the execution duration.
[0024] Furthermore, the step of generating a task scheduling scheme based on multiple gene positions specifically includes:
[0025] If the result of the task scheduling scheme obtained through fitness evaluation does not meet the preset target scheduling condition, a preset number of first scheduling schemes are determined from the scheduling schemes;
[0026] A new scheduling scheme is generated based on the preset genetic operation and the first scheduling scheme.
[0027] Furthermore, based on the latest completion time of each task, the step of evaluating the fitness of the task scheduling scheme specifically includes:
[0028] In the task scheduling scheme, the shortest latest completion time is taken as the result of fitness evaluation.
[0029] In order to solve the above technical problems, the embodiment of the present application further provides a task scheduling device, which adopts the following technical solutions:
[0030] A task acquisition module is used to acquire multiple tasks to be scheduled; each task includes resource consumption;
[0031] A scheme generation module is used to construct gene positions based on multiple tasks corresponding to the same task priority, and generate a task scheduling scheme based on the multiple gene positions; wherein the gene positions include the starting scheduling time of the task;
[0032] A completion time determination module is used to determine the latest completion time of each task based on resource consumption and start scheduling time;
[0033] The fitness evaluation module is used to evaluate the fitness of the task scheduling scheme based on the latest completion time of each task;
[0034] The solution output module is used to output the target task scheduling solution corresponding to the fitness when the evaluation result meets the preset target scheduling conditions.
[0035] In order to solve the above technical problems, an embodiment of the present application further provides a computer device, including a memory and a processor, wherein a computer program is stored in the memory, and the processor implements the steps of the above task scheduling method when executing the computer program.
[0036] In order to solve the above technical problems, an embodiment of the present application further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the above task scheduling method are implemented.
[0037] Compared with the related art, the embodiments of the present application have the following beneficial effects:
[0038] By obtaining multiple tasks to be scheduled, constructing gene bits based on multiple tasks corresponding to the same task priority, and generating task scheduling schemes based on multiple gene bits, wherein the gene bits include the starting scheduling time of the task, determining the latest completion time of each task based on resource consumption and the starting scheduling time, and performing fitness evaluation on the task scheduling scheme based on the latest completion time of each task. When the evaluation result meets the preset target scheduling condition, the target task scheduling scheme corresponding to the fitness is output, that is, a reasonable scheduling scheme is generated by combining the starting scheduling time, the scheduling order (i.e., the task priority) and the resource consumption. Compared with the traditional manual scheduling method, the method of automatically constructing gene bits and generating scheduling schemes can significantly reduce the scheduling time and effectively improve the scheduling efficiency. In addition, combining resource consumption and the starting scheduling time to determine the latest completion time of the task can effectively avoid resource conflicts between tasks, thereby improving resource utilization. At the same time, by calculating the latest completion time of each task and evaluating the fitness, the task delay problem that may occur in the scheduling process is effectively avoided, and the timeliness of the task is guaranteed, especially the high-priority tasks can be completed on time, which helps to meet strict business needs and timeliness requirements. BRIEF DESCRIPTION OF THE DRAWINGS
[0039] In order to more clearly illustrate the scheme in the present application, a brief introduction is given below to the drawings required for use in the description of the embodiments of the present application. Obviously, the drawings described below are some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0040] Figure 1 is an exemplary system architecture diagram to which the present application may be applied;
[0041] Figure 2 is a flow chart of an embodiment of the task scheduling method of the present application;
[0042] Figure 3 It is a task coding diagram provided in an embodiment of the present application;
[0043] Figure 4 A schematic diagram of a flow chart of a scheduling scheme generation provided in an embodiment of the present application;
[0044] Figure 5 is a structural diagram of an embodiment of a task scheduling device according to the present application;
[0045] Figure 6 It is a structural diagram of an embodiment of a computer device according to the present application. DETAILED DESCRIPTION
[0046] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by technicians in the technical field of the present application; the terms used in the specification of the application herein are only for the purpose of describing specific embodiments and are not intended to limit the present application; the terms "including" and "having" and any variations thereof in the specification and claims of the present application and the above-mentioned drawings are intended to cover non-exclusive inclusions. The terms "first", "second", etc. in the specification and claims of the present application or the above-mentioned drawings are used to distinguish different objects, not to describe a specific order.
[0047] Reference to "embodiments" herein means that a particular feature, structure, or characteristic described in conjunction with the embodiments may be included in at least one embodiment of the present application. The appearance of the phrase in various locations in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those skilled in the art that the embodiments described herein may be combined with other embodiments.
[0048] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the accompanying drawings.
[0049] like Figure 1 As shown, the system architecture 100 may include a terminal device 101, a network 102 and a server 103. The terminal device 101 may be a laptop 1011, a tablet computer 1012 or a mobile phone 1013. The network 102 is used to provide a medium for a communication link between the terminal device 101 and the server 103. The network 102 may include various connection types, such as wired, wireless communication links or optical fiber cables.
[0050] The user can use the terminal device 101 to interact with the server 103 through the network 102 to receive or send messages, etc. Various communication client applications can be installed on the terminal device 101, such as web browser applications, shopping applications, search applications, instant messaging tools, email clients, social platform software, etc.
[0051] The terminal device 101 can be any electronic device with a display screen and supporting web browsing. In addition to a laptop computer 1011, a tablet computer 1012 or a mobile phone 1013, the terminal device 101 can also be an e-book reader, an MP3 player (Moving Picture Experts Group Audio Layer III), an MP4 (Moving Picture Experts Group Audio Layer IV), a laptop computer, a desktop computer, etc.
[0052] The server 103 may be a server that provides various services, such as a background server that provides support for web pages displayed on the terminal device 101 .
[0053] It should be noted that the task scheduling method provided in the embodiment of the present application is generally executed by a server / terminal device, and accordingly, the task scheduling device is generally set in the server / terminal device.
[0054] It should be understood that Figure 1 The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to implementation requirements.
[0055] Continue to refer Figure 2 , shows a flow chart of an embodiment of a method for task scheduling according to the present application. The task scheduling method comprises the following steps:
[0056] Step S201, obtaining a plurality of tasks to be scheduled, wherein each task includes resource consumption.
[0057] In this embodiment, the task scheduling method is executed on the electronic device (eg Figure 1 The server / terminal device shown in the figure can receive the task to be scheduled through a wired connection or a wireless connection. It should be noted that the above wireless connection method may include but is not limited to 3G / 4G / 5G connection, WiFi connection, Bluetooth connection, WiMAX connection, Zigbee connection, UWB (ultra wideband) connection, and other wireless connection methods currently known or to be developed in the future.
[0058] In this embodiment, resource consumption may refer to the occupation and use of system resources (such as computing power, storage space, network bandwidth, etc.) by a task during execution. Different tasks have different requirements for system resources. Resource consumption is usually used to measure the running overhead of tasks and is a key indicator in task scheduling and resource management. For example, resource consumption may include but is not limited to CPU consumption (referring to the computing resources used by a task during execution, usually measured by CPU time, usage rate, etc. For example, a task may need to occupy multiple CPU cores and run for several hours), memory consumption, storage consumption, and network bandwidth consumption.
[0059] In the task scheduling scenario, resource consumption is an important basis for determining task allocation and execution order. For example, ensure that high-consumption tasks are not concentrated at the same time to avoid excessive system load; balance resource consumption to avoid task delays and failures due to insufficient resources; fill tasks with less resource consumption in resource idle periods to improve the overall utilization efficiency of the system.
[0060] Specifically, the tasks to be scheduled usually come from various business systems and data sources, including business databases, data warehouses, real-time data streams or third-party systems, etc. The tasks to be scheduled are the basis for scheduling decisions, helping each system analyze the resource requirements, priorities and dependencies of tasks.
[0061] For example, in the financial or e-commerce fields, the system needs to process a certain batch of data every day or every hour (such as report generation, bill processing, order reconciliation, etc.), that is, the data is the task to be scheduled.
[0062] Step S202, constructing gene bits based on multiple tasks corresponding to the same task priority, and generating a task scheduling plan based on the multiple gene bits; wherein the gene bits include a starting scheduling time of the task.
[0063] In this embodiment, the tasks to be scheduled include predecessor tasks and current tasks. A predecessor task refers to a task that must be completed before a certain task during task scheduling or execution. In other words, the start time of a task depends on the completion of its predecessor task. For example, in a big data processing task scenario, there are dependencies between tasks, including Task A for data collection, Task B for data cleaning, and Task C for data analysis, that is, the predecessor task of Task B is Task A, because data cleaning must be started after data collection is completed. Similarly, the predecessor task of Task C is Task B, because data analysis must be performed after data cleaning. In the task scheduling process, the completion time of the predecessor tasks needs to be considered to ensure that the dependencies are met, so as to reasonably arrange the execution time of each task.
[0064] It should be noted that in the task scheduling problem, the starting scheduling time is used to more effectively plan the execution order of tasks and resource allocation, ensure that tasks can be completed as required, and at the same time avoid resource conflicts and task delays. For example, in high-priority tasks, high-priority tasks must be completed before time T1. If the starting scheduling time for this task is set to T0 (T0 < T1), it can be ensured that it can be completed on time before T1. In this embodiment, the starting scheduling time of task execution can be expressed as:
[0065]
[0066] where Ki j represents the current task, and Ki k represents the previous task of Ki j , is the starting scheduling time of the current task, is the ending scheduling time of the previous task. If the starting scheduling time of the current task is greater than or equal to the ending scheduling time of the previous task, then the current task can be started at its starting scheduling time. If the starting scheduling time of the current task is earlier than the ending scheduling time of the previous task, then the starting scheduling time of the current task must be delayed until the previous task is completed, that is, the starting scheduling time is Ki k .
[0067] Multiple tasks corresponding to the same task priority can be represented, for example, as the first-priority tasks in the market and their previous tasks as k1 = (K11, K12,..., K1 a ), and the latest completion time is T k1 ; the second-priority tasks in the market and their previous tasks as k2 = (K21, K22,..., K2 b ), and the latest completion time is T k2 ; the third-priority tasks in the market and their previous tasks as k3 = (K31, K32,..., K3 c ), and the latest completion time is T k3 .
[0068] In this embodiment, each gene bit represents a corresponding specific task to be scheduled. Various information of the task (such as resource requirements, priority, starting scheduling time) is recorded on the gene bit, and different task scheduling schemes can be generated by adjusting the starting scheduling time in the gene bit to evaluate the effects of tasks starting to execute at different time points.
[0069] Furthermore, the starting scheduling time of the randomly generated task is used as the first generated task scheduling plan. Each task scheduling plan consists of n gene bits, each gene bit corresponds to a market task (i.e., multiple tasks corresponding to the same task priority), and the time data in the gene bit represents the starting scheduling time of the task. Specifically, a time data in the format of HH:mm is randomly generated in the gene bit as the starting scheduling time of the corresponding market task. Figure 3 As shown, Figure 3 The task coding diagram provided in the embodiment of the present application is shown in FIG. The random numbers under the gene positions corresponding to the tasks with market priority k1, k2, and k3 are restricted. For example, the coding range of the k1 task is (00:00, T k1 ), the k2 task coding range is (00:00, T k2 ), the k3 task coding range is (00:00, T k3 ). The random individual code is as follows: X = ((K11, 00:15), (K12, 00:15), ..., (K1 a , 01:15), (K21, 01:30), (K22, 04:30),..., (K2 b , 06:45), (K31, 12:00), (K32, 09:15),..., (K3 c 14:00), the meaning of this individual code identifier is that the starting scheduling time of task K11 is 00:15, the starting scheduling time of task K12 is 00:15, and the starting scheduling time of task K1 a The starting schedule time of task K2 is 01:15, the starting schedule time of task K21 is 01:30, the starting schedule time of task K22 is 04:30, and the starting schedule time of task K2 b The starting scheduling time is 06:45 etc.
[0070] Step S203, determining the latest completion time of each task based on resource consumption and the start scheduling time.
[0071] Each task usually has a latest completion time or other timeliness requirements. During the scheduling process, specifying the start scheduling time can ensure that the task starts within the specified time so that there is enough time to complete. By planning the start scheduling time, task delays can be minimized and timeliness requirements can be ensured. By properly arranging the start scheduling time of tasks, the idle time between tasks can be reduced and the total completion time of the entire task set can be minimized. By controlling the start scheduling time of tasks, resource usage can be distributed over a longer period of time to avoid resource peak conflicts.
[0072] The latest completion time is equal to the starting scheduling time plus the execution time, and the execution time is affected by the CPU consumption time and the degree of parallelism. Through calculations based on resource consumption and the starting scheduling time, the latest completion time of each task can be accurately estimated to ensure that the task completion time is optimized when resources allow, and the scheduling can be adjusted in time to meet the priority and timeliness requirements of different tasks.
[0073] Step S204: Based on the latest completion time of each task, the task scheduling scheme is evaluated for fitness.
[0074] Among them, fitness evaluation can use fitness function to evaluate the quality of task scheduling scheme. The fitness function quantifies the quality of each solution by calculating a given target, indicating how close the solution is to the expected optimal solution. The higher the fitness value, the more the solution meets the optimization goal of the problem. In multi-objective optimization (i.e., each task to be scheduled with different task priorities in this application), each target may have a fitness function. Combining the fitness of multiple targets can help select a solution that performs better on multiple targets. Define fitness function f n =min(f1(X), f2(X), f3(X)); where f n represents fitness, f1(X) represents the latest completion time of high-priority tasks, f2(X) and f3(X) represent the latest completion time of medium-priority and low-priority tasks, respectively.
[0075]
[0076] f1(X) represents the latest completion time of the priority k1 task under solution X, and when the latest completion time max(t k1 ) is not greater than T k1 When max(t k1 ), otherwise it takes infinity, f2(X) and f3(X) are defined in the same way as f1(X). n =min(f1(X), f2(X), f3(X)) represents the minimum value that satisfies the three conditions at the same time. For non-trivial multi-objective problems, it is impossible to find a solution that satisfies all three objectives at the same time, but it is possible to find infinite Pareto optimal solutions.
[0077] Furthermore, based on the latest completion time of each task, the step of evaluating the fitness of the task scheduling scheme specifically includes:
[0078] In the task scheduling scheme, the shortest latest completion time is used as the result of fitness evaluation.
[0079] In this embodiment, minimizing the completion time without significantly increasing resource consumption can be used as a criterion for fitness evaluation.
[0080] Step S205: When the evaluation result meets the preset target scheduling condition, the target task scheduling plan corresponding to the fitness is output.
[0081] Among them, the preset target scheduling condition refers to the specific standard or goal set in the task scheduling process to generate a final acceptable scheduling plan, which is used to determine whether the current scheduling plan has achieved the optimization goal, thereby deciding whether to output the current scheduling plan or continue iterative optimization.
[0082] Exemplarily, the preset target scheduling condition is that high-priority tasks and other important tasks must be completed before the set latest completion time. If some tasks in the scheduling plan are not completed on time, the scheduling plan does not meet the preset target scheduling condition; the scheduling plan needs to ensure that system resources (such as CPU, memory, network bandwidth and other resources) are used reasonably to avoid idleness or overload. For example, the preset target scheduling condition is set to the target resource utilization rate (such as above 85%) to ensure that the scheduling plan optimizes task scheduling under the premise of reasonable use of system resources.
[0083] By obtaining multiple tasks to be scheduled, constructing gene bits based on multiple tasks corresponding to the same task priority, and generating task scheduling schemes based on multiple gene bits, wherein the gene bits include the starting scheduling time of the task, determining the latest completion time of each task based on resource consumption and the starting scheduling time, and performing fitness evaluation on the task scheduling scheme based on the latest completion time of each task. When the evaluation result meets the preset target scheduling condition, the target task scheduling scheme corresponding to the fitness is output, that is, a reasonable scheduling scheme is generated by combining the starting scheduling time, the scheduling order (i.e., the task priority) and the resource consumption. Compared with the traditional manual scheduling method, the method of automatically constructing gene bits and generating scheduling schemes can significantly reduce the scheduling time and effectively improve the scheduling efficiency. In addition, combining resource consumption and the starting scheduling time to determine the latest completion time of the task can effectively avoid resource conflicts between tasks, thereby improving resource utilization. At the same time, by calculating the latest completion time of each task and evaluating the fitness, the task delay problem that may occur in the scheduling process is effectively avoided, and the timeliness of the task is guaranteed, especially the high-priority tasks can be completed on time, which helps to meet strict business needs and timeliness requirements.
[0084] In some optional implementations, resource consumption includes the total running time of each task and the total number of resources running in parallel. For example, step S203 of determining the latest completion time of each task based on resource consumption and the starting scheduling time specifically includes:
[0085] Step S2031: Determine the execution duration of the task based on the total running duration and the total number of resources.
[0086] The total running time indicates the CPU consumption time, and the total number of resources can be the number of parallelism (MapReduce), where MapReduce indicates the parallel processing capability or amount of a task, that is, how many subtasks the task can be decomposed into and run simultaneously, thus determining the resource requirements and execution time. The total number of CPU resources can be expressed as M, and when allocated to each task, for example, task Ki j The CPU consumption time is The total number of resources corresponding to this task is
[0087] Step S2032: Determine the latest completion time of the task based on the starting scheduling time and the execution duration.
[0088] Among them, the latest completion time = starting scheduling time + execution time. Through calculations based on the total running time, total number of resources and starting scheduling time, the latest completion time of each task can be accurately estimated to ensure that the system optimizes the task completion time when resources allow, and can adjust the scheduling in time to meet the priority and timeliness requirements of different tasks.
[0089] Furthermore, the resource consumption includes the current remaining resource quantity. Based on the total running time and the total resource quantity, the steps of determining the execution time of the task specifically include:
[0090] Compare the total resource quantity with the current remaining resource quantity;
[0091] If the total number of resources is less than or equal to the current number of remaining resources, the ratio of the total running time to the total number of resources is used as the execution time.
[0092] For example, the current remaining resource quantity can be expressed as M 余 , continue with the task Ki j For example, when Mission Ki j Execution time
[0093] Furthermore, after the step of comparing the total resource quantity with the current remaining resource quantity, the method further includes:
[0094] If the total resource quantity is greater than the current remaining resource quantity, the remaining resource quantity is compared with the preset value;
[0095] If the current number of remaining resources is greater than the preset value, the ratio of the total running time to the current number of remaining resources is used as the execution time.
[0096] The preset value can be an integer value such as 0. j For example, Mission Ki j Execution time
[0097] Furthermore, resource consumption includes task loading time. Based on the total running time and the total number of resources, the steps of determining the execution time of the task specifically include:
[0098] If the current number of remaining resources is equal to the preset value, the ratio of the total running time to the current number of remaining resources is used as the addend;
[0099] The sum of the addend and the task loading duration is taken as the execution duration.
[0100] Continue with Mission Ki j For example, M 余 = 0, task Ki j Execution time
[0101] In some optional implementations, the step of generating a task scheduling scheme based on multiple gene positions in step S202 specifically includes:
[0102] If the result of the task scheduling scheme obtained through fitness evaluation does not meet the preset target scheduling condition, a preset number of first scheduling schemes are determined from the scheduling schemes;
[0103] A new scheduling scheme is generated based on the preset genetic operation and the first scheduling scheme.
[0104] Among them, the preset genetic operations include replication, crossover and mutation. Specifically, replication means eliminating the scheduling scheme with poor fitness according to the fitness function, and retaining the scheduling scheme with better fitness (i.e., the first scheduling scheme) for replication, and the preset number can be set according to the actual situation; crossover means performing crossover operations on the gene bits in different scheduling schemes to generate new scheduling schemes; mutation means randomly mutating the gene bits of some individuals to generate a new starting scheduling time. Furthermore, the gene bits of the new starting scheduling time are reconstructed, and the above S202-S204 are repeatedly executed until the fitness evaluation result of the task scheduling scheme meets the preset target scheduling conditions.
[0105] Exemplarily, there are three initial scheduling schemes, each of which corresponds to the starting scheduling time of a group of tasks, as shown in the following table:
[0106]
[0107]
[0108] It can be seen from the above table data that the scheduling schemes 1 and 2 have higher fitness and can be selected as the first scheduling scheme (i.e., copy); the scheduling scheme 2 and the scheduling scheme 1 are single-point crossed (i.e., crossed), and the starting scheduling time of the second task in the scheduling scheme is swapped to generate two new scheduling schemes: new scheduling scheme A: [08:30, 09:00, 10:00] and new scheduling scheme B: [08:00, 09:30, 10:30]; the time of the second task of the new scheduling scheme A is fine-tuned (i.e., mutated), that is, its starting scheduling time is changed from 09:00 to 09:15, to obtain a new scheduling scheme after fine-tuning; and the fitness of the new scheduling scheme after fine-tuning is recalculated. If the new scheduling scheme meets the preset target scheduling condition (such as the fitness exceeds 0.90), the new scheduling scheme is output, otherwise the above steps S202-S204 are continued to be executed until the iteration result meets the preset target scheduling condition.
[0109] Through genetic operations such as replication, crossover, and mutation, new task scheduling solutions can be continuously generated to explore a wider solution space. In the task scheduling problem, genetic operations make it possible to balance multiple goals such as task completion time, resource usage, and dependencies, and ultimately find one or more near-optimal scheduling solutions.
[0110] Further, such as Figure 4 As shown, Figure 4 A schematic diagram of a process flow for generating a scheduling solution provided in an embodiment of the present application, wherein the specific process includes:
[0111] Enter the tasks to be scheduled;
[0112] Encode the tasks to be scheduled based on their priority and starting scheduling time;
[0113] Randomly generate multiple task scheduling schemes (each scheduling scheme is a population), each scheduling scheme consists of n gene positions, each gene position corresponds to the task to be scheduled with the same task priority, and evaluate the pros and cons of the scheduling scheme according to the fitness obtained by the fitness function;
[0114] Eliminate scheduling plans with poor fitness and select scheduling plans with better fitness;
[0115] If the scheduling plan changes for 50 consecutive generations, replication, crossover, and mutation will be performed in the population to generate the next generation of population, that is, to generate a new scheduling plan.
[0116] After multiple iterations, if the population gradually tends to be stable, an approximate optimal solution is finally obtained and the approximate optimal solution is output, that is, the final target scheduling plan is output.
[0117] Through the above method, we can quickly find a scheduling method that theoretically meets multiple requirements, which greatly reduces the manpower investment in scheduling configuration in complex systems. At the same time, the optimized algorithm can also expand resource utilization as a goal to improve the resource utilization of the queue.
[0118] The embodiments of the present application can acquire and process relevant data based on artificial intelligence technology. Among them, artificial intelligence (AI) is the theory, method, technology and application system that uses digital computers or machines controlled by digital computers to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge and use knowledge to obtain the best results.
[0119] AI basic technologies generally include sensors, dedicated AI chips, cloud computing, distributed storage, big data processing technology, operation / interaction systems, mechatronics, etc. AI software technologies mainly include computer vision technology, robotics technology, biometrics technology, speech processing technology, natural language processing technology, and machine learning / deep learning.
[0120] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiments can be implemented by instructing the relevant hardware through computer-readable instructions, and the computer-readable instructions can be stored in a computer-readable storage medium. When the program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, the aforementioned storage medium can be a non-volatile storage medium such as a disk, an optical disk, a read-only memory (ROM), or a random access memory (RAM).
[0121] It should be understood that, although the steps in the flowchart of the accompanying drawings are displayed in sequence as indicated by the arrows, these steps are not necessarily executed in sequence in the order indicated by the arrows. Unless otherwise specified herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least a part of the steps in the flowchart of the accompanying drawings may include multiple sub-steps or multiple stages, and these sub-steps or stages are not necessarily executed at the same time, but can be executed at different times, and their execution order is not necessarily sequential, but can be executed in turn or alternately with other steps or at least a part of the sub-steps or stages of other steps.
[0122] Further references Figure 5 , as a response to the above Figure 2 The present application provides an embodiment of a task scheduling device, and the embodiment of the device is similar to Figure 2Corresponding to the method embodiment shown, the device can be specifically applied to various electronic devices.
[0123] like Figure 5 As shown, the task scheduling device 500 described in this embodiment includes a task acquisition module 501, a solution generation module 502, a completion time determination module 503, a fitness evaluation module 504 and a solution output module 505. Among them:
[0124] The task acquisition module 501 is used to acquire a plurality of tasks to be scheduled, wherein each task includes resource consumption;
[0125] A scheme generating module 502 is used to construct gene positions based on multiple tasks corresponding to the same task priority, and generate a task scheduling scheme based on the multiple gene positions; wherein the gene positions include the starting scheduling time of the task;
[0126] A completion time determination module 503, used to determine the latest completion time of each task based on resource consumption and the start scheduling time;
[0127] A fitness evaluation module 504 is used to evaluate the fitness of the task scheduling scheme based on the latest completion time of each task;
[0128] The solution output module 505 is used to output the target task scheduling solution corresponding to the fitness when the evaluation result meets the preset target scheduling condition.
[0129] Furthermore, resource consumption includes the total running time of each task and the total number of resources running in parallel. The completion time determination module 503 includes:
[0130] The execution time determination submodule is used to determine the execution time of the task based on the total running time and the total number of resources;
[0131] The completion time determination submodule is used to determine the latest completion time of the task based on the starting scheduling time and the execution duration.
[0132] Furthermore, the execution time determination submodule includes:
[0133] A first resource quantity comparison unit, used for comparing the total resource quantity with the current remaining resource quantity;
[0134] The first execution duration determination unit is used to use the ratio of the total running time to the total resource quantity as the execution duration if the total resource quantity is less than or equal to the current remaining resource quantity.
[0135] Furthermore, the task scheduling device 500 further includes:
[0136] a second resource quantity comparison unit, configured to compare the remaining resource quantity with a preset value if the total resource quantity is greater than the current remaining resource quantity;
[0137] The second execution duration determination unit is used to use the ratio of the total running time to the current remaining resource quantity as the execution duration if the current remaining resource quantity is greater than a preset value.
[0138] Furthermore, resource consumption includes task loading duration, and the task scheduling device 500 further includes:
[0139] The third execution duration determination unit is used to take the sum of the ratio of the total running time to the current remaining resource quantity and the task loading time as the execution time if the current remaining resource quantity is equal to a preset value.
[0140] Furthermore, the task scheduling device 500 further includes:
[0141] A scheme determination module is used to determine a preset number of first scheduling schemes from the scheduling schemes if the result obtained by the fitness evaluation of the task scheduling scheme does not meet the preset target scheduling condition;
[0142] The scheme generation module is used to generate a new scheduling scheme based on a preset genetic operation and the first scheduling scheme.
[0143] Furthermore, the fitness evaluation module 504 includes:
[0144] The result evaluation module is used to use the shortest latest completion time as the result of fitness evaluation in the task scheduling scheme.
[0145] To solve the above technical problems, the present application also provides a computer device. Figure 6 , Figure 6 This is a basic structural block diagram of the computer device in this embodiment.
[0146] The computer device 6 includes a memory 61, a processor 62, and a network interface 63 that are interconnected and communicated through a system bus. It should be noted that the figure only shows a computer device 6 with a memory 61, a processor 62, and a network interface 63, but it should be understood that it is not required to implement all the components shown, and more or fewer components can be implemented instead. Among them, those skilled in the art can understand that the computer device here is a device that can automatically perform numerical calculations and / or information processing according to pre-set or stored instructions, and its hardware includes but is not limited to microprocessors, application specific integrated circuits (Application Specific Integrated Circuit, ASIC), programmable gate arrays (Field-Programmable Gate Array, FPGA), digital processors (Digital Signal Processor, DSP), embedded devices, etc.
[0147] The computer device may be a computing device such as a desktop computer, a notebook, a PDA, a cloud server, etc. The computer device may interact with a user through a keyboard, a mouse, a remote controller, a touch pad, or a voice control device.
[0148] The memory 61 includes at least one type of readable storage medium, and the readable storage medium includes flash memory, hard disk, multimedia card, card-type memory (for example, SD or DX memory, etc.), random access memory (RAM), static random access memory (SRAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), programmable read-only memory (PROM), magnetic memory, disk, optical disk, etc. In some embodiments, the memory 61 can be an internal storage unit of the computer device 6, such as a hard disk or memory of the computer device 6. In other embodiments, the memory 61 can also be an external storage device of the computer device 6, such as a plug-in hard disk equipped on the computer device 6, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (FlashCard), etc. Of course, the memory 61 can also include both the internal storage unit of the computer device 6 and its external storage device. In this embodiment, the memory 61 is generally used to store the operating system and various application software installed on the computer device 6, such as computer-readable instructions of the task scheduling method, etc. In addition, the memory 61 can also be used to temporarily store various types of data that have been output or are to be output.
[0149] The processor 62 may be a central processing unit (CPU), a controller, a microcontroller, a microprocessor, or other data processing chips in some embodiments. The processor 62 is generally used to control the overall operation of the computer device 6. In this embodiment, the processor 62 is used to run computer-readable instructions stored in the memory 61 or process data, such as computer-readable instructions for running the task scheduling method.
[0150] The network interface 63 may include a wireless network interface or a wired network interface. The network interface 63 is generally used to establish a communication connection between the computer device 6 and other electronic devices.
[0151] The present application also provides another implementation, namely, providing a computer-readable storage medium, wherein the computer-readable storage medium stores computer-readable instructions, and the computer-readable instructions can be executed by at least one processor to enable the at least one processor to perform the steps of the task scheduling method as described above.
[0152] The non-Company software tools or components appearing in the embodiments of this application are merely examples and do not represent actual use.
[0153] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk), and includes a number of instructions for a terminal device (which can be a mobile phone, computer, server, air conditioner, or network device, etc.) to execute the methods described in each embodiment of the present application.
[0154] Obviously, the embodiments described above are only some embodiments of the present application, rather than all embodiments. The preferred embodiments of the present application are given in the accompanying drawings, but they do not limit the patent scope of the present application. The present application can be implemented in many different forms. On the contrary, the purpose of providing these embodiments is to make the understanding of the disclosure of the present application more thorough and comprehensive. Although the present application is described in detail with reference to the aforementioned embodiments, for those skilled in the art, it is still possible to modify the technical solutions recorded in the aforementioned specific implementation methods, or to perform equivalent replacement of some of the technical features therein. Any equivalent structure made using the contents of the specification and drawings of this application, directly or indirectly used in other related technical fields, is similarly within the scope of patent protection of this application.
Claims
1. A task scheduling method, characterized in that: The steps include: Acquire multiple tasks to be scheduled; wherein each of the tasks includes resource consumption; Constructing gene bits based on multiple tasks corresponding to the same task priority, and generating a task scheduling plan based on the multiple gene bits; wherein the gene bits include the starting scheduling time of the task; Determine the latest completion time of each of the tasks based on resource consumption and the starting scheduling time; Based on the latest completion time of each of the tasks, evaluating the fitness of the task scheduling scheme; When the evaluation result meets the preset target scheduling condition, the target task scheduling plan corresponding to the fitness is output.
2. The task scheduling method according to claim 1, characterized in that: The resource consumption includes the total running time of each task and the total number of resources running in parallel. The step of determining the latest completion time of each task based on the resource consumption and the starting scheduling time specifically includes: Determining the execution time of the task based on the total running time and the total number of resources; Based on the starting scheduling time and the execution duration, the latest completion time of the task is determined.
3. The task scheduling method according to claim 2, characterized in that: The resource consumption includes the current remaining resource quantity, and the step of determining the execution duration of the task based on the total running duration and the total resource quantity specifically includes: Compare the total resource quantity with the current remaining resource quantity; If the total number of resources is less than or equal to the current remaining number of resources, the ratio of the total running time to the total number of resources is used as the execution time.
4. The task scheduling method according to claim 3, characterized in that: After the step of comparing the total resource quantity with the current remaining resource quantity, the method further includes: If the total resource quantity is greater than the current remaining resource quantity, comparing the remaining resource quantity with a preset value; If the current remaining resource quantity is greater than a preset value, the ratio of the total running time to the current remaining resource quantity is used as the execution time.
5. The task scheduling method according to claim 4, characterized in that: The resource consumption includes the task loading duration. After the step of comparing the remaining resource quantity with a preset value, the method further includes: If the current remaining resource quantity is equal to the preset value, the ratio of the total running time to the current remaining resource quantity is used as the addend; The sum of the addend and the task loading duration is taken as the execution duration.
6. The task scheduling method according to claim 1, characterized in that: After the step of evaluating the fitness of the task scheduling scheme, the method further includes: If the result of the task scheduling scheme obtained through the fitness evaluation does not meet the preset target scheduling condition, determining a preset number of first scheduling schemes from the scheduling schemes; A new scheduling scheme is generated based on the preset genetic operation and the first scheduling scheme.
7. The task scheduling method according to any one of claims 1 to 6, characterized in that: The step of evaluating the fitness of the task scheduling scheme based on the latest completion time of each of the tasks specifically includes: In the task scheduling scheme, the shortest latest completion time is used as the result obtained by the fitness evaluation.
8. A task scheduling device, characterized in that: include: A task acquisition module, used to acquire a plurality of tasks to be scheduled; wherein each of the tasks includes resource consumption; A scheme generating module, used for constructing gene positions based on a plurality of tasks corresponding to the same task priority, and generating a task scheduling scheme based on the plurality of gene positions; wherein the gene positions include the starting scheduling time of the task; A completion time determination module, used to determine the latest completion time of each of the tasks based on resource consumption and the start scheduling time; A fitness evaluation module, used for evaluating the fitness of the task scheduling scheme based on the latest completion time of each of the tasks; The scheme output module is used to output the target task scheduling scheme corresponding to the fitness when the evaluation result meets the preset target scheduling condition.
9. A computer device, characterized in that: The method comprises a memory and a processor, wherein the memory stores computer-readable instructions, and the processor implements the steps of the task scheduling method according to any one of claims 1 to 7 when executing the computer-readable instructions.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-readable instructions, and when the computer-readable instructions are executed by a processor, the steps of the task scheduling method according to any one of claims 1 to 7 are implemented.