A delivery route generation method, device, electronic device and storage medium

By selecting the greedy method or dynamic planning method according to the number of distribution points to generate the distribution path, the problem of high computational complexity in large-scale distribution path planning problems is solved, and efficient path generation is achieved.

CN114254979BActive Publication Date: 2025-02-11SHENZHEN E6 TECHNOLOGE CO INC
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202111582647.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-12-22
Publication Date
2025-02-11
Estimated Expiration
2041-12-22

AI Technical Summary

Technical Problem

When solving the problem of large-scale distribution path planning, the existing technology has high computational complexity, resulting in excessive consumption of computing resources and is difficult to meet application needs.

Method used

Select different TSP problem solving methods according to the number of distribution points. If the number is greater than the preset threshold, the greedy method will be used to generate the delivery path; if the number is less than or equal to the threshold, the dynamic programming method will be used.

Benefits of technology

It effectively improves the efficiency of distribution path generation and avoids the problem that dynamic programming method takes too long in large-scale problems.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114254979B_ABST
    Figure CN114254979B_ABST
Patent Text Reader

Abstract

The present invention provides a method for generating a distribution path, including: obtaining a distance matrix corresponding to a plurality of distribution points; the distance matrix includes navigation distances between distribution points; determining whether the number of distribution points is greater than a preset threshold; if the number is greater than the preset threshold, using a greedy method and a distance matrix to generate a target distribution path corresponding to the distribution point; if the number is less than or equal to the preset threshold, using a dynamic programming method to generate a target distribution path; outputting the target distribution path; the dynamic programming method and the greedy method can be used in combination, and the number of distribution points is used as a basis for selecting the above two methods, thereby effectively improving the generation efficiency of the distribution path. The present invention also provides a distribution path generation device, an electronic device, and a storage medium, which have the above beneficial effects.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of logistics distribution, and in particular to a distribution path generation method, device, electronic equipment and storage medium. Background Art

[0002] In the field of logistics, in order to avoid the impact of artificially generated poor distribution routes on logistics transportation, distribution route planning is usually solved by solving the TSP problem (Traveling Salesman Problem). However, the complexity of the TSP problem increases with the increase of distribution points, which leads to excessive consumption of time and space resources by computers to solve the optimal solution of large-scale path planning problems, making it difficult to meet application requirements.

[0003] Therefore, how to efficiently generate a delivery route is a technical problem that technicians in this field need to face. Summary of the invention

[0004] The purpose of the present invention is to provide a distribution path generation method, device, electronic device and storage medium, which can select different TSP problem solving methods according to the number and scale of distribution points, thereby effectively improving the generation efficiency of the distribution path.

[0005] In order to solve the above technical problems, the present invention provides a method for generating a delivery path, comprising:

[0006] Obtaining a distance matrix corresponding to a plurality of delivery points; the distance matrix including navigation distances between the delivery points;

[0007] Determining whether the number of the delivery points is greater than a preset threshold;

[0008] If the quantity is greater than the preset threshold, a target delivery path corresponding to the delivery point is generated using a greedy method and the distance matrix;

[0009] If the quantity is less than or equal to the preset threshold, the target delivery path is generated using a dynamic programming method;

[0010] The target delivery route is output.

[0011] Optionally, the generating the target delivery path corresponding to the delivery point by using the greedy method and the distance matrix includes:

[0012] Adding the delivery point to a delivery point set, and determining whether the delivery point includes a preset starting point;

[0013] If not, then using the distance matrix to find the candidate delivery point with the longest navigation distance, and setting any of the candidate delivery points as the starting point;

[0014] The target delivery path is generated using the greedy method, the delivery point set, the starting point and the distance matrix.

[0015] Optionally, the generating the target delivery path by using the greedy method, the delivery point set, the starting point and the distance matrix includes:

[0016] Creating an initial delivery path, and adding the starting point to the initial delivery path;

[0017] The starting point is set as the current point, and the distance matrix is ​​used to search the set of delivery points for the target delivery point that is closest to the current point and has not appeared in the initial delivery path;

[0018] Adding the target delivery point to the initial delivery path, and updating the current point to the target delivery point;

[0019] Enter the step of using the distance matrix to search the target delivery point in the delivery point set that is closest to the current point and has not appeared in the initial delivery path, until the target delivery point cannot be found in the delivery point set, and then set the initial delivery path to the target delivery path.

[0020] Optionally, before using the greedy method, the delivery point set, the starting point and the distance matrix to generate the target delivery path, the method further includes:

[0021] Determining whether the delivery point includes a preset destination;

[0022] If yes, the destination is moved out of the set of delivery points;

[0023] Correspondingly, when the delivery point includes the destination, the method of generating the target delivery path by using the greedy method, the delivery point set, the starting point and the distance matrix includes:

[0024] The target delivery path is generated by using the greedy method, the set of delivery points that have been removed, the starting point and the distance matrix, and the end point is set as the last delivery point in the target delivery path.

[0025] Optionally, the generating the target delivery path by using a dynamic programming method includes:

[0026] Adding the delivery point to a delivery point set, and determining whether the delivery point includes a preset starting point;

[0027] If not, a virtual delivery point is created, the navigation distance between the virtual delivery point and each of the delivery points is set to zero, and the virtual delivery point is set as the starting point;

[0028] Generate an initial delivery path using the dynamic programming method, the delivery point set, the starting point and the distance matrix; the initial delivery path is a loop starting from the starting point, passing through each of the delivery points once and returning to the starting point;

[0029] Determining whether the initial delivery path includes the virtual delivery point;

[0030] If not, setting the initial delivery path as the target delivery path;

[0031] If so, the virtual delivery point is removed, and the initial delivery path after the removal is set as the target delivery path.

[0032] Optionally, before using the dynamic programming method, the delivery point set, the starting point and the distance matrix to generate an initial delivery path, the method further includes:

[0033] Determining whether the delivery point includes a preset end point and the end point is different from the start point;

[0034] If yes, the destination is removed from the delivery point set, and the other delivery points except the starting point are set as target delivery points, and the navigation distance from the target delivery point to the starting point in the distance matrix is ​​modified to the navigation distance from the target delivery point to the destination;

[0035] Correspondingly, when the delivery point includes the end point and the end point is different from the starting point, the generating of the initial delivery path by using the dynamic programming method, the delivery point set, the starting point and the distance matrix includes:

[0036] Generate the initial delivery path using the dynamic programming method, the set of delivery points that have been removed, the starting point, and the modified distance matrix;

[0037] Correspondingly, when the delivery point includes the end point and the end point is different from the starting point, after setting the initial delivery path that has been removed as the target delivery path, the method further includes:

[0038] The end point is set as the last delivery point of the target delivery path.

[0039] Optionally, before determining whether the number of the delivery points is greater than a preset threshold, the method further includes:

[0040] Determining whether the delivery points only include preset destinations;

[0041] If yes, mark the end point and modify the end point to the starting point;

[0042] Accordingly, the outputting of the target delivery path includes:

[0043] Determining whether the starting point of the target delivery path has been marked;

[0044] If yes, output the target delivery path in reverse order;

[0045] If not, the target delivery route is output normally.

[0046] The present invention also provides a distribution path generation device, comprising:

[0047] An acquisition module, used to acquire a distance matrix corresponding to a plurality of delivery points; the distance matrix includes navigation distances between the delivery points;

[0048] A judgment module, used to judge whether the number of the delivery points is greater than a preset threshold;

[0049] A first generation module, configured to generate a target delivery path corresponding to the delivery point by using a greedy method and the distance matrix if the number is greater than the preset threshold;

[0050] A second generation module, configured to generate the target delivery path using a dynamic programming method if the quantity is less than or equal to the preset threshold;

[0051] The output module is used to output the target delivery path.

[0052] The present invention also provides an electronic device, comprising:

[0053] Memory for storing computer programs;

[0054] A processor is used to implement the delivery route generation method as described above when executing the computer program.

[0055] The present invention also provides a storage medium, in which computer executable instructions are stored. When the computer executable instructions are loaded and executed by a processor, the distribution path generation method as described above is implemented.

[0056] The present invention provides a distribution path generation method, comprising: obtaining a distance matrix corresponding to a plurality of distribution points; the distance matrix includes navigation distances between the distribution points; judging whether the number of the distribution points is greater than a preset threshold; if the number is greater than the preset threshold, generating a target distribution path corresponding to the distribution points by using a greedy method and the distance matrix; if the number is less than or equal to the preset threshold, generating the target distribution path by using a dynamic programming method; and outputting the target distribution path.

[0057] It can be seen that after receiving the distance matrix corresponding to the distribution point, the present invention will first determine whether the number of distribution points is greater than the preset threshold. When the number is less than the preset threshold, the present invention will use the dynamic programming method to generate the target distribution path for the distribution point. This is because the dynamic programming method can generate the optimal route in the small-scale path generation problem; and when the number is greater than the preset threshold, the present invention will use the greedy method to generate the target distribution path for the distribution point. This is because although the dynamic programming method can generate the optimal route, its calculation complexity increases with the increase in the number of distribution points. In the face of more distribution points, the time consumption of the dynamic programming method will be greatly increased, and the greedy method can greatly improve the generation efficiency of the target distribution path while ensuring a certain path optimization range, and can avoid the problem of the dynamic programming method taking too long. In short, the present invention uses a mixed use of the dynamic programming method and the greedy method, and uses the number of distribution points as the basis for selecting the above two methods, which can effectively improve the generation efficiency of the distribution path. The present invention also provides a distribution path generation device, an electronic device and a storage medium, which have the above beneficial effects. BRIEF DESCRIPTION OF THE DRAWINGS

[0058] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying creative work.

[0059] Figure 1 A flow chart of a method for generating a delivery route provided by an embodiment of the present invention;

[0060] Figure 2 This is a structural block diagram of a delivery route generation device provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0061] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0062] In the field of logistics, in order to avoid the impact of artificially generated poor distribution routes on logistics transportation, distribution route planning is usually solved by solving the TSP problem (Traveling Salesman Problem). However, the complexity of the TSP problem increases with the increase of distribution points, which leads to excessive consumption of time and space resources by computers to solve the optimal solution of large-scale path planning problems, making it difficult to meet application requirements. In view of this, the present invention provides a distribution route generation method, which can select different TSP problem solving methods according to the number of distribution points, thereby effectively improving the generation efficiency of distribution routes. Please refer to Figure 1 , Figure 1 A flow chart of a method for generating a delivery path provided by an embodiment of the present invention, the method may include:

[0063] S101. Obtain a distance matrix corresponding to a plurality of delivery points; the distance matrix includes navigation distances between the delivery points.

[0064] In an embodiment of the present invention, the distance matrix is ​​a matrix form of the distances between the distribution points. It should be pointed out that the distances in the distance matrix carry direction information. For example, for distribution point A and distribution point B, the matrix records both the distance from distribution point A to distribution point B and the distance from distribution point B to distribution point A. It is understandable that the distances between distribution points are usually calculated based on map data, that is, the navigation distance. It should be noted that due to factors such as traffic control, the navigation distances between two distribution points may be different. For example, the navigation distance from distribution point A to distribution point B is X, but the navigation distance from distribution point B to distribution point A is Y, and X and Y are not the same. It should be noted that the embodiment of the present invention does not limit the specific number of distribution points, and can be set according to actual application requirements.

[0065] Furthermore, in order to improve the convenience of use, the user can specify a starting point or an end point in the distribution point, and of course, can also specify both the end point and the starting point. The embodiment of the present invention does not limit the specific method of designation, for example, a distribution point set as the starting point or the end point is specially marked, as long as the starting point and the end point can be distinguished from other distribution points. Furthermore, the starting point and the end point can also be the same distribution point, which can be set according to actual application requirements.

[0066] S102: Determine whether the number of delivery points is greater than a preset threshold.

[0067] In the embodiment of the present invention, the preset threshold is used to distinguish between small-scale path solving situations and large-scale path solving situations, and then a suitable method can be selected for each situation to generate the target path. It should be noted that the embodiment of the present invention does not limit the specific value of the preset threshold, and it can be set according to actual application requirements. In one possible situation, the preset threshold can be 20.

[0068] S103: If the quantity is greater than a preset threshold, a target delivery path corresponding to the delivery point is generated using a greedy method and a distance matrix.

[0069] The greedy method generally refers to a greedy algorithm, which usually divides the problem to be solved into multiple sub-problems, generates local optimal solutions to the sub-problems, and then integrates all local optimal solutions to obtain the solution to the problem to be solved. In large-scale path generation problems, the greedy method can generate a better solution to the problem to be solved at a faster speed, thereby improving the path generation efficiency on the basis of meeting application requirements. It should be noted that the embodiments of the present invention do not limit the specific process of using the greedy method to generate the target delivery path, and reference may be made to the relevant technologies of the greedy method.

[0070] S104: If the quantity is less than or equal to the preset threshold, a target delivery path is generated using a dynamic programming method.

[0071] Dynamic Programming (DP) is a process for optimizing the decision-making process. In path planning, dynamic programming can generally generate an overall optimal solution, which is of great significance for shortening the path length in small-scale path problems. However, since the dynamic programming method needs to optimize the target delivery path from an overall perspective, its complexity is easily affected by the number of delivery points. Compared with the greedy method, it is less efficient in large-scale path generation problems. Therefore, the present invention only uses the dynamic programming method in small-scale path generation scenarios. It should be noted that the embodiments of the present invention do not limit the specific process of generating the target delivery path by the dynamic programming method, and reference may be made to the relevant technologies of the dynamic programming method.

[0072] S105: Output the target delivery route.

[0073] It is understandable that the target delivery path is a sequence of delivery points that have been sorted. The embodiment of the present invention does not limit the output form of the target delivery path, for example, it can be directly output in the form of a sequence, of course, it can also be output in the form of a path in the map data, which can be set according to actual application requirements.

[0074] Furthermore, if the user only specifies the end point in the delivery point but does not specify the starting point, in order to facilitate the generation of the target delivery path, the preset end point can be changed to the starting point and specially marked; after the target delivery path is generated, it can be determined whether the starting point of the path has passed the special mark. If so, the target delivery path will be output in reverse order.

[0075] In a possible case, before determining whether the number of delivery points is greater than a preset threshold, the following steps may also be included:

[0076] Step 11: Determine whether the delivery point only includes the preset destination; if so, proceed to step 12; if not, proceed to step S102;

[0077] Step 12: Mark the end point and change it to the starting point.

[0078] Accordingly, the output target delivery path may include:

[0079] Step 21: Determine whether the starting point of the target delivery path has been marked; if so, proceed to step 22; if not, proceed to step 23;

[0080] Step 22: Output the target delivery path in reverse order;

[0081] Step 23: Output the target delivery path normally.

[0082] It should be noted that the embodiments of the present invention do not limit the specific form of the above-mentioned marks, which can be set according to actual application requirements.

[0083] Based on the above embodiment, after receiving the distance matrix corresponding to the distribution point, the present invention will first determine whether the number of distribution points is greater than the preset threshold. When the number is less than the preset threshold, the present invention will use the dynamic programming method to generate the target distribution path for the distribution point. This is because the dynamic programming method can generate the optimal route in the small-scale path generation problem; and when the number is greater than the preset threshold, the present invention will use the greedy method to generate the target distribution path for the distribution point. This is because although the dynamic programming method can generate the optimal route, its calculation complexity increases with the increase in the number of distribution points. In the face of more distribution points, the time consumption of the dynamic programming method will be greatly increased, and the greedy method can greatly improve the generation efficiency of the target distribution path while ensuring a certain path optimization range, and can avoid the problem of the dynamic programming method taking too long. In short, the present invention uses a combination of the dynamic programming method and the greedy method, and uses the number of distribution points as the basis for selecting the above two methods, which can effectively improve the generation efficiency of the distribution path.

[0084] Based on the above embodiment, the specific process of generating the target path using the greedy method is described below. In one possible case, generating the target delivery path corresponding to the delivery point using the greedy method and the distance matrix may include:

[0085] S201, adding the delivery point to the delivery point set, and determining whether the delivery point contains a preset starting point; if so, proceeding to step S203; if not, proceeding to step S202.

[0086] S202: Use the distance matrix to find the candidate delivery point with the longest navigation distance, and set any candidate delivery point as the starting point.

[0087] It should be emphasized that the distance here is the distance between the delivery points, that is, the meaning of step S202 is to set the two delivery points farthest apart as candidate delivery points, and set any candidate delivery point as the starting point.

[0088] S203, generating a target delivery path using a greedy method, a delivery point set, a starting point and a distance matrix.

[0089] Specifically, the target delivery path is generated using the greedy method, the delivery point set, the starting point and the distance matrix, which may include:

[0090] Step 31: Create an initial delivery path and add the starting point to the initial delivery path.

[0091] Step 32: Set the starting point as the current point, and use the distance matrix to find the target delivery point in the delivery point set that is closest to the current point and has not appeared in the initial delivery path.

[0092] This step is the main content of the greedy method, that is, the delivery point closest to the current point and not added to the initial delivery path is set as the target delivery point. Obviously, in the process of path generation, this method only considers the local optimal result and does not perform overall optimization, so it can generate the target path at a faster speed.

[0093] Step 33: Add the target delivery point to the initial delivery path and update the current point as the target delivery point.

[0094] Step 34: Enter the step of using the distance matrix to search for a target delivery point in the delivery point set that is closest to the current point and has not appeared in the initial delivery path, until the target delivery point cannot be found in the delivery point set, and then set the initial delivery path as the target delivery path.

[0095] Furthermore, in actual applications, the user may also specify a destination in the delivery point. In this case, the destination can be removed from the delivery point set, that is, the destination does not participate in the path generation process of steps 31 to 34; and after determining that the target delivery point cannot be found in the delivery point set, the destination is added to the end of the path, and the target delivery path that can reach the user-specified destination can be obtained.

[0096] In one possible case, before using the greedy method, the delivery point set, the starting point and the distance matrix to generate the target delivery path, it may also include:

[0097] Step 41: Determine whether the delivery point includes the preset destination; if so, proceed to step 42; if not, proceed to step S203;

[0098] Step 42: Move the destination out of the distribution point set;

[0099] Correspondingly, when the delivery point includes the destination, the target delivery path is generated using the greedy method, the delivery point set, the starting point and the distance matrix, which can include:

[0100] Step 51: Use the greedy method, the removed delivery point set, the starting point and the distance matrix to generate the target delivery path, and set the end point as the last delivery point in the target delivery path.

[0101] Based on the above embodiments, the present invention can use the greedy method to improve the path generation efficiency in the large-scale path generation problem, and thus can greatly improve the generation efficiency of the target delivery path while ensuring a certain path optimization range.

[0102] Based on the above embodiment, the specific process of generating the target path by dynamic programming is introduced below. In one possible case, generating the target delivery path by dynamic programming may include:

[0103] S301, adding the delivery point to the delivery point set, and determining whether the delivery point contains a preset starting point; if so, proceeding to step S303; if not, proceeding to step S302.

[0104] S302: Create a virtual distribution point, set the navigation distance between the virtual distribution point and each distribution point to zero, and set the virtual distribution point as the starting point.

[0105] It should be noted that when using the dynamic programming method to solve the TSP problem, it is necessary to specify a starting point to start the solution process. Therefore, the embodiment of the present invention needs to set a separate starting point to start the subsequent solution process when the user does not specify a starting point; in addition, in order to generate the shortest path, when the user does not specify a starting point, it is necessary to try each distribution point as a starting point. However, if each distribution point is repeatedly set as a starting point and the calculation process of the dynamic programming method is repeatedly executed, a large amount of computing resources will be easily wasted. Therefore, in the embodiment of the present invention, a virtual distribution point is set, and the distance between this point and each distribution point is set to zero, that is, it can be used as the logical starting point of the target distribution path, thereby avoiding the computing resources wasted by repeatedly setting the starting point and repeatedly executing the calculation process of the dynamic programming method, thereby improving the computing efficiency.

[0106] S303, generating an initial delivery path using a dynamic programming method, a delivery point set, a starting point, and a distance matrix; the initial delivery path is a loop starting from the starting point, passing through each delivery point once and returning to the starting point;

[0107] Specifically, the derivation function of the dynamic programming method can be expressed using the following formula:

[0108]

[0109] Where s is the starting point; V′ is the set of distribution points. At the beginning, V′=V-{i}; d(i,V′) represents the shortest path from point i through each point in V′ once and only once to the starting point s. When V′ is an empty set and i is not the starting point s, the value of d(i,V′) is c is , that is, the distance from point i to point s directly; and when V′ is not an empty set, the value of d(i,V′) is Where k is a point belonging to the set V′, and min represents the minimum function.

[0110] S304, determine whether the initial delivery path contains a virtual delivery point; if so, proceed to step S306; if not, proceed to step S305.

[0111] S305, setting the initial delivery path to the target delivery path;

[0112] S306: Remove the virtual delivery point, and set the initial delivery path that has been removed as the target delivery path.

[0113] After the initial delivery path is generated, the virtual delivery points in the path can be deleted to obtain the desired target delivery path.

[0114] Of course, in actual situations, the user may also specify an end point. If the end point is not the same as the starting point, the process of solving the TSP problem by dynamic programming needs to be adjusted. Specifically, in the TSP problem, the required path is a loop starting from the starting point and returning to the starting point, that is, the last section of the path is from the distribution point back to the starting point. Therefore, the embodiment of the present invention needs to modify the distance from each distribution point to the starting point in the distance matrix to the distance from each distribution point to the end point; in addition, in order to avoid the end point from participating in the generation process of step S303, thereby causing path generation errors, it is also necessary to remove the end point from the distribution point set, and set the end point as the last point of the path after the initial distribution path generation is completed.

[0115] In one possible scenario, before generating an initial delivery path using a dynamic programming method, a delivery point set, a starting point, and a distance matrix, the following is further included:

[0116] Step 61: Determine whether the delivery point contains a preset destination and the destination is different from the starting point; if so, proceed to step 62; if not, proceed to step S303.

[0117] Step 62: The destination is removed from the distribution point set, and the other distribution points except the starting point are set as target distribution points, and the navigation distance from the target distribution point to the starting point is modified to the navigation distance from the target distribution point to the destination in the distance matrix;

[0118] It should be noted that step 62 only modifies the distance from the target delivery point to the starting point, but does not change the distance from the starting point to each target delivery point.

[0119] Accordingly, when the delivery point includes the end point and the end point is different from the starting point, the initial delivery path is generated using the dynamic programming method, the delivery point set, the starting point and the distance matrix, which may include:

[0120] Step 71: Generate an initial delivery path using a dynamic programming method, a set of delivery points to be removed, a starting point, and a modified distance matrix;

[0121] Accordingly, when the delivery point includes an end point and the end point is different from the start point, after setting the initial delivery path that has been removed as the target delivery path, it also includes:

[0122] Step 81: Set the destination as the last delivery point of the target delivery path.

[0123] Based on the above embodiments, the present invention can use dynamic programming to effectively reduce the length of the target delivery path in the small-scale path generation problem, thereby effectively improving the accuracy of the target delivery path in the small-scale path generation problem.

[0124] The following is an introduction to the delivery path generation device, electronic device and storage medium provided in the embodiments of the present invention. The delivery path generation device, electronic device and storage medium described below and the delivery path generation method described above can be referenced to each other.

[0125] Please refer to Figure 2 , Figure 2 A structural block diagram of a distribution path generation device provided by an embodiment of the present invention, the device may include:

[0126] Acquisition module 201, used to acquire a distance matrix corresponding to a plurality of delivery points; the distance matrix includes navigation distances between the delivery points;

[0127] A determination module 202 is used to determine whether the number of delivery points is greater than a preset threshold;

[0128] The first generation module 203 is used to generate a target delivery path corresponding to the delivery point using a greedy method and a distance matrix if the quantity is greater than a preset threshold;

[0129] The second generation module 204 is used to generate a target delivery path using a dynamic programming method if the quantity is less than or equal to a preset threshold;

[0130] The output module 205 is used to output the target delivery path.

[0131] Optionally, the first generating module 203 may include:

[0132] The first adding submodule is used to add the delivery point to the delivery point set and determine whether the delivery point contains the preset starting point;

[0133] The first starting point setting submodule is used for, if not, using the distance matrix to find the candidate delivery point with the longest navigation distance, and setting any candidate delivery point as the starting point;

[0134] The first generation submodule is used to generate a target delivery path using a greedy method, a delivery point set, a starting point and a distance matrix.

[0135] Optionally, the first generation submodule may include:

[0136] A creation unit is used to create an initial delivery path and add the starting point to the initial delivery path;

[0137] A search unit is used to set the starting point as the current point, and use the distance matrix to search for a target delivery point in the delivery point set that is closest to the current point and has not appeared in the initial delivery path;

[0138] An updating unit, used to add the target delivery point to the initial delivery path and update the current point to the target delivery point;

[0139] The setting unit is used to enter the step of using the distance matrix to find the target delivery point in the delivery point set that is closest to the current point and has not appeared in the initial delivery path, until the target delivery point cannot be found in the delivery point set, and the initial delivery path is set as the target delivery path.

[0140] Optionally, the first generating module 203 may include

[0141] The first judgment submodule is used to judge whether the delivery point contains a preset destination;

[0142] A removal submodule is used to remove the destination from the distribution point set if yes;

[0143] Correspondingly, when the delivery points include the end point, the first generation submodule can also be used to generate the target delivery path using the greedy method, the set of removed delivery points, the starting point and the distance matrix, and set the end point as the last delivery point in the target delivery path.

[0144] Optionally, the second generating module 204 may include:

[0145] The second adding submodule is used to add the delivery point to the delivery point set and determine whether the delivery point contains the preset starting point;

[0146] A second starting point creation submodule is used for, if not, creating a virtual distribution point, setting the navigation distance between the virtual distribution point and each distribution point to zero, and setting the virtual distribution point as the starting point;

[0147] The second generation submodule is used to generate an initial delivery path using a dynamic programming method, a delivery point set, a starting point and a distance matrix; the initial delivery path is a loop starting from the starting point, passing through each delivery point once and returning to the starting point;

[0148] The second judgment submodule is used to judge whether the initial delivery path contains a virtual delivery point;

[0149] A first setting submodule, for setting the initial delivery path as the target delivery path if no;

[0150] The second setting submodule is used for removing the virtual delivery point and setting the initial delivery path after the removal as the target delivery path;

[0151] Optionally, the second generating module 204 may further include:

[0152] The third judgment submodule is used to judge whether the delivery point contains a preset end point and the end point is different from the starting point;

[0153] A modification submodule is used for, if yes, removing the destination from the distribution point set, setting the other distribution points except the starting point as the target distribution points, and modifying the navigation distance from the target distribution point to the starting point to the navigation distance from the target distribution point to the destination in the distance matrix;

[0154] Correspondingly, when the delivery point includes the end point and the end point is different from the starting point, the second generation submodule can also be used to generate the initial delivery path using the dynamic programming method, the set of delivery points removed, the starting point and the modified distance matrix;

[0155] Accordingly, the second generating module 204 may further include:

[0156] The third setting submodule is used to set the end point as the last delivery point of the target delivery path.

[0157] Optionally, the device may further include:

[0158] A judgment module, used to judge whether the delivery point only includes the preset end point;

[0159] A marking module is used for marking the end point and changing the end point to the starting point;

[0160] Accordingly, the output module 205 includes:

[0161] The fourth judgment submodule is used to judge whether the starting point of the target delivery path has been marked;

[0162] A first output submodule, for outputting the target delivery path in reverse order if yes;

[0163] The second output submodule is used to output the target delivery path normally if no.

[0164] An embodiment of the present invention further provides an electronic device, including:

[0165] Memory for storing computer programs;

[0166] A processor is used to implement the steps of the delivery route generation method as described above when executing a computer program.

[0167] Since the embodiments of the electronic device part correspond to the embodiments of the delivery path generation method part, please refer to the description of the embodiments of the delivery path generation method part for the embodiments of the electronic device part, which will not be repeated here.

[0168] An embodiment of the present invention further provides a storage medium having a computer program stored thereon. When the computer program is executed by a processor, the steps of the delivery route generation method of any of the above embodiments are implemented.

[0169] Since the embodiments of the storage medium part correspond to the embodiments of the delivery path generation method part, the embodiments of the storage medium part refer to the description of the embodiments of the delivery path generation method part, which will not be repeated here.

[0170] The various embodiments in the specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referred to each other. For the device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part.

[0171] Professionals may further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in the above description according to function. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians may use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention.

[0172] The steps of the method or algorithm described in conjunction with the embodiments disclosed herein may be implemented directly using hardware, a software module executed by a processor, or a combination of the two. The software module may be placed in a random access memory (RAM), a memory, a read-only memory (ROM), an electrically programmable ROM, an electrically erasable programmable ROM, a register, a hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.

[0173] The above is a detailed introduction to a distribution path generation method, device, electronic device and storage medium provided by the present invention. This article uses specific examples to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core idea. It should be pointed out that for ordinary technicians in this technical field, without departing from the principle of the present invention, several improvements and modifications can be made to the present invention, and these improvements and modifications also fall within the scope of protection of the claims of the present invention.

Claims

1. A method for generating a delivery route, characterized in that: include: Get the distance matrix corresponding to multiple delivery points; The distance matrix includes navigation distances between the delivery points, and the navigation distances carry direction information; Determining whether the number of the delivery points is greater than a preset threshold; If the quantity is greater than the preset threshold, a target delivery path corresponding to the delivery point is generated using a greedy method and the distance matrix; If the quantity is less than or equal to the preset threshold, the target delivery path is generated using a dynamic programming method; Outputting the target delivery path; The method of generating the target delivery path by using the dynamic programming method includes: Adding the delivery point to a delivery point set, and determining whether the delivery point includes a preset starting point; If not, a virtual delivery point is created, the navigation distance between the virtual delivery point and each of the delivery points is set to zero, and the virtual delivery point is set as the starting point; Generate an initial delivery path using the dynamic programming method, the delivery point set, the starting point and the distance matrix; the initial delivery path is a loop starting from the starting point, passing through each of the delivery points once and returning to the starting point; Determining whether the initial delivery path includes the virtual delivery point; If not, setting the initial delivery path as the target delivery path; If yes, the virtual delivery point is removed, and the initial delivery path after the removal is set as the target delivery path; Before using the dynamic programming method, the delivery point set, the starting point and the distance matrix to generate an initial delivery path, the method further includes: Determining whether the delivery point includes a preset end point and the end point is different from the start point; If yes, the destination is removed from the delivery point set, and the other delivery points except the starting point are set as target delivery points, and the navigation distance from the target delivery point to the starting point in the distance matrix is ​​modified to the navigation distance from the target delivery point to the destination; Correspondingly, when the delivery point includes the end point and the end point is different from the starting point, the generating of the initial delivery path by using the dynamic programming method, the delivery point set, the starting point and the distance matrix includes: Generate the initial delivery path using the dynamic programming method, the set of delivery points that have been removed, the starting point, and the modified distance matrix; Correspondingly, when the delivery point includes the end point and the end point is different from the starting point, after setting the initial delivery path that has been removed as the target delivery path, the method further includes: The end point is set as the last delivery point of the target delivery path.

2. The method for generating a delivery route according to claim 1, characterized in that: The method of using the greedy method and the distance matrix to generate the target delivery path corresponding to the delivery point includes: Adding the delivery point to a delivery point set, and determining whether the delivery point includes a preset starting point; If not, then using the distance matrix to find the candidate delivery point with the longest navigation distance, and setting any of the candidate delivery points as the starting point; The target delivery path is generated using the greedy method, the delivery point set, the starting point and the distance matrix.

3. The method for generating a delivery route according to claim 2, characterized in that: The method of generating the target delivery path by using the greedy method, the delivery point set, the starting point and the distance matrix includes: Creating an initial delivery path, and adding the starting point to the initial delivery path; The starting point is set as the current point, and the distance matrix is ​​used to search the set of delivery points for the target delivery point that is closest to the current point and has not appeared in the initial delivery path; Adding the target delivery point to the initial delivery path, and updating the current point to the target delivery point; Enter the step of using the distance matrix to search the target delivery point in the delivery point set that is closest to the current point and has not appeared in the initial delivery path, until the target delivery point cannot be found in the delivery point set, and then set the initial delivery path to the target delivery path.

4. The method for generating a delivery route according to claim 2, wherein: Before using the greedy method, the delivery point set, the starting point and the distance matrix to generate the target delivery path, the method further includes: Determining whether the delivery point includes a preset destination; If yes, the destination is moved out of the set of delivery points; Correspondingly, when the delivery point includes the destination, the method of generating the target delivery path by using the greedy method, the delivery point set, the starting point and the distance matrix includes: The target delivery path is generated by using the greedy method, the set of delivery points that have been removed, the starting point and the distance matrix, and the end point is set as the last delivery point in the target delivery path.

5. The method for generating a delivery route according to any one of claims 1 to 4, characterized in that: Before determining whether the number of the delivery points is greater than a preset threshold, the method further includes: Determining whether the delivery points only include preset destinations; If yes, mark the end point and modify the end point to the starting point; Accordingly, the outputting of the target delivery path includes: Determining whether the starting point of the target delivery path has been marked; If yes, output the target delivery path in reverse order; If not, the target delivery route is output normally.

6. A delivery route generation device, characterized in that: include: An acquisition module is used to obtain distance matrices corresponding to multiple delivery points; The distance matrix contains navigation distances between the delivery points; A judgment module, used to judge whether the number of the delivery points is greater than a preset threshold; A first generation module, configured to generate a target delivery path corresponding to the delivery point by using a greedy method and the distance matrix if the number is greater than the preset threshold; A second generation module, configured to generate the target delivery path using a dynamic programming method if the quantity is less than or equal to the preset threshold; An output module, used for outputting the target delivery path; The second generating module comprises: A second adding submodule, used for adding the delivery point to the delivery point set, and determining whether the delivery point includes a preset starting point; A second starting point creation submodule is used for, if not, creating a virtual distribution point, setting the navigation distance between the virtual distribution point and each of the distribution points to zero, and setting the virtual distribution point as the starting point; The second generation submodule is used to generate an initial delivery path using the dynamic programming method, the delivery point set, the starting point and the distance matrix; the initial delivery path is a loop starting from the starting point, passing through each of the delivery points once and returning to the starting point; A second judgment submodule is used to judge whether the initial delivery path contains the virtual delivery point; A first setting submodule, for setting the initial delivery path as the target delivery path if no; A second setting submodule is used for removing the virtual delivery point and setting the initial delivery path after the removal as the target delivery path; A third judgment submodule is used to judge whether the delivery point includes a preset end point and the end point is different from the starting point; a modification submodule, for, if yes, removing the destination from the set of delivery points, setting the other delivery points except the starting point as target delivery points, and modifying the navigation distance from the target delivery point to the starting point in the distance matrix to the navigation distance from the target delivery point to the destination; Correspondingly, when the delivery point includes the end point and the end point is different from the starting point, the second generating submodule is further used to: Generate the initial delivery path using the dynamic programming method, the set of delivery points that have been removed, the starting point, and the modified distance matrix; Correspondingly, the second generation module further includes: The third setting submodule is used to set the end point as the last delivery point of the target delivery path.

7. An electronic device, characterized in that: include: Memory for storing computer programs; A processor, configured to implement the delivery route generation method as described in any one of claims 1 to 5 when executing the computer program.

8. A storage medium, characterized in that: The storage medium stores computer executable instructions, and when the computer executable instructions are loaded and executed by the processor, the delivery route generation method according to any one of claims 1 to 5 is implemented.

Citation Information

Patent Citations

  • Path determination method and device

    CN109615133A