Task allocation method and device, electronic equipment and storage medium
By generating task chromosomes and calculating fitness values and usage rates, the problem of low utilization of experimental equipment in manufacturing is solved, and work efficiency and equipment usage rates are improved, ensuring timely processing of tasks and load balancing of equipment.
Patent Information
- Application Number
- CN202411917102.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-24
- Publication Date
- 2025-03-28
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
In the manufacturing industry, there are many material inspection tasks and limited experimental equipment, and it is difficult to consider comprehensive human arrangements, resulting in low usage rates of some experimental equipment and experimental hysteresis problems.
By generating task chromosomes containing task sequences and device sequences, systematically explore different task execution orders and device allocation schemes, calculate the fitness value and usage rate of the device, and select the optimal or near-optimal allocation method.
It improves overall work efficiency and equipment utilization rate, ensures that critical tasks are processed in a timely manner, reduces unbalanced equipment usage, and achieves the flexibility of task execution and improvement of response speed.
Smart Images

Figure CN119721635A_ABST
Abstract
Description
Technical Field
[0001] Embodiments of the present invention relate to the technical field of production management, and in particular to a method, device, electronic device and storage medium for task allocation. Background Art
[0002] In the manufacturing industry, in order to strictly control product quality, it is common to inspect confirmed materials on a monthly or quarterly basis. However, there are many material inspection tasks, and the number of experimental equipment is limited. It is difficult to consider all aspects of human arrangements, which can easily lead to low utilization rates of some experimental equipment and experimental delays. Summary of the invention
[0003] The purpose of the present invention is to at least provide a method, device, electronic device and storage medium for task allocation, which can at least solve the problem that it is difficult to take all aspects into consideration in human arrangements, which easily leads to low utilization rate of some experimental equipment, and at least can achieve the effect of improving overall work efficiency and equipment utilization rate.
[0004] To solve the above technical problems, at least one embodiment of the present application provides a method for task allocation, including:
[0005] For a given task set and a device set for executing the task set, a plurality of task chromosomes are generated, each of which includes a task sequence and a device sequence of the same length; the task sequence corresponds to the execution order of the tasks in the task set, each task is set with a task priority, and the devices at each sequence in the device sequence correspond to the execution devices of the tasks at the same sequence in the task sequence;
[0006] The following steps are performed for each of the task chromosomes:
[0007] For the same device in the device sequence of the task chromosome, extracting a first task sequence corresponding to the device from the task sequence;
[0008] Calculating the fitness value of the device in the current task chromosome according to the changing trend of the task priority of each task in the first task sequence as the task execution order changes;
[0009] Calculate the utilization rate of the device among all devices of the current task chromosome according to the proportion of the task priorities of all tasks in the first task sequence in the task priorities of all tasks in the task set;
[0010] According to the fitness value of each device in the current task chromosome and the utilization rate of each device in all devices of the current task chromosome, a task chromosome is selected for task allocation.
[0011] At least one embodiment of the present application further provides a task allocation device, including:
[0012] A task chromosome generation module is used to generate multiple task chromosomes for a given task set and a device set for executing the task set, each of which includes a task sequence and a device sequence of the same length; the task sequence corresponds to the execution order of each task in the task set, each task is set with a task priority, and the devices at each sequence in the device sequence correspond to the execution devices of the tasks at the same sequence in the task sequence;
[0013] The following steps are performed for each of the task chromosomes:
[0014] A task sequence extraction module, used for extracting a first task sequence corresponding to a same device in the device sequence of the task chromosome from the task sequence;
[0015] A fitness value calculation module, used to calculate the fitness value of the device in the current task chromosome according to the changing trend of the task priority of each task in the first task sequence with the task execution order;
[0016] A device usage rate calculation module, used to calculate the usage rate of the device among all devices of the current task chromosome according to the task priorities of all tasks in the first task sequence and the proportion of the task priorities of all tasks in the task set;
[0017] The task allocation module is used to select a task chromosome for task allocation according to the fitness value of each device in the current task chromosome and the utilization rate of each device in all devices of the current task chromosome.
[0018] At least one embodiment of the present application also provides an electronic device, comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the above-mentioned task allocation method.
[0019] At least one embodiment of the present application further provides a computer-readable storage medium storing a computer program, wherein the computer program implements the above-mentioned task allocation method when executed by a processor.
[0020] The method, device, electronic device and storage medium for task allocation provided by the embodiments of the present application generate task chromosomes containing task sequences and equipment sequences to systematically and comprehensively explore different task execution orders and equipment allocation schemes, which helps to find the optimal or near-optimal allocation method; in the calculation of the fitness value, the changing trend of task priority with the task execution order is taken into account, so that the method can give priority to important or urgent tasks, ensure that key tasks are processed in a timely manner, and improve the flexibility and response speed of task processing. By calculating the utilization rate of the equipment in the current task chromosome, it helps to reduce the situation where some equipment is overused while other equipment is idle. Finally, by calculating the fitness value and utilization rate, and comprehensively considering these two indicators, the comprehensiveness and objectivity of the scheme evaluation are improved, which helps to achieve a better balance between execution efficiency and equipment utilization, and solves the problem that it is difficult to consider the overall situation of human arrangements, which easily leads to the low utilization rate of some experimental equipment.
[0021] In some optional embodiments, calculating the fitness value of the device in the current task chromosome according to the changing trend of the task priority of each task in the first task sequence with the task execution order includes:
[0022] For two adjacent tasks in the first task sequence, if the priority of the previous task is greater than the priority of the next task, the fitness value increases by a preset increment; if the priority of the previous task is less than the priority of the next task, the fitness value decreases by a preset increment; if the priority of the previous task is equal to the priority of the next task, the fitness value increment is zero.
[0023] In this embodiment, task allocation is optimized by rewarding (increasing fitness values) the task sequence executed in descending order of task priority, ensuring that high-priority tasks can be executed as early as possible, thereby improving overall work efficiency and response speed.
[0024] In some optional embodiments, selecting a task chromosome for task allocation according to the fitness value of each device in the current task chromosome and the utilization rate of each device in all devices of the current task chromosome in each task chromosome includes:
[0025] Performing a weighted summation on the fitness value and the usage rate of each device in each task chromosome, and accumulating the weighted summation values of each device to obtain a comprehensive evaluation value of the current task chromosome;
[0026] The task chromosome with the highest comprehensive evaluation value is selected for task allocation.
[0027] In this embodiment, the comprehensive evaluation value calculated by weighted summation not only takes into account the fitness value of the device (i.e., the quality of the task priority order), but also takes into account the utilization rate of the device, which helps to balance the efficiency of task execution and the load balancing of the device, and avoid the situation where some devices are overused while other devices are idle.
[0028] In some optional embodiments, before generating a plurality of task chromosomes, the process further includes:
[0029] Priority calculation parameters are obtained, and task priorities of each task in the task set are calculated according to the priority calculation parameters, wherein the priority calculation parameters include at least one of task urgency and dependencies between tasks.
[0030] In this embodiment, by comprehensively considering multiple factors such as the urgency of tasks and the dependencies between tasks, a more accurate priority basis is provided for task allocation, which helps to ensure that key tasks are given priority, thereby improving the efficiency and quality of overall task execution. On the other hand, the priority calculation parameters can be adjusted according to actual needs. For example, the weight of the urgency can be increased in an emergency to quickly respond to key tasks. This flexibility enables task allocation to adapt to different application scenarios and changing needs.
[0031] In some optional embodiments, generating a plurality of task chromosomes includes:
[0032] Randomly generate a preset number of task chromosomes as the initial population;
[0033] Task chromosomes whose fitness values reach a preset standard are selected from the initial population for reproduction until a preset reproduction upper limit is met, thereby generating a plurality of task chromosomes.
[0034] In this embodiment, randomly generating the initial population can ensure the diversity of task chromosomes, thereby covering a wider range of potential solution spaces, which is helpful to find a better task allocation solution in the subsequent optimization process.
[0035] In some optional embodiments, the step of selecting task chromosomes whose fitness values meet a preset standard from the initial population for reproduction includes:
[0036] Use the roulette wheel selection method to select the task chromosome whose fitness value reaches the preset standard;
[0037] Random mutation is performed on the selected task chromosomes that meet the preset standards to update the population.
[0038] In this embodiment, the roulette wheel selection method tends to select individuals with high fitness, but due to the existence of randomness, individuals with low fitness still have a certain chance of being selected. In addition, the random mutation operation can introduce new genotypes, further increasing the diversity of the population. This diversity helps to discover new and better solutions during the evolution process.
[0039] In some optional embodiments, the randomly mutating the selected task chromosomes that meet the preset criteria includes:
[0040] In the device sequence in the selected task chromosome that meets the preset standard, the device corresponding to the task assigned with a task priority less than a preset threshold is selected for change.
[0041] In this embodiment,
[0042] In some optional embodiments, selecting a task chromosome for task allocation includes:
[0043] Generate a task allocation plan based on the selected task chromosome;
[0044] An interactive operation instruction is received to adjust the task allocation scheme, and tasks are allocated according to the adjusted task allocation scheme.
[0045] In this embodiment, by preferentially changing the devices assigned with low-priority tasks, interference with the devices executing high-priority tasks can be reduced, which helps to avoid unnecessary waste of resources and task delays, and improves the overall resource utilization efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0046] One or more embodiments are exemplarily described by the pictures in the corresponding drawings, and these exemplary descriptions do not constitute limitations on the embodiments.
[0047] Figure 1 This is a process of a task allocation method provided by an embodiment of the present application Figure 1 ;
[0048] Figure 2 This is a process of a task allocation method provided by an embodiment of the present application Figure 2 ;
[0049] Figure 3 This is a process of a task allocation method provided by an embodiment of the present application Figure 3 ;
[0050] Figure 4 It is a schematic diagram of a device for task allocation provided by another embodiment of the application. DETAILED DESCRIPTION
[0051] To make the purpose, technical scheme and advantages of the embodiments of the present application clearer, the embodiments of the present application will be described in detail below in conjunction with the accompanying drawings. However, it will be appreciated by those skilled in the art that in the present application, many technical details are proposed in order to enable the reader to better understand the present application. However, even without these technical details and various changes and modifications based on the following embodiments, the technical scheme claimed in the present application can also be implemented. The division of the following embodiments is for the convenience of description, and the specific implementation of the present application should not be construed as any limitation, and the various embodiments can be combined and referenced with each other under the premise of no contradiction.
[0052] In order to solve the technical problem that the above-mentioned manual arrangement is difficult to take into account comprehensively, which easily leads to low utilization rate of some experimental equipment, the present invention proposes a task allocation method. The implementation details of the task allocation method of this embodiment are specifically described below. The following content is only the implementation details provided for easy understanding and is not necessary for the implementation of this solution.
[0053] Embodiment 1:
[0054] The task allocation method of this embodiment can be applied to electronic devices with communication, computing and data storage capabilities. Task allocation is a core issue in many fields, such as production scheduling in the manufacturing industry, resource allocation in the service industry, and parallel computing task allocation in computer science. An effective task allocation method can significantly improve resource utilization efficiency, reduce costs, and improve the performance of the overall system. This paper proposes a task allocation method based on genetic algorithm, which simulates the selection, crossover and mutation operations in the biological evolution process to find the optimal or approximately optimal task allocation scheme. The following is a detailed explanation and implementation of each step of the method. The specific process can be as follows Figure 1 As shown, including:
[0055] Step 110, for a given task set and a device set for executing the task set, a plurality of task chromosomes are generated, each of the task chromosomes includes a task sequence and a device sequence of the same length; the task sequence corresponds to the execution order of the tasks in the task set, each task is set with a task priority, and the devices at each sequence in the device sequence correspond to the execution devices of the tasks at the same sequence in the task sequence;
[0056] In this embodiment, the task set includes a series of tasks that need to be executed, each task has a unique identifier and may have some additional attributes, such as task priority, execution time, required resources, etc. The device set includes a series of devices that can be used to execute tasks, each device also has a unique identifier and may have some attributes, such as processing power, available time, cost, etc.
[0057] The task chromosome is the basic unit in the genetic algorithm, which represents a possible task allocation scheme. Each task chromosome consists of two sequences of equal length: the task sequence and the equipment sequence. Each position in the task sequence corresponds to a task in the task set and is arranged in a certain order. Each position in the equipment sequence corresponds to the execution device of the task at the same position in the task sequence. In order to start the iterative process of the genetic algorithm, it is first necessary to generate an initial population containing multiple task chromosomes. This can be achieved by randomly selecting the arrangement of the task sequence and the equipment sequence. For example, the order of tasks in the task set can be randomly shuffled to generate a task sequence, and then an available execution device can be randomly selected for each task to generate an equipment sequence.
[0058] For example, a task chromosome can be [0,1,2,3,4|0,1,0,1,1], where the first five digits represent the execution order of the tasks, i.e., the task sequence, and the last five digits represent the devices to which the tasks are assigned, i.e., the device sequence. For this task chromosome, it means that the execution order of the tasks is task 1, task 2, task 3, task 4, task 5, and that task 1 and task 3 are assigned to device 1, and task 2, task 5, and task 4 are assigned to device 2.
[0059] The following steps are performed for each of the task chromosomes:
[0060] Step 120, for the same device in the device sequence of the task chromosome, extracting a first task sequence corresponding to the device from the task sequence;
[0061] In this embodiment, for each task chromosome, it is necessary to extract the first task sequence corresponding to each device in its device sequence from the task sequence. The first task sequence refers to a sequence in which all tasks assigned to the device in the device sequence are arranged in the order in the task sequence.
[0062] Specifically, suppose there is a task chromosome whose task sequence is [T1, T2, T3, T4, T5] and whose device sequence is [D1, D2, D1, D3, D2]. For device D1, we can extract its corresponding first task sequence from the task sequence as [T1, T3]. For device D2, its corresponding first task sequence is [T2, T5]. For device D3, its corresponding first task sequence is [T4].
[0063] Step 130, calculating the fitness value of the device in the current task chromosome according to the changing trend of the task priority of each task in the first task sequence with the task execution order;
[0064] In this embodiment, the fitness value is a standard for measuring the quality of a task chromosome. In this method, the fitness value is calculated according to the changing trend of the task priority of the device in the current task chromosome with the task execution order.
[0065] Specifically, for each task in the first task sequence, calculate the priority difference between it and the previous task, and find the sum of the absolute values of these differences. Then, we divide this sum by 1 as the fitness value. This method can better reflect the changing trend of task priority with the order of task execution.
[0066] In some optional embodiments, for the first task sequence of each device, the mean value, standard deviation or other statistics of its task priority can be calculated to evaluate the distribution of task priority. A possible fitness value calculation method is: first calculate the mean value of the task priority in the first task sequence, then calculate the difference between each task priority and the mean value, and find the sum of the squares of these differences. Finally, divide 1 by this sum of squares as the fitness value (the inverse of the sum of squares is used as the fitness value so that the larger the fitness value, the better the task allocation scheme).
[0067] Step 140, calculating the utilization rate of the device among all devices of the current task chromosome according to the proportion of the task priorities of all tasks in the first task sequence in the task priorities of all tasks in the task set;
[0068] In this embodiment, the utilization rate is an indicator to measure the degree to which a device is utilized in the current task chromosome. In the method of this embodiment, the utilization rate is calculated according to the proportion of the task priorities of all tasks in the first task sequence to the task priorities of all tasks in the task set.
[0069] Specifically, first calculate the sum of the task priorities of all tasks in the task set. Then, for the first task sequence of each device, calculate the sum of the task priorities of all tasks therein. Finally, divide this sum by the sum of the task priorities of all tasks in the task set to obtain the utilization rate of the device in the current task chromosome.
[0070] In some possible embodiments, the relative differences between task priorities are better considered. A more complex implementation is: for the first task sequence of each device, the ranking of the task priority of each task in the task priority of all tasks in the task set is calculated (percentage ranking or other ranking methods can be used). Then, the average value of these rankings is calculated as the utilization rate of the device in the current task chromosome. This method can better reflect the degree of device utilization and the priority distribution of tasks.
[0071] In some possible embodiments, the utilization rate of the device among all devices of the current task chromosome is calculated based on the ratio of the sum of the execution time of all tasks in the first task sequence to the sum of the execution time of all tasks in the task set. This method can better reflect the degree of utilization of the device from the dimension of time.
[0072] Step 150 , selecting a task chromosome for task allocation according to the fitness value of each device in the current task chromosome and the utilization rate of each device in all devices of the current task chromosome.
[0073] In this embodiment, when selecting a task chromosome for task allocation, two key factors are mainly used: one is the fitness value of each device in the current task chromosome, and the other is the utilization rate of these devices in all devices of the current task chromosome. The higher the fitness value, the more tasks may be assigned to the device, and correspondingly, the fewer tasks will be assigned to other devices, resulting in an unbalanced resource allocation, which affects the progress and efficiency of the actual task execution. The criterion of comprehensive equipment utilization rate can be considered in a coordinated manner to balance the situation of resource tilt and find a solution that can both efficiently complete tasks and achieve a better balance in equipment allocation.
[0074] For example, five tasks with task priorities of 2, 4, 6, 8, and 10 are assigned to device A and device B for execution. There are three task assignment schemes:
[0075] Solution 1: Distribute the last four tasks with task priorities of 2, 4, 6, 8, and 10 to device A in the order of 10, 8, 6, and 4; distribute the task with task priority 2 to device B;
[0076] Solution 2: Distribute tasks with priority levels 10, 8, and 6 to device A, and tasks with priority levels 4 and 2 to device B.
[0077] Solution 3: Distribute tasks with priority 10 and 8 to device A, and tasks with priority 6, 4, and 2 to device B.
[0078] In the above three allocation schemes, the fitness values of the changing trends of the task priorities in the first task sequence with the task execution order are the same. Therefore, further analysis is performed in combination with the utilization rate of the equipment.
[0079] Solution 1: A(10, 8, 6, 4), B(2) For device A: 28 / 30=0.93, while for device B, the execution time is: 2, and the utilization rate is 2 / 30=0.07. Similarly, according to this calculation method, in solution 2, the utilization rate of device A is 24 / 30=0.8, and that of device B is 0.2. In solution 3, the utilization rate of device A is 18 / 30=0.6, and that of device B is 0.4. In the comparison of these three solutions, solution 3 is better because devices A and B bear the workload more evenly, while for solutions 1 and 2, the workload of devices A and B is relatively unbalanced.
[0080] In summary, the method of task allocation provided by the embodiment of the present application generates a task chromosome containing a task sequence and a device sequence to systematically and comprehensively explore different task execution orders and device allocation schemes, which helps to find the optimal or near-optimal allocation method; in the calculation of the fitness value, the changing trend of the task priority with the task execution order is taken into account, so that the method can give priority to important or urgent tasks, ensure that key tasks are processed in a timely manner, and improve the flexibility and response speed of task processing. By calculating the utilization rate of the equipment in the current task chromosome, it helps to reduce the situation where some equipment is overused while other equipment is idle. Finally, by calculating the fitness value and the utilization rate, and comprehensively considering these two indicators, the comprehensiveness and objectivity of the scheme evaluation are improved, which helps to achieve a better balance between execution efficiency and equipment utilization, and solves the problem that it is difficult to consider the overall situation of human arrangement, which easily leads to the low utilization rate of some experimental equipment.
[0081] In some embodiments, in some optional embodiments, the fitness value of the device in the current task chromosome is calculated based on the changing trend of the task priority of each task in the first task sequence with the task execution order, including: for two adjacent tasks in the first task sequence, if the priority of the previous task is greater than the priority of the next task, the fitness value is increased by a preset increment; if the priority of the previous task is less than the priority of the next task, the fitness value is reduced by a preset increment; if the priority of the previous task is equal to the priority of the next task, the fitness value increment is zero.
[0082] In this embodiment, task allocation is optimized by rewarding (increasing fitness values) the task sequence executed in descending order of task priority, ensuring that high-priority tasks can be executed as early as possible, thereby improving overall work efficiency and response speed.
[0083] For example, if a device can only perform one task at a time, the tasks assigned to the device are executed according to the priority. For example, in the allocation scheme [4,3,2,0,1|0,1,0,1,1], the inspection tasks assigned to device 1 are 4,2, and the corresponding task priorities are 10,6. The tasks assigned to device 2 are 3,0,1, and the corresponding task priorities are 8,2,4. Set the initial fitness value to 0, and compare the priority of the previous inspection task with the priority of the next inspection task. If the previous priority is higher than the next priority, the fitness value is increased by 1, otherwise it is reduced by 1. For device 1, the priority is (10,6). Since 10>6, the fitness is 0+1=1. For device 2, the priority is (8,2,4). For device 2, 8>2 (fitness: 0+1=1)2<4 (fitness 1-1=0), so the total fitness of the allocation scheme is 1 (device 1)+0 (device 2)=1.
[0084] In some optional embodiments, a task chromosome is selected for task allocation based on the fitness value of each device in the current task chromosome and the utilization rate of each device in all devices of the current task chromosome, including: taking a weighted sum of the fitness value and the utilization rate of each device in each task chromosome, and accumulating the weighted sum values of each device to obtain a comprehensive evaluation value of the current task chromosome; and selecting the task chromosome with the highest comprehensive evaluation value for task allocation.
[0085] In this embodiment, the comprehensive evaluation value calculated by weighted summation not only takes into account the fitness value of the device (i.e., the quality of the task priority order), but also takes into account the utilization rate of the device, which helps to balance the efficiency of task execution and the load balancing of the device, and avoid the situation where some devices are overused while other devices are idle.
[0086] For example, there are two task chromosomes, Chromosome_A and Chromosome_B,
[0087] Chromosome_A: Device 1: Task sequence [T1, T3], fitness value = 8, usage rate = 0.4; Device 2: Task sequence [T2, T4], fitness value = 7, usage rate = 0.6;
[0088] Chromosome_B: Device 1: Task sequence [T2, T4], fitness value = 6, usage rate = 0.7; Device 2: Task sequence [T1, T3], fitness value = 9, usage rate = 0.3;
[0089] Calculate the combined score of the two task chromosomes:
[0090] Set weights for the fitness value and the usage rate respectively, for example, weight w1 = 0.7 (giving more importance to the fitness value), w2 = 0.3 (giving less importance to the usage rate, but hoping to maintain a certain balance).
[0091] Comprehensive evaluation value of Chromosome_A = (0.78 + 0.30.4) + (0.77 + 0.30.6) = 5.6 + 5.14 = 10.74
[0092] Comprehensive evaluation value of Chromosome_B = (0.76 + 0.30.7) + (0.79 + 0.30.3) = 4.41 + 6.42 = 10.83
[0093] Select the task chromosome:
[0094] According to the comprehensive score, Chromosome_B is selected for task assignment because it has a higher comprehensive score, indicating that it achieves a better balance between fitness value and utilization rate.
[0095] It should be noted that the calculation methods of fitness value and utilization rate, weight setting and comprehensive score in the above examples are all hypothetical. In actual application, these parameters and methods need to be determined according to specific problems and needs.
[0096] In some optional embodiments, before generating multiple task chromosomes, it also includes: obtaining priority calculation parameters, and calculating the task priority of each task in the task set according to the priority calculation parameters, wherein the priority calculation parameters include at least one of task urgency and dependency between tasks.
[0097] In this embodiment, before generating multiple task chromosomes, it is necessary to assign task priorities to each task in the task set. For example, a manufacturing company needs to perform quality inspection on a batch of incoming materials to ensure that they meet production standards. This batch of incoming materials includes many different types of raw materials, each of which has different inspection requirements and urgency. In addition, the inspection of certain raw materials may also depend on the inspection results of other raw materials (for example, one raw material may require the inspection data of another raw material as a reference).
[0098] Task urgency: It can be determined based on the delivery date of the raw materials, the urgency of the production line's needs, or the requirements of the customer order. For example, if a raw material is required to produce a rush order, then the inspection task for that raw material will be considered high urgency.
[0099] Dependency between tasks: refers to the fact that the inspection tasks of some raw materials must be carried out after the inspection tasks of other raw materials are completed. For example, one raw material may need some inspection data of another raw material as a reference, or two raw materials may need to undergo some composite inspection together.
[0100] Therefore, it is necessary to collect information about the inspection requirements and urgency of each raw material, as well as the dependencies between them. This information can come from the purchasing department, production planning department, or quality control department, etc.
[0101] By comprehensively considering multiple factors such as task urgency and inter-task dependencies, a more accurate priority basis is provided for task allocation, which helps ensure that key tasks are given priority, thereby improving the efficiency and quality of overall task execution. On the other hand, priority calculation parameters can be adjusted according to actual needs. For example, the weight of urgency can be increased in emergency situations to quickly respond to key tasks. This flexibility enables task allocation to adapt to different application scenarios and changing needs.
[0102] In some optional embodiments, generating multiple task chromosomes includes: randomly generating a preset number of task chromosomes as an initial population; selecting task chromosomes whose fitness values meet a preset standard from the initial population for reproduction until a preset reproduction upper limit is met, thereby generating multiple task chromosomes.
[0103] In this embodiment, randomly generating the initial population can ensure the diversity of task chromosomes, thereby covering a wider range of potential solution spaces, which is helpful to find a better task allocation solution in the subsequent optimization process.
[0104] In some optional embodiments, selecting task chromosomes whose fitness values meet preset standards from the initial population for reproduction includes: using a roulette wheel selection method to select task chromosomes whose fitness values meet preset standards; and performing random mutations on the selected task chromosomes that meet the preset standards to update the population.
[0105] In this embodiment, excellent individuals are selected from the initial population as the basis for generating the next generation of individuals. The roulette wheel selection method is used to determine the probability of each chromosome being selected based on its fitness value. The higher the fitness value, the greater the probability of the chromosome being selected. Roulette wheel selection method: It is usually used to select individuals with higher fitness for reproduction. The higher the fitness, the greater the probability of individual selection. The specific steps are:
[0106] 1) Calculate the sum of individual (task chromosome) fitness values;
[0107] 2) Calculate the cumulative probability of each individual;
[0108] 3) Generate a random number of 0 and 1;
[0109] 4) Starting from the first individual, if the cumulative probability is greater than or equal to the random number, select the individual. Suppose a population has 5 individuals (A, B, C, D, E): the fitness values are 0.05, 0.1, 0.2, 0.15, 0.5, then the total fitness is 1.0, the selection probability of each individual (1 / fitness value) is 0.05, 0.1, 0.2, 0.15, 0.5, and the cumulative probability of each individual is: 0.05, 0.15 (0.05+0.1 and so on), 0.35, 0.5, 1.0, and a random number of 0.72 is generated from 0 to 1. Since 1.0 is greater than 0.72, individual E is selected.
[0110] 5) Use the random mutation method to select a task chromosome and mutate a value in its task sequence or a value in the device sequence to other possible values or swap positions. The mutation operation is used to increase the diversity of the population and prevent the final result from falling into the local optimal solution. Suppose a chromosome is [4,3,2,0,1|1,0,1,1,0], and randomly select the 1st and 2nd positions in [4,3,2,0,1] to swap positions, such as [3,4,2,0,1|1,0,1,1,0].
[0111] In this embodiment, the roulette wheel selection method tends to select individuals with high fitness, but due to the existence of randomness, individuals with low fitness still have a certain chance of being selected. In addition, the random mutation operation can introduce new genotypes, further increasing the diversity of the population. This diversity helps to discover new and better solutions during the evolution process.
[0112] In some optional embodiments, the random mutation of the selected task chromosome that meets the preset standard includes: in the device sequence in the selected task chromosome that meets the preset standard, selecting the device corresponding to the task assigned a task priority less than a preset threshold for change.
[0113] In this embodiment, a position with a lower priority in a chromosome is selected and mutated to other possible values or swapped. The position with a higher priority is placed in the front and remains unchanged to ensure that its task can be executed first. Assume that a chromosome is [4,3,2,0,1|1,0,1,1,0], where tasks 4 and 3 have higher priorities, so the first two items in the task sequence are kept unchanged, and the fifth position is randomly selected from [1,0,1,1,0] for mutation to other possible values, such as [4,3,2,0,1|1,0,1,1,1].
[0114] In some optional embodiments, the selecting a task chromosome for task allocation includes: generating a task allocation plan based on the selected task chromosome; receiving an interactive operation instruction to adjust the task allocation plan, and performing task allocation according to the adjusted task allocation plan. In this embodiment, by giving priority to changing the devices to which low-priority tasks are assigned, interference with high-priority task execution devices can be reduced, which helps to avoid unnecessary waste of resources and task delays, and improves overall resource utilization efficiency.
[0115] Embodiment 2:
[0116] Based on the above embodiment, this embodiment provides another method for task allocation, and its specific process can be as follows: Figure 2 As shown, including:
[0117] Step 210, for a given task set and a device set for executing the task set, based on a preset fitness value calculation rule and with the goal of maximizing the fitness value, generate a plurality of task chromosomes;
[0118] In this embodiment, the preset fitness value calculation rule is consistent with that in the first embodiment, and it is defined that in a task chromosome, for two adjacent tasks in a task sequence assigned to a specific device, if the priority of the previous task is greater than the priority of the next task, the fitness value increases by a preset increment; if the priority of the previous task is less than the priority of the next task, the fitness value decreases by a preset increment; if the priority of the previous task is equal to the priority of the next task, the fitness value increment is zero. Based on the fitness value calculation rule, multiple task chromosomes are generated with the maximum fitness value as the goal. The composition of the task chromosome is consistent with that of the first embodiment, and will not be repeated here to avoid repetition.
[0119] Step 220, for the same device in the device sequence of the task chromosome, extracting a first task sequence corresponding to the device from the task sequence;
[0120] In this embodiment, the specific implementation of step 220 is similar to that of step 120 in the first embodiment, and will not be described again here to avoid repetition.
[0121] Step 230, calculating the utilization rate of the device among all devices of the current task chromosome according to the proportion of the task priorities of all tasks in the first task sequence in the task priorities of all tasks in the task set;
[0122] In this embodiment, the specific implementation of step 230 is similar to that of step 130 in the first embodiment, and will not be described again here to avoid repetition.
[0123] Step 240: determine the first task chromosome with the smallest difference between the usage rates of the devices as the optimal task chromosome, and generate a task allocation plan based on the optimal task chromosome.
[0124] In this embodiment, in a task chromosome, if the difference between the utilization rates of the devices is smaller, it means that the load distribution between the devices is more balanced. When the fitness values of multiple task chromosomes meet the standard, the task chromosome is further optimized according to the utilization rate difference between the devices.
[0125] In an optional embodiment, determining the first task chromosome with the smallest difference between the utilization rates of each of the device carriers as the optimal task chromosome includes: calculating the standard deviation of the utilization rates of the devices in the corresponding task chromosome based on the utilization rates of each of the devices in each of the task chromosomes; and determining the task chromosome with the smallest standard deviation as the optimal task chromosome.
[0126] For example, there are two task chromosomes, Chromosome_A and Chromosome_B,
[0127] Chromosome_A: Device 1: Task sequence [T1, T3], fitness value = 8, usage rate = 0.4; Device 2: Task sequence [T2, T4], fitness value = 7, usage rate = 0.6;
[0128] Chromosome_B: Device 1: Task sequence [T2, T4], fitness value = 6, usage rate = 0.7; Device 2: Task sequence [T1, T3], fitness value = 8, usage rate = 0.3;
[0129] After calculation, the standard deviation of the device utilization in Chromosome_A is 0.1, while the standard deviation of the utilization of the two devices in Chromosome_B is 0.2. This shows that in Chromosome_A, the utilization of the two devices is more balanced. Therefore, Chromosome_A is selected as the optimal task chromosome to generate the task allocation solution.
[0130] In summary, the task allocation method in this embodiment first screens out a batch of potential high-quality task chromosomes by maximizing the fitness value, ensuring that the selected chromosomes have reached a high level in key indicators such as task priority and execution order, which helps to quickly exclude those chromosomes that obviously do not meet the optimization goals, thereby reducing the number of chromosomes to be processed later. After narrowing the selection range, the utilization rate of this batch of task chromosomes is analyzed to determine the optimal solution, so that the task chromosomes finally selected not only have high fitness values, but also have more balanced equipment utilization, thereby achieving a more comprehensive optimization goal.
[0131] Embodiment three:
[0132] Based on the above embodiment, this embodiment provides an application example. It is applied to the performance inspection of production materials. The specific flow of the task allocation method can be as follows: Figure 3 As shown, including:
[0133] Step 301, adding the inspection task to the scheduling plan: According to the inspection requirements of the inspection standard management system, the materials that need to be inspected each month or quarter can be obtained. Each material has a corresponding inspection item, and each inspection item corresponds to an inspection task and inspection duration. The inspection duration corresponds to the corresponding priority, and the higher the inspection duration, the higher the priority. For example, the inspection items of white boxes include: odor, toxic and hazardous substances detection, etc. Take the quarter as an example: at the beginning of each quarter (such as 2024-01-01), the corresponding inspection task is added to the scheduling plan and the completion time is before the end of the quarter (such as 2024-03-31), and the number of available equipment is counted at the same time. There are different types of equipment, and there are multiple equipment of the same type. Each equipment of the same type can perform multiple types of inspection tasks, but one equipment can only perform one inspection task at the same time. For example, there are 5 chemical analyzers, 3 microbial detectors and 4 physical property testers in the laboratory. Each chemical analyzer can perform a variety of chemical testing tasks, such as pH testing, metal content analysis and organic matter detection; each microbial detector can perform bacterial culture, virus detection and antibiotic sensitivity testing; each physical properties tester can perform hardness testing, tensile testing and wear resistance testing.
[0134] Step 302, grouping of inspection tasks: grouping inspection tasks for different types of equipment. Take the same type of equipment as an example: 2 chemical analyzers (0, 1) have corresponding inspection tasks: tasks 0, 1, 2, 3, 4, and the corresponding inspection durations are 2, 4, 6, 8, and 10 hours, and then the inspection tasks are allocated.
[0135] Step 303, initialize the chromosome encoding method: use chromosomes to represent a possible allocation scheme. Each chromosome consists of two parts: the execution order of tasks and the device allocation. Specifically, an integer array is used to represent the task order, and a binary array is used to represent the device allocation. For example, a chromosome can be [0,1,2,3,4|0,1,0,1,1], where the first five digits represent the execution order of tasks, and the last five digits represent the devices to which the tasks are assigned. For this chromosome, it means that the execution order of tasks is task 1, task 2, task 3, task 4, and task 5, and task 1 and task 3 are assigned to device 1, and task 2, task 5, and task 4 are assigned to device 2.
[0136] Step 304, initialize the population: combine task priority and random allocation to generate a certain number of chromosomes as the initial population: for example, referring to the above example, such as tasks 0, 1, 2, 3, 4, the corresponding inspection time of the tasks is 2, 4, 6, 8, 10 hours, then the corresponding priorities are: 2, 4, 6, 8, 10, the top 1 to 2 with high priority are always placed at the front, and the rest are randomly allocated, then the generated solutions may be: [4,3,2,0,1|0,1,0,1,1]; [4,3,1,0,2|1,0,1,0,0], etc.
[0137] Step 305, evaluate the fitness value: use the fitness value to evaluate the quality of each chromosome. The higher the fitness, the better the chromosome. The fitness evaluation rule is: such as [4,3,2,0,1|0,1,0,1,1], the tasks assigned to device 1 are 4, 2, corresponding to the priorities of 10, 6, and the tasks assigned to device 2 are 3, 0, 1, corresponding to the priorities of 8, 2, 4. Set the initial fitness value to 0. For device 1, compare the priority of the previous inspection task with the priority of the next inspection task. If the previous priority is higher than the next priority, the fitness value is increased by 1, otherwise it is reduced by 1. The same is true for device B (fitness values are accumulated). For the above, the fitness is (device A) 1 + 0 (device B) = 1.
[0138] Step 306, select excellent individuals using the roulette wheel selection method: select excellent individuals from the current population as the basis for generating the next generation of individuals. Use the roulette wheel selection method to determine the probability of each chromosome being selected based on its fitness value. The higher the fitness value, the greater the probability of the chromosome being selected. Roulette wheel selection method: usually used to select individuals with higher fitness for reproduction. The higher the fitness, the greater the probability of individual selection. The specific steps are: 1: calculate the sum of individual fitness values, 2: calculate the cumulative probability of each individual, 3: generate a random number of 0 and 1, 4: starting from the first individual, if the cumulative probability is greater than or equal to the random number, select the individual. Suppose a population has 5 individuals (A, B, C, D, E): the fitness values are 0.05, 0.1, 0.2, 0.15, and 0.5 respectively, then the total fitness is 1.0, the selection probability of each individual (1 / fitness value) is 0.05, 0.1, 0.2, 0.15, 0.5, and the cumulative probability of each individual is: 0.05, 0.15 (0.05+0.1 and so on), 0.35, 0.5, 1.0, and a random number 0.72 is generated from 0 to 1. Since 1.0 is greater than 0.72, individual E is selected.
[0139] Step 307, random mutation: Use the random mutation method to select a position with a lower priority in a chromosome, and mutate it to other possible values or swap positions. The higher priority ones are placed in front and remain unchanged to ensure that their tasks can be executed first. The mutation operation is used to increase the diversity of the population and prevent the final result from falling into a local optimal solution. Assume that a chromosome is [4,3,2,0,1|1,0,1,1,0], and randomly select the 5th position in [1,0,1,1,0] for mutation, and mutate it to other possible values, such as [4,3,2,0,1|1,0,1,1,1].
[0140] Step 308, update the population through selection, crossover and mutation: Update the population by generating new individuals through selection, crossover and mutation operations. Keep several individuals with the highest fitness values, and introduce new individuals to ensure the diversity of the population. Assuming that there are 10 chromosomes in the current population, we generate 10 new chromosomes through selection, crossover and mutation operations, and keep the 5 chromosomes with the highest fitness values in the new population, and introduce 5 new chromosomes.
[0141] Step 309: Output the optimal solution: Set a maximum number of iterations. When the maximum number of iterations is reached, the mutation terminates. For example, assuming that the maximum number of iterations is 10,000, the algorithm terminates after 10,000 iterations. When it terminates, the allocation scheme with the highest fitness value is selected as an optimal solution. The details are as follows:
[0142] For example, the last four tasks with priorities of 2, 4, 6, 8, and 10 are distributed to device A, and the execution order is 10, 8, 6, and 4; the task with priority 2 is distributed to device B, at which point the fitness value is 3, reaching the maximum value;
[0143] Distribute the tasks with priorities 10, 8, and 6 to A, and 4 and 2 to B. At this time, the fitness value is also 3, reaching the maximum value;
[0144] Distribute the tasks with priorities 10 and 8 to A, and 6, 4, and 2 to B. The fitness value is 3, which reaches the maximum value.
[0145] The fitness values of the above three allocation schemes are the same and have reached the upper limit of the fitness value. The optimization is further performed based on the utilization rate of the equipment.
[0146] In the first scheme: A(10,8,6,4), B(2), the execution time for device A is: 10+8+6+4=28, and the execution time for device B is: 2. According to this calculation method, the execution time of A in scheme 2 is 24, and that of B is 6. The execution time of A in scheme 3 is 18, and that of B is 12. In the comparison of these three schemes, considering the equipment utilization rate and the total completion time, among these three schemes: Scheme 3 is better because devices A and B bear the workload more evenly, while for schemes 1 and 2, the workload of devices A and B is relatively unbalanced. In terms of total completion time: take the one with the longest completion time in the scheme, such as 28 for scheme 1, 24 for scheme 2, and 18 for scheme 3. Scheme 3 is better because it has a shorter time.
[0147] Embodiment 4:
[0148] Based on the above embodiments, another embodiment of the present application relates to a device for task allocation. The implementation details of the device for task allocation in this embodiment are described in detail below. The following content is only for the convenience of understanding the implementation details provided, and is not necessary for the implementation of this solution. The schematic diagram of the device for task allocation in this embodiment can be as follows Figure 4 As shown, it includes a task chromosome generation module 410, a task sequence extraction module 420, a fitness value calculation module 430, an equipment utilization rate calculation module 440 and a task allocation module 450.
[0149] The task chromosome generation module 410 is used to generate multiple task chromosomes for a given task set and a device set for executing the task set, each of which includes a task sequence and a device sequence of the same length; the task sequence corresponds to the execution order of each task in the task set, each task is set with a task priority, and the devices at each sequence in the device sequence correspond to the execution devices of the tasks at the same sequence in the task sequence;
[0150] The following steps are performed for each of the task chromosomes:
[0151] A task sequence extraction module 420 is used to extract a first task sequence corresponding to a same device in the device sequence of the task chromosome from the task sequence;
[0152] A fitness value calculation module 430, configured to calculate the fitness value of the device in the current task chromosome according to a trend of a task priority of each task in the first task sequence changing with a task execution order;
[0153] The device usage rate calculation module 440 is used to calculate the usage rate of the device among all devices of the current task chromosome according to the task priorities of all tasks in the first task sequence and the proportion of the task priorities of all tasks in the task set;
[0154] The task allocation module 450 is used to select one of the task chromosomes for task allocation according to the fitness value of each of the devices in the current task chromosome and the utilization rate of each of the devices in all the devices in the current task chromosome.
[0155] It is worth mentioning that all modules involved in this embodiment are logic modules. In practical applications, a logic unit can be a physical unit, a part of a physical unit, or a combination of multiple physical units. In addition, in order to highlight the innovative part of this application, this embodiment does not introduce units that are not closely related to solving the technical problems proposed by this application, but this does not mean that there are no other units in this embodiment.
[0156] Embodiment five:
[0157] Another embodiment of the present application relates to an electronic device, comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to execute the method of task allocation in the above-mentioned embodiments.
[0158] Among them, the memory and the processor are connected in a bus manner, and the bus may include any number of interconnected buses and bridges, and the bus connects various circuits of one or more processors and memories together. The bus can also connect various other circuits such as peripherals, voltage regulators, and power management circuits, which are well known in the art and are therefore not further described herein. The bus interface provides an interface between the bus and the transceiver. The transceiver can be one element or multiple elements, such as multiple receivers and transmitters, providing a unit for communicating with various other devices on a transmission medium. The data processed by the processor is transmitted on a wireless medium via an antenna, and further, the antenna also receives data and transmits the data to the processor.
[0159] The processor is responsible for managing the bus and general processing, and can also provide various functions, including timing, peripheral interfaces, voltage regulation, power management, and other control functions. Memory can be used to store data used by the processor when performing operations.
[0160] Embodiment six:
[0161] Another embodiment of the present application relates to a computer-readable storage medium storing a computer program, which implements the above method embodiment when executed by a processor.
[0162] That is, those skilled in the art can understand that all or part of the steps in the above-mentioned embodiment method can be completed by instructing the relevant hardware through a program, and the program is stored in a storage medium, including a number of instructions to enable a device (which can be a single-chip microcomputer, chip, etc.) or a processor to execute all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (Read-Only Memory, referred to as: ROM), random access memory (Random Access Memory, referred to as: RAM), disk or optical disk and other media that can store program codes.
[0163] Those skilled in the art will appreciate that the above embodiments are specific embodiments for implementing the present application, and in actual applications, various changes may be made thereto in form and detail without departing from the spirit and scope of the present application.
Claims
1. A method for task allocation, characterized in that: include: For a given task set and a device set for executing the task set, a plurality of task chromosomes are generated, each of which includes a task sequence and a device sequence of the same length; the task sequence corresponds to the execution order of the tasks in the task set, each task is set with a task priority, and the devices at each sequence in the device sequence correspond to the execution devices of the tasks at the same sequence in the task sequence; The following steps are performed for each of the task chromosomes: For the same device in the device sequence of the task chromosome, extracting a first task sequence corresponding to the device from the task sequence; Calculating the fitness value of the device in the current task chromosome according to the changing trend of the task priority of each task in the first task sequence as the task execution order changes; Calculate the utilization rate of the device among all devices of the current task chromosome according to the proportion of the task priorities of all tasks in the first task sequence in the task priorities of all tasks in the task set; According to the fitness value of each device in the current task chromosome and the utilization rate of each device in all devices of the current task chromosome, one task chromosome is selected for task allocation.
2. The method for task allocation according to claim 1, characterized in that: The calculating the fitness value of the device in the current task chromosome according to the changing trend of the task priority of each task in the first task sequence with the task execution order includes: For two adjacent tasks in the first task sequence, if the priority of the previous task is greater than the priority of the next task, the fitness value increases by a preset increment; if the priority of the previous task is less than the priority of the next task, the fitness value decreases by a preset increment; if the priority of the previous task is equal to the priority of the next task, the fitness value increment is zero.
3. The method for task allocation according to claim 1, characterized in that: The selecting a task chromosome for task allocation according to the fitness value of each device in the current task chromosome and the utilization rate of each device in all devices of the current task chromosome in each task chromosome comprises: Performing a weighted summation on the fitness value and the usage rate of each device in each task chromosome, and accumulating the weighted summation values of each device to obtain a comprehensive evaluation value of the current task chromosome; The task chromosome with the highest comprehensive evaluation value is selected for task allocation.
4. The method for task allocation according to claim 1, characterized in that: Before generating a plurality of task chromosomes, the method further includes: Priority calculation parameters are obtained, and task priorities of each task in the task set are calculated according to the priority calculation parameters, wherein the priority calculation parameters include at least one of task urgency and dependencies between tasks.
5. The method for task allocation according to claim 1, characterized in that: The generating of multiple task chromosomes comprises: Randomly generate a preset number of task chromosomes as the initial population; Task chromosomes whose fitness values reach a preset standard are selected from the initial population for reproduction until a preset reproduction upper limit is met, thereby generating a plurality of task chromosomes.
6. The method for task allocation according to claim 5, characterized in that: The step of selecting task chromosomes whose fitness values meet a preset standard from the initial population for reproduction includes: Use the roulette wheel selection method to select the task chromosome whose fitness value reaches the preset standard; Random mutation is performed on the selected task chromosomes that meet the preset standards to update the population.
7. The method for task allocation according to claim 6, characterized in that: The randomly mutating the selected task chromosomes that meet the preset standards comprises: In the device sequence in the selected task chromosome that meets the preset standard, the device corresponding to the task assigned with a task priority less than a preset threshold is selected for change.
8. The method for task allocation according to any one of claims 1 to 7, characterized in that: The step of selecting a task chromosome for task allocation includes: Generate a task allocation plan based on the selected task chromosome; An interactive operation instruction is received to adjust the task allocation scheme, and tasks are allocated according to the adjusted task allocation scheme.
9. An electronic device, characterized in that: include: at least one processor; as well as, a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the task allocation method according to any one of claims 1 to 8.
10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the method for task allocation according to any one of claims 1 to 8 is implemented.
Citation Information
Patent Citations
Task scheduling method, device, equipment, system, program product and medium
CN118394488A