A method and apparatus for task allocation
Patent Information
- Application Number
- CN202311545192.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-11-17
- Publication Date
- 2026-09-22
- Estimated Expiration
- 2043-11-17
AI Technical Summary
[0006]针对现有技术的以上缺陷或改进需求,本发明解决了标准粒子群算法容易早熟收敛的问题
[0018]与现有技术相比,本发明的有益效果在于:提出一种用于求解任务分配问题的改进离散粒子群算法,通过引入强化学习中的探索-利用机制以及机器学习中的学习率衰减,分别对标准粒子群算法的速度和位置更新公式进行改进,有效克服了标准粒子群算法由于早熟收敛导致容易陷入局部最优的问题。
Smart Images

Figure CN117455193B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of operations research and optimization, and in particular to a method and apparatus for task allocation. Background Technology
[0002] Task allocation is an important topic in operations research and optimization. It studies how to allocate limited human resources to different tasks under certain constraints, so as to maximize task benefits while minimizing labor costs. Since its inception, this problem has received widespread attention from researchers in industry and academia.
[0003] Task allocation is a typical nonlinear combinatorial optimization problem. As the problem size increases, the computational cost grows exponentially. Therefore, how to solve it efficiently has always been a key research focus and challenge in this field. After years of development, current algorithms for solving task allocation problems mainly fall into three categories: First, exact solution algorithms, including enumeration methods, branch and bound methods, column generation methods, dynamic programming algorithms, and auction algorithms; second, heuristic intelligent search algorithms, including simulated annealing, tabu search, large-scale neighborhood search, genetic algorithms, particle swarm optimization, ant colony optimization, artificial bee colony optimization, and hybrid intelligent search algorithms integrating multiple of these algorithms; and third, algorithms based on deep reinforcement learning, including deep Q-network algorithms and multi-agent reinforcement learning algorithms.
[0004] Among the aforementioned solution algorithms, particle swarm optimization (PSO) has been widely used due to its advantages such as fewer parameters, simple implementation, and fast convergence. However, as iterations proceed, the diversity of the particle swarm is gradually lost, making it prone to getting trapped in local optima and leading to premature convergence. Furthermore, the standard PSO algorithm is suitable for scenarios with continuous solution spaces; for problems with discrete solution spaces, such as task assignment, the algorithm needs to be adjusted accordingly.
[0005] Therefore, how to overcome the shortcomings of existing technologies and solve the problem of premature convergence in the standard particle swarm optimization algorithm is a problem to be solved in this technical field. Summary of the Invention
[0006] In view of the above-mentioned defects or improvement needs of the existing technology, the present invention solves the problem of premature convergence of the standard particle swarm algorithm.
[0007] The embodiments of the present invention adopt the following technical solutions:
[0008] Firstly, this invention provides a method for task allocation, specifically: an optimization objective that maximizes the cost-effectiveness ratio is obtained based on all task benefits and worker costs; constraints for task allocation are obtained based on the characteristics of tasks and workers; a mathematical model for task allocation is established based on the optimization objective and constraints; workers and tasks to be processed in the mathematical model are particle-based; the velocity and position of the particles are randomly initialized; and the individual optimal position of each particle and the global optimal position of the population are recorded based on the fitness value of each particle; the velocity of the particles is iteratively updated according to the exploration strategy of the particles in the solution space of the mathematical model; the position of the particles is iteratively updated according to the decay of the particle learning rate; the fitness value of each particle is recalculated; and the individual optimal position of the particles and the global optimal position of the population are updated according to the fitness value; when the fitness value converges, the global optimal position of the particles is obtained, and workers required for each task are allocated according to the obtained position.
[0009] Preferably, the optimization objective that maximizes the cost-effectiveness ratio based on the acquisition of all task revenues and worker costs specifically includes: acquiring the total revenue that can be obtained by completing all tasks, and acquiring the total cost of all workers; using the ratio of total revenue to total cost as the cost-effectiveness ratio of task allocation, and using the maximum value of the cost-effectiveness ratio as the optimization objective.
[0010] Preferably, the constraint conditions for task allocation based on the characteristics of tasks and workers specifically include: obtaining the number of workers of each type, and setting one of the constraint conditions to: the sum of the number of workers of any type allocated to all tasks is less than or equal to the number of workers of that type; specifying the maximum number of workers for each task, and setting one of the constraint conditions to: the sum of the number of workers allocated to any task is less than or equal to the maximum number of workers for that task; for each task, setting one of the constraint conditions to: the number of workers of each type allocated to the task is a non-negative integer.
[0011] Preferably, the step of particleizing the workers and tasks to be processed in the mathematical model specifically includes: treating the number of each type of worker assigned to each task as a particle, forming a two-dimensional array of particles, with the dimensions of the two-dimensional array being the worker type and the task; calculating the maximum speed of the particles based on the size of the exploration space in each dimension, and setting the initial speed of the particles in the corresponding dimension based on the maximum speed.
[0012] Preferably, the step of iteratively updating the particle velocity based on the particle's exploration strategy in the mathematical model solution space specifically includes: calculating the equilibrium parameter for the current iteration based on the number of iterations, and obtaining the random parameter for the current iteration; when the random parameter is less than the equilibrium parameter, randomly updating the particle velocity; when the random parameter is greater than or equal to the equilibrium parameter, updating the particle velocity based on the particle's individual optimal position, global optimal position, inertia weight, and learning factor.
[0013] Preferably, the step of iteratively updating the particle position based on the decay of the particle learning rate specifically includes: obtaining the learning rate of the current iteration based on the current iteration number and the maximum iteration number, and updating the particle position based on the learning rate and the particle velocity to obtain a particle position with the smallest possible fitness value.
[0014] Preferably, it further includes: setting a penalty factor according to the constraints, and constructing a fitness function based on the penalty factor and the reciprocal of the optimization objective; the step of recalculating the fitness value of each particle and updating the individual optimal position of the particle and the global optimal position of the population based on the fitness value specifically includes: calculating the fitness value of each particle using the fitness function based on the updated position, and updating the individual optimal position of the particle and the global optimal position of the population based on the fitness value.
[0015] Preferably, the method further includes: updating the inertial weight in the particle velocity update formula using a linear decreasing method; updating the first learning factor in the particle velocity update formula using a linear decreasing method; and updating the second learning factor in the particle velocity update formula using a linear increasing method.
[0016] Preferably, the step of allocating workers required for each task according to the obtained positions specifically includes: obtaining the task and worker type represented by the globally optimal particle, and allocating the corresponding number and type of workers to the corresponding task according to the number represented by the position of the particle.
[0017] On the other hand, the present invention provides a task allocation apparatus, specifically comprising at least one processor and a memory, wherein the at least one processor and the memory are connected via a data bus, the memory stores instructions executable by the at least one processor, and the instructions, after being executed by the processor, are used to complete the task allocation method in the first aspect.
[0018] Compared with the prior art, the beneficial effects of the present invention are as follows: an improved discrete particle swarm optimization algorithm for solving the task allocation problem is proposed. By introducing the exploration-exploitation mechanism in reinforcement learning and the learning rate decay in machine learning, the speed and position update formulas of the standard particle swarm optimization algorithm are improved respectively, which effectively overcomes the problem that the standard particle swarm optimization algorithm is prone to getting trapped in local optima due to premature convergence. Attached Figure Description
[0019] To more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings used in the embodiments of the present invention will be briefly described below. Obviously, the drawings described below are merely some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without any creative effort.
[0020] Figure 1 A flowchart of a task allocation method provided in an embodiment of the present invention;
[0021] Figure 2 A flowchart illustrating another task allocation method provided in an embodiment of the present invention;
[0022] Figure 3 A flowchart illustrating another task allocation method provided in an embodiment of the present invention;
[0023] Figure 4 A flowchart illustrating another task allocation method provided in an embodiment of the present invention;
[0024] Figure 5 A flowchart illustrating another task allocation method provided in an embodiment of the present invention;
[0025] Figure 6 A schematic diagram of a task allocation device provided in an embodiment of the present invention;
[0026] The reference numerals in the attached figures are as follows:
[0027] 11: Processor; 12: Memory. Detailed Implementation
[0028] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the invention.
[0029] This invention is an architecture of a specific functional system. Therefore, the specific embodiments mainly describe the functional logic relationship of each structural module, and do not limit the specific software and hardware implementation methods.
[0030] Furthermore, the technical features involved in the various embodiments of the present invention described below can be combined with each other as long as they do not conflict with each other. The present invention will now be described in detail with reference to the accompanying drawings and embodiments.
[0031] Example 1:
[0032] The method provided in this embodiment relates to the field of task allocation in operations research optimization, specifically to an improved discrete particle swarm optimization (DSO) algorithm for solving the task allocation problem. It provides a mathematical model for the task allocation problem that simultaneously considers task benefits and labor costs, as well as an improved DSO algorithm for solving this problem. This method overcomes the problem of premature convergence in the standard particle swarm optimization algorithm and can avoid getting trapped in local optima during the solution process.
[0033] like Figure 1As shown, the specific steps of the task allocation method provided in this embodiment of the invention are as follows:
[0034] Step 101: Based on the acquisition of all task benefits and worker costs, we can obtain the optimization objective that maximizes the cost-effectiveness ratio, and obtain the constraints for task allocation based on the characteristics of tasks and workers.
[0035] To achieve optimal task allocation, the first step is to define the optimization objective during iterative calculations, ensuring that each iteration approaches the desired allocation result. Real-world task allocation scenarios involve various tasks and different types of workers. Each task offers different rewards, and each worker type has varying costs per unit of time and efficiency in executing tasks. To maximize total revenue, both task rewards and worker costs must be considered, maximizing total revenue and minimizing total cost when all types of workers work together to complete all tasks. The ratio of task rewards to worker costs, known as the cost-effectiveness ratio, can be used as a quantifiable metric for the optimization objective. The allocation scheme that achieves the highest ratio of task rewards to worker costs is considered to have the highest cost-effectiveness ratio.
[0036] On the other hand, when assigning tasks, it is also necessary to consider the constraints in the actual scenario to avoid the calculated assignment scheme failing to meet actual needs. Constraints to consider include: the number of workers assigned cannot exceed the total number; the same worker cannot be repeatedly assigned to multiple tasks; and certain tasks can only use certain types of workers.
[0037] Step 102: Establish a mathematical model for task allocation based on the optimization objective and constraints. Particleize the workers and tasks to be processed in the mathematical model. Randomly initialize the velocity and position of the particles. Record the individual optimal position of each particle and the global optimal position of the population based on the fitness value of each particle.
[0038] To perform task allocation using the Discrete Particle Swarm Optimization (DPO) algorithm, a mathematical model of the task scenario is first required. This model needs to include information such as the number of tasks and workers within the scenario, as well as the optimization objective and constraints. In this mathematical model, the workers and tasks to be processed are represented as particles. Since there are different tasks and different types of workers, tasks and worker types can be combined into a two-dimensional array. Each row represents a type of worker, and each column represents a task. The value of each element in the two-dimensional array represents the number of workers of the corresponding type in the row assigned to the corresponding task in the corresponding column. After completing all subsequent calculations, the entire two-dimensional array represents the optimal position of the particles globally, i.e., a globally optimal solution for the task allocation scenario. The value of each element in the two-dimensional array can represent the number of workers of different types assigned to different tasks, thus obtaining the solution to the task allocation problem.
[0039] In this embodiment, the particle swarm optimization algorithm can incorporate an exploration-exploitation mechanism for task allocation calculation. Each particle, based on the optimization objective and constraints in the mathematical model, explores progressively along different dimensions of a two-dimensional array at its own speed. After each exploration, the fitness value of each particle is calculated according to the fitness function, and the individual optimal position of the particle and the global optimal position of the population are recorded. To implement the corresponding calculation process, the mathematical model and particles first need to be initialized according to the actual scenario. For example, the population size, maximum number of iterations, initial particle velocity, and initial position are set based on the number of tasks and workers.
[0040] Step 103: Iteratively update the particle velocity according to the particle's exploration strategy in the mathematical model solution space, iteratively update the particle position according to the decay of the particle's learning rate, recalculate the fitness value of each particle, and update the individual optimal position of the particle and the global optimal position of the population according to the fitness value.
[0041] During the exploratory computation process, based on the particle swarm optimization algorithm, it is necessary to adaptively adjust two parameters: inertia weight and learning factor.
[0042] Meanwhile, to avoid the premature convergence problem that may exist in existing particle swarm optimization algorithms, the method provided in this embodiment updates the particle velocity and position in each iteration using a different approach than existing techniques. For example, particle velocity is updated based on an explore-exploitation mechanism to balance the diversity and effectiveness of exploration; particle position is updated based on learning rate decay to adjust the position update rate in the early and later stages of the iteration. This approach overcomes the premature convergence problem of standard particle swarm optimization algorithms and can avoid getting trapped in local optima during the solution process.
[0043] In practice, the fitness value can be used as a criterion for determining whether the optimization objective has been achieved. In each iteration, the fitness value of each particle needs to be recalculated, and the optimal position of each individual particle and the global optimal position of the population need to be updated. When the fitness value no longer decreases, it indicates that the fitness value has converged, and at this point, the optimization objective can be considered achieved.
[0044] Step 104: When the fitness value converges, obtain the global optimal position of the particle and allocate the workers required for each task according to the obtained position.
[0045] When the fitness value converges, the termination condition is met, and the optimal solution for the current particle position is output. Otherwise, the parameter update and iterative calculation in steps 102 and 103 continue. In practice, the termination condition is generally that the number of iterations reaches the specified maximum number of iterations, or the algorithm has converged to an acceptable solution, i.e., the fitness value no longer decreases.
[0046] Once the termination condition is met and the global optimal position of the final output is obtained, the workers required for each task can be allocated according to the global optimal position of the particles. In specific implementation, the task and worker type represented by the global optimal particle can be obtained, and the corresponding number and type of workers can be allocated to the corresponding task based on the quantity represented by the particle's position.
[0047] After steps 101-104 provided in this embodiment, the modeling of the task allocation problem can be completed, and the premature convergence problem of the existing particle swarm algorithm during iterative calculation can be eliminated by the improved particle swarm algorithm, so as to obtain the globally optimal task allocation scheme.
[0048] In this embodiment of the invention, a mathematical model is used to calculate task allocation. For ease of description, mathematical formulas are used below to describe the mathematical model and the corresponding calculation process. It is understood that the following process is merely an example of a specific implementation of the method provided in this embodiment and is not intended to constrain the scope of protection. In actual implementation, the following mathematical model can be adjusted or modified according to the actual scenario needs and specific calculation objectives.
[0049] The mathematical symbols used in the following mathematical models and calculation formulas, along with their meanings, are shown below:
[0050] 1)W i : The i-th type of worker, assuming there are a total of W types of workers;
[0051] 2)T j : The j-th task, assuming there are a total of T tasks;
[0052] 3)N i : The number of workers of the i-th type;
[0053] 4)M j : The maximum number of workers to be assigned to the j-th task;
[0054] 5)C i : The unit cost of the i-th type of worker;
[0055] 6)V j The value of the j-th task;
[0056] 7)P ij : The competence of the i-th type of worker for the j-th task, that is, the probability that the worker can complete a certain task independently;
[0057] 8)X ij : Decision variable, the number of workers of type i assigned to task j.
[0058] like Figure 2 As shown, the optimization objective that maximizes the cost-effectiveness ratio can be obtained based on the acquisition of all task benefits and worker costs.
[0059] Step 201: Obtain the total revenue that can be obtained by completing all tasks, and obtain the total cost of all workers.
[0060] In this embodiment, the cost-effectiveness ratio is used as an indicator of the optimization objective. To calculate the cost-effectiveness ratio, the total revenue and total cost must first be obtained.
[0061] The total reward you can obtain after completing all tasks can be calculated in the following way:
[0062]
[0063] The total cost of workers can be calculated in the following ways:
[0064]
[0065] Step 202: Use the ratio of total revenue to total cost as the cost-effectiveness ratio for task allocation, and use the maximum value of the cost-effectiveness ratio as the optimization objective.
[0066] In the task allocation problem, the goal is to maximize the total revenue of the tasks while minimizing the total cost to the workers. In other words, the optimization objective is to maximize the cost-effectiveness ratio.
[0067] Taking both factors into consideration, the optimization objective of the task allocation problem is set as the following objective function:
[0068]
[0069] After steps 201-202 provided in this embodiment, the optimization target for task allocation can be obtained.
[0070] On the other hand, it is also necessary to obtain the constraints for task allocation based on the characteristics of the task and the worker. In the task allocation scenario, the following constraints are usually included. In actual implementation, other constraints can also be set according to the actual task requirements.
[0071] (1) Obtain the number of workers of each type and set one of the constraints to: the sum of the number of workers of any type assigned to all tasks is less than or equal to the number of workers of that type.
[0072] The total number of workers of each type assigned to all tasks must not exceed the total number of workers of that type, i.e.:
[0073]
[0074] (2) Specify the maximum number of workers for each task and set one of the constraints to: the sum of the number of workers assigned to any task is less than or equal to the maximum number of workers for that task.
[0075] To avoid assigning the same task to different types of workers multiple times, a limit is placed on the total number of workers assigned to each task, namely:
[0076]
[0077] (3) For each task, set one of the constraints to be: the number of workers of each type assigned to the task is a non-negative integer.
[0078] The number of workers of type i assigned to task j is a non-negative integer, i.e.:
[0079] X ij ≥0,X ij ∈Z.
[0080] By comprehensively optimizing the objective and constraints, a mathematical model for the task allocation problem can be obtained, which can be expressed by the following formula:
[0081]
[0082] like Figure 3 As shown, in order to use the particle swarm optimization algorithm for data processing, it is also necessary to particleize the workers and tasks to be processed in the mathematical model.
[0083] Step 301: Treat the number of workers of each type assigned to each task as a particle, and arrange the particles into a two-dimensional array. The dimensions of the two-dimensional array are the worker type and the task.
[0084] In the mathematical model of this embodiment, the position of a particle corresponds to the solution of the task allocation problem. For computational simplicity, the particles can be encoded in decimal. In a real-world scenario, there are W types of workers and T tasks. The particle-based tasks and workers can be represented as the following two-dimensional array:
[0085]
[0086] In this two-dimensional array, each row represents a type of worker, each column represents a task, and each element X... ij This represents the number of workers of type i assigned to task j.
[0087] Step 302: Calculate the maximum velocity of the particles based on the size of the exploration space in each dimension, and set the initial velocity of the particles for exploration in the corresponding dimension based on the maximum velocity.
[0088] After representing tasks and workers using particles, the particle velocities and positions need to be initialized for subsequent exploration. To avoid the initial values affecting subsequent calculations, the particle velocities and positions are initialized using a randomized method.
[0089] The position of the particles can be set completely randomly, as long as the constraints are met.
[0090] The speed of the particles will be limited to a certain range, that is:
[0091]
[0092] Among them, v max The maximum velocity of a particle can generally be represented by a search space of the corresponding dimension. The sign of the velocity value indicates the direction of exploration in a certain dimension; the specific sign corresponding to the direction can be specified as needed. After obtaining the maximum velocity, the particle velocity is then randomly set within the range represented by the maximum velocity.
[0093] After steps 301-302 provided in this embodiment, the task and worker can be particleized, and the particle-related attributes can be initialized.
[0094] To enhance particle diversity and explore the solution space as much as possible to find the global optimum, this embodiment introduces the exploration-exploitation mechanism from reinforcement learning.
[0095] In the training phase of reinforcement learning, a balanced greedy (ε-greedy) strategy is often used for action selection. In this strategy, an action is randomly selected with a small probability based on the balance parameter ε, and the optimal action is selected based on the current policy with a larger probability of 1-ε. In the algorithm of this embodiment, the position and velocity in particle swarm optimization can be analogized to the state and action in reinforcement learning. An ε-greedy strategy is used to update particle velocities: exploration is performed with a small probability, resulting in random, small-scale updates; updates are performed with a larger probability using information from the particle's own velocity, its optimal individual position, and the global optimal position. This method of updating particle velocities ensures both effectiveness and diversity.
[0096] like Figure 4 As shown, the velocity of a particle can be iteratively updated based on its exploration strategy in the solution space of the mathematical model, as shown in the following method.
[0097] Step 401: Calculate the balance parameters for this iteration based on the number of iterations, and obtain the random parameters for this iteration.
[0098] First, determine the value of the equilibrium parameter ε. It can be a fixed value, such as 0.1, or it can gradually decrease as the iteration progresses, for example:
[0099]
[0100] Among them, T cur This represents the current iteration number. After each iteration, the balancing parameter is reduced proportionally.
[0101] After obtaining the balance parameter ε, it is also necessary to generate a random number n1 between 0 and 1, and use n1 as the random parameter in the exploration mechanism.
[0102] Step 402: When the random parameter is less than the equilibrium parameter, the particle velocity is updated randomly.
[0103] If n1 < ε, then the particle velocity is updated randomly, i.e.:
[0104] v(t+1)=n2v max .
[0105] Where n2 is a random number between (-1, 1), v max This indicates the maximum velocity of the particle.
[0106] Step 403: When the random parameter is greater than or equal to the equilibrium parameter, update the particle's velocity based on the particle's individual optimal position, global optimal position, inertia weight, and learning factor.
[0107] Otherwise, update the particle velocity according to the standard formula, that is:
[0108] v(t+1)=ωv(t)+c1r1[p x best(t)-x(t)]+c2r2[g x best(t)-x(t)]
[0109] Where, p x best(t) represents the individual optimal position of the particle, g x best(t) represents the global optimal position of the particle swarm, ω is the inertia weight, c1 and c2 are learning factors, and r1 and r2 are random numbers between (0,1).
[0110] After steps 401-403 provided in this embodiment, the particle velocity update can be completed for each iteration.
[0111] After updating the particle velocity, the particle position also needs to be iteratively updated based on the decay of the particle learning rate. The learning rate for this iteration is obtained based on the current iteration number and the maximum iteration number. The particle position is then updated based on the learning rate and the particle velocity to obtain a particle position with the smallest possible fitness value.
[0112] In practice, a learning rate can be introduced into the particle swarm optimization algorithm to control the updating of particle positions. In the initial stage of the algorithm, the particles move towards the global optimum at a faster pace to improve the convergence speed; in the later stages of iteration, the position update speed is slowed down to enhance the local search capability and prevent particles from jumping out of the optimum.
[0113] When updating particle positions using a learning rate decay method, the particle positions can be calculated using the following formula:
[0114]
[0115] Where lr is the position of the particle, e is the natural constant, and T cur T max These are the current iteration number and the maximum iteration number, respectively.
[0116] In practice, other parameters required for iterative calculations in the particle swarm optimization algorithm can be updated as needed.
[0117] (1) The inertial weight in the particle velocity update formula is updated using a linear decreasing method.
[0118] The inertia weight ω reflects the degree to which a particle inherits its current velocity. A larger ω indicates stronger global optimization capability, while a smaller ω indicates stronger local optimization capability. An appropriate value can enable the particle to achieve a balance between global and local optimization. Compared to using a fixed value, an adaptive adjustment method better meets practical needs, using a larger inertia weight in the initial stage and a smaller inertia weight in the later stages of iteration.
[0119] In this embodiment, the inertia weight is updated using a linear decreasing method, and the calculation formula is as follows:
[0120]
[0121] Where, ω max ω min These are the maximum and minimum values of the inertia weight, T. cur T max These are the current iteration number and the maximum iteration number, respectively.
[0122] (2) The first learning factor in the particle velocity update formula is updated using a linear decreasing method, and the second learning factor in the particle velocity update formula is updated using a linear increasing method.
[0123] The first learning factor c1 and the second learning factor c2 control the degree to which particles learn from their own experience and the experience of the population. In the early stages of iteration, a larger c1 and a smaller c2 are used to enhance the global search capability; in the later stages, the opposite settings are used to make particles move toward the optimal position of the population and avoid getting trapped in local optima.
[0124] In this embodiment, the first learning factor c1 is adjusted using a linear decreasing method, and the second learning factor c2 is adjusted using a linear increasing method. The calculation formula is as follows:
[0125]
[0126]
[0127] Among them, c 1_max c 1_min Let c be the maximum and minimum values of the first learning factor c1. 2_max c 2_min These are the maximum and minimum values of the second learning factor c2.
[0128] After updating the above calculation parameters, as follows: Figure 5 As shown, the fitness value and position of the particle at each iteration can be calculated in the following manner.
[0129] Step 501: Set the penalty factor according to the constraints, and construct the fitness function based on the penalty factor and the reciprocal of the optimization objective.
[0130] In particle swarm optimization (PSO), a suitable fitness function needs to be selected to evaluate the quality of particles. Generally, the fitness function is related to the objective function, while also considering the impact of constraints. In practice, a penalty function method can be used to incorporate constraints into the fitness function. In this embodiment, penalty factors K1, K2, and K3 are introduced, all of which are large positive numbers, such as 1000. When a solution fails to meet the constraints, a large penalty is imposed. After adding penalty factors, the value of the penalized solution will be large; therefore, the smaller the value of the fitness function, the better the fitness of the solution.
[0131] Furthermore, the fitness function also needs to incorporate an objective function to indicate the optimization goal, and a larger objective function value indicates closer proximity to the optimization goal. Therefore, to match the characteristic that a smaller fitness function value is better, the reciprocal of the objective function needs to be added to the fitness function.
[0132] The final fitness function is shown below:
[0133]
[0134] Step 502: Based on the updated position, calculate the fitness value of each particle using the fitness function, and update the individual optimal position of the particle and the global optimal position of the population based on the fitness value.
[0135] Once the fitness of each particle is obtained, the individual optimal position of the particle and the global optimal position of the population can be updated based on the fitness. The particle position indicator function is as follows:
[0136]
[0137] When X ij When the value is greater than or equal to 0, it means that the j-th task has been assigned workers of the i-th type according to this method, and the number of workers assigned is X. ij The value of X. ij When the value is less than 0, it means that the i-th type of worker has not been assigned to the j-th task.
[0138] After steps 501-502 provided in this embodiment, the fitness value and position of the particle after each iteration can be calculated until the fitness value converges, that is, the global optimal position of the particle is calculated, and the required task allocation scheme is obtained.
[0139] The task allocation method provided in this embodiment:
[0140] (1) This embodiment provides a mathematical model for the task allocation problem, which takes into account both task benefits and labor costs, and models the model with the goal of maximizing the cost-effectiveness ratio, which meets the needs of actual application scenarios.
[0141] (2) This embodiment provides an improved discrete particle swarm algorithm for solving the task allocation problem. By introducing the exploration-exploitation mechanism in reinforcement learning and the learning rate decay in machine learning, the speed and position update formulas of the standard particle swarm algorithm are improved respectively, overcoming the problem of premature convergence of the standard particle swarm algorithm and avoiding getting trapped in local optima during the solution process.
[0142] Example 2:
[0143] Based on the task allocation method provided in Embodiment 1, it can be implemented in some specific embodiments through the specific implementation methods described in this embodiment. It is understood that the specific implementation methods provided in this embodiment are only used to illustrate the specific implementation process of the method in Embodiment 1 in certain specific scenarios and are not intended to limit the scope of protection.
[0144] In this embodiment, it is assumed that there are 6 different types of workers and 5 tasks in the initial state.
[0145] The number of workers of each type is as follows:
[0146] N = [7, 6, 8, 6, 5, 7]
[0147] The unit costs of workers are as follows:
[0148] C=[0.15,0.21,0.16,0.16,0.22,0.19];
[0149] The maximum number of workers assigned to different tasks are as follows:
[0150] M = [8,8,8,8,8];
[0151] The values of the different tasks are as follows:
[0152] V=[0.57,0.49,0.72,0.69,0.43].
[0153] The workers' competence in the task is shown in Table 1:
[0154] Table 1. Workers' Competency with the Task
[0155]
[0156] First, following step 101, based on the above constraints, a corresponding mathematical model is established with the goal of maximizing the cost-effectiveness ratio. In this embodiment, for the sake of simplicity, the mathematical model established in Example 1 is used.
[0157] Then, following step 102 and the actual data mentioned above, the task and worker are particleized and initialized.
[0158] In this embodiment, during initialization, it is necessary to set the population size, maximum number of iterations, initial velocity of the particles, and initial position.
[0159] The population size is set to 40, and the maximum number of iterations is set to 100. Particle positions are randomly initialized using a uniform integer distribution, such as using `numpy.random.randint` in Python. The lower bound of the particle position is set to 0, and the upper bound is the minimum of (the number of workers of each type and the maximum number of workers assigned to different tasks).
[0160] In this embodiment, the upper bound of the particle position is as follows:
[0161]
[0162] The particle velocity is initialized randomly using a continuous uniform distribution, such as through `numpy.random.uniform` in Python. The lower bound of the particle velocity is -v. max The upper bound of the particle velocity is v max v max It is 0.3 times the difference between the upper and lower bounds of the particle position.
[0163] In this embodiment, the upper bound of the particle velocity is as follows:
[0164]
[0165] The fitness value of each particle is calculated based on the fitness function, and the individual optimal position of the particle in the initial state and the global optimal position of the population are recorded.
[0166] In this embodiment, the fitness function is as follows:
[0167]
[0168] Where I (·) For indicator functions:
[0169]
[0170] When X ij When the value is greater than or equal to 0, it means that the j-th task has been assigned workers of the i-th type according to this method, and the number of workers assigned is X. ijThe value of X. ij When the value is less than 0, it means that the i-th type of worker has not been assigned to the j-th task.
[0171] In this initial state, K1, K2, and K3 are all set to 1000. The number of workers of each type N, the unit cost of workers C, the maximum number of workers M assigned to different tasks, the value V of different tasks, and the worker's competence P in the task are as described above. Based on the fitness value, the optimal position p of each individual is recorded. x best(t) and the global optimal position g x best(t).
[0172] Once initialization is complete, iterative calculations can be performed, and each parameter can be updated during the iteration process according to step 103.
[0173] (1) Adaptively adjust the two parameters, inertia weight and learning factor.
[0174] The inertia weights are updated using a linear decreasing method, as shown below:
[0175]
[0176] Where, ω max =0.9, ω min =0.4, T cur T is the current iteration number. max =100.
[0177] The first learning factor c1 is adjusted using a linear decreasing method, and the second learning factor c2 is adjusted using a linear increasing method, as shown below:
[0178]
[0179]
[0180] Among them, c 1_max =2, c 1_min =0.5; c 2_max =2.5, c 2_min =0.5.
[0181] (2) Update particle velocity based on the exploration-exploitation mechanism.
[0182] The particle velocity is updated using an ε-greedy strategy, as detailed below:
[0183] 1) First, determine the value of ε, which gradually decreases as the iteration progresses:
[0184]
[0185] 2) Generate a random number n1 between 0 and 1.
[0186] 3) If n1 < ε, then the particle velocity is updated randomly, i.e.:
[0187] v(t+1)=n2v max .
[0188] Where n2 is a random number between (-1, 1), v max This indicates the maximum velocity of the particle.
[0189] 4) Otherwise, update the particle velocity according to the standard formula, that is:
[0190] v(t+1)=ωv(t)+c1r1[p x best(t)-x(t)]+c2r2[g x best(t)-x(t)].
[0191] Where, p x best(t) represents the individual optimal position of the particle, g x best(t) represents the global optimal position of the particle swarm, ω is the inertia weight, c1 and c2 are learning factors, and r1 and r2 are random numbers between (0,1).
[0192] (3) Update the particle position based on the learning rate decay.
[0193] The particle position is updated using a learning rate decay method, as shown in the following equation:
[0194]
[0195] Where e is the natural constant.
[0196] After completing the parameter update, according to step 104, the fitness value of each particle is recalculated, and the optimal position p of each particle is updated. x best(t) and the global optimal position g of the population x best(t).
[0197] After each iteration, it is necessary to determine whether the termination condition has been met. If the termination condition is met, the optimal solution is output; otherwise, proceed to step 102 to continue iteration. In this embodiment, the termination condition is reaching the maximum number of iterations, 100.
[0198] The optimal solution to the task allocation problem in this embodiment, obtained by the above method, is as follows:
[0199] Table 2 shows the optimal solution to the task allocation problem in this embodiment.
[0200]
[0201] The corresponding task allocation schemes are as follows: Type 1 workers are assigned 4 to task 3 and 3 to task 4; Type 2 workers are assigned 5 to task 2 and 1 to task 3; Type 3 workers are assigned 3 to task 1 and 5 to task 4; Type 4 workers are assigned 3 to task 1 and 3 to task 2; Type 5 workers are assigned 2 to task 3 and 1 to task 5; Type 6 workers are assigned 1 to task 1, 1 to task 3, and 5 to task 5.
[0202] Example 3:
[0203] Based on the task allocation methods provided in Embodiments 1 and 2 above, the present invention also provides an apparatus for implementing the task allocation methods described above, such as... Figure 6 The diagram shown is a schematic representation of the device architecture according to an embodiment of the present invention. The task allocation device in this embodiment includes one or more processors 11 and a memory 12. Figure 6 Take a processor 11 as an example.
[0204] Processor 11 and memory 12 can be connected via a bus or other means. Figure 6 Taking the example of a connection between China and Israel via a bus.
[0205] The memory 12, as a non-volatile computer-readable storage medium for task allocation, can be used to store non-volatile software programs, non-volatile computer-executable programs, and modules, such as the task allocation methods in Embodiments 1 and 2. The processor 11 executes various functional applications and data processing of the task allocation device by running the non-volatile software programs, instructions, and modules stored in the memory 12, thereby implementing the task allocation methods of Embodiments 1 and 2.
[0206] Memory 12 may include high-speed random access memory, and may also include non-volatile memory, such as at least one disk storage device, flash memory device, or other non-volatile solid-state storage device. In some embodiments, memory 12 may optionally include memory remotely located relative to processor 11, which can be connected to processor 11 via a network. Examples of such networks include, but are not limited to, the Internet, intranets, local area networks, mobile communication networks, and combinations thereof.
[0207] The program instructions / modules are stored in memory 12. When executed by one or more processors 11, they perform the task allocation methods described in Embodiments 1 and 2 above, for example, executing the methods described above. Figures 1-5The steps shown.
[0208] Those skilled in the art will understand that all or part of the steps in the various methods of the embodiments can be implemented by a program instructing related hardware. The program can be stored in a computer-readable storage medium, which may include: read-only memory (ROM), random access memory (RAM), magnetic disk or optical disk, etc.
[0209] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of the present invention should be included within the protection scope of the present invention.
Claims
1. A method for task allocation, characterized in that, include: The optimization objective that maximizes the cost-effectiveness ratio can be obtained by considering all task benefits and worker costs. The constraints for task allocation are obtained based on the characteristics of tasks and workers. A mathematical model for task allocation is established based on the optimization objective and constraints. The workers and tasks to be processed in the mathematical model are particleized, the velocity and position of the particles are randomly initialized, and the individual optimal position of the particle and the global optimal position of the population are recorded according to the fitness value of each particle. The particle velocity is iteratively updated based on the particle's exploration strategy in the mathematical model solution space, the particle position is iteratively updated based on the decay of the particle's learning rate, the fitness value of each particle is recalculated, and the individual optimal position of the particle and the global optimal position of the population are updated based on the fitness value. When the fitness value converges, the global optimal position of the particle is obtained, and workers are allocated to each task according to the obtained position. The process of particleizing the workers and tasks to be processed in the mathematical model specifically includes: treating the number of each type of worker assigned to each task as a particle, forming a two-dimensional array of particles, with the dimensions of the two-dimensional array being the worker type and the task; calculating the maximum speed of the particles based on the size of the exploration space in each dimension, and setting the initial speed of the particles in the corresponding dimension based on the maximum speed. The step of iteratively updating the particle velocity based on the particle's exploration strategy in the mathematical model solution space specifically includes: calculating the equilibrium parameter for this iteration based on the number of iterations, and obtaining the random parameter for this iteration; when the random parameter is less than the equilibrium parameter, randomly updating the particle velocity; when the random parameter is greater than or equal to the equilibrium parameter, updating the particle velocity based on the particle's individual optimal position, global optimal position, inertia weight, and learning factor. The method further includes: setting a penalty factor according to the constraints, and constructing a fitness function based on the penalty factor and the reciprocal of the optimization objective; the recalculation of the fitness value of each particle, and updating the individual optimal position of the particle and the global optimal position of the population based on the fitness value, specifically includes: calculating the fitness value of each particle using the fitness function based on the updated position, and updating the individual optimal position of the particle and the global optimal position of the population based on the fitness value. The method further includes: updating the inertial weight in the particle velocity update formula using a linear decreasing method; updating the first learning factor in the particle velocity update formula using a linear decreasing method; and updating the second learning factor in the particle velocity update formula using a linear increasing method.
2. The task allocation method according to claim 1, characterized in that, The optimization objective, which maximizes the cost-effectiveness ratio based on the acquisition of all task benefits and worker costs, specifically includes: Obtain the total revenue that can be obtained by completing all tasks, and obtain the total cost of all workers; The ratio of total revenue to total cost is used as the cost-effectiveness ratio for task allocation, and the maximum value of the cost-effectiveness ratio is used as the optimization objective.
3. The task allocation method according to claim 1, characterized in that, The constraints for task allocation based on the characteristics of tasks and workers specifically include: Get the number of workers of each type, and set one of the constraints to: the sum of the number of workers of any type assigned to all tasks is less than or equal to the number of workers of that type; Specify the maximum number of workers for each task, and set one of the constraints to: the sum of the number of workers assigned to any task is less than or equal to the maximum number of workers for that task; For each task, set one of the constraints to be: the number of workers of each type assigned to the task is a non-negative integer.
4. The task allocation method according to claim 1, characterized in that, The iterative update of particle positions based on the decay of the particle learning rate specifically includes: The learning rate for this iteration is obtained based on the current iteration number and the maximum iteration number. The particle position is updated based on the learning rate and the particle velocity to obtain a particle position with the smallest possible fitness value.
5. The task allocation method according to claim 1, characterized in that, The process of allocating workers for each task according to the obtained locations specifically includes: Obtain the task and worker type represented by the globally optimal particle, and assign the corresponding number and type of workers to the corresponding task based on the number represented by the particle's position.
6. A task allocation device, characterized in that: It includes at least one processor and a memory, the at least one processor and the memory being connected via a data bus, the memory storing instructions executable by the at least one processor, the instructions being executed by the processor to perform the task allocation method according to any one of claims 1-5.
Citation Information
Patent Citations
Crowdsourcing software project scheduling method based on grouping learning particle swarm optimization and medium
CN114139453A
Cloud computing task scheduling method
CN115794330A