Path planning method and device, storage medium and computer equipment
Through improved difficulty adaptive course strategy and weight computer system, the initial solver is trained, which solves the problem of slow solution speed and difficulty in adapting to different difficulty levels in the existing technology, and achieves rapid large-scale path planning Solve and comprehensive performance improvement.
Patent Information
- Application Number
- CN202411057789.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-02
- Publication Date
- 2024-12-27
AI Technical Summary
When the existing path planning algorithm deals with the problem of large-scale travel merchants, the solution speed is slow and difficult to adapt to TSP instances of different difficulties, causing the solver to ignore the processing of simple TSPs during training.
The initial solver is trained using an improved difficulty adaptive course strategy, and the parameters are updated through infinite norms and the weighting computer system is introduced to automatically assign weights to TSP instances of different difficulties, so that the solver can better adapt to various situations.
Improve the comprehensive performance of the solver, can quickly solve large-scale path planning problems, and ensure good solution performance for both simple and complex samples.
Smart Images

Figure CN119204366A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of path planning, and in particular to a path planning method and device, a storage medium, and a computer device. Background Art
[0002] Currently, there are path planning problems in the fields of logistics and scheduling. It can be said that path planning has important application value in real life. Path planning problems can be solved by path optimization, which can be formalized as the Traveling Saleman Problem (TSP), that is, given a set of nodes and the distances between nodes, find the shortest path so that after passing through each node, it can return to the starting point. Since TSP is an NP (Nondeterministic Polynomial time, a decision problem of a specific complexity class) problem, it is extremely difficult to solve for a large set of nodes, so it has attracted the attention of a large number of researchers.
[0003] Existing algorithms have made some progress in solving TSP, but they still face many challenges when dealing with large-scale problems and complex constraints in practical application scenarios. On the one hand, with the large-scale increase in the number of nodes, the speed of solving TSP is greatly affected by the current algorithm; on the other hand, during the training process of the TSP solver, the weight of each TSP is manually set for TSPs of different difficulty as training samples, so that the solver can pay more attention to the more difficult TSPs. The accuracy of setting weights in this way is directly related to manual experience, and it is easy to ignore the processing of simple TSPs. Summary of the invention
[0004] In view of this, the present application provides a path planning method and device, storage medium, and computer equipment, which adopts an improved difficulty adaptive course strategy to train the initial solver to obtain the target solver. On the one hand, this improved strategy updates the parameters of the initial solver through the infinite norm, so that it can adapt to a wider range of problems, while improving the convergence speed, and then quickly solves; on the other hand, the initial solver introduces a weight calculation mechanism during the training process, and the weight calculation mechanism can be used to add weights to each TSP instance in the training sample. In this way, during the training process, samples of different difficulty levels can be automatically assigned different weights without the need to manually set weights. At the same time, weights can be scientifically added to difficult samples and simple samples, so that the solver can better learn and adapt to various situations. In this way, the solver has good solving performance for both simple and complex samples, thereby improving the overall performance of the solver.
[0005] According to one aspect of the present application, a path planning method is provided, comprising:
[0006] Determine a plurality of target locations for path planning, and determine a target matrix according to the plurality of target locations, wherein the target matrix is used to indicate access consumption resources between any two target locations;
[0007] Input the target matrix into a target solver, determine the target path with the minimum total access resource consumption according to the target matrix through the target solver, and output the target path;
[0008] Determining final paths corresponding to the multiple target locations according to the target paths;
[0009] The target solver is trained based on an improved difficulty adaptive curriculum strategy, the improved difficulty adaptive curriculum strategy updates the parameters of the initial solver based on the infinite norm, and adds weights to the training samples of the initial solver through a weight calculation mechanism.
[0010] According to another aspect of the present application, a path planning device is provided, comprising:
[0011] A matrix determination module, used to determine a plurality of target locations to be routed, and determine a target matrix according to the plurality of target locations, wherein the target matrix is used to indicate access consumption resources between any two target locations;
[0012] A path solving module, used for inputting the target matrix into a target solver, determining a target path with the minimum total access resource consumption according to the target matrix through the target solver, and outputting the target path;
[0013] A final path determination module, used to determine the final paths corresponding to the multiple target locations according to the target paths;
[0014] The target solver is trained based on an improved difficulty adaptive curriculum strategy, the improved difficulty adaptive curriculum strategy updates the parameters of the initial solver based on the infinite norm, and adds weights to the training samples of the initial solver through a weight calculation mechanism.
[0015] According to another aspect of the present application, a storage medium is provided, on which a computer program is stored, and when the program is executed by a processor, the above-mentioned path planning method is implemented.
[0016] According to another aspect of the present application, a computer device is provided, including a storage medium, a processor, and a computer program stored on the storage medium and executable on the processor, wherein the processor implements the above-mentioned path planning method when executing the program.
[0017] By means of the above technical solution, a path planning method and device, storage medium, and computer equipment provided by the present application can first determine multiple target locations that need to be planned. Then, a target matrix can be constructed based on these target locations. Specifically, the elements in this target matrix represent the consumed resources (such as distance, time, etc.) required for access between any two target locations. Afterwards, the target matrix can be input into the target solver. Further, the target path given by the target solver can be directly used as the final path corresponding to the above multiple target locations, and each target location can be directly accessed using the final path. The embodiment of the present application adopts an improved difficulty adaptive course strategy to train the initial solver, thereby obtaining a target solver. On the one hand, this improved strategy updates the parameters of the initial solver through an infinite norm, so that it can adapt to a wider range of problems, while improving the convergence speed, and then quickly solving; on the other hand, the initial solver introduces a weight calculation mechanism during the training process, and the weight calculation mechanism can add weights to each TSP instance in the training sample. In this way, during the training process, samples of different difficulty levels can be automatically assigned different weights without the need to manually set the weights. At the same time, weights can be scientifically added to difficult samples and simple samples, allowing the solver to better learn and adapt to various situations. In this way, the solver has good solving performance for both simple and complex samples, thereby improving the overall performance of the solver.
[0018] The above description is only an overview of the technical solution of the present application. In order to more clearly understand the technical means of the present application, it can be implemented in accordance with the contents of the specification. In order to make the above and other purposes, features and advantages of the present application more obvious and easy to understand, the specific implementation methods of the present application are listed below. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
[0020] Figure 1 A schematic diagram of a process flow of a path planning method provided in an embodiment of the present application is shown;
[0021] Figure 2 A schematic diagram showing a flow chart of another path planning method provided in an embodiment of the present application is shown;
[0022] Figure 3 A schematic diagram of the structure of a path planning device provided in an embodiment of the present application is shown;
[0023] Figure 4 A schematic diagram of the device structure of a computer device provided in an embodiment of the present application is shown. DETAILED DESCRIPTION
[0024] The present application will be described in detail below with reference to the accompanying drawings and in combination with embodiments. It should be noted that the embodiments and features in the embodiments of the present application can be combined with each other without conflict.
[0025] In this embodiment, a path planning method is provided, such as Figure 1 As shown, the method includes:
[0026] Step 101, determining a plurality of target locations to be routed, and determining a target matrix according to the plurality of target locations, wherein the target matrix is used to indicate access consumption resources between any two target locations;
[0027] Step 102, inputting the target matrix into a target solver, determining a target path with the minimum total access resource consumption according to the target matrix through the target solver, and outputting the target path;
[0028] Step 103, determining the final paths corresponding to the multiple target locations according to the target paths;
[0029] The target solver is trained based on an improved difficulty adaptive curriculum strategy, the improved difficulty adaptive curriculum strategy updates the parameters of the initial solver based on the infinite norm, and adds weights to the training samples of the initial solver through a weight calculation mechanism.
[0030] A path planning method provided by an embodiment of the present application can be solved as a traveling salesman problem. First, multiple target locations that need to be planned can be determined. These target locations can be any entities that need to be visited, such as cities, stores, service points, etc. Then, a target matrix can be constructed based on these target locations. Specifically, the elements in this target matrix represent the required consumption resources (such as distance, time, etc.) for access between any two target locations. For example, the elements in the mth row and nth column in the target matrix can represent the access consumption resources between target location m and target location n. Among them, when the access consumption resource is distance, then the elements in the mth row and nth column in the target matrix can represent the distance between target location m and target location n; when the access consumption resource is time, then the elements in the mth row and nth column in the target matrix can represent the time spent from target location m to target location n.
[0031] After that, the goal matrix can be input into the goal solver. This goal solver is a pre-trained solver that can handle this type of path planning problem. The goal solver analyzes the goal matrix through complex algorithms (such as dynamic programming, heuristic search, etc.) to find a visit sequence that minimizes the total visit resource consumption when visiting all target locations in this order. After the solution is completed, the target path with the minimum total visit resource consumption is output.
[0032] Furthermore, the target path (ie, the optimal access sequence) provided by the target solver can be directly used as the final path corresponding to the above-mentioned multiple target locations, and each target location can be directly accessed using the final path.
[0033] In addition, the performance of the target solver is crucial, as it directly affects the quality of the final path and the speed of solution. In order to improve the performance of the initial solver, an improved difficulty adaptive curriculum strategy is adopted for training. On the one hand, this improved strategy updates the parameters of the initial solver through the infinite norm (a mathematical measurement method often used in optimization problems), so that it can adapt to a wider range of problems, while improving the convergence speed and thus quickly solving. On the other hand, the initial solver introduces a weight calculation mechanism during the training process, through which weights can be added to each TSP instance in the training sample. In this way, during the training process, samples of different difficulty levels can be automatically assigned different weights without the need to manually set weights. At the same time, weights can be scientifically added to difficult samples and simple samples, so that the solver can better learn and adapt to various situations. In this way, the solver has good solution performance for both simple and complex samples, thereby improving the overall performance of the solver.
[0034] By applying the technical solution of this embodiment, first, multiple target locations that need to be planned can be determined. Then, a target matrix can be constructed based on these target locations. Specifically, the elements in this target matrix represent the consumed resources (such as distance, time, etc.) required for access between any two target locations. Afterwards, the target matrix can be input into the target solver. Further, the target path given by the target solver can be directly used as the final path corresponding to the above-mentioned multiple target locations, and each target location can be directly accessed using the final path. The embodiment of the present application adopts an improved difficulty adaptive course strategy to train the initial solver, thereby obtaining the target solver. On the one hand, this improved strategy updates the parameters of the initial solver through the infinite norm, so that it can adapt to a wider range of problems, while improving the convergence speed, and then quickly solving; on the other hand, the initial solver introduces a weight calculation mechanism during the training process, and the weight calculation mechanism can add weights to each TSP instance in the training sample. In this way, during the training process, samples of different difficulty levels can be automatically assigned different weights without the need to manually set the weights. At the same time, weights can be scientifically added to difficult samples and simple samples, allowing the solver to better learn and adapt to various situations. In this way, the solver has good solving performance for both simple and complex samples, thereby improving the overall performance of the solver.
[0035] Further, as a refinement and extension of the specific implementation of the above embodiment, in order to fully illustrate the specific implementation process of this embodiment, another path planning method is provided, such as Figure 2 As shown, the method includes:
[0036] Step 201, determining a plurality of target locations to be routed, and determining a target matrix according to the plurality of target locations, wherein the target matrix is used to indicate access consumption resources between any two target locations;
[0037] Step 202, inputting the target matrix into a target solver, determining a target path with the minimum total access resource consumption according to the target matrix through the target solver, and outputting the target path, wherein the target solver is trained based on an improved difficulty adaptive course strategy, the improved difficulty adaptive course strategy updates the parameters of the initial solver based on the infinite norm, and adds weights to the training samples of the initial solver through a weight calculation mechanism;
[0038] Step 203, determining the final paths corresponding to the multiple target locations according to the target paths;
[0039] Step 204, in response to the navigation instruction, obtaining electronic map information, and generating navigation information corresponding to the multiple target locations based on the final path and the electronic map information, wherein the navigation information includes weather information and / or clothing index information corresponding to each target location.
[0040] The path planning method in the embodiment of the present application can be applied to the client side or the server side. When applied on the server side, after the server calculates the final path, it can send the final path to the client corresponding to the user to prompt the user that the final path has been generated. In addition, the client interface can also display an icon indicating whether navigation is required. When the user triggers the icon, the client can generate a navigation instruction and respond to the navigation instruction; when applied on the client side, after the client calculates the final path, the client can directly display the final path on the client interface, as well as an icon indicating whether navigation is required. When the user triggers the icon, the client can generate a navigation instruction and respond to the navigation instruction.
[0041] After responding to the navigation instruction, the electronic map information can be further obtained from the server. The electronic map is the basic data support of the navigation system, which contains detailed geographical location information, road network, traffic signs, traffic rules, etc. The electronic map is not only used for path planning, but also for providing real-time information required in the navigation process, such as current location, driving direction, distance, etc. The navigation information is generated based on the final path and the electronic map information, and is used to guide the user on how to drive. In addition to basic driving instructions (such as turning, going straight, changing lanes, etc.), the navigation information can also be combined with additional information services, such as weather information, clothing index information, etc. In this way, the user can determine the local weather conditions in time according to the weather information and clothing index information, so that in the case of cargo transportation, express delivery, etc., the delivery time, delivery protection measures, etc. can be adjusted in advance according to the weather conditions to cope with weather changes. After obtaining the final path, the embodiment of the present application directly asks the user whether it needs to navigate according to the final path, and after the user selects navigation, the navigation information with weather information and / or clothing index information is directly displayed to the user, which can greatly enhance the user's experience.
[0042] In an embodiment of the present application, optionally, before step 202, the method further includes: obtaining a training sample, wherein the training sample includes a plurality of TSP instances, and each TSP instance corresponds to a plurality of differently distributed location sets; determining an actual total access consumption resource corresponding to any TSP instance according to the location distribution corresponding to any TSP instance, and determining a benchmark access consumption resource corresponding to any TSP instance, and determining a target ratio corresponding to any TSP instance according to the actual total access consumption resource and the benchmark access consumption resource; performing a log-likelihood operation on the target ratio, and exponentially processing the target ratio after the operation to obtain an initial weight corresponding to any TSP instance; mapping the initial weight through a hyperbolic tangent function, and dividing the mapping result by a temperature function to obtain a target weight corresponding to any TSP instance; training the initial solver according to each TSP instance and the target weight corresponding to each TSP instance to obtain the target solver.
[0043] In this embodiment, first, a training sample can be obtained. Specifically, a series of TSP instances can be collected as training samples. Each TSP instance represents a problem to be solved, including a series of locations (cities, nodes, etc.) to be visited. The locations included in different TSP instances can be distributed differently in space, that is, different TSP instances can represent different distributions of location sets.
[0044] Secondly, the actual total access consumption resources and the benchmark access consumption resources corresponding to each TSP instance can be determined. For each TSP instance, the actual total access consumption resources can be calculated based on its location distribution. Specifically, all access paths corresponding to these locations can be determined, and the access consumption resources corresponding to each access path can be calculated in turn. The access consumption resources with the smallest access consumption resources are used as the actual total access consumption resources corresponding to the TSP instance. For the benchmark access consumption resources, it can be determined based on the average value of the actual total access consumption resources of all TSP instances in the training sample.
[0045] Next, the target ratio corresponding to each TSP instance can be further calculated based on the actual total access consumption resources and the benchmark access consumption resources of each TSP instance. The difficulty of the current TSP instance can be seen from the target ratio. The larger the target ratio, the greater the difficulty of the current TSP instance.
[0046] The target ratio may then be subjected to a log-likelihood operation and an exponential processing. Specifically, the target ratio may be subjected to a log-likelihood operation and an exponential processing to obtain an initial weight for each TSP instance. The purpose of this step is to transform the target ratio so that it is more suitable for subsequent weight allocation.
[0047] After the exponential processing, the initial weights can be mapped using the hyperbolic tangent function to limit the range of the weights and make their distribution smoother. Then, the mapped result is divided by a temperature function. Here, the reference to the temperature function helps to gradually stabilize the performance of the solver during the training process. For example, by gradually reducing the value of the temperature function, the randomness and instability in the training process can be gradually reduced, so that the solver gradually converges to a better solution.
[0048] Finally, the initial solver is trained using each TSP instance and its corresponding target weight to obtain the final target solver. The size of the target weight can affect the importance of the initial solver to each instance during the training process. The target solver trained in this way can learn how to solve TSP instances with different characteristics more effectively, thereby improving its generalization ability and solving efficiency.
[0049] In one embodiment, optionally, the target weight of the i-th TSP instance may be calculated by the following formula:
[0050]
[0051] Among them, cost(Xi) represents the actual total access consumption resources corresponding to the i-th TSP instance, cost(Xi) * represents the benchmark access consumption resources corresponding to the i-th TSP instance, LL(Θ) represents the log-likelihood operation, exp represents the exponential processing, tanh represents the hyperbolic tangent function, T represents the temperature function, the temperature function is not limited here, and can be a function related to the current CPU (Central Processing Unit) temperature set according to requirements, cost(Xj) represents the actual total access consumption resources corresponding to the j-th TSP instance, j∈[1,n], n is the total number of TSP instances in the training sample.
[0052] When training the initial solver, the embodiment of the present application assigns target weights to different TSP instances according to the difficulty of the TSP instances, further enhancing the adaptability of the target solver to TSP instances of different difficulty levels and improving the performance of solving complex problems.
[0053] In an embodiment of the present application, optionally, the "training the initial solver according to each TSP instance and the target weight corresponding to each TSP instance to obtain the target solver" includes: performing matrix transformation on each TSP instance to obtain a sample matrix corresponding to each TSP instance; inputting any sample matrix into the initial solver, and calculating a first loss value corresponding to any sample matrix through a preset loss function according to the predicted path obtained by the initial solver and the true path corresponding to any sample matrix, wherein the true path is a path with the minimum total access resource consumption corresponding to any sample matrix; obtaining a second loss value corresponding to any sample matrix according to the target weight corresponding to any sample matrix and the first loss value; summing the second loss values corresponding to each TSP instance in the training sample to obtain a target loss value, and comparing the size relationship between the target loss value and the preset loss threshold; when the target loss value is greater than the preset loss threshold, updating the model parameters of the initial solver through the infinite norm, and calculating the target loss value again, until the calculated target loss value is less than or equal to the preset loss threshold, and obtaining the target solver.
[0054] In this embodiment, each TSP instance contains a series of locations and the access consumption resources between them. This information is converted into a matrix form (such as an adjacency matrix) to obtain a sample matrix. Among them, each element in the sample matrix represents the access consumption resources (time, distance, etc.) between two locations. Each sample matrix can be used as a representation of a TSP instance for subsequent solution and training processes.
[0055] The initial solver can be an untrained TSP solving algorithm. The initial solver can accept a TSP instance (i.e., a sample matrix) as input and output a predicted path. This predicted path is calculated by the initial solver according to the current model parameters and may not be the optimal path. In fact, for each sample matrix, there is a corresponding optimal true path, that is, a path with the least total access resource consumption. Then, the difference between the predicted path and the true path is calculated by a preset loss function to obtain a first loss value. Here, the preset loss function can be a function of calculating the path length difference, the number of incorrect city visit sequences, etc., which is not limited here. After that, the first loss value can be weighted according to the importance of each sample matrix (i.e., the target weight) to obtain a second loss value. Assuming that the training sample includes 5 TSP instances, after each TSP instance calculates a first loss value, each first loss value can be multiplied by the corresponding target weight to obtain the second loss value corresponding to the TSP instance. Further, the second loss values of all TSP instances in the training sample can be summed to obtain the target loss value corresponding to the training sample.
[0056] Next, compare the target loss value with the preset loss threshold. If the target loss value is greater than the preset loss threshold, it means that the prediction accuracy of the current initial solver is not enough and further training is required. At this time, the infinite norm can be used to update the model parameters of the initial solver to reduce the difference between the predicted path and the actual path. Repeat the above process until the calculated target loss value is less than or equal to the preset loss threshold. At this point, the solver is trained and the target solver is obtained. The embodiment of the present application enhances the adaptability of the target solver to TSP instances of different difficulties by assigning a target weight to each TSP instance in the training sample; when training the initial solver, the infinite norm is used to update the model parameters of the initial solver, providing a stable learning rate adjustment mechanism, accelerating the convergence speed of the algorithm, and thus significantly improving the solution efficiency and overall performance.
[0057] In an embodiment of the present application, optionally, the "updating the model parameters of the initial solver by the infinite norm" includes: according to the preset loss function, calculating the gradient of the preset loss function for each parameter in the initial solver by the chain rule, and calculating the first-order moment estimate and the infinite norm corresponding to each gradient; according to the infinite norm corresponding to any parameter, updating the accumulated infinite norm estimate, and calculating the parameter update amount corresponding to any parameter according to the target learning rate, the first-order moment estimate corresponding to any parameter and the updated accumulated infinite norm estimate; based on the parameter update amount corresponding to any parameter, updating any parameter.
[0058] In this embodiment, first, the gradient of the preset loss function for each parameter in the initial solver is calculated by the chain rule (also called back propagation), wherein the gradient indicates the direction in which the target loss value changes steepest with the parameter. Further, for the gradient corresponding to each parameter, its first-order moment estimate and infinite norm are calculated. Among them, the first-order moment estimate corresponding to the parameter can be obtained by calculating the historical weighted average of the gradient of the parameter. Specifically, for each parameter, a first-order moment estimate is maintained, which can be obtained by the weighted sum of the current gradient and the first-order moment estimate at the previous moment, and the weight is usually a decay factor less than 1, which is used to control the degree of retention of historical information. The first-order moment estimate helps to smooth the change of the gradient and reduce the oscillation during the optimization process. For the infinite norm (also called the maximum absolute value norm) of each parameter, the infinite norm represents the maximum value of the absolute values of all elements in the vector. During the optimization process, the infinite norm can be used to measure the "size" of the gradient, thereby controlling the step size of the parameter update. For each parameter, a cumulative infinite norm estimator can also be maintained. This estimator is updated based on the infinite norm of the historical gradient. The specific updating method can be the larger value of the infinite norm of the current gradient and the infinite norm estimator accumulated at the previous moment. The accumulated infinite norm estimate can be used to smooth and stabilize the adjustment of the learning rate.
[0059] After that, the update amount of the parameter can be calculated using the target learning rate, the first-order moment estimate corresponding to the parameter, and the updated cumulative infinite norm estimate. Here, the target learning rate can be set in advance based on experience. The update amount can be used to decide how to adjust the value of the parameter during the optimization process. Here, the target learning rate controls the step size of the parameter update, the first-order moment estimate provides a smooth representation of the gradient information, and the cumulative infinite norm estimate is used to adjust the update amount to cope with gradients of different sizes. Specifically, the update amount can be a combination of the learning rate, the first-order moment estimate, and the infinite norm estimate, aiming to balance fast convergence and avoid local minima. Specifically, the update amount can be calculated in the following way: first, multiply the target learning rate by the inverse of the cumulative infinite norm estimate to obtain a scaling factor; then, multiply this scaling factor by the first-order moment estimate to obtain the final parameter update amount. Doing so can reduce the update amount when the gradient is large and increase the update amount when the gradient is small, which helps to maintain the stability of the training process.
[0060] Finally, based on the calculated parameter update amount, each parameter in the initial solver is updated. This process is iterative until the target loss value is less than or equal to the preset loss threshold. Through the above process, the parameters in the initial solver can be gradually optimized so that the final target solver can more accurately solve the optimal path. The embodiment of the present application can automatically adjust the internal parameters of the initial solver through the infinite norm optimization method, which can speed up the convergence speed of the algorithm and improve the solution efficiency.
[0061] In an embodiment of the present application, optionally, before the "obtaining training samples", the method also includes: determining multiple first target spatial ranges, and the first target number of locations contained in each first target spatial range; within each first target spatial range, generating multiple sets of coordinate sets in a uniformly distributed manner, wherein each set of coordinate sets includes coordinates corresponding to the first target number of locations; generating multiple first TSP instances according to the multiple sets of coordinate sets corresponding to each first target spatial range; generating multiple second TSP instances through a difficulty adaptive generator; generating a symmetric TSP instance and a rotated TSP instance corresponding to each second TSP instance through a preset generation algorithm; and using the first TSP instance, the second TSP instance, the symmetric TSP instance and the rotated TSP instance as the training samples.
[0062] In this embodiment, first, multiple first target space ranges and the number of first targets of locations contained in each first target space range are determined. Each first target space range may be an area on a two-dimensional plane, which is used to limit the number of locations of the first target to be generated in the area. For example, if the number of first targets corresponding to the first target space range a is 10, then 10 locations can be generated correspondingly within the first target space range a, and finally these 10 locations can form a TSP instance. It should be noted that different first target ranges can be set to different numbers of first targets. Then, within each first target space range, multiple sets of coordinate sets are generated in a uniformly distributed manner, wherein each set of coordinate sets contains coordinates corresponding to a number of locations equal to the number of first targets, that is, each set of coordinate sets generates a TSP instance. Assuming that m first target space ranges are determined and n sets of coordinate sets are generated for each first target space range, then m×n first TSP instances can be generated correspondingly in the end. In addition, multiple second TSP instances can also be generated by a difficulty adaptive generator. The difficulty adaptive generator can dynamically generate TSP instances with different difficulty levels according to preset difficulty parameters or rules, thereby improving the target solver's ability to handle scenarios of various complexities. For each second TSP instance, a corresponding symmetric TSP instance and a rotated TSP instance are generated through a preset generation algorithm. These transformations can increase the diversity of TSP instances with higher difficulty, that is, second TSP instances, because the symmetric and rotated instances are structurally similar to the original instances but not exactly the same, which helps the training solver to identify and utilize these structural features. Finally, these instances are combined as training samples. Using such training samples allows the initial solver to use more diverse instances in training, significantly improving the robustness and generalization performance of the target solver, and ensuring that the target solver can obtain good solution results in various practical application scenarios.
[0063] In one embodiment, optionally, the symmetric TSP instance of the second TSP instance may include a horizontal TSP instance and a vertical TSP instance, and the horizontal TSP instance may be calculated by the following formula:
[0064]
[0065] Where X is the second TSP instance; (xi, yi) is the coordinate of the i-th location in the second TSP instance, (xix, yiy) is the coordinate of the i-th location in the horizontal TSP instance; X max is the maximum abscissa of all locations in the second TSP instance, X min is the minimum abscissa among all the locations in the second TSP instance, Y maxis the maximum ordinate of all the locations in the second TSP instance, Y min is the minimum ordinate among the ordinates of all the locations in the second TSP instance. Therefore, the horizontal TSP instance corresponding to each second TSP instance can be calculated by the above. For any second TSP instance, assuming that the second TSP instance includes 10 locations, 10 new coordinates can be calculated using the above formula 2, and these 10 new coordinates can constitute the horizontal TSP instance corresponding to the second TSP instance.
[0066] The vertical TSP instance can be calculated by the following formula:
[0067]
[0068] Where X is the second TSP instance; (xi, yi) is the coordinate of the i-th location in the second TSP instance, (xix, yiy) is the coordinate of the i-th location in the vertical TSP instance; X max is the maximum abscissa of all locations in the second TSP instance, X min is the minimum abscissa among all the locations in the second TSP instance, Y max is the maximum ordinate of all the locations in the second TSP instance, Y min is the minimum ordinate among the ordinates of all locations in the second TSP instance. Therefore, the vertical TSP instance corresponding to each second TSP instance can be calculated by the above. For any second TSP instance, assuming that the second TSP instance includes 10 locations, 10 new coordinates can be calculated using the above formula 3, and these 10 new coordinates can form the vertical TSP instance corresponding to the second TSP instance.
[0069] The rotated TSP instance can be calculated by the following formula:
[0070]
[0071] Where X is the second TSP instance; (xi, yi) is the coordinate of the i-th location in the second TSP instance, (xix, yiy) is the coordinate of the i-th location in the rotated TSP instance; X max is the maximum abscissa of all locations in the second TSP instance, X min is the minimum abscissa among all the locations in the second TSP instance, Y max is the maximum ordinate of all the locations in the second TSP instance, Y minis the minimum ordinate among the ordinates of all locations in the second TSP instance. Therefore, the rotated TSP instance corresponding to each second TSP instance can be calculated by the above. For any second TSP instance, assuming that the second TSP instance includes 10 locations, 10 new coordinates can be calculated using the above formula 4, and these 10 new coordinates can constitute the rotated TSP instance corresponding to the second TSP instance.
[0072] In an embodiment of the present application, optionally, the "generating multiple second TSP instances through a difficulty adaptive generator" includes: determining a second target spatial range, and determining multiple clustering parameters corresponding to the second target spatial range, wherein the clustering parameters include the number of clusters and the second target number of included locations; for any clustering parameter, uniformly setting the number of cluster points within the second target spatial range, and randomly matching a cluster point to each location; generating a Gaussian distribution with any cluster point as the mean, and randomly sampling from the Gaussian distribution, using each sampling point as a plurality of locations corresponding to any cluster point, wherein the sum of the locations corresponding to each cluster point is the second target number; and obtaining a second TSP instance corresponding to any cluster parameter according to the locations corresponding to each cluster point.
[0073] In this embodiment, first, a second target space range and a plurality of clustering parameters corresponding to the second target space range are determined. Each clustering parameter may include the number of clusters, the second target number of places contained in the second target space range, the number of clusters specifies the number of clusters to be formed within the second target space range, and the second target number specifies the number of places corresponding to these clusters in total. Here, as with the first target space range, the second target space range may be an area on a two-dimensional plane, which is used to limit the generation of the second target number of places within the area. For each clustering parameter, a cluster number of clustering points is evenly set within the second target space range, and these clustering points represent the central position of the place gathering. Then, a clustering point is randomly matched for each place. For example, if the second target number is 15, then it is pre-set that places 1 to 5 match a clustering point, places 6 to 8 match a clustering point, places 9 to 11 match a clustering point, and places 12 to 15 match a clustering point, so that each place is matched with a clustering point, and the coordinates of subsequent places can be generated based on the corresponding clustering points. For any cluster point, a Gaussian distribution (also called normal distribution) is generated with it as the mean. Among them, the parameter of the mean of the Gaussian distribution is the position of the above-mentioned cluster point. The distribution density and range of the location around the cluster point can be controlled by the Gaussian distribution. Finally, random sampling can be performed from this Gaussian distribution, and a sampling point is obtained each time the sampling is performed. This sampling point will be used as a location corresponding to the cluster point. Repeat this process until a specified number of locations are generated for the cluster point, and the sum of the locations corresponding to all cluster points within each second target space range is equal to the second target number. For example, cluster point A is matched with locations 1 to 5. After generating a Gaussian distribution based on cluster point A, 5 points can be randomly sampled from the Gaussian distribution corresponding to cluster point A, and these 5 points are used as locations 1 to 5. Finally, the location generated corresponding to each set of clustering parameters is used as a second TSP instance, and multiple sets of clustering parameters can generate multiple second TSP instances. The embodiment of the present application greatly increases the complexity and diversity of TSP instances by using a difficulty adaptive generator to generate high-difficulty instances of complex city arrangements.
[0074] It should be noted that for the same clustering parameter, multiple second TSP instances can also be generated by simply repeatedly setting the number of clustering points uniformly within the second target space. Since the locations of the set clustering points are different, the resulting second TSP instances are also different, which can further increase the diversity of the second TSP instances.
[0075] Further, as Figure 1 The specific implementation of the method, the embodiment of the present application provides a path planning device, such as Figure 3 As shown, the device comprises:
[0076] A matrix determination module, used to determine a plurality of target locations to be routed, and determine a target matrix based on the plurality of target locations, wherein the target matrix is used to indicate access consumption resources between any two target locations;
[0077] A path solving module, used for inputting the target matrix into a target solver, determining a target path with the minimum total access resource consumption according to the target matrix through the target solver, and outputting the target path;
[0078] A final path determination module, used to determine the final paths corresponding to the multiple target locations according to the target paths;
[0079] The target solver is trained based on an improved difficulty adaptive curriculum strategy, the improved difficulty adaptive curriculum strategy updates the parameters of the initial solver based on the infinite norm, and adds weights to the training samples of the initial solver through a weight calculation mechanism.
[0080] Optionally, the device further comprises:
[0081] A sample acquisition module, used for acquiring training samples before inputting the target matrix into the target solver, wherein the training samples include a plurality of TSP instances, each TSP instance corresponding to a plurality of differently distributed location sets;
[0082] A target ratio determination module, used to determine the actual total access consumption resources corresponding to any TSP instance according to the location distribution corresponding to any TSP instance, and determine the benchmark access consumption resources corresponding to any TSP instance, and determine the target ratio corresponding to any TSP instance according to the actual total access consumption resources and the benchmark access consumption resources;
[0083] An initial weight determination module, used for performing a log-likelihood operation on the target ratio and performing an exponential processing on the target ratio after the operation to obtain an initial weight corresponding to any TSP instance;
[0084] A target weight determination module, used to map the initial weights by a hyperbolic tangent function, and divide the mapping result by a temperature function to obtain a target weight corresponding to any TSP instance;
[0085] The training module is used to train the initial solver according to each TSP instance and the target weight corresponding to each TSP instance to obtain the target solver.
[0086] Optionally, the training module is used to:
[0087] Perform matrix transformation on each TSP instance to obtain the sample matrix corresponding to each TSP instance;
[0088] Input any sample matrix into the initial solver, and calculate the first loss value corresponding to any sample matrix through a preset loss function according to the predicted path obtained by the initial solver and the real path corresponding to any sample matrix, wherein the real path is the path corresponding to any sample matrix with the minimum total access resource consumption;
[0089] Obtaining a second loss value corresponding to any sample matrix according to the target weight corresponding to any sample matrix and the first loss value;
[0090] Sum the second loss values corresponding to each TSP instance in the training sample to obtain a target loss value, and compare the target loss value with a preset loss threshold;
[0091] When the target loss value is greater than the preset loss threshold, the model parameters of the initial solver are updated through the infinite norm, and the target loss value is calculated again until the calculated target loss value is less than or equal to the preset loss threshold, thereby obtaining the target solver.
[0092] Optionally, the training module is further used to:
[0093] According to the preset loss function, the gradient of the preset loss function for each parameter in the initial solver is calculated by the chain rule, and the first-order moment estimate and the infinite norm corresponding to each gradient are calculated;
[0094] According to the infinite norm corresponding to any parameter, the accumulated infinite norm estimate is updated, and according to the target learning rate, the first-order moment estimate corresponding to any parameter and the updated accumulated infinite norm estimate, the parameter update amount corresponding to any parameter is calculated;
[0095] Based on the parameter update amount corresponding to the any parameter, the any parameter is updated.
[0096] Optionally, the device further includes an instance generation module, wherein the instance generation module is configured to:
[0097] Before obtaining the training samples, a plurality of first target spatial ranges and the number of first targets at locations contained in each first target spatial range are determined;
[0098] In each first target space range, multiple sets of coordinate sets are generated by uniform distribution, wherein each set of coordinate sets includes coordinates corresponding to the first target number of locations;
[0099] Generate multiple first TSP instances according to multiple sets of coordinate sets corresponding to each first target space range;
[0100] Generate multiple second TSP instances through a difficulty adaptive generator;
[0101] Generate a symmetric TSP instance and a rotational TSP instance corresponding to each of the second TSP instances by using a preset generation algorithm;
[0102] The first TSP instance, the second TSP instance, the symmetric TSP instance and the rotated TSP instance are used as the training samples.
[0103] Optionally, the instance generation module is further used to:
[0104] Determine a second target spatial range, and determine a plurality of clustering parameters corresponding to the second target spatial range, wherein the clustering parameters include the number of clusters and the number of second targets in the included locations;
[0105] For any clustering parameter, evenly set the number of clustering points within the second target space, and randomly match a clustering point to each location;
[0106] Generate a Gaussian distribution with any cluster point as the mean, and randomly sample from the Gaussian distribution, and use each sampling point as a plurality of locations corresponding to any cluster point, wherein the sum of the locations corresponding to each cluster point is the second target quantity;
[0107] According to the locations corresponding to the cluster points, a second TSP instance corresponding to any clustering parameter is obtained.
[0108] Optionally, the device further comprises:
[0109] A navigation information generation module is used to obtain electronic map information in response to a navigation instruction after determining the final paths corresponding to the multiple target locations, and to generate navigation information corresponding to the multiple target locations based on the final paths and the electronic map information, wherein the navigation information includes weather information and / or clothing index information corresponding to each target location.
[0110] It should be noted that for other corresponding descriptions of the functional units involved in the path planning device provided in the embodiment of the present application, reference can be made to Figure 1 to Figure 2 The corresponding description in the method will not be repeated here.
[0111] The present application also provides a computer device, which may be a personal computer, a server, a network device, etc. Figure 4As shown, the computer device includes a bus, a processor, a memory and a communication interface, and may also include an input and output interface and a display device. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store location information. The network interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, the steps in each method embodiment are implemented.
[0112] Those skilled in the art will understand that Figure 4 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0113] In one embodiment, a computer-readable storage medium is provided. The computer-readable storage medium may be non-volatile or volatile, and stores a computer program thereon. When the computer program is executed by a processor, the steps in the above-mentioned method embodiments are implemented.
[0114] In one embodiment, a computer program product is provided, including a computer program, which implements the steps in the above method embodiments when executed by a processor.
[0115] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties.
[0116] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in the present application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetoresistive random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, etc., but are not limited to this.
[0117] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0118] The above-described embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.
Claims
1. A path planning method, characterized in that: include: Determine a plurality of target locations for path planning, and determine a target matrix according to the plurality of target locations, wherein the target matrix is used to indicate access consumption resources between any two target locations; Input the target matrix into a target solver, determine the target path with the minimum total access resource consumption according to the target matrix through the target solver, and output the target path; Determining final paths corresponding to the multiple target locations according to the target paths; The target solver is trained based on an improved difficulty adaptive curriculum strategy, the improved difficulty adaptive curriculum strategy updates the parameters of the initial solver based on the infinite norm, and adds weights to the training samples of the initial solver through a weight calculation mechanism.
2. The method according to claim 1, characterized in that Before inputting the target matrix into the target solver, the method further includes: Acquire a training sample, wherein the training sample includes a plurality of TSP instances, each TSP instance corresponding to a plurality of differently distributed location sets; According to the location distribution corresponding to any TSP instance, determine the actual total access consumption resources corresponding to the any TSP instance, and determine the benchmark access consumption resources corresponding to the any TSP instance, and determine the target ratio corresponding to the any TSP instance according to the actual total access consumption resources and the benchmark access consumption resources; Performing a log-likelihood operation on the target ratio and exponentially processing the target ratio after the operation to obtain an initial weight corresponding to any TSP instance; The initial weight is mapped by a hyperbolic tangent function, and the mapping result is divided by a temperature function to obtain a target weight corresponding to any TSP instance; The initial solver is trained according to each TSP instance and the target weight corresponding to each TSP instance to obtain the target solver.
3. The method according to claim 2, characterized in that The initial solver is trained according to each TSP instance and the target weight corresponding to each TSP instance to obtain the target solver, including: Perform matrix transformation on each TSP instance to obtain the sample matrix corresponding to each TSP instance; Input any sample matrix into the initial solver, and calculate the first loss value corresponding to any sample matrix through a preset loss function according to the predicted path obtained by the initial solver and the real path corresponding to any sample matrix, wherein the real path is the path corresponding to any sample matrix with the minimum total access resource consumption; Obtaining a second loss value corresponding to any sample matrix according to the target weight corresponding to any sample matrix and the first loss value; Sum the second loss values corresponding to each TSP instance in the training sample to obtain a target loss value, and compare the target loss value with a preset loss threshold; When the target loss value is greater than the preset loss threshold, the model parameters of the initial solver are updated through the infinite norm, and the target loss value is calculated again until the calculated target loss value is less than or equal to the preset loss threshold, thereby obtaining the target solver.
4. The method according to claim 3, characterized in that: The updating of the model parameters of the initial solver by the infinite norm includes: According to the preset loss function, the gradient of the preset loss function for each parameter in the initial solver is calculated by the chain rule, and the first-order moment estimate and the infinite norm corresponding to each gradient are calculated; According to the infinite norm corresponding to any parameter, the accumulated infinite norm estimate is updated, and according to the target learning rate, the first-order moment estimate corresponding to any parameter and the updated accumulated infinite norm estimate, the parameter update amount corresponding to any parameter is calculated; Based on the parameter update amount corresponding to the any parameter, the any parameter is updated.
5. The method according to any one of claims 2 to 4, characterized in that Before obtaining the training sample, the method further includes: Determine a plurality of first target spatial ranges and the number of first targets of locations included in each first target spatial range; In each first target space range, multiple sets of coordinate sets are generated by uniform distribution, wherein each set of coordinate sets includes coordinates corresponding to the first target number of locations; Generate multiple first TSP instances according to multiple sets of coordinate sets corresponding to each first target space range; Generate multiple second TSP instances through a difficulty adaptive generator; Generate a symmetric TSP instance and a rotational TSP instance corresponding to each of the second TSP instances by using a preset generation algorithm; The first TSP instance, the second TSP instance, the symmetric TSP instance and the rotated TSP instance are used as the training samples.
6. The method according to claim 5, characterized in that The step of generating a plurality of second TSP instances by a difficulty adaptive generator includes: Determine a second target spatial range, and determine a plurality of clustering parameters corresponding to the second target spatial range, wherein the clustering parameters include the number of clusters and the number of second targets in the included locations; For any clustering parameter, evenly set the number of clustering points within the second target space, and randomly match a clustering point to each location; Generate a Gaussian distribution with any cluster point as the mean, and randomly sample from the Gaussian distribution, and use each sampling point as a plurality of locations corresponding to any cluster point, wherein the sum of the locations corresponding to each cluster point is the second target quantity; According to the locations corresponding to the cluster points, a second TSP instance corresponding to any clustering parameter is obtained.
7. The method according to claim 1, characterized in that After determining the final paths corresponding to the multiple target locations, the method further includes: In response to the navigation instruction, electronic map information is acquired, and navigation information corresponding to the multiple target locations is generated based on the final path and the electronic map information, wherein the navigation information includes weather information and / or clothing index information corresponding to each target location.
8. A path planning device, characterized in that: include: A matrix determination module, used to determine a plurality of target locations to be routed, and determine a target matrix according to the plurality of target locations, wherein the target matrix is used to indicate access consumption resources between any two target locations; A path solving module, used for inputting the target matrix into a target solver, determining a target path with the minimum total access resource consumption according to the target matrix through the target solver, and outputting the target path; A final path determination module, used to determine the final paths corresponding to the multiple target locations according to the target paths; The target solver is trained based on an improved difficulty adaptive curriculum strategy, the improved difficulty adaptive curriculum strategy updates the parameters of the initial solver based on the infinite norm, and adds weights to the training samples of the initial solver through a weight calculation mechanism.
9. A storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.
10. A computer device comprising a storage medium, a processor, and a computer program stored in the storage medium and executable on the processor, characterized in that: When the processor executes the computer program, the method according to any one of claims 1 to 7 is implemented.