A method for assigning target to UAV sequence based on greedy algorithm
Through the drone sequence target allocation method based on greedy algorithm, greedy strategies and backtracking algorithms are used to optimize drone target allocation, the problems of error and limitation in existing technology in dynamic tasks are solved, and efficient drone task allocation is achieved , adapt to the real-time and accuracy requirements in the field of drones.
Patent Information
- Application Number
- CN202410482864.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-04-22
- Publication Date
- 2024-12-27
- Estimated Expiration
- 2044-04-22
AI Technical Summary
The existing drone target allocation algorithm has errors and limitations in dynamic tasks, especially based on Hungarian algorithms and KM algorithms, it can only achieve one-to-one corresponding allocation of drones-targets, and deep reinforcement learning technology is difficult to achieve in real environments. Dead.
Using the drone sequence target allocation method based on greedy algorithm, the two cost matrices M1 and M2 represent the distance between the drone and the target and the distance between the target, and the target is used to allocate the target by using greedy strategy and backtracking algorithm. , ensure that the total distance for the drone to complete the mission is minimized.
It realizes high accuracy and rapidity of drone sequence target allocation, can adapt to the real-time and accuracy requirements of the drone field, and has obvious advantages over traditional enumeration methods and reinforcement learning algorithms.
Smart Images

Figure CN118313610B_ABST
Abstract
Description
Technical Field
[0001] The invention belongs to the technical field of unmanned aerial vehicles, and in particular relates to a method for allocating unmanned aerial vehicle sequence targets based on a greedy algorithm. Background Art
[0002] The application of drone target allocation is quite extensive, including search and rescue, patrol, attack, etc. How to realize drone target allocation intelligently is a hot topic in the field of unmanned equipment.
[0003] Most current research focuses on the allocation of static tasks to drones, that is, the tasks have been determined in advance and no new tasks will be added. Drones are driven manually or by algorithms to their assigned targets.
[0004] The technologies currently used to deal with static target allocation problems mainly include auction-based algorithms, game theory-based algorithms, optimization-based algorithms (ant colony algorithm, Hungarian algorithm and KM algorithm, etc.) and learning-based algorithms. Among them, auction-based and game theory-based algorithms can also be used to simply allocate dynamic tasks through variations, but the allocation results of such algorithms have certain errors because they do not consider the changes in the position of the drone. The target allocation methods based on the Hungarian algorithm and the KM algorithm can only achieve a one-to-one allocation of drones and targets, and require the cost matrix to be a square matrix, which limits the promotion of such algorithms in dynamic tasks. Learning-based methods, especially deep reinforcement learning technology, are more prominent in dynamic target allocation and dynamic environments, but most models remain in academic laboratory environments and are currently difficult to implement in reality. Summary of the invention
[0005] 1. Technical issues to be resolved
[0006] The technical problem to be solved by the present invention is how to provide a UAV sequence target allocation method based on a greedy algorithm to solve the UAV sequence target allocation problem.
[0007] (II) Technical solution
[0008] In order to solve the above technical problems, the present invention proposes a method for allocating UAV sequence targets based on a greedy algorithm. The method describes the UAV target allocation problem as follows: n UAVs are allocated m targets; two cost matrices M1 are set n×m and M2 m×m , respectively representing the distance matrix between the drone and the target and the distance matrix between the targets, element m1 ij ∈M1 n×m Represents the distance between drone i and target j, element m2 ij ∈M2 m×m represents the distance between target i and target j;
[0009] This method adopts the following greedy strategy when sending the target task to each drone:
[0010] S1, from matrix M1 n×m Select the minimum value m1 kl , assigning target l to UAV k means that target l is in the task sequence of UAV k;
[0011] S2, since the distance that drone k needs to travel to execute target l is s = M1 n×m [k][l], then drone k will be at the location of target l, so the distance between drone k and other targets is transformed into the distance between target l and other targets, that is, matrix M1 n×m The kth row of the matrix M2 is set equal to m×m The lth row of ;
[0012] S3: The next time you assign target q to drone k, the distance drone k needs to travel is s+M1 n×m [k]q], so the matrix M1 in step S2 n×m The kth row of is updated to matrix M2 m×m After the first row of M1 n×m Add s to each element of the k-th row;
[0013] S4, then matrix M1 n×m The lth column of is assigned a value of ∞, indicating that the target has been assigned and will not be selected for assignment next time;
[0014] S5. Repeat steps S1 to S4 m times until all targets are assigned.
[0015] (III) Beneficial effects
[0016] The present invention proposes a UAV sequence target allocation method based on a greedy algorithm. The present invention adopts a UAV sequence target allocation method based on a greedy algorithm. Compared with the traditional enumeration method and the emerging reinforcement learning algorithm, the accuracy and speed of this algorithm have obvious advantages, and can better adapt to the real-time and accuracy requirements in the field of UAVs. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] Figure 1 is a flow chart of the present invention;
[0018] Figure 2 Schematic diagram of the position of the UAV and the target;
[0019] Figure 3 Schematic diagram of drone patrol targets. DETAILED DESCRIPTION
[0020] In order to make the purpose, content and advantages of the present invention more clear, the specific implementation methods of the present invention are further described in detail below in conjunction with the drawings and examples.
[0021] The purpose of the present invention is to provide a method for allocating UAV sequence targets based on a greedy algorithm, so that the UAV system can autonomously allocate static targets according to its own load, and can realize the allocation of dynamic target tasks, ensuring that the total distance to complete all tasks is small.
[0022] The present invention proposes a method for allocating UAV sequence targets based on a greedy algorithm, which can automatically allocate a sequenced target list to the UAV and plan the corresponding route. In addition, for newly added target tasks, this technology can also dynamically and quickly allocate the target to a certain UAV, ensuring that the total distance to complete all targets is small.
[0023] The present invention proposes a method for allocating UAV sequence targets based on a greedy algorithm, and describes the UAV target allocation problem as follows: n UAVs are allocated m targets, one UAV can be allocated multiple or zero targets, one target can only be allocated to one UAV, a UAV needs to travel a specific route and spend a specific time to reach a target, and it also takes a specific time for the UAV to process the target. How to quickly achieve target allocation and ensure that the total time cost of completing the task is as small as possible.
[0024] First, this method sets two cost matrices M1 n×m and M2 m×m , respectively representing the distance matrix between the drone and the target and the distance matrix between the targets. Element m1 ij ∈M1 n×m Represents the distance between drone i and target j, element m2 ij ∈M2 m×m Represents the distance between target i and target j.
[0025] In order to assign the target tasks to each drone so that the distance traveled by the drone to complete all tasks is small, the following greedy strategy is adopted:
[0026] S1, from matrix M1 n×m Select the minimum value m1 kl , assigning target l to UAV k means that target l is in the task sequence of UAV k;
[0027] S2, since the distance that drone k needs to travel to execute target l is s = M1 n×m [k][l] (i.e. matrix M1 n×m Then, UAV k will be located at the position of target l, so the distance between UAV k and other targets is transformed into the distance between target l and other targets, that is, the matrix M1n×m The kth row is set to the matrix M2 m×m The lth row of ;
[0028] S3: The next time you assign target q to drone k, the distance drone k needs to travel is s+M1 n×m [k][q], for convenience, the matrix M1 in step S2 is n×m The kth row of is updated to matrix M2 m×m After the first row of M1 n×m Add s to each element of the k-th row;
[0029] S4, then matrix M1 n×m The lth column of is assigned a value of ∞, indicating that the target has been assigned and will not be selected for assignment next time;
[0030] S5. Repeat steps S1 to S4 m times until all targets are assigned.
[0031] In step S1, matrix M1 n×m There may be more than one minimum value in the problem. In this case, a backtracking algorithm is needed to perform a depth-first search, taking into account every possibility, to find the global optimal solution. The backtracking algorithm specifically includes the following steps:
[0032] S11. Define a global variable ans (float variable) to record the minimum value of the distance and the searched solution, and a global variable project (a two-dimensional list, which has n one-dimensional lists, each one-dimensional list represents the task sequence that each drone needs to complete), which is used to record the distance and the searched allocation solution corresponding to ans. These two variables will be updated according to each recursive result;
[0033] S12. Define a recursive function dfs(dis, robots_ans, inf), where the variable dis (float variable) represents the distance sum of this round of recursion, robots_ans (a two-dimensional list, which has n one-dimensional lists, each one-dimensional list represents a sequence of tasks that each drone needs to complete) represents the allocation plan of this round of recursion, and inf (a one-dimensional list) represents the set of target numbers that have been allocated in this round of recursion;
[0034] S13, same as step S1, matrix M1 n×m The two-dimensional indexes corresponding to all the minimum values in the list are recorded in the list list, and the list list is traversed. For the i-th element in the list [r i ,t i ] (indicates the horizontal and vertical coordinates corresponding to the i-th minimum value), and performs the following target allocation recursive operation:
[0035] S131, will t iAdd it to inf, representing target t i has been assigned;
[0036] S132. Add t i to robots_ans[r i , representing target t i has been executed by drone r i ;
[0037] S133. Introduce intermediate variable lr = M1 n×m [r i , temporarily store the value of M1 n×m [r i in lr for convenient restoration during the backtracking process;
[0038] S134. dis = dis + M1 n×m [r i [t i , that is, add the distance consumed by drone r i executing target t i to the total distance;
[0039] S135. M1 n×m [r i = M2 m×m [t i + M1 n×m [r i [t i ;
[0040] S136. Introduce intermediate variable linf = M1 n×m [:, inf], temporarily store the value of M1 n×m [:, inf] in linf for convenient restoration during the backtracking process;
[0041] S137. M1 n×m [:, inf] = ∞;
[0042] S138. Execute the recursive function dfs(dis, robots_ans, inf), that is, enter the recursive process. The recursive exit is that the minimum value of M1 n×m is ∞, which means all targets have been assigned; when reaching the recursive exit, compare the sizes of ans and dis. If dis < ans, update ans to dis and project to robots_ans, otherwise directly execute return (the function returns, indicating the end of the recursion);
[0043] S14. After the recursive process is the backtracking process, which requires reverse operations on process S13, that is, restore matrix M1 n×m, dis, robots_ans, and inf:
[0044] S141, execute M1 n×m [:,inf]=linf, restore M1 n×m inf columns;
[0045] S142, execute M1 n×m [r i ]=lr, restore M1 n×m The rth i OK;
[0046] S143, execute dis=dis-M1 n×m [r i ][t i ];
[0047] S144, execute robots_ans[r i ].pop(), that is, release robots_ans[r i ]'s last element;
[0048] S145, execute inf.pop(), that is, release the last element of inf;
[0049] S15. After the backtracking process is completed, continue to perform recursion and backtracking steps on the i+1th element in the list until all minimum values have been traversed.
[0050] The step S5 also includes: after the target allocation is completed, the total range and task list of each drone are obtained, and the drones will patrol and execute in sequence according to their respective task lists. Each time a task is completed, the task will be deleted from the list and the range will be updated (i.e., the distance of the most recent patrol will be subtracted from the current range).
[0051] The step S5 also includes: when encountering a new target, by obtaining the route and distance from the target to the last target in each drone task list, calculating the drone that minimizes (estimated range = current range + distance from the target to the last target in each drone task list), adding the target to the task list of the drone with the smallest estimated range, and updating the range of the drone (i.e., the current range plus the distance from the target to the last target in the drone task list).
[0052] Embodiment 1:
[0053] The present invention is a method for allocating unmanned aerial vehicle sequence targets based on a greedy algorithm.
[0054] Figure 1The target allocation greedy algorithm execution flow diagram of the present invention is shown in FIG. First, two input matrices M1 need to be obtained. n×m (Distance matrix between drone and target) and M2 m×m (Distance matrix between targets), then find M1 n×m The minimum element is used for target allocation, and a combination of recursive backtracking and ordinary algorithms is used to ensure that the final search result is optimal.
[0055] A method for assigning targets to UAV sequences based on a greedy algorithm, the steps are as follows:
[0056] The drone target allocation problem can be described as: n drones are assigned m targets, one drone can be assigned multiple or zero targets, and one target can only be assigned to one drone. A drone needs to take a specific route and spend a specific time to reach a target, and it also takes a specific time for a drone to achieve the target. How to quickly achieve target allocation and ensure that the total time cost to complete the task is as small as possible.
[0057] First, the algorithm input requires two cost matrices M1 n×m and M2 m×m , respectively representing the distance matrix between the drone and the target and the distance matrix between the targets. Element m1 ij (∈M1 n×m ) represents the distance between drone i and target j, and element m2 ij (∈M2 m×m ) represents the distance between target i and target j.
[0058] In order to assign the target tasks to each drone so that the distance traveled by the drone to complete all tasks is small, the following greedy strategy is adopted:
[0059] (1) From the matrix M1 n×m Select the minimum value m1 kl , assigning target l to UAV k means that target l is in the task sequence of UAV k;
[0060] (2) Since the distance that drone k needs to travel to execute target l is s = M1 n×m [k][l] (i.e. matrix M1 n×m Then, UAV k will be located at the position of target l, so the distance between UAV k and other targets is transformed into the distance between target l and other targets, that is, matrix M1 n×m The kth row of the matrix M2 is equal to m×m The lth row of ;
[0061] (3) The next time drone k is assigned target q, the distance drone k needs to travel is s+M1 n×m[k][q], for convenience, let the matrix M1 in step (2) n×m The kth row of is updated to matrix M2 m×m After the first row of M1 n×m Add s to each element of the k-th row;
[0062] (4) Then the matrix M1 n×m The lth column of is assigned a value of ∞, indicating that the target has been assigned and will not be selected for assignment next time;
[0063] (5) Repeat steps (1) to (4) m times until all targets are assigned.
[0064] Step (1) Matrix M1 n×m There may be more than one minimum value in the problem, so a backtracking algorithm is needed to perform a depth-first search, taking into account every possibility, to find the global optimal solution. The backtracking algorithm is as follows:
[0065] 1) Define a global variable ans (float variable) to record the minimum value of the distance and the searched solution, and a global variable project (a two-dimensional list, which has n one-dimensional lists, each one-dimensional list represents the task sequence that each drone needs to complete), to record the distance and the searched allocation solution corresponding to ans. These two variables will be updated according to each recursive result;
[0066] 2) Define the recursive function dfs(dis, robots_ans, inf), where the variable dis (float variable) represents the distance sum of this round of recursion, robots_ans (a two-dimensional list, which has n one-dimensional lists, each one-dimensional list represents the task sequence that each drone needs to complete) represents the allocation plan of this round of recursion, and inf (a one-dimensional list) represents the set of target numbers that have been allocated in this round of recursion;
[0067] 3) Same as step (1), matrix M1 n×m The two-dimensional indexes corresponding to all the minimum values in the list are recorded in the list list, and the list list is traversed. For the i-th element in the list [r i ,t i ] (indicates the horizontal and vertical coordinates corresponding to the i-th minimum value), perform the following operations:
[0068] ①T i Add to inf to indicate target t i has been assigned;
[0069] ②T i Join robots_ans[r i ], indicating the target t i Has been drone iExecute;
[0070] ③ Introduce an intermediate variable lr = M1 n×m [r i , temporarily store the value of M1 n×m [r i in lr for convenient restoration during the backtracking process;
[0071] ④ dis = dis + M1 n×m [r i [t i , that is, add the distance that the drone r i needs to consume to execute the target t i to the total distance;
[0072] ⑤ M1 n×m [r i = M2 m×m [t i + M1 n×m [r i [t i , that is, steps (2)-(3) of the above process;
[0073] ⑥ Introduce an intermediate variable linf = M1 n×m [:, inf], temporarily store the value of M1 n×m [:, inf] in linf for convenient restoration during the backtracking process;
[0074] ⑦ M1 n×m [:, inf] = ∞, that is, step (4) of the above process;
[0075] ⑧ Execute the recursive function dfs(dis, robots_ans, inf), that is, enter the recursive process. The recursive exit is that the minimum value of M1 n×m is ∞, that is, all targets have been assigned; when reaching the recursive exit, compare the sizes of ans and dis. If dis < ans, update ans to dis and project to robots_ans, otherwise directly execute return (the function returns, indicating the end of the recursion);
[0076] 4) After the recursive process is the backtracking process, which requires reverse operations on process 3), that is, restore the matrices M1 n×m , dis, robots_ans, and inf:
[0077] ① Execute M1 n×m [:, inf] = linf, restore the inf column of M1 n×m ;
[0078] ② Execute M1 n×m [r i]=lr, restore M1 n×m The rth i OK;
[0079] ③Execute dis=dis-M1 n×m [r i ][t i ], corresponding to the fourth step of the recursive process;
[0080] ④Execute robots_ans[r i ].pop(), that is, release robots_ans[r i ] corresponds to the second step of the recursive process;
[0081] ⑤Execute inf.pop(), which releases the last element of inf, corresponding to step ① of the recursive process;
[0082] 5) After the backtracking process is completed, continue the recursive and backtracking steps for the i+1th element in the list until all minimum values have been traversed.
[0083] After the target allocation is completed, the total range and task list of each drone can be obtained. The drones will patrol and execute in sequence according to their respective task lists. Each time a task is completed, the task will be deleted from the list and the range will be updated (that is, the distance of the most recent patrol will be subtracted from the current range).
[0084] When encountering a new target, by obtaining the route and distance from the target to the last target in each drone task list, calculate the drone that minimizes (current range + distance from the target to the last target in each drone task list), add the target to the drone's task list, and update the drone's range (i.e., current range plus distance from the target to the last target in the drone task list).
[0085] Example 2
[0086] The following is a simple example to illustrate the process of this algorithm:
[0087] Assume there are 2 drones with 4 tasks, the distance matrix M1 of each drone to each target n×m As shown in Table 1, the distance matrix M2 between each target m×m As shown in Table 2. The positions of the drone and each target are shown in Table 2. Figure 2 shown.
[0088] Table 1 Distance matrix M1 n×m
[0089]
[0090] Table 2 Distance matrix M2 m×m
[0091]
[0092]
[0093] (1) Find M1 n×m The minimum value is 1, and its row and column are [1,1]. Therefore, target 1 is assigned to drone 1. At this time, the task list of drone 1 is [1], and the task list of drone 2 is [].
[0094] (2) Update matrix M1 n×m , i.e. M1 n×m [1][:]=M2 m×m [1][:]+[1,1,1,1]=[1,3.3,3.5,7], at the same time, M1 n×m The first column of is updated to ∞, thus obtaining M1 n×m =[[∞,3.3,3.5,7],[∞,5,7,3.5]];
[0095] (3) Find M1 n×m The minimum value is 3.3, and its row and column are [1,2]. Therefore, target 2 is assigned to drone 1. At this time, the task list of drone 1 is [1,2], and the task list of drone 2 is [].
[0096] (4) Update matrix M1 n×m , i.e. M1 n×m [1][:]=M2 m×m [2][:]+[3.3,3.3,3.3,3.3]=[5.6,0,5.4,11.3], at the same time, M1 n×m The second column of is updated to ∞, keeping M1 n×m The first column of is ∞, so we get M1 n×m =[[∞,∞,5.4,11.3],[∞,∞,7,3.5]];
[0097] (5) Find M1 n×m The minimum value is 3.5, and its row and column are [2,4]. Therefore, target 4 is assigned to UAV 2. At this time, the task list of UAV 1 is [1,2], and the task list of UAV 2 is [4].
[0098] (6) Update matrix M1 n×m , i.e. M1 n×m [2][:]=M2 m×m [4][:]+[3.5,3.5,3.5,3.5]=[9.5,11.5,12.5,3.5], at the same time, M1n×m The fourth column of is updated to ∞, keeping M1 n×m The first and second columns of M1 are ∞, so we get n×m =[[∞,∞,5.4,∞],[∞,∞,12.5,∞]];
[0099] (7) Find M1 n×m The minimum value is 5.4, and its row and column are [1,3]. Therefore, target 3 is assigned to UAV 1. At this time, the task list of UAV 1 is [1,2,3], and the task list of UAV 2 is [4].
[0100] (8) Update matrix M1 n×m , i.e. M1 n×m [1][:]=M2 m×m [3][:]+[5.4,5.4,5.4,5.4]=[7.9,7.5,5.4,14.4], at the same time, M1 n×m The third column of is updated to ∞, keeping M1 n×m The first, second, and fourth columns of M1 are ∞, so we get n×m =[[∞,∞,∞,∞],[∞,∞,∞,∞]];
[0101] (9) All four targets have been assigned, and the assignment result is that drone 1 performs tasks 1->2->3 in sequence, and drone 2 performs task 4. The execution plan is as follows: Figure 3 shown.
[0102] The present invention adopts a UAV sequence target allocation method based on a greedy algorithm. Compared with the traditional enumeration method and the emerging reinforcement learning algorithm, this algorithm has obvious advantages in accuracy and speed, and can better adapt to the real-time and accuracy requirements in the field of UAVs.
[0103] The above is only a preferred embodiment of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the technical principles of the present invention. These improvements and modifications should also be regarded as the scope of protection of the present invention.
Claims
1. A method for allocating target of UAV sequence based on greedy algorithm, characterized in that: This method describes the UAV target allocation problem as: n UAVs are assigned m targets; Set up two cost matrices M1 n×m and M2 m×m , respectively representing the distance matrix between the drone and the target and the distance matrix between the targets, element m1 ij ∈M1 n×m Represents the distance between drone i and target j, element m2 ij ∈M2 m×m represents the distance between target i and target j; This method adopts the following greedy strategy when sending the target task to each drone: S1, from matrix M1 n×m Select the minimum value m1 kl , assigning target l to UAV k means that target l is in the task sequence of UAV k; S2, since the distance that drone k needs to travel to execute target l is s = M1 n×m [k][l], then drone k will be at the location of target l, so the distance between drone k and other targets is transformed into the distance between target l and other targets, that is, matrix M1 n×m The kth row of the matrix M2 is set equal to m×m The lth row of ; S3: The next time you assign target q to drone k, the distance drone k needs to travel is s+M1 n×m [k][q], so the matrix M1 in step S2 n×m The kth row of is updated to matrix M2 m×m After the first row of M1 n×m Add s to each element of the k-th row; S4, then matrix M1 n×m The lth column of is assigned a value of ∞, indicating that the target has been assigned and will not be selected for assignment next time; S5, repeat steps S1 to S4 m times until all targets are assigned; in, In step S1, when the matrix M1 n×m When there is more than one minimum value, a backtracking algorithm is used to perform a depth-first search, taking into account every possibility to find the global optimal solution. The backtracking algorithm specifically includes the following steps: S11. Define a global variable ans to record the minimum value of the distance and the searched solution, and a global variable project to record the distance and the searched allocation solution corresponding to ans. These two variables will be updated according to each recursive result. S12. Define a recursive function dfs(dis, robots_ans, inf), where the variable dis represents the distance sum of this round of recursion, robots_ans represents the allocation scheme of this round of recursion, and inf represents the target number set that has been allocated in this round of recursion; S13, matrix M1 n×m The two-dimensional indexes corresponding to all the minimum values in the list are recorded in the list list, and the list list is traversed. For the i-th element in the list [r i ,t i ], represents the horizontal and vertical coordinates corresponding to the i-th minimum value, and performs the target allocation recursive operation; S14, after the recursive process, there is a backtracking process, which requires the reverse operation of process S13, that is, restoring the matrix M1 n×m , dis, robots_ans, and inf: S15. After the backtracking process is completed, continue to perform recursion and backtracking steps on the i+1th element in the list until all minimum values have been traversed.
2. The method for allocating target of UAV sequence based on greedy algorithm as claimed in claim 1, characterized in that: A drone can be assigned multiple or zero targets, and a target can only be assigned to one drone.
3. The method for allocating target of UAV sequence based on greedy algorithm as claimed in claim 1, characterized in that: ans is a float variable, project is a two-dimensional list, which has n one-dimensional lists, each of which represents the task sequence that each drone needs to complete.
4. The method for allocating target of UAV sequence based on greedy algorithm as claimed in claim 1, characterized in that: dis is a float variable, robots_ans is a two-dimensional list, which has n one-dimensional lists. Each one-dimensional list represents the task sequence that each drone needs to complete, and inf is a one-dimensional list.
5. The method for allocating target of UAV sequence based on greedy algorithm as claimed in claim 1, characterized in that: The recursive operation in step S13 includes the following steps: S131, will t i Add to inf to indicate target t i has been assigned; S132, will t i Join robots_ans[r i ], indicating the target t i Has been drone i implement; S133, introduce intermediate variable lr=M1 n×m [r i ], temporarily set M1 n×m [r i The value of ] is stored in lr to facilitate the restoration of the backtracking process; S134, dis=dis+M1 n×m [r i ][t i ], the drone will be i Execution target i The distance to be consumed is added to the total distance; S135、M1 n×m [r i ]=M2 m×m [t i ]+M1 n×m [r i ][t i ]; S136, introduce intermediate variable linf = M1 n×m [:,inf], temporarily set M1 n×m The value of [:,inf] is stored in linf to facilitate the restoration of the backtracking process; S137、M1 n×m [:,inf]=∞; S138. Execute the recursive function dfs(dis, robots_ans, inf), that is, enter the recursive process. The recursive exit is M1 n×m The minimum value is ∞, that is, all targets have been allocated; when reaching the recursive exit, compare the sizes of ans and dis. If dis < ans, update ans to dis and project to robots_ans. Otherwise, directly execute return.
6. The method for allocating target of UAV sequence based on greedy algorithm as claimed in claim 5, characterized in that: The S14 specifically includes: S141, execute M1 n×m [:,inf]=linf, restore M1 n×m inf columns; S142, execute M1 n×m [r i ]=lr, restore M1 n×m The rth i OK; S143, execute dis=dis-M1 n×m [r i ][t i ]; S144, execute robots_ans[r i ].pop(), that is, release robots_ans[r i ]'s last element; S145. Execute inf.pop() to release the last element of inf.
7. The method for allocating target of UAV sequence based on greedy algorithm according to any one of claims 1 to 6, characterized in that: The step S5 also includes: after the target allocation is completed, the total range and task list of each drone are obtained, and the drones will patrol and execute in sequence according to their respective task lists. Each time a task is completed, the task will be deleted from the list and the range will be updated, that is, the distance of the most recent patrol will be subtracted from the current range.
8. The method for allocating target of UAV sequence based on greedy algorithm as claimed in claim 7, characterized in that: After S5, it also includes: when encountering a new target, by obtaining the route and distance from the target to the last target in each drone task list, calculating the drone with the smallest estimated range, estimated range = current range + distance from the target to the last target in each drone task list, adding the target to the task list of the drone with the smallest estimated range, and updating the range of the drone, that is, the current range plus the distance from the target to the last target in the drone task list.