A CTSP solving method and system based on convolution-enhanced proxy attention mechanism
By constructing a neural policy network and reinforcement learning algorithm based on the convolution-enhanced agent attention mechanism and combining it with the traditional optimizer, the low efficiency problem of the existing TSP solver is solved, high-quality path solutions are efficiently generated, and the reasoning efficiency and scalability of the model are improved.
Patent Information
- Application Number
- CN202510833906.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-20
- Publication Date
- 2025-09-16
- Estimated Expiration
- 2045-06-20
AI Technical Summary
Existing mainstream neural TSP solvers are inefficient when processing large-scale graph instances, making it difficult to meet the requirements for efficiency and scalability in practical applications. They also lack effective collaboration between neural networks and traditional optimization paradigms, making it difficult to achieve a good balance between solution efficiency and solution quality.
A neural policy network based on the convolution-enhanced agent attention mechanism is constructed, combined with reinforcement learning algorithm training to generate a preliminary optimal path plan, which is then fine-tuned through a traditional optimizer to form the final optimal path plan.
It significantly improves the reasoning efficiency and scalability of the model in large-scale graph instances, achieves efficient generation of high-quality solutions, and achieves a good balance between computational efficiency and solution quality.
Smart Images

Figure CN120354086B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of data processing technology, and in particular to a CTSP solving method and system based on a convolution-enhanced proxy attention mechanism. Background Art
[0002] The Traveling Salesman Problem (TSP), a representative problem in combinatorial optimization, has long played an important role in practical scenarios such as transportation scheduling, logistics routing optimization, and power system layout. Its extended form, the Multi-Travelling Salesman Problem (MTSP), further introduces a collaborative path planning mechanism among multiple traveling salesmen to accommodate the needs of complex task allocation and multi-agent systems. With the development of intelligent manufacturing, intelligent urban transportation, and intelligent logistics systems, the demand for heterogeneous path planning capabilities is increasing, giving rise to more complex models and algorithmic mechanisms.
[0003] In recent years, Neural Combinatorial Optimization (NCO), as an emerging strategy, has gradually become an effective tool for solving such problems. The autoregressive (AR) paradigm, represented by pointer networks and attention-based models (such as the Attention Model (AM),) has demonstrated strong modeling capabilities in tasks such as the TSP and the Vehicle Routing Problem (VRP). Further research, such as the POMO strategy and the non-autoregressive (NAR) heatmap method, has achieved significant results in improving solution space representation, enhancing diversity, and improving inference efficiency.
[0004] However, existing mainstream neural TSP solvers are inefficient when processing large-scale graph instances, making them difficult to meet the efficiency and scalability requirements of practical applications. Furthermore, existing methods often rely on either a single neural network or a traditional optimization paradigm, lacking effective synergy between the two and struggling to strike a good balance between efficiency and solution quality. Summary of the Invention
[0005] In view of the above shortcomings of the existing technology, the purpose of the embodiments of the present invention is to provide a CTSP solving method based on a convolution-enhanced proxy attention mechanism. This method can address the low efficiency of existing mainstream neural TSP solvers when processing large-scale graph instances, making it difficult to meet the requirements of efficiency and scalability in practical applications. At the same time, existing methods generally rely on a single neural network or traditional optimization paradigm, lacking effective synergy between the two, and it is difficult to achieve a good balance between solution efficiency and solution quality.
[0006] In a first aspect of an embodiment of the present invention, a method for solving CTSP based on a convolution-enhanced proxy attention mechanism is proposed, comprising:
[0007] S1: Obtain city data and salesperson data;
[0008] S2: Based on the city data and the salesperson data, construct a complete graph for describing the CTSP problem instance;
[0009] S3: Based on the complete graph, a constrained Markov decision process model is constructed, and the path generation process of the CTSP problem is modeled as a step-by-step decision mechanism by defining the state space, action space, transition dynamics and reward function of the constrained Markov decision process model;
[0010] S4: constructing a neural policy network based on convolutional enhancement and agent attention mechanism, wherein the neural policy network is used to solve the constrained Markov decision process model;
[0011] S5: Using a reinforcement learning algorithm to train the neural policy network based on convolutional enhancement and agent attention mechanism;
[0012] S6: Generate a preliminary optimal path plan through the trained neural policy network based on convolutional enhancement and agent attention mechanism;
[0013] S7: Input the optimal path solution into a traditional optimizer for fine optimization to obtain a final optimal path solution.
[0014] A second aspect of an embodiment of the present invention provides a CTSP solving system based on a convolution-enhanced proxy attention mechanism, comprising: a processor and a memory;
[0015] The memory stores a program or instruction that can be run on the processor, and when the program or instruction is executed by the processor, the steps of the CTSP solving method based on the convolution enhanced proxy attention mechanism as described in the first aspect are implemented.
[0016] In a third aspect of an embodiment of the present invention, a readable storage medium is proposed, on which a program or instruction is stored. When the program or instruction is executed by a processor, the steps of the CTSP solving method based on the convolution-enhanced proxy attention mechanism as described in the first aspect are implemented.
[0017] The beneficial effects brought about by the technical solution provided by the embodiment of the present invention include at least:
[0018] In an embodiment of the present invention, by constructing a neural policy network based on convolution enhancement and proxy attention mechanism, combined with the attention structure and local convolution feature extraction module, the reasoning efficiency and scalability of the model in large-scale graph instances are significantly improved. At the same time, a reinforcement learning algorithm is introduced to train the network, so that the model has efficient policy exploration capabilities and can quickly generate preliminary high-quality solutions. On this basis, a traditional optimizer is further introduced for fine optimization, achieving an effective fusion of the rapid modeling advantages of neural networks and the precise solution capabilities of traditional algorithms, taking into account the quality of understanding and computational efficiency, and achieving a good balance between understanding accuracy and computing resources. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] The accompanying drawings are only for the purpose of illustrating specific embodiments and are not to be considered as limiting the present invention. Throughout the drawings, the same reference symbols represent the same components. Obviously, the drawings described below are only some embodiments of the present invention. It is clear that those skilled in the art can derive other drawings based on these drawings without inventive effort.
[0020] Figure 1 1 is a flow chart of a CTSP solving method based on a convolution-enhanced proxy attention mechanism provided by an embodiment of the present invention;
[0021] Figure 2 Schematic diagram of the structure of a CTSP solving system based on a convolution-enhanced proxy attention mechanism provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0022] In order to enable those skilled in the art to better understand the technical solutions in the embodiments of the present invention, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the embodiments described are part of the embodiments of the present invention, rather than all of the embodiments. It should be understood that these descriptions are merely exemplary and are not intended to limit the scope of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative work should fall within the scope of protection of the present invention.
[0023] The CTSP solving method based on the convolution-enhanced proxy attention mechanism provided by the embodiment of the present invention is described in detail below with reference to the accompanying drawings through specific embodiments and their application scenarios.
[0024] Reference Manual Figure 1 , which shows a flow chart of a CTSP solving method based on a convolution-enhanced proxy attention mechanism provided by an embodiment of the present invention.
[0025] The embodiment of the present invention provides a CTSP solving method based on a convolution-enhanced proxy attention mechanism, which may include the following steps:
[0026] S1: Get city data and salesperson data.
[0027] In a possible implementation, the city data includes: location coordinates of each city and a color tag assigned to each city, wherein each city includes one or more color attributes.
[0028] Salesperson data includes: Each traveling salesman is assigned a color tag.
[0029] In the embodiment of the present invention, the method of assigning color tags to each city and salesperson effectively realizes the management of constraints, the flexibility and sharing of path planning, the optimization of computing efficiency, and enhances the scalability of the model.
[0030] S2: Based on the city data and salesperson data, a complete graph is constructed to describe the CTSP problem instance.
[0031] Among them, TSP is a multi-salesperson constrained path planning problem, which requires collaborative completion of the access task of all graph nodes and optimization of path costs under the premise of satisfying color access constraints.
[0032] In a possible implementation, S2 specifically includes:
[0033] S201: Define a city node set.
[0034] S202: Assign coordinate and color attributes to each node in the node set.
[0035] S203: Define an edge set.
[0036] S204: Calculate the Euclidean distance between each node as the edge weight.
[0037] S205: Add access color constraints to each salesperson, where the access color constraints mean that each salesperson can only access city nodes with matching colors.
[0038] S206: Construct a complete graph for describing the CTSP problem instance based on the node set, the edge set, the edge set, and the visit color constraint.
[0039] Specifically, the complete graph The coloring traveling salesman problem (CTSP) is defined on Indicates the need to access Cities, borders Contains undirected connections between all cities (that is, any two cities are directly reachable). Each salesperson In the collection is assigned a unique color The question asks for each color The salesperson designs a Hamiltonian circuit that follows certain color constraints, ultimately achieving full coverage (visiting all cities exactly once) while optimizing the global path cost, such as minimizing the total distance or the longest single path distance. The complete graph structure means that the number of edges Each node Associate a plane coordinate vector . Color mapping function For each node Assign a non-empty color subset ,in .make Indicates salesperson (Associated Color ) accessible cities that satisfy the color compatibility condition:
[0040] .
[0041] It is worth noting that any multi-colored node (in ) essentially belongs to a specific set of multiple salespeople , thereby allowing cross-agent task sharing while maintaining color constraints.
[0042] In an embodiment of the present invention, by uniformly modeling city nodes, coordinate information, color attributes, salesperson access rules and edge weights into a structured complete graph, not only is the explicit expression of color access constraints achieved, but a clear graph structure foundation is also provided for subsequent path generation and optimization algorithms, further improving the efficiency, flexibility and controllability of path planning.
[0043] S3: Based on the complete graph, a constrained Markov decision process model is constructed. By defining the state space, action space, transition dynamics and reward function of the constrained Markov decision process model, the path generation process of the CTSP problem is modeled as a step-by-step decision mechanism.
[0044] The Constrained Markov Decision Process (CMDP) is an extended modeling framework based on the standard Markov Decision Process (MDP) by introducing constraints. Its goal is not only to maximize the cumulative reward, but also to meet certain cost or resource constraints.
[0045] In a possible implementation, S3 specifically includes:
[0046] S301: Based on the complete graph, define the state space of the constrained Markov decision process model, wherein the states in the state space include the identifier of the current salesperson, the set of currently visited nodes, the current node position, and the color attribute carried by the current salesperson.
[0047] In the embodiment of the present invention, this step clearly expresses the decision context of the current path construction, including: salesperson identity, current location, historical visit status and color attributes, providing comprehensive state input information for the policy function, which is conducive to learning effective decision-making.
[0048] S302: Based on the complete graph, define the action space of the constrained Markov decision process model.
[0049] It should be noted that the action space is defined as the node selection operation that meets the color constraint, for example, Action Join the current path.
[0050] In an embodiment of the present invention, the node selection process is explicitly converted into a set of legal actions subject to color constraints, ensuring that path construction is performed only in accessible cities, achieving effective action screening in the policy generation phase, and avoiding invalid calculations and illegal paths.
[0051] S303: Designing transition dynamics for constrained Markov decision process models.
[0052] It should be noted that the transfer dynamics achieves constraint compliance through deterministic state updates and invalid action shielding.
[0053] In the embodiment of the present invention, deterministic state updates are used to make the path generation process controllable. At the same time, combined with an invalid action shielding mechanism, illegal states such as repeated access or unauthorized access can be automatically excluded, thereby strengthening the legitimacy of the path.
[0054] S304: Set the reward function of the constrained Markov decision process model:
[0055] ;
[0056] in, Indicates the t The immediate reward for each time step, Indicates the t +1 node to be visited in the next time step, Indicates the t The nodes visited in each time step, represents the Euclidean distance norm.
[0057] S305: Define a policy function of the constrained Markov decision process model.
[0058] S306: Based on the state space, action space, transition dynamics, reward function, and policy function, a decision mechanism is constructed to gradually generate path solutions that meet the constraints:
[0059] ;
[0060] in, represents the policy function, represents a valid path solution, represents a valid path solution, Indicates the The salesperson's path, Indicates the Salesperson in The nodes selected at each time step, represents the complete graph, Indicates the Salesperson in t -1 time step selected nodes.
[0061] In simple terms, we input a CTSP (Constrained Traveling Salesman Problem) instance into the encoder, which transforms the node coordinates and their attributes into a unified representation space. Next, the decoder autoregressively generates a solution. At each time step, the decoder calculates the probability of each node being selected in the next state based on the node embeddings selected at the previous time point and the color attributes of the salesperson's vehicle. Through a masking operation, the algorithm removes nodes that have already been visited and any options that violate the color constraints, thereby determining the node to be selected in the next state. This process continues until all nodes in all cities have been visited.
[0062] In the embodiment of the present invention, the path generation task is structured, regularized, and strategically implemented through the CMDP model, so that the CTSP problem is transformed from a constraint graph structure into an optimizable and learnable decision-making process, laying the core foundation for building an efficient and compliant path generation system.
[0063] S4: Construct a neural policy network based on convolutional enhancement and agent attention mechanism, where the neural policy network is used to solve the constrained Markov decision process model.
[0064] Among them, the neural policy network is an intelligent path generation strategist that integrates graph structure modeling, context perception and attention mechanism. It can generate optimized paths through step-by-step probabilistic selection under the premise of satisfying access constraints. It is the core decision-making module for solving complex path planning problems such as CTSP.
[0065] In a possible implementation, S4 specifically includes:
[0066] S401: Process the complete graph through the problem initialization network to generate an initial input vector for the neural policy network.
[0067] In a possible implementation, S401 specifically includes:
[0068] S4011: Extract the spatial coordinates and color attributes of each node in the complete graph, and construct a node feature aggregation tensor based on the spatial coordinates and color attributes of each node.
[0069] S4012: Perform linear projection transformation on each coordinate in the node feature aggregation tensor to obtain coordinate embedding:
[0070] ;
[0071] in, represents position embedding, The weight matrix representing the warehouse node coordinates, represents element-wise multiplication, Indicates the i The coordinates of the node cities, The bias matrix representing the warehouse node coordinates, represents the weight matrix of city node coordinates, Bias matrix representing the coordinates of city nodes.
[0072] S4013: Perform linear projection transformation on the color attribute vector in the node feature aggregation tensor to obtain color embedding:
[0073] ;
[0074] in, represents color embedding, The weight matrix representing the color attribute of the warehouse node, Indicates the i The color attribute of each node city, The bias matrix representing the color attribute of the warehouse node, represents the weight matrix of the city node color attribute, Bias matrix representing the color attribute of city nodes.
[0075] S4014: Fusing coordinate embedding and color embedding to generate the initial input vector of the neural policy network:
[0076] ;
[0077] in, Represents the initial input vector.
[0078] In this embodiment of the present invention, independent linear projections are performed on coordinate and color information, achieving dual spatial and semantic representation. Furthermore, the initial input vector contains both geometric position and access constraint context information, providing an expressive foundation for deep network modeling.
[0079] S402: Extract the deep features of the initial input vector through the convolution enhancement and proxy attention mechanism in the encoder to obtain a deep feature embedding vector.
[0080] In a possible implementation, S402 specifically includes:
[0081] S4021: Extract global semantic features from the initial input vector through the proxy attention mechanism:
[0082] ;
[0083] in, represents the proxy attention mechanism, represents the attention function, represents the query matrix, represents the proxy matrix, Represents the value matrix.
[0084] S4022: Extract local geometric features from the initial input vector through convolution enhancement:
[0085] ;
[0086] in, Indicates the i Convolutional augmented embedding of layers, represents the activation function, represents the convolution operation, Represents the value matrix.
[0087] S4023: Fusion of global semantic features and local geometric features, and nonlinear transformation and residual connection through a feedforward neural network to obtain a deep feature embedding vector:
[0088] ;
[0089] in, Indicates the i The node embedding vector of the layer, represents the RMS normalization layer, represents the deep feature embedding vector, represents the feed-forward layer.
[0090] In an embodiment of the present invention,
[0091] S403: Based on the deep feature embedding vector and the historical state information of the path construction, the context variables of the current time step are constructed, where the context variables include the average embedding vector of the graph and the node embedding vector and node color attribute of the node selected in the previous step.
[0092] In an embodiment of the present invention, by integrating the proxy attention mechanism and the convolution enhancement module in the encoder, the global semantic features and local geometric features of the initial input vector are jointly extracted, and a high-dimensional deep embedding representation is constructed by fusion, thereby significantly improving the representation and distinction capabilities of the neural policy network for node features, and enhancing the model's perception of complex graph structures and color constraint semantics.
[0093] In a possible implementation, S403 specifically includes:
[0094] S4031: Perform average calculation on the deep feature embedding vector to obtain an average embedding vector.
[0095] S4032: Extract the node embedding vector and node color attribute of the node selected in the previous step in the history path.
[0096] S4033: Concatenate the average embedding vector, node embedding vector, and node color attribute to construct the context variable for the current time step:
[0097] ;
[0098] in, Represents context variables, represents the concatenation function, represents the average embedding vector, represents the embedding vector of the warehouse node, Indicates the color of the salesperson starting from the warehouse node. Indicates the t- The embedding vector of the selected node at 1 time step, Indicates the t- The color attribute of the salesperson at 1 time step.
[0099] In an embodiment of the present invention, the context variable of the current time step is constructed by fusing the average semantic representation of the nodes in the entire graph, the embedded vector of the node selected in the previous step in the historical path, and its color attribute. This enables the policy network to perceive the historical state and graph structure information during the path construction process, thereby realizing a context-aware node selection mechanism and improving the rationality and coherence of path generation.
[0100] S404: Based on the context variables and the node embedding vector, the node selection probability distribution is determined through the proxy attention mechanism and convolution enhancement module in the decoder.
[0101] Among them, Agent Attention is an improved self-attention mechanism that aims to reduce the computational complexity while retaining the global semantic modeling capability.
[0102] The convolutional enhancement module is an improved method used to compensate for the attention mechanism's weak ability to perceive local structure. It adds a lightweight convolutional network before or after the attention module to capture local geometric patterns and neighborhood structure information, preserve spatial location information, and enhance feature diversity.
[0103] In a possible implementation, S404 specifically includes:
[0104] S4041: Using the context variable as the query vector and the node embedding vector as the key vector and value vector, the attention score of each candidate node is calculated through the attention layer composed of the proxy attention mechanism and convolution enhancement:
[0105] ;
[0106] in, Indicates the i The attention scores of candidate nodes, C represents the hyperparameter, represents the hyperbolic tangent operator, d Represents the dimension of the embedding vector.
[0107] Optionally, C=10.
[0108] S4042: Validation is performed on each candidate node to select target candidate nodes that meet the gating conditions:
[0109] ;
[0110] in, Indicates the t Select the color of the node at each time step, Indicates the t- 1 time step selects the color of the node, represents the empty set, Indicates the The nodes visited in each time step.
[0111] S4043: Normalize the attention scores of each target candidate node to generate the node selection probability distribution:
[0112] ;
[0113] in, Indicates t-1 time step edge connected to the probability of the i-th candidate node, Indicates that the edges connecting the nodes are t- 1 time step i The feature representation of candidate nodes, e represents the exponential function, Indicates the i The attention scores of candidate nodes, Represents the value of the attention score of the i-th candidate node after exponential transformation, n represents the total number of target candidate nodes, j represents the index variable to be summed, represents the sum of the exponential attention scores of all candidate nodes.
[0114] In an embodiment of the present invention, by taking context variables as query vectors and combining them with node embedding vectors as key values to input into the attention calculation layer that integrates proxy attention and convolution enhancement mechanism, the importance of each candidate node at the current time step is accurately modeled; at the same time, color compatibility and access uniqueness rules are combined to perform legitimacy screening, and a differentiable node selection probability distribution is output through normalization operation, thereby realizing a constraint-aware, context-driven path selection strategy, significantly improving the compliance and strategy quality of path generation.
[0115] S405: According to the node selection probability distribution, a target node visited in the current time step is selected by greedy selection, and the target node is appended to the current path sequence.
[0116] S406: Update the current path construction state and the candidate node set according to the target node, and repeat the process from S403 to S405 until all city nodes are visited.
[0117] In this embodiment of the present invention, greedy node selection is performed at each time step based on the node selection probability distribution, and the candidate node set and path status are dynamically updated during the path construction process, thereby gradually constructing a city path sequence that satisfies color access constraints. This path generation method has a clear control flow, good computational efficiency, and trainability. It can efficiently complete the coverage of city nodes in the entire graph while maintaining legality, thereby generating an optimal initial path solution with a reasonable structure and compliant constraints.
[0118] S5: Use reinforcement learning algorithms to train neural policy networks based on convolutional enhancement and agent attention mechanisms.
[0119] Among them, reinforcement learning (RL) is a machine learning method that allows a learning agent to learn the optimal strategy by interacting with the environment and obtaining reward signals through trial and error.
[0120] Optionally, the model training steps specifically include:
[0121] In each training round, the input graph instances are desampled according to the path generation strategy to generate a node arrangement sequence.
[0122] Based on each graph instance and the corresponding starting node, a path trajectory is generated through a policy function.
[0123] Calculate the cumulative reward corresponding to each sampling path:
[0124] ;
[0125] in, Represents the sampling path The corresponding cumulative rewards, represents a sampling path, Indicates the moment when the path ends, represents the discount factor, represents the immediate reward obtained at the t-th time step.
[0126] It should be noted that the discount factor is used to reduce the weight of future rewards to reflect the view that immediate rewards are more certain and more valuable than distant rewards.
[0127] Using the REINFORCE method, the cumulative reward on the sampled trajectory is used to estimate the gradient of the expected return of the policy function:
[0128] ;
[0129] in, Indicates about parameters The gradient estimate of , which is used to update the policy function parameters to maximize the expected value of the cumulative reward, Represents the output of a line function, which depends on the current state or context G , Represents the sampling trajectory The corresponding cumulative rewards, This represents the policy function About parameters The log-likelihood gradient of .
[0130] Calculates a shared baseline based on the POMO policy.
[0131] Specifically, using the POMO structure, in each training round, N Different starting nodes are generated Ngreedy trajectories and use the average reward of these trajectories as a shared baseline to reduce the variance of gradient estimation.
[0132] Repeat the path sampling, reward evaluation, baseline calculation and gradient update process, and use the optimizer to iteratively optimize the policy network parameters until the model reaches the expected convergence condition or the upper limit of training rounds on the training set.
[0133] In this embodiment of the present invention, a reinforcement learning algorithm is introduced to train a neural policy network based on convolutional augmentation and a proxy attention mechanism. This enables the model to continuously learn and generate high-quality path solutions through path sampling, reward feedback, and policy optimization without supervised labeling. The REINFORCE method is used for unbiased policy gradient estimation, combined with the POMO multi-start greedy solution as a shared baseline, effectively reducing training variance and improving policy stability and convergence speed. This method significantly enhances the model's path optimization capabilities while satisfying color constraints.
[0134] S6: Generate a preliminary optimal path plan through the trained neural policy network based on convolutional enhancement and agent attention mechanism.
[0135] Specifically, the model uses a trained neural policy network to receive graph instance input. Through encoding embedding, context construction and greedy policy reasoning, it constructs a path for each salesperson in sequence according to color constraints, and finally generates a set of preliminary feasible path solutions that meet the constraints.
[0136] In this embodiment of the present invention, a trained neural policy network is used to embed and context-awarely model the Color Traveling Salesman Problem instance during the inference phase. Combined with a greedy selection strategy, this method rapidly generates preliminary feasible path solutions that satisfy color constraints. This path generation process, which eliminates the need for traditional heuristics or enumeration algorithms, offers advantages such as explicit constraint control, full-graph structure awareness, and efficient decoding. This significantly improves path construction speed and scalability while ensuring solution legitimacy, providing a well-structured, high-quality initial solution for subsequent refined optimization.
[0137] S7: The optimal path solution is input into the traditional optimizer for fine optimization to obtain the final optimal path solution.
[0138] Optionally, traditional optimizers include Gurobi, COPT, and OR-Tools.
[0139] In an embodiment of the present invention, based on the initial solution with reasonable structure and color compliance provided by the neural model, the traditional optimizer can focus on local path adjustment or global reconstruction, thereby significantly shortening the optimization convergence time and obtaining a better path length or cost indicator.
[0140] The beneficial effects brought about by the technical solution provided by the embodiment of the present invention include at least:
[0141] In an embodiment of the present invention, by constructing a neural policy network based on convolution enhancement and proxy attention mechanism, combined with the attention structure and local convolution feature extraction module, the reasoning efficiency and scalability of the model in large-scale graph instances are significantly improved. At the same time, a reinforcement learning algorithm is introduced to train the network, so that the model has efficient policy exploration capabilities and can quickly generate preliminary high-quality solutions. On this basis, a traditional optimizer is further introduced for fine optimization, achieving an effective fusion of the rapid modeling advantages of neural networks and the precise solution capabilities of traditional algorithms, taking into account the quality of understanding and computational efficiency, and achieving a good balance between understanding accuracy and computing resources.
[0142] Reference Manual Figure 2 , which shows a structural diagram of a CTSP solving system based on a convolution-enhanced proxy attention mechanism provided by an embodiment of the present invention.
[0143] The embodiment of the present invention provides a CTSP solving system 20 based on a convolution-enhanced proxy attention mechanism, comprising: a processor 201 and a memory 202;
[0144] The memory 202 stores a program or instruction that can be run on the processor 201. When the program or instruction is executed by the processor 201, the steps of the CTSP solving method based on the convolution enhanced proxy attention mechanism are implemented, and the same technical effect can be achieved. To avoid repetition, the present invention will not be repeated.
[0145] It should be understood that the processor 201 in the embodiment of the present invention may be a central processing unit (CPU), or may be other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field programmable gate arrays (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor, etc.
[0146] It should also be understood that the memory 202 in the embodiments of the present invention may be a volatile memory or a non-volatile memory, or may include both volatile and non-volatile memories. The non-volatile memory may be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), or a flash memory. The volatile memory may be a random access memory (RAM), which is used as an external cache. By way of example and not limitation, many forms of random access memory (RAM) are available, such as static RAM (SRAM), dynamic random access memory (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDR SDRAM), enhanced SDRAM (ESDRAM), synchronous link DRAM (SLDRAM), and direct rambus RAM (DR RAM).
[0147] The above embodiments can be implemented in whole or in part via software, hardware (e.g., circuits), firmware, or any other combination thereof. When implemented using software, the above embodiments can be implemented in whole or in part in the form of a computer program product. The computer program product comprises one or more computer instructions or computer programs. When loaded or executed on a computer, the processes or functions described in accordance with the embodiments of the present invention are fully or partially performed. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wired means (e.g., infrared, wireless, microwave, etc.). The computer-readable storage medium can be any available medium accessible by a computer or a data storage device such as a server or data center that contains a collection of one or more available media. The available medium can be magnetic media (e.g., floppy disks, hard disks, magnetic tapes), optical media (e.g., DVDs), or semiconductor media. The semiconductor media can be a solid-state drive.
[0148] It should be understood that in various embodiments of the present invention, the size of the serial numbers of the above-mentioned processes does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present invention.
[0149] Those skilled in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of the present invention.
[0150] Those skilled in the art will clearly understand that, for the convenience and brevity of description, the specific working processes of the above-described equipment, devices and units can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0151] In the several embodiments provided by the present invention, it should be understood that the disclosed devices, apparatuses and methods can be implemented in other ways. For example, the device embodiments described above are merely illustrative. For example, the division of the units is merely a logical function division. In actual implementation, there may be other division methods, such as multiple units or components can be combined or integrated into another device, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interface, indirect coupling or communication connection of the device or unit, which can be electrical, mechanical or other forms.
[0152] The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of these units may be selected to achieve the purpose of this embodiment according to actual needs.
[0153] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
[0154] If the functions are implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the portion that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions for causing a computer device (which can be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in various embodiments of the present invention. The aforementioned storage media include various media capable of storing program code, such as USB flash drives, mobile hard drives, read-only memories (ROMs), random access memories (RAMs), magnetic disks, or optical disks.
[0155] An embodiment of the present invention provides a readable storage medium comprising: a program or instruction stored on the readable storage medium, and when the program or instruction is executed by the processor, the steps of the CTSP solving method based on the convolution enhanced proxy attention mechanism are implemented, and the same technical effect can be achieved. To avoid repetition, the present invention will not be repeated.
[0156] Finally, it should be noted that the above embodiments are merely illustrative of the technical solutions of the embodiments of the present invention, and are not intended to limit them. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they may still modify the technical solutions described in the aforementioned embodiments, or replace some of the technical features therein with equivalents; and such modifications or replacements do not deviate from the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention. Any changes or replacements that can be easily conceived by those skilled in the art within the technical scope disclosed in the present invention should be covered by the scope of protection of the present invention.
Claims
1. A CTSP solving method based on convolution-enhanced proxy attention mechanism, characterized in that: include: S1: Obtain city data and salesperson data; S2: Based on the city data and the salesperson data, construct a complete graph for describing the CTSP problem instance; S3: Based on the complete graph, a constrained Markov decision process model is constructed, and the path generation process of the CTSP problem is modeled as a step-by-step decision mechanism by defining the state space, action space, transition dynamics and reward function of the constrained Markov decision process model; S4: constructing a neural policy network based on convolutional enhancement and agent attention mechanism, wherein the neural policy network is used to solve the constrained Markov decision process model; S5: Using a reinforcement learning algorithm to train the neural policy network based on convolutional enhancement and agent attention mechanism; S6: Generate a preliminary optimal path plan through the trained neural policy network based on convolutional enhancement and agent attention mechanism; S7: Inputting the optimal path solution into a traditional optimizer for fine optimization to obtain a final optimal path solution; The neural strategy network includes a problem initialization network, an encoder, and a decoder; S4 specifically includes: S401: Processing the complete graph through the problem initialization network to generate an initial input vector for the neural policy network; S402: extracting deep features of the initial input vector through convolution enhancement and proxy attention mechanism in the encoder to obtain a deep feature embedding vector; S403: Constructing context variables for the current time step based on the deep feature embedding vector and the historical state information of the path construction, wherein the context variables include the average embedding vector of the graph and the node embedding vector and node color attribute of the node selected in the previous step; S404: Determine a node selection probability distribution based on the context variable and the node embedding vector through a proxy attention mechanism and a convolution enhancement module in the decoder; S405: Selecting a target node to be accessed in the current time step by greedy selection according to the node selection probability distribution, and appending the target node to the current path sequence; S406: updating the current path construction state and the candidate node set according to the target node, and repeating the process from S403 to S405 until all city nodes are visited; The S404 specifically includes: S4041: Using the context variable as the query vector and the node embedding vector as the key vector and value vector, the attention score of each candidate node is calculated through the attention layer composed of the proxy attention mechanism and convolution enhancement: ; in, Indicates the i The attention scores of candidate nodes, C represents the hyperparameter, represents the hyperbolic tangent operator, d represents the dimension of the embedding vector; S4042: Validation is performed on each candidate node to select target candidate nodes that meet the gating conditions: ; in, Indicates the t Select the color of the node at each time step, Indicates the t- 1 time step selects the color of the node, represents the empty set, Indicates the Nodes visited in time steps; S4043: Normalize the attention scores of the target candidate nodes to generate the node selection probability distribution: ; in, Indicates t -1 time step edge connected to the probability of the i-th candidate node, Indicates that the edges connecting the nodes are t- 1 time step i The feature representation of candidate nodes, e represents the exponential function, Indicates the i The attention scores of candidate nodes, Represents the value of the attention score of the i-th candidate node after exponential transformation, n represents the total number of target candidate nodes, j represents the index variable to be summed, represents the sum of the exponential attention scores of all candidate nodes.
2. The CTSP solving method based on the convolution-enhanced proxy attention mechanism according to claim 1 is characterized in that: The city data includes: location coordinates of each city and color tags assigned to each city, wherein each city includes one or more color attributes; The salesperson data includes: each traveling salesman is assigned a color mark.
3. The CTSP solving method based on the convolution-enhanced proxy attention mechanism according to claim 1 is characterized in that: The S2 specifically includes: S201: define city node set; S202: assigning coordinate and color attributes to each node in the node set; S203: define edge set; S204: Calculate the Euclidean distance between each node as the edge weight; S205: Adding access color constraints to each salesperson, where the access color constraints are such that each salesperson can only access city nodes that match the color; S206: Construct a complete graph for describing a CTSP problem instance based on the node set, the edge set, the edge set, and the visit color constraint.
4. The CTSP solving method based on the convolution-enhanced proxy attention mechanism according to claim 3 is characterized in that: The S3 specifically includes: S301: Based on the complete graph, define a state space of the constrained Markov decision process model, wherein the states in the state space include the identifier of the current salesperson, the set of currently visited nodes, the current node position, and the color attribute carried by the current salesperson; S302: Based on the complete graph, define the action space of the constrained Markov decision process model; S303: Designing the transition dynamics of the constrained Markov decision process model; S304: Setting the reward function of the Constrained Markov Decision Process model: ; in, Indicates the t The immediate reward for each time step, Indicates the t +1 node to be visited in the next time step, Indicates the t The nodes visited in each time step, represents the Euclidean distance norm; S305: defining a policy function of the constrained Markov decision process model; S306: Based on the state space, the action space, the transition dynamics, the reward function, and the policy function, a decision mechanism is constructed for gradually generating a path solution that satisfies the constraint conditions. ; in, represents the policy function, represents a valid path solution, Indicates the number of salespeople, Indicates the The salesperson's path, Indicates the Salesperson in The nodes selected at each time step, represents the complete graph, Indicates the Salesperson in t -1 time step selected nodes.
5. The CTSP solving method based on convolution-enhanced proxy attention mechanism according to claim 1 is characterized in that: The S401 specifically includes: S4011: extracting the spatial coordinates and color attributes of each node in the complete graph, and constructing a node feature aggregation tensor based on the spatial coordinates and color attributes of each node; S4012: Perform linear projection transformation on each coordinate in the node feature aggregation tensor to obtain coordinate embedding: ; in, represents position embedding, The weight matrix representing the warehouse node coordinates, represents element-wise multiplication, Indicates the i The coordinates of the node cities, The bias matrix representing the warehouse node coordinates, represents the weight matrix of city node coordinates, The bias matrix representing the coordinates of city nodes; S4013: Perform a linear projection transformation on the color attribute vector in the node feature aggregation tensor to obtain a color embedding: ; in, represents color embedding, The weight matrix representing the color attribute of the warehouse node, Indicates the i The color attribute of each node city, The bias matrix representing the color attribute of the warehouse node, represents the weight matrix of the city node color attribute, The bias matrix representing the color attribute of the city node; S4014: Fusing the coordinate embedding and the color embedding to generate an initial input vector for the neural strategy network: ; in, Represents the initial input vector.
6. The CTSP solving method based on convolution-enhanced proxy attention mechanism according to claim 1 is characterized in that: The S402 specifically includes: S4021: Extracting global semantic features from the initial input vector through the proxy attention mechanism: ; in, represents the proxy attention mechanism, represents the attention function, represents the query matrix, represents the proxy matrix, represents the value matrix; S4022: Extracting local geometric features from the initial input vector through the convolution enhancement: ; in, Indicates the i Convolutional augmented embedding of layers, represents the activation function, represents the convolution operation, represents the value matrix; S4023: Fusing the global semantic features with the local geometric features, and performing nonlinear transformation and residual connection through a feedforward neural network to obtain the deep feature embedding vector: ; in, Indicates the i The node embedding vector of the layer, represents the RMS normalization layer, represents the deep feature embedding vector, represents the feed-forward layer.
7. The CTSP solving method based on convolution-enhanced proxy attention mechanism according to claim 1 is characterized in that: The S403 specifically includes: S4031: Performing average calculation on the deep feature embedding vector to obtain an average embedding vector; S4032: Extracting the node embedding vector and the node color attribute of the node selected in the previous step in the historical path; S4033: Connect the average embedding vector, the node embedding vector, and the node color attribute to construct the context variable of the current time step: ; in, Represents context variables, represents the concatenation function, represents the average embedding vector, represents the embedding vector of the warehouse node, Indicates the color of the salesperson starting from the warehouse node. Indicates the t- The embedding vector of the selected node at 1 time step, Indicates the t- The color attribute of the salesperson at 1 time step.
8. A CTSP solving system based on convolution-enhanced proxy attention mechanism, characterized in that: include: processor and memory; The memory stores a program or instruction that can be run on the processor, and when the program or instruction is executed by the processor, the steps of the CTSP solving method based on the convolution enhanced proxy attention mechanism according to any one of claims 1 to 7 are implemented.
Citation Information
Patent Citations
Large-scale traveling salesman problem solving method based on deep reinforcement learning
CN119047671A