Path optimization method and device, electronic equipment and storage medium

By obtaining the optimal path and optimization operators, calculating the new path and determining its length, and optimizing the path using the first and second operators, the problem of long path lengths in the Traveling Salesman Problem is solved, achieving a reduction in path length and a smoothing effect.

CN113962453BActive Publication Date: 2026-01-27GREE ELECTRIC APPLIANCE INC OF ZHUHAI +1
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202111211264.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-10-18
Publication Date
2026-01-27
Estimated Expiration
2041-10-18

AI Technical Summary

Technical Problem

Existing technologies do not provide an efficient method for finding approximate solutions to the Traveling Salesman Problem (TSP), resulting in long path lengths.

Method used

The path optimization method is adopted. By obtaining the optimal path and optimization operator, a new path is calculated, and it is determined whether the length of the new path is less than the length of the optimal path. The new path is then determined as the new optimal path. The first and second operators are used to optimize the path, and the path length is reduced by reversing the sub-paths and adjusting the order of the sub-paths, respectively.

Benefits of technology

It achieves the effects of reducing path length and smoothing the path, improving the efficiency and accuracy of path optimization.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113962453B_ABST
    Figure CN113962453B_ABST
Patent Text Reader

Abstract

The application relates to a path optimization method and device, electronic equipment and a storage medium. The method comprises the following steps: acquiring an optimal path and an optimization operator; the optimal path comprises a path for reaching a starting point from a plurality of locations in sequence, and each location is passed through only once; a new path of the plurality of locations is calculated according to the optimization operator and the optimal path; it is judged whether the path length of the new path is smaller than the path length of the optimal path; when the path length of the new path is smaller than the path length of the optimal path, the new path is determined as a new optimal path. The scheme provided by the application can reduce the path length.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of path optimization technology, and in particular to a path optimization method, apparatus, electronic device and storage medium. Background Technology

[0002] The Traveling Salesman Problem (TSP) is defined as follows: Given a set of cities and the distance between each pair of cities, find the shortest loop that visits each city once and returns to the starting city. The TSP is a difficult problem in combinatorial optimization, and it is very important in operations research and theoretical computer science. Traversing its solution space results in high time complexity, and to date, no efficient solution has been found; only efficient approximate solutions can be sought. The TSP is also a class of problems widely present in real life; many problems can be abstracted into the TSP problem, or its variations, such as flight route planning, courier delivery, and circuit board printing. Therefore, finding simple and efficient approximate solutions to the TSP has high research and practical application value.

[0003] However, there is currently no efficient method for solving the Traveling Salesman Problem that results in a shorter path length. Summary of the Invention

[0004] This application provides a path optimization method, apparatus, electronic device, and storage medium to solve the technical problem of long paths.

[0005] Firstly, this application provides a path optimization method, the method comprising:

[0006] Obtain the optimal path and the optimization operator; wherein the optimal path includes a path that returns to the starting point by passing through multiple locations in sequence, and each location is visited only once;

[0007] Calculate a new path for the multiple locations based on the optimization operator and the optimal path;

[0008] Determine whether the path length of the new path is less than the path length of the optimal path;

[0009] When the path length of the new path is less than the path length of the optimal path, the new path is determined as the new optimal path.

[0010] In one embodiment, when the optimization operator is a first operator, calculating a new path for the plurality of locations based on the optimization operator and the optimal path includes:

[0011] Randomly select the first sub-path from the optimal path; wherein, the optimal path includes multiple sub-paths;

[0012] Reverse the order of the locations in the first sub-path to obtain the second sub-path;

[0013] The first sub-path is replaced with the second sub-path to obtain a new path for the plurality of locations.

[0014] In one embodiment, when the optimization operator is a second operator, calculating a new path for the plurality of locations based on the optimization operator and the optimal path includes:

[0015] The optimal path is randomly divided into multiple sub-paths in sequence;

[0016] The order of the multiple sub-paths is adjusted to generate a new path for the multiple locations.

[0017] In one embodiment, obtaining the optimization operator includes:

[0018] Choose either the first operator or the second operator as the optimization operator.

[0019] In one embodiment, the method for calculating the path length includes:

[0020] The path length is calculated using the following formula (1):

[0021]

[0022] Where tar(S) represents the path length, and dis(C1,C n ) represents the Euclidean distance between the 1st and Nth locations in the path, dis(C i C i+1 ) represents the Euclidean distance between the i-th location and the (i+1)-th location in the path.

[0023] In one embodiment, obtaining the optimal path includes:

[0024] When a new optimal path exists, obtain the new optimal path;

[0025] If no new optimal path exists, a random path is generated and used as the optimal path.

[0026] In one embodiment, after determining whether the path length of the new path is less than the path length of the optimal path, the method further includes:

[0027] When the path length of the new path is greater than or equal to the path length of the optimal path, the number of times the optimal path remains unchanged is obtained; wherein, each time a new path is generated, when it is determined that the path length of the new path is greater than or equal to the path length of the current optimal path, the number of times the current optimal path remains unchanged is incremented by 1.

[0028] The optimization process ends when the number of times the optimal path remains unchanged is greater than or equal to the number of times it was first changed.

[0029] When the number of times the optimal path remains unchanged is less than the first number of times, the optimization operator is obtained again; a new path is calculated for the multiple locations based on the optimization operator and the optimal path; it is determined whether the path length of the new path is less than the path length of the optimal path; when the path length of the new path is less than the path length of the optimal path, the new path is determined as the new optimal path.

[0030] Secondly, this application provides a path optimization apparatus, the path optimization apparatus comprising:

[0031] The first acquisition module is used to acquire the optimal path and the optimization operator; wherein, the optimal path includes a path that returns to the starting point by passing through multiple locations in sequence, and each location is visited only once;

[0032] The calculation module is used to calculate a new path for the multiple locations based on the optimization operator and the optimal path;

[0033] The judgment module is used to determine whether the path length of the new path is less than the path length of the optimal path;

[0034] The determination module is used to determine the new path as the new optimal path when the path length of the new path is less than the path length of the optimal path.

[0035] Thirdly, this application provides an electronic device, including a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other through the communication bus;

[0036] Memory, used to store computer programs;

[0037] When a processor executes a program stored in memory, it implements the steps of the method described in any embodiment of the first aspect.

[0038] Fourthly, this application provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the method as described in any embodiment of the first aspect.

[0039] The technical solutions provided in this application have the following advantages compared with the prior art:

[0040] The method provided in this application embodiment can reduce the path length. Attached Figure Description

[0041] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with the invention and, together with the description, serve to explain the principles of the invention.

[0042] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, for those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0043] Figure 1 A flowchart illustrating a path optimization method provided in an embodiment of this application;

[0044] Figure 2 This is a schematic diagram illustrating the path optimization process in an application embodiment of this application;

[0045] Figure 3 This is a schematic diagram of the previous path optimized for the application embodiments of this application;

[0046] Figure 4 This is a schematic diagram of the optimized path in the application embodiments of this application;

[0047] Figure 5 This is a schematic diagram of the path optimization results in Example 1 of this application;

[0048] Figure 6 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation

[0049] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.

[0050] Figure 1 This is a flowchart illustrating a path optimization method provided in an embodiment of this application. Figure 1 As shown, the method includes:

[0051] Step 101: Obtain the optimal path and the optimization operator; wherein, the optimal path includes a path that returns to the starting point by passing through multiple locations in sequence, and each location is visited only once;

[0052] Step 102: Calculate new paths for the multiple locations based on the optimization operator and the optimal path;

[0053] Step 103: Determine whether the path length of the new path is less than the path length of the optimal path;

[0054] Step 104: When the path length of the new path is less than the path length of the optimal path, the new path is determined as the new optimal path.

[0055] Specifically, the obtained optimal path contains multiple locations arranged in a certain order. For example, the multiple locations include six locations: A, B, C, D, E, and F. The order of these six locations could be ABECFD; the corresponding path could be S1: [ABECFD]. As another example, the order of these six locations could also be ABFECD. The corresponding path could be S2: [ABFECD].

[0056] In practical applications, this application achieves global optimization by finding local optima. Based on this, to improve the processing efficiency and accuracy of this application, two operators can be preset: a first operator and a second operator, which are used to optimize the path.

[0057] Specifically, in one embodiment, the acquisition of the optimization operator includes:

[0058] Choose either the preset first operator or the preset second operator as the optimized operator.

[0059] In practical applications, the above optimization process can be repeated multiple times, meaning the steps in the above embodiments can be repeated multiple times to achieve further optimization effects. During each optimization, any one of the preset first and second operators can be selected as the optimization operator. For example, if the optimization process is repeated three times, the first operator can be used for the first optimization; the second operator can be used for the second optimization; and the first operator can be used again for the third optimization. The selected optimization operator for each optimization can be either the first or second operator, i.e., it can be random, to enhance the optimization effect.

[0060] Further, in one embodiment, when the optimization operator is a first operator, calculating a new path for the plurality of locations based on the optimization operator and the optimal path includes:

[0061] Randomly select the first sub-path from the optimal path; wherein, the optimal path includes multiple sub-paths;

[0062] Reverse the order of the locations in the first sub-path to obtain the second sub-path;

[0063] The first sub-path is replaced with the second sub-path to obtain a new path for the plurality of locations.

[0064] Specifically, when selecting the first sub-path from the optimal path, the number of locations N in the optimal path can be obtained, and two numbers A and B can be randomly selected between 1 and N. The first sub-path can then be selected from the optimal path based on A and B. For example, when A is less than B, the path between the Ath location and the (B-1)th location in the optimal path can be selected as the first sub-path; when A is greater than B, the path between the Bth location and the (A-1)th location in the optimal path can be selected as the first sub-path.

[0065] In practical applications, to obtain the second sub-path, one can use the location order of the first sub-path and reverse that order to obtain the second sub-path. For example, if the optimal path is S:[ABCDEF] and the first sub-path is [BCD], then reversing the location order in the first sub-path will yield the second sub-path [DCB].

[0066] Furthermore, the following example illustrates the complete process of calculating new paths for multiple locations using the first operator and the optimal path:

[0067] The optimal path is S:[ABCDEF]. Randomly select two numbers, 5 and 2, from 1 to 6, sort them in ascending order and assign a=2 and b=5. Extract the 2nd to 4th numbers from S as the first sub-path [BCD]. Reverse the sub-path to obtain the second sub-path [DCB]. Replace the first sub-path in the original optimal path with the second sub-path and return the new path [AD CB EF].

[0068] It should be noted that this embodiment uses the first operator for optimization, which can not only reduce the path length, but also correct the intersecting parts in the path.

[0069] Further, in one embodiment, when the optimization operator is a second operator, calculating a new path for the plurality of locations based on the optimization operator and the optimal path includes:

[0070] The optimal path is randomly divided into multiple sub-paths in sequence;

[0071] The order of the multiple sub-paths is adjusted to generate a new path for the multiple locations.

[0072] In practical applications, the optimal path can be randomly divided into four sub-paths, and the order of these four sub-paths can be adjusted to generate new paths to the multiple locations. For example, the optimal path can be randomly divided into a third, fourth, fifth, and sixth sub-path in sequence; and new paths to the multiple locations can be generated using these sub-paths in the order of the third, fourth, fifth, and sixth sub-paths.

[0073] Specifically, when dividing the optimal path into third, fourth, fifth, and sixth sub-paths, we can obtain the number of locations N in the optimal path, and randomly select three numbers a, b, and c between 1 and N. Based on a, b, and c, the optimal path is then divided into the third, fourth, fifth, and sixth sub-paths. For example, if we randomly select three numbers between 0 and N and arrange them in ascending order as a, b, and c, then 0 to a-1 can be considered the third sub-path, a to b-1 the fourth sub-path, b to c-1 the fifth sub-path, and c to N the sixth sub-path.

[0074] Furthermore, an example will be provided below to illustrate the complete process of calculating new paths for multiple locations using the second operator and the optimal path:

[0075] The optimal path is S:[ABECFD]. Randomly select 3 numbers from 1 to 6, sort them in ascending order and assign them the values: a=3, b=5, c=6. Based on a=3, b=5, c=6, the optimal path can be divided into four sub-paths: [AB][EC][F][D]. Rearrange them into [AB][F][EC][D] and return the new path [ABFECD].

[0076] It should be noted that this embodiment uses the second operator for optimization, which can not only reduce the path length, but also reduce the degree of path concavity and achieve path smoothing.

[0077] Furthermore, in one embodiment, the method for calculating the path length includes:

[0078] The path length is calculated using the following formula (1):

[0079]

[0080] Where tar(S) represents the path length, and dis(C1,C n ) represents the Euclidean distance between the 1st and Nth locations in the path, dis(C i C i+1 ) represents the Euclidean distance between the i-th location and the (i+1)-th location in the path.

[0081] Here, the total number of locations in the path is n, and the path length can be calculated using the formula above.

[0082] Furthermore, in one embodiment, obtaining the optimal path to multiple locations includes:

[0083] When a new optimal path exists, obtain the new optimal path;

[0084] If no new optimal path exists, a random path is generated and used as the optimal path.

[0085] In practical applications, when performing route optimization for the first time, a randomly generated route can be used as the optimal route. For example, given six locations A, B, C, D, E, and F, a route S: [ABFECD] can be randomly generated based on these six locations, and this route can be used as the optimal route before optimization. Once at least one route optimization has been performed, the optimal route from the most recent optimization can be used as the optimal route before the current optimization.

[0086] Furthermore, in one embodiment, after determining whether the path length of the new path is less than the path length of the optimal path, the method further includes:

[0087] When the path length of the new path is greater than or equal to the path length of the optimal path, the number of times the optimal path remains unchanged is obtained; wherein, each time a new path is generated, when it is determined that the path length of the new path is greater than or equal to the path length of the current optimal path, the number of times the current optimal path remains unchanged is incremented by 1.

[0088] The optimization process ends when the number of times the optimal path remains unchanged is greater than or equal to the number of times it was first changed.

[0089] When the number of times the optimal path remains unchanged is less than the first number of times, the optimization operator is obtained again; a new path is calculated for the multiple locations based on the optimization operator and the optimal path; it is determined whether the path length of the new path is less than the path length of the optimal path; when the path length of the new path is less than the path length of the optimal path, the new path is determined as the new optimal path.

[0090] In practical applications, the initial number can be set according to the actual situation. For example, the initial number can be set to the square of the number of locations. That is, when the number of locations is 6, the initial number can be set to 6 multiplied by 6, which equals 36.

[0091] Specifically, when repeating the path optimization process multiple times, it's possible to record whether the optimal path changes in each optimization step. If the optimal path remains unchanged during the current optimization, increment the count from the previous iteration by 1. Comparing this count with the initial count determines whether to terminate the repeated optimization process. The process ends when the count is greater than or equal to the initial count. If the count is less than the initial count, the path optimization process is repeated.

[0092] The path optimization method provided in this invention obtains optimal paths for multiple locations and an optimization operator; calculates new paths for the multiple locations based on the optimization operator and the optimal paths; determines whether the path length of the new path is less than the path length of the optimal path; and when the path length of the new path is less than the path length of the optimal path, determines the new path as the new optimal path. The solution provided by this invention can reduce path length and achieve path smoothing.

[0093] The present invention will be further described in detail below with reference to application examples.

[0094] This embodiment proposes a method for solving the Traveling Salesman Problem (TSP) based on Monte Carlo local search. Building upon Monte Carlo local search, a path smoothing operator is proposed, which, combined with the traditional 2-opt operator, can reduce the overall path length of the TSP.

[0095] Before describing the specific process of this embodiment, the symbols used in the description will be explained:

[0096] (1) The city can be represented as city name:(horizontal coordinate, vertical coordinate), for example A:(2,1).

[0097] (2) The path can be represented as path code: [city name 1 city name 2 city name 3...]. For example, path 1 can be represented as S1: [ABECFD] and path 2 can be represented as S2: [ABFECD].

[0098] (3) A TSP problem can be represented as: Problem Name: [City 1 City 2 City 3]. For example, a TSP problem can be represented as TSP1: [A:(2,1),B:(3,4),C:(1,2),D:(2,2),E:(1,3),F:(2,3)]

[0099] Specifically, see Figure 2 The specific process of this embodiment is as follows:

[0100] S1: Read and store all city names, x-coordinates, y-coordinates, and record the number of cities (size).

[0101] S2: Calculate the Euclidean distance between any two cities, storing the results in a matrix. The formula for calculating the distance between cities C1:(x1,y2) and C2:(x2,y2) is as follows:

[0102] S3: Randomly arrange the cities to obtain a random sequence as the optimal solution (initial solution).

[0103] S4: Randomly select one of the following two operators as the operation operator op.

[0104] Operator 1: 2-opt

[0105] Operator 1 content: Randomly select two numbers from 1 to size and sort them in ascending order. The two numbers are denoted as a and b. Extract the city from city a to city b-1 in the input path as a sub-path, flip the sub-path, replace the atomic path, and return the new path.

[0106] Example of operator 1: For TSP1, its size = 6, input path S: [ABCDEF], assume that two numbers 5 and 2 are selected from 1 to 6, sorted in ascending order and assigned a = 2 and b = 5, extract the 2nd to 4th numbers in S as sub-paths [BCD], flip the sub-paths to [DCB], replace the atomic path, and return the new path [ADCBEF].

[0107] Operator 2: Smooth Path

[0108] Operator 2: Randomly select three numbers from 1 to size and sort them in ascending order, denoted as a, b, and c. Extract 0 to a-1 as sub-path 1, a to b-1 as sub-path 2, b to c-1 as sub-path 3, and c to size as sub-path 4. Then, reassemble the sub-paths into a new path and return in the order of sub-path 1, sub-path 3, sub-path 2, and sub-path 4.

[0109] Operator 2 example: For TSP1, its size = 6, input path S1: [ABECFD], assuming random numbers a = 3, b = 5, c = 6, divide S1 into four sub-paths: [AB][EC][F][D], rearrange them into [AB][F][EC][D], and return the new path [ABFECD].

[0110] S5: Take best as input, execute operator op, and get the new path as new.

[0111] S6: Calculate the path lengths of best and new respectively. The path length calculation formula for S[C1 C2...Cn] can be the formula (1) in the above embodiment, and determine whether the path length of new is less than the path length of best.

[0112] S7: If it is less than, replace best with new.

[0113] If it is not less than, then no replacement is needed.

[0114] S8: Determine if the number of times best remains unchanged exceeds size*size.

[0115] S9: If it exceeds the limit, return best.

[0116] If no more are exceeded, return to S4.

[0117] 10: End the algorithm.

[0118] According to the isoperimetric theorem, when the areas are equal, the perimeter of a circle is the shortest. Therefore, in this embodiment, operator 2 smooths the path and reduces the degree of path concavity during the TSP local search, thus reducing the path length. In other words, operator 2 in this embodiment can smooth concave paths during the TSP local search process.

[0119] Specifically, the example image of the path before smoothing is as follows: Figure 3 As shown in the example image, the smoothed path is as follows: Figure 4 As shown.

[0120] Furthermore, to illustrate the effect of this embodiment in reducing path length, the shortest paths to 34 provincial capital cities in China are listed below, such as... Figure 5 As shown.

[0121] Using the 34 provincial capitals of China as the TSP (Tracking Path Spreading) problem, this paper uses Python to program the algorithm without and with the smooth path operator 100 times each, and obtains the average optimized path length as follows:

[0122] algorithm Average path length No smooth path added 163.8174 Add smooth path 160.6902

[0123] As can be seen from the above, the Monte Carlo local search performance is significantly improved by adding the smooth path operator.

[0124] China's 34 provincial capitals: [Beijing:(116.46,39.92), Tianjin:(117.20,39.13), Shanghai:(121.48,31.22), Chongqing:(106.54,29.59), Lhasa:(91.11,29.97), Urumqi:(87.68,43.77), Yinchuan:(106.27,38.47), Hohhot:(111.65,40.82), Nanning] :(108.33,22.84), Harbin:(126.63,45.75), Changchun:(125.35,43.88), Shenyang:(123.38,41.80), Shijiazhuang:(114.48,38.03), Taiyuan:(112.53,37.87), Xining:(101.74,36.56), Jinan:(117.00,36.65), Zhengzhou:(113.60,36.84), 4.76), Nanjing:(118.78,32.04), Hefei:(117.27,31.86), Hangzhou:(120.19,30.26), Fuzhou:(119.30,26.08), Nanchang:(115.89,28.68), Changsha:(113.00,28.21), Wuhan:(114.31,30.52), Guangzhou:(113.23,23.16), Taipei:(12 1.50, 25.05), Haikou: (110.35, 20.02), Lanzhou: (103.73, 36.03), Xi'an: (108.95, 34.27), Chengdu: (104.06, 30.67), Guiyang: (106.71, 26.57), Kunming: (102.73, 25.04), Hong Kong: (114.10, 22.20), Macau: (113.33, 22.13)).

[0125] To implement the method of the embodiments of the present invention, the embodiments of the present invention also provide a path optimization device, which includes:

[0126] The acquisition module is used to acquire the optimal path and the optimization operator; wherein, the optimal path includes a path that returns to the starting point by passing through multiple locations in sequence, and each location is visited only once;

[0127] The calculation module is used to calculate a new path for the multiple locations based on the optimization operator and the optimal path;

[0128] The judgment module is used to determine whether the path length of the new path is less than the path length of the optimal path;

[0129] The determination module is used to determine the new path as the new optimal path when the path length of the new path is less than the path length of the optimal path.

[0130] It should be noted that the above-described apparatus, when executed, is only illustrated by the division of the program modules described above. In actual applications, the processing can be assigned to different program modules as needed, that is, the internal structure of the terminal can be divided into different program modules to complete all or part of the processing described above. Furthermore, the apparatus and method embodiments described above belong to the same concept, and their specific implementation processes are detailed in the method embodiments, and will not be repeated here.

[0131] like Figure 6 As shown in the figure, this application provides an electronic device, including a processor 111, a communication interface 112, a memory 113, and a communication bus 114, wherein the processor 111, the communication interface 112, and the memory 113 communicate with each other through the communication bus 114.

[0132] Memory 113 is used to store computer programs;

[0133] In one embodiment of this application, when the processor 111 executes the program stored in the memory 113, it implements the steps of the method provided in any of the foregoing method embodiments.

[0134] This application also provides a computer-readable storage medium storing a computer program thereon, which, when executed by a processor, implements the steps of the method provided in any of the foregoing method embodiments.

[0135] It should be noted that, in this document, relational terms such as "first" and "second" are used merely to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.

[0136] The above description is merely a specific embodiment of the present invention, enabling those skilled in the art to understand or implement the invention. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the invention. Therefore, the present invention is not to be limited to the embodiments shown herein, but is to be accorded the widest scope consistent with the principles and novel features claimed herein.

Claims

1. A path optimization method, characterized in that, The method includes: Obtain the optimal path and the optimization operator; wherein the optimal path includes a path that returns to the starting point by passing through multiple locations in sequence, and each location is visited only once; Calculate a new path for the multiple locations based on the optimization operator and the optimal path; Determine whether the path length of the new path is less than the path length of the optimal path; When the path length of the new path is less than the path length of the optimal path, the new path is determined as the new optimal path; When the optimization operator is the first operator, calculating the new path for the multiple locations based on the optimization operator and the optimal path includes: Randomly select the first sub-path from the optimal path, wherein the optimal path includes multiple sub-paths; Reverse the order of the locations in the first sub-path to obtain the second sub-path; By replacing the first sub-path with the second sub-path, a new path is obtained for the plurality of locations; When the optimization operator is the second operator, calculating the new path for the multiple locations based on the optimization operator and the optimal path includes: The optimal path is randomly divided into multiple sub-paths in sequence; Adjust the order of the multiple sub-paths to generate a new path for the multiple locations; The optimization operator includes: The optimization process is repeated multiple times. During each optimization, any one of the first operator and the second operator is selected as the optimization operator.

2. The method according to claim 1, characterized in that, The method for calculating the path length includes: The path length is calculated using the following formula (1): Where tar(S) represents the path length, and dis(C1,C n ) represents the Euclidean distance between the 1st and Nth locations in the path, dis(C i C i+1 ) represents the Euclidean distance between the i-th location and the (i+1)-th location in the path.

3. The method according to claim 1, characterized in that, The process of obtaining the optimal path includes: When a new optimal path exists, obtain the new optimal path; If no new optimal path exists, a random path is generated and used as the optimal path.

4. The method according to claim 1, characterized in that, After determining whether the path length of the new path is less than the path length of the optimal path, the method further includes: When the path length of the new path is greater than or equal to the path length of the optimal path, the number of times the optimal path remains unchanged is obtained; wherein, each time a new path is generated, when it is determined that the path length of the new path is greater than or equal to the path length of the current optimal path, the number of times the current optimal path remains unchanged is incremented by 1. The optimization process ends when the number of times the optimal path remains unchanged is greater than or equal to the number of times it was first changed. When the number of times the optimal path remains unchanged is less than the first number of times, the optimization operator is obtained again; a new path is calculated for the multiple locations based on the optimization operator and the optimal path; it is determined whether the path length of the new path is less than the path length of the optimal path; when the path length of the new path is less than the path length of the optimal path, the new path is determined as the new optimal path.

5. A path optimization device, characterized in that, The path optimization device includes: The acquisition module is used to acquire the optimal path and the optimization operator; wherein, the optimal path includes a path that returns to the starting point by passing through multiple locations in sequence, and each location is visited only once; The calculation module is used to calculate a new path for the multiple locations based on the optimization operator and the optimal path; The judgment module is used to determine whether the path length of the new path is less than the path length of the optimal path; The determining module is used to determine the new path as the new optimal path when the path length of the new path is less than the path length of the optimal path; When the optimization operator is the first operator, calculating the new path for the multiple locations based on the optimization operator and the optimal path includes: Randomly select the first sub-path from the optimal path, wherein the optimal path includes multiple sub-paths; Reverse the order of the locations in the first sub-path to obtain the second sub-path; By replacing the first sub-path with the second sub-path, a new path is obtained for the plurality of locations; When the optimization operator is the second operator, calculating the new path for the multiple locations based on the optimization operator and the optimal path includes: The optimal path is randomly divided into multiple sub-paths in sequence; Adjust the order of the multiple sub-paths to generate a new path for the multiple locations; The optimization operator includes: The optimization process is repeated multiple times. During each optimization, any one of the first operator and the second operator is selected as the optimization operator.

6. An electronic device, characterized in that, It includes a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other through the communication bus; Memory, used to store computer programs; A processor, when executing a program stored in memory, implements the steps of the method according to any one of claims 1 to 4.

7. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method as described in any one of claims 1 to 4.

Citation Information

Patent Citations

  • Unmanned ship path planning method and system based on greedy mechanism particle swarm algorithm

    CN111338350A

  • Distribution robot path planning system

    CN113485364A