CARSS: Cooperative Attention-guided Reinforcement Subpath Synthesis for Solving Traveling Salesman Problem
Abstract
This paper introduces CARSS (Cooperative Attention-guided Reinforcement Subpath Synthesis), a novel approach to address the Traveling Salesman Problem (TSP) by leveraging cooperative Multi-Agent Reinforcement Learning (MARL). CARSS decomposes the TSP solving process into two distinct yet synergistic steps: "subpath generation" and "subpath merging." In the former, a cooperative MARL framework is employed to iteratively generate subpaths using multiple agents. In the latter, these subpaths are progressively merged to form a complete cycle. The algorithm’s primary objective is to enhance efficiency in terms of training memory consumption, testing time, and scalability, through the adoption of a multi-agent divide and conquer paradigm. Notably, attention mechanisms play a pivotal role in feature embedding and parameterization strategies within CARSS. The training of the model is facilitated by the independent REINFORCE algorithm. Empirical experiments reveal CARSS’s superiority compared to single-agent alternatives: it demonstrates reduced GPU memory utilization, accommodates training graphs nearly 2.5 times larger, and exhibits the potential for scaling to even more extensive problem sizes. Furthermore, CARSS substantially reduces testing time and optimization gaps by approximately 50% for TSP instances of up to 1000 vertices, when compared to standard decoding methods.
1 Introduction
The Traveling Salesman Problem (TSP) stands as one of the quintessential combinatorial optimization challenges, seeking the shortest route to visit a set of cities and return to the origin. Its NP-hard nature has spurred continuous research into develo** efficient algorithms capable of tackling real-world instances. Traditional methods, such as exact algorithms based on cutting plane method (Chvátal et al., 2009) or dynamic programming (Held and Karp, 1962; Bellman, 1962), and heuristic algorithms based on insertion (Rosenkrantz et al., 1974), local search (Helsgaun, 2000) or population (Dorigo and Gambardella, 1997), often struggle with scalability and optimality for larger problem sizes, prompting the exploration of innovative paradigms that transcend the limitations of single-agent approaches.
In recent times, the field of Multi-Agent Reinforcement Learning (MARL) has gained prominence as a promising avenue for tackling intricate optimization problems. Notable examples include Level-Based Foraging (Albrecht and Ramamoorthy, 2013), Multi-Agent Particle Environment (Mordatch and Abbeel, 2018; Lowe et al., 2017), StarCraft Multi-Agent Challenge (Samvelyan et al., 2019), Multi-Robot Warehouse (Christianos et al., 2020; Dhamankar et al., 2020), Google Research Football (Kurach et al., 2020), and Hanabi (Bard et al., 2020). Through harnessing the collaborative proficiencies of multiple agents, cooperative MARL brings about the potential to enhance the efficiency of problem-solving processes, overcome computational bottlenecks, and advance scalability. Within this context, we introduce a pioneering algorithm—Cooperative Attention-guided Reinforcement Subpath Synthesis (CARSS)—crafted to transform the approach to solving the Traveling Salesperson Problem (TSP).
CARSS adopts a distinctive two-step strategy to decompose the TSP solving process. The first step, termed "subpath generation", harnesses the power of cooperative MARL to iteratively generate subpaths. Each agent contributes to constructing a subpath, collectively working towards achieving an optimal solution. The second step, "subpath merging," involves the incremental fusion of these subpaths to ultimately form a complete cycle that represents the solution to the TSP. This decomposition not only capitalizes on the strengths of MARL but also strategically divides the problem to mitigate the computational and memory burdens associated with large-scale instances.
A notable feature of CARSS lies in its incorporation of attention mechanisms, which serve a dual role in both feature embedding and parameterization strategies. These mechanisms enhance the agents’ ability to capture relevant information and learn effectively from their interactions with the environment. The training of the CARSS model is facilitated by the independent REINFORCE algorithm, a proven reinforcement learning technique.
Our contributions are threefold:
-
•
A novel algorithm, CARSS, is introduced for solving the TSP by leveraging cooperative MARL and attention mechanisms. The algorithm decomposes the problem into "subpath generation" and "subpath merging" steps, addressing memory consumption and scalability challenges.
-
•
The proposed approach demonstrates substantial improvements in terms of memory efficiency and testing times when compared to conventional single-agent algorithms. CARSS extends the capability to train on larger problem instances while maintaining solution quality.
-
•
Empirical results show that the CARSS algorithm reduces testing times and optimization gaps by approximately 50% for TSP instances of up to 1000 vertices, underscoring its potential to significantly enhance the efficiency of TSP-solving techniques.
2 Related Works
A considerable portion of the research in the realm of solving the TSP through supervised and reinforcement learning has been rooted in constructive modeling methodologies (Vinyals et al., 2015; Bello et al., 2016; Khalil et al., 2017; Kool et al., 2018; Bresson and Laurent, 2021). These approaches involve the stepwise selection of individual points, akin to methods driven by a singular agent. However, it is noteworthy that these methodologies tend to exhibit elevated time and space complexities when confronted with the task of addressing expansive problem scales. As a testament to this, numerous algorithms demonstrate their efficacy solely on problems of modest proportions, typically up to a size of 200, utilizing a prescribed quantum of GPU resources. For instance, Joshi et al. (2020) expound upon the challenges by affirming that "Training on large TSP200 from scratch is intractable and sample inefficient." This intrinsic computational burden consequently restricts their performance when applied to more substantial problem instances. Nevertheless, in contrast to these conventional paradigms, the CARSS algorithm introduces a pioneering approach that strategically decomposes the TSP-solving process into two distinct stages: subpath generation and subpath merging. By leveraging the principles of MARL, CARSS endeavors to surmount the limitations of memory consumption during training, mitigate testing duration, and amplify its scalability.
In the realm of TSP variations, Zhang et al. (2020) introduced a MARL-oriented framework addressing the vehicle routing problem encompassing soft time windows for a multi-vehicle scenario. This approach hinged upon predefined regulations, dictating a rotational decision-making process among vehicles. Notably, all vehicles shared a singular policy network, inadvertently rendering the framework functionally akin to single-agent control. Building upon this premise, Zong et al. (2022) advanced the paradigm by fashioning independent policy networks, eschewing the necessity for predetermined coordination rules in scenarios involving vehicle interaction. This liberation substantially expanded the exploration capacity within the collective of vehicle agents, efficiently tackling the intricacies posed by pickup and delivery problems. Extending this innovation, the CARSS algorithm extrapolates the concept into the domain of TSP, orchestrating a divide-and-conquer methodology tailored to surmount the challenges of larger-scale problem instances.
3 Method
In this section, we present the methodology of CARSS. The subsections that follow outline the cooperative Markov game formulation, algorithm specifics, policy parameterization, policy optimization, and complexity analysis.
3.1 Cooperative Markov Game Formulation for Traveling Salesman Problem
Define TSP as the tuple , where represents the set of graph instances, denotes the set of all feasible solutions for the graph within the context of . Here, each graph comprises vertices and edges. The function quantifies the value of solution within the set concerning the problem’s objective. In the context of TSP, equates to , where signifies the weight of edge . The ultimate objective of the problem is to determine the solution that minimizes this objective value across all instances , formally expressed as .
For a multi-agent system involving agents, we can establish the corresponding cooperative Markov game as follows:
-
•
The state space, denoted as , encompasses all possible states. The initial state, , is represented by the null graph , while the state space at the final time step is . Each agent shares an identical state at every time step and enjoys full access to all environmental observations.
-
•
The action space for agent , noted as , includes all vertices and edges of graph . Furthermore, characterizes the set of feasible actions for agent within state .
-
•
The state transition probability function, , is defined as follows:
where represents the probabilistic simplex in the state space , and signifies the disjoint union of graph and graph .
-
•
The reward function is defined by . It evaluates to if does not belong to but does; otherwise, it is .
Solving TSP involves the acquisition of a strategy denoted as , which is crafted to optimize the expected partial return .
In the scenario where the number of agents, denoted as , and the approach employed is deep reinforcement learning for solving TSP, the model adheres to the classical reinforcement learning methodology for addressing the TSP (Kool et al., 2018; Bresson and Laurent, 2021). However, this conventional approach exhibits several limitations:
-
•
As a TSP route comprises a composition of edges, invoking the policy network a minimum of times diminishes the potential benefits of parallel computation within sequential models. Additionally, the substantial computational overhead hampers the training of the model for larger-scale problems.
-
•
Policy networks conventionally rely on the computation of the attention matrix, entailing a time and space complexity of (Vaswani et al., 2017). This propensity for excessive memory utilization renders training infeasible for more extensive problem instances.
-
•
The actions generated through policy network sampling do not invariably constitute feasible solutions. Consequently, decoding necessitates the application of a mask to regulate the selection of visited vertices. However, as the termination point approaches, the number of visited vertices increases, resulting in a diminished space of viable actions. Consequently, the efficiency of attention matrix computation diminishes, leading to inefficient resource utilization.
On the other hand, in scenarios where the number of agents , the policy network is invoked a minimum of times. By predetermining the feasible actions for each agent, the number of viable actions per agent is averaged to , thereby reducing the time and space complexity of attention matrix computation to . This approach also indirectly enhances the efficiency of computational resource utilization, alleviating some of the constraints faced in the single-agent setting.
3.2 CARSS Algorithm
To address the limitations inherent in solving TSP with a single agent, we propose the CARSS algorithm. Designed for tackling the TSP within Euclidean space, CARSS effectively mitigates these limitations by strategically reducing the action and state space of the underlying Markov game, thereby approximating its optimal strategy.
The CARSS algorithm is structured around two pivotal phases: subpath generation and subpath merging. Within this context, "subpaths" represent non-circular graphs that form integral parts of the problem’s final solution tour.
During the subpath generation phase, CARSS initialization features an empty graph, denoted as . Each agent independently selects a vertex to ensure non-overlap** choices. Subsequently, during each time step, every agent gradually extends an edge to their selected vertex. This synchronized edge addition results in the simultaneous incorporation of edges. This process continues until several subpaths of uniform lengths, devoid of intersections, are established. Here, "intersecting" indicates the absence of any intersection between the vertex sets of two subpaths. It is noteworthy that this phase constitutes the majority of the algorithm’s runtime due to its computationally intensive nature.
The subsequent subpath mergings phase can be analogously conceived as a single-agent approach. Within this phase, the algorithm connects subpaths and, at most, isolated points. This gradual connection is achieved by adding up to edges, ultimately culminating in a complete cycle. This phase is crucial for addressing a specific TSP instance of a size not exceeding . The computation time associated with this phase is nearly negligible due to the relatively diminutive size of the subproblem.
Subsequently, we provide the temporal range encompassing time step within the two phases of subpath generation and subpath merging. Furthermore, we expound upon the precise structure of the space of feasible actions within state during these two phases.
3.2.1 Subpath Generation
In the subpath generation phase, we consider time steps denoted by , where
The rationale for treating the case of evenly dividing separately arises from the following consideration: when the algorithm advances to the th time step, a total of paths exist within the current state, each with a length of . At this point, the number of visited vertices is , and the number of isolated points is . Consequently, by considering isolated points as subpaths with a length of 0, the total count of subpaths to be connected amounts to . When each agent carries out an additional action, the count of isolated points decreases to , resulting in a reduction of the number of subpaths to . It is evident that a scarcity of isolated points will lead to fewer optional vertices in later stages of the subpath generation phase, thereby reducing training efficiency. Hence, a balance is struck between the number of time steps in the subpath generation phase and the problem size in the subpath merging phase. This strategic compromise enhances overall algorithm performance by marginally decreasing the number of time steps in the subpath generation phase while augmenting the problem’s complexity during the subpath merging phase.
At the initial time step , the feasible action space for state is defined as , where each initial action corresponds to the overlap** initial endpoints of a subpath. For each agent , we respectively denote these front and rear endpoints at its current state as and . For subsequent time steps, when , i.e., when , is determined by addressing the following specialized assignment problem:
subject to | ||||
Here, signifies whether the th vertex is assigned to the th agent. represents the minimum distance from the th vertex to either the first or last endpoint of the path corresponding to the th agent. The objective function aims to minimize the total sum of distances from each vertex to its closest endpoint within the assigned agent’s path. The first constraint mandates that each vertex must be assigned to exactly one agent. The second constraint ensures that each agent is assigned at least one vertex, thereby guaranteeing that the length of subpaths generated by each agent consistently increases over time. It’s worth noting that the vertex assignment obtained from solving this problem might not necessarily lead to the optimal solution of the original problem. However, it can significantly reduce the action space for the agents, resulting in a substantial acceleration of subpath generation.
A heuristic is designed to efficiently solve the assignment problem. It involves iterating over each agent and having them select the nearest unassigned vertex to fulfill the first constraint. Subsequently, each unassigned vertex is assigned to its nearest agent. The "distances" between vertices and agents are defined with respect to the metric . The complete algorithm for solving this assignment problem is presented in Algorithm 1.
Having obtained an approximate solution to the problem, the feasible action space for each agent in state is characterized as , which denotes an edge in with unvisited vertices at one end and front and rear vertices of the path corresponding to agent at the other end. Notably, these sets do not overlap with each other, i.e., . This ensures that the states at each time step consist of disjoint paths.
To enhance the model’s viability in addressing large-scale problems, the feasible action space for each agent in this phase is restricted to a maximum of actions, encompassing those closest to the respective agent.
3.2.2 Subpath Merging
The subpath merging stage can be conceptualized as addressing a specific variant of TSP using single-agent reinforcement learning. Upon completing the subpath generation, the state encompasses two distinct components: firstly, disjoint paths each of length , and secondly, isolated vertices , which can also be envisaged as paths of length , creating a total of paths. To connect these paths into a complete tour, extra edges need to be incorporated. This gives rise to a graph of size constructed as follows:
Here, for . consists of the front and rear vertices of each path in state . comprises all potential edges that may be required to amalgamate subpaths into cycles. The edge weights correspond to those in the original graph . Our objective is to ascertain an algorithm that is both highly effective and efficient in order to identify edges within the graph , forming a tour encompassing edges . This involves selecting an initial vertex and subsequently adding edges, thereby rendering . Given that reinforcement learning enables rapid approximate solutions in batch compared to exact algorithms, we employ single-agent reinforcement learning to address this sub-problem. The superscript indicating the single agent is omitted below for simplicity. The initial vertex can be selected at random from the set of all vertices in . For time steps , we begin by determining the other end of the current subpath from vertex , denoted as . Subsequently, we derive the set of feasible actions and the action chosen at that particular time step is denoted as . In the final time step , a terminal edge must be selected to seamlessly integrate the path into a complete cycle.
The comprehensive CARSS algorithm is depicted in Algorithm 2, while an illustrative example is showcased in Figure 1.
![Refer to caption](x1.png)
3.3 Policy Parameterization
3.3.1 Subpath Generation Parameterization
The input data to the subpath generation stage within the CARSS algorithm comprises the 2D Euclidean spatial coordinates of the graph’s vertex set , represented as . The action index is determined by the probability distribution of feasible actions for agent at time step within state , denoted as . This index is selected from the set , ultimately defining the action .
To efficiently capture information about neighboring vertices for each vertex, we employ a map** from the 2D vertex coordinates to higher-dimensional vertex features :
Here, , where and are trainable parameters. The parameter indicates the dimension of vertex features, represents the layer index of the vertex encoder within the subpath generation stage, and denotes the -order square matrix filled with entries.
Drawing inspiration from Zong Zefang et al.’s MAPDP paper (Zong et al., 2022), we adopt a novel approach by concatenating the feature vectors of both the front and rear vertices across all agents. This strategy facilitates the sharing of positional information among agents and yields the global information feature vector for agent :
Subsequently, it is concatenated with the feature vectors of the agent’s starting and ending vertices (comprising the comprehensive feature representation of the visited vertices), thus forming the feature vector for agent :
To facilitate cooperative interactions, a multi-head attention mechanism is then employed on the feature vectors of the aforementioned agents. This mechanism enhances the exchange of vital information among the agents:
Here, denotes the layer index of the agent encoder, and represents a -order square matrix composed entirely of entries.
Inspired by the utilization of the original Transformer model by Bresson and Laurent (2021) for addressing the TSP, we have introduced a novel concept of memory vectors with increasing lengths over time. These vectors enhance the model’s capacity to incorporate historical information progressively:
Subsequently, these feature vectors and memory vectors of the agents are harnessed as inputs to the multi-head attention mechanism. This integration enables the model to adeptly capture the characteristics of partial solutions:
Here, the operation alters the dimensions of the tensor from to , preserving its elements while aligning its dimensions with those of the memory vector at time step . designates the decoder layer index.
Subsequently, we construct feature vectors for each assigned vertex of every agent along with their corresponding masks. It should be noted that in Subsection 3.2, the solution to the assignment problem has been approximated using a heuristic algorithm. Each non-zero element of represents the vertex being assigned to the agent . However, the number of vertices assigned to each agent, denoted as , varies. To enable an efficient computation of the policy, we propose selecting feature vectors of vertices that are assigned to each agent based on their proximity. If the feasible actions are fewer than , we supplement the feature vectors with those of arbitrarily chosen infeasible vertices. This process yields the feature vector , which represents the assignments. Subsequently, we utilize the mask to prevent the model from generating these additionally introduced actions. This can be formally expressed as follows:
Here, the notation signifies selecting the first rows of the matrix, and the function serves to associate the mask index back to the vertex index of the initial instance during the subpath generation stage.
Finally, we proceed to identify the index of the selected feasible action at time step for each agent within the assignment list, denoted as . Subsequently, we map back to the original graph’s vertex index and determine the adjacent edge closer to the front and rear of that agent. This mapped vertex and edge combination serves as the action at time step , with ranging from to . The probability distribution of is formulated using the input features of the agents, namely , the vertex feature vectors for assignment denoted as , and the mask . This distribution is computed according to the following equation:
Here, serves as a crop** threshold. The parameters and are trainable parameters.
Once the index for agent within the assignment vector at time step is determined, the corresponding action can be computed as:
Here, the operation serves to establish a correspondence between the indices within the mask and the vertices of instance graph . This process results in connecting that vertex to the nearest endpoint along the subpath represented by agent .
3.3.2 Subpath Merging Parameterization
The input to the subpath merging phase in the CARSS algorithm is represented by the graph denoted as . This graph is utilized in conjunction with the probability distribution of feasible actions at time under the state , denoted as . The selection of the vertex index from the graph is a crucial step in determining the eventual action , with taking values from the set .
It’s important to note that the input graph size for this phase is , where the vertices comprise the front and rear endpoints of the paths corresponding to each agent from the previous phase, and the total number of edges to be added is . In order to facilitate the efficient extraction of information from the opposite end of the road as well as from other vertices within the neighborhood, a two-step process is employed. Initially, the two-dimensional vertex coordinates of the front (rear) vertex are concatenated with the two-dimensional coordinates of the rear (front) vertex. Subsequently, this amalgamated information is projected into a higher-dimensional vertex feature space denoted as . This transformation can be expressed as follows:
Here, signifies the coordinates of the th vertex in graph . The parameters and are trainable parameters. The dimensionality of the feature vector is denoted by . The layer index of the vertex encoder at the subpath merging stage is denoted by , and represents a square matrix of order with all elements equal to .
Building upon Kool et al.’s pioneering work in employing reinforcement learning for solving pathfinding problems (Kool et al., 2018), we adopt a similar approach to formulate the feature representation of states, allowing us to effectively capture the relevant information from the graph’s vertex features and incorporate it into the state representation. Specifically, we construct the feature representation by averaging the vertex feature vectors on the graph, combining the feature vector of the initially selected vertex, and concatenating it with the feature vector of the previously chosen vertex in the sequence of steps"
Here, and are trainable parameters. The parameter corresponds to the vertex indices selected from the graph during the subpath merging phase at time step .
Ultimately, we determine the index of the viable action chosen at time from the set of vertices in graph using the parameterized strategy . This index is then translated back to the vertex indexes of the original graph to yield action at time , where . The probability distribution of is computed based on the input feature vector of states , the vertex feature vector of graph , denoted as , and the mask . The calculation follows this pattern:
In the equation above, denotes the decoder layer index specific to the subpath merging stage. The parameter is set to as a crop** threshold, while represents the vertex mask that has yet to be accessed. and are trainable parameters. Once the vertex index is established on graph , chosen by agent at time , the corresponding action becomes
Here, denotes the -th vertex in graph , and functions as a logic operator returning either or . It serves to determine whether corresponds to the front or rear vertex. If it represents the front vertex, its index is increased by to ensure that the newly selected vertex at time connects to its endpoint. Conversely, if it represents the rear vertex, its index is decreased by to link it properly.
At the final time step , a decisive selection of a singular edge ensures the formation of a cycle. As a result, the need for parameterized strategies is obviated.
3.4 Policy Optimization
This section introduces optimization methods for the parameterized strategies involved in the CARSS algorithm’s subroute generation and subroute merging phases. In the subroute generation phase, initially, a set of groups of starting vertices is selected within the vertex set , ensuring distinct vertices within each group. Subsequently, leveraging the probability distribution of the policy , trajectories are sampled for the same instance. This results in a sequence of states, assignment vector indices, and reward trajectories , where is the number of agents and is the termination time of the subroute generation phase.
Moving to the subroute merging phase, a choice is made to establish sets of initial vertex indices for time in graph . Specifically, indices are assigned as . Then, employing the probability distribution of policy , each of the indices is sampled independently. This process yields another sequence of states, vertex indices in graph , and reward trajectories . Here, signifies the set of isolated points in graph at the end of the subroute generation phase, and represents the -th vertex in graph .
It is important to note, as defined Section 3.1, that the reward functions are structured such that for all and for all , and for all and . Non-zero rewards are solely associated with , for all and , representing the final circuit length.
When considering the policy gradient for each agent, the remaining agents are treated as part of the environment. With reference to the Policy Gradient Theorem (Sutton et al., 1999), the gradient of the expected cumulative reward can be approximated as follows:
Here, and . The former corresponds to the Policy Optimization with Multiple Optima (POMO) baseline (Kwon et al., 2020) obtained by sampling the decoding of merged subpaths from the randomly selected vertices in the subpath merging stage. The latter signifies the POMO baseline obtained by sampling vertices decoded from randomly chosen vertices in the subpath generation stage.
We trained the model using the independent REINFORCE algorithm (Williams, 1992) with the POMO baseline, employing the Adam optimizer (Kingma and Ba, 2015) for parameter updates. The training procedure is detailed in Algorithm 3.
3.5 Complexity Analysis
In this section, we present an analysis of the overall time and space complexity of the CARSS algorithm. This analysis highlights the advantages of our approach in terms of complexity compared to classical reinforcement learning-based methods for solving TSP (Kool et al., 2018; Bresson and Laurent, 2021). Moreover, it underscores the potential for training on larger problem instances.
Firstly, let’s consider the algorithm’s time complexity. This algorithm involves the utilization of the self-attention mechanism from multiple Transformer models during both the encoding and decoding processes. For a sequence of length , the time complexity of this algorithm is determined by , as discussed in Vaswani et al. (2017), where represents the model’s dimension. For the sake of simplicity, we can omit the term , particularly since during algorithm execution, the difference between and tends to be marginal or in scenarios where . Additionally, we will disregard certain network-specific parameters like , , etc. Furthermore, our analysis will focus solely on the case where a single trajectory is sampled in both phases (). The computational approach is as follows:
Next, we delve into the consideration of the algorithm’s space complexity. For a sequence of length , the space complexity of the self-attention module is , as indicated by Vaswani et al. (2017). However, recent advancements in the field have demonstrated that for encoders, this complexity can be reduced to (Rabe and Staats, 2021). By employing this technique, the space complexity can be expressed as follows:
Through these calculations, it is evident that the CARSS algorithm, which involves the collaborative efforts of multiple agents to solve TSP as opposed to the conventional algorithm with , significantly reduces the temporal and spatial complexities during both training and testing phases. Specifically, the CARSS algorithm achieves a complexity reduction of approximately times that of the original algorithm. This reduction in complexity translates to a substantial enhancement in the scalability of the model using the same computational resources.
4 Experiments
In this section, we outline the training process and experimental results of the CARSS algorithm. The training and test datasets are prepared in alignment with Kool et al. (2018). All instance vertices are drawn from a uniform distribution . The instance sizes, , are set to , and the number of agents, , ranges from . Both training and testing are performed on a GeForce RTX 3090 GPU, where instances with sizes less than 100 utilize a single GPU, while the rest employ two GPUs; however, testing is executed on a single GPU. The decoding strategy involves a greedy approach, selecting the action with the highest probability from the model’s action distribution. The optimization gap is computed as , with Obj. representing the cost associated with a solution calculated by a specific algorithm, and BKS denoting the cost of the instance’s optimal solution.
The model’s hyperparameters are largely consistent with Kool et al. (2018). The vertex parameters and hidden layer dimensions of the feedforward neural networks are set to and respectively. Within the generated subpath model, attention heads are employed. The encoder comprises layers of vertex feature aggregation attention, layers of agent feature aggregation attention, and the decoder has a single attention layer . Here, the superscripts , , and correspond to the encoder for vertex features, encoder for agent features, and decoder for generating policies, respectively. In the subpath merging model, attention heads are used, and in both the encoder and decoder, there are and attention layers, where the superscripts and pertain to the vertex encoder and policy decoder, respectively. The model undergoes iterations, with each iteration comprising batches, and each batch containing 512 instances. The learning rate remains fixed at .
Under the aforementioned settings, training a single iteration of this model on a GeForce RTX 3090 GPU takes approximately 10 to 25 minutes for instances with 100 vertices, around 25 to 31 minutes for instances with 200 vertices, and about 49 minutes for instances with 500 vertices. It’s noteworthy that the training time for models with the same training set size varies based on the number of agents; larger numbers of agents correspond to shorter training times. For the single-agent Attention Model (AM) proposed by Kool et al. (2018), its training times on smaller instances align with those of the CARSS algorithm, potentially due to the relatively high number of sequential execution steps during training or excessive sampling, which suggests room for optimization. As for memory consumption, the model can be trained on instances with 100 or 200 vertices using a single GPU, consuming up to a maximum of 12000 MiB of memory. However, for instances with 500 vertices, two GPUs are required, with each consuming around 16000 MiB of memory. On the other hand, the AM model requires two GPUs for training on instances with 200 vertices, consuming approximately 15000 MiB of memory per card. For larger instances, dual-GPU training is infeasible. This highlights the substantial memory optimization improvements achieved by the CARSS algorithm during training.
4.1 Performance on Random Instances
As shown in 1, we employed the CARSS algorithm to conduct tests on randomly generated instances with a maximum size of 1000 vertices. The Best Known Solution (BKS) was obtained using solvers such as Concorde or Gurobi. Since conventional reinforcement learning-based solving methods perform worse than 2-opt and insertion algorithms for instances of this size, only these few algorithms were included in the comparison. Test instances were generated randomly within the domain , with each instance type consisting of samples. During testing, 4096 results were obtained using greedy decoding for each instance, with the best result and solving time reported. The average values were then computed based on instance sets of equivalent scale. In the "Solver" column, "AM (sample)" represents the sample decoding version of the single-agent algorithm proposed by Kool et al. (Kool et al., 2018). On the other hand, indicates the CARSS algorithm trained with agents on a graph of size . As Gurobi’s solving time becomes prohibitively long for larger instances, it wasn’t employed to solve instances with 500 and 1000 vertices, and thus, "–" is used to indicate untested results.
Observing the results, it is evident that for instances with 100 vertices, CARSS (100,2) outperforms the farthest insertion algorithm but slightly lags behind AM (sample). For instances with 200 vertices, the performance of CARSS (100,4) is on par with the farthest insertion method, and superior to AM (sample). As the instance size increases to 500 or 1000 vertices, the optimization gap of CARSS (500,20) is inferior to the nearest insertion algorithm but far better than AM (sample). Even with the increase in sampling iterations, the algorithm retains the potential to achieve better solutions. In terms of testing time, the CARSS algorithm consistently outperforms AM (sample).
Problem Size 100 200 500 1000 Algorithm Obj. Gap Time Obj. Gap Time Obj. Gap Time Obj. Gap Time Concorde 7.74 0.00% 0.189s 10.71 0.00% 1.015s 16.55 0.00% 18.844s 23.09 0.00% 1.366m Gurobi 7.74 0.00% 1.008s 10.71 0.00% 14.585s - - 2-opt 8.34 7.79% 0.198s 11.67 8.94% 0.606s 18.20 9.98% 2.948s 25.60 10.90% 31.792s FI 8.34 7.85% 0.006s 11.68 9.06% 0.022s 18.26 10.37% 0.160s 25.74 11.52% 1.014s RI 8.51 9.95% 0.004s 11.94 11.54% 0.009s 18.46 11.56% 0.038s 26.10 13.07% 0.111s NI 9.45 22.20% 0.006s 13.28 23.97% 0.022s 20.63 24.66% 0.153s 28.93 25.32% 0.999s AM (sample) 7.92 2.39% 1.119m 11.50 7.48% 1.547m 22.65 36.82% 3.180m 42.94 85.96% 6.482m CARSS (100, 2) 8.09 4.53% 7.998s 12.11 13.03% 16.577s 21.87 32.15% 44.526s 35.28 52.83% 1.671m CARSS (100, 3) 8.15 5.39% 6.631s 12.13 13.25% 12.985s 21.78 31.63% 34.216s 34.97 51.48% 1.274m CARSS (100, 4) 8.12 4.93% 5.589s 12.00 12.02% 11.232s 21.24 28.36% 29.356s 33.85 46.62% 1.081m CARSS (100, 5) 8.15 5.34% 5.372s 12.03 12.36% 10.323s 21.17 27.93% 26.184s 33.32 44.36% 58.039s CARSS (100, 6) 8.23 6.44% 5.239s 12.26 14.51% 9.595s 21.56 30.30% 24.265s 34.03 47.40% 53.644s CARSS (100, 7) 8.34 7.87% 4.771s 12.33 15.10% 9.389s 21.71 31.22% 22.947s 34.14 47.90% 50.660s CARSS (100, 8) 8.34 7.83% 5.345s 12.33 15.10% 10.649s 22.04 33.20% 23.163s 34.78 50.67% 50.139s CARSS (100, 9) 8.56 10.60% 4.827s 12.70 18.57% 9.012s 22.47 35.77% 22.853s 36.28 57.16% 46.253s CARSS (100, 10) 8.18 5.76% 7.802s 12.13 13.23% 11.628s 21.37 29.12% 23.896s 34.08 47.60% 49.034s CARSS (200, 5) 8.23 6.36% 5.529s 12.03 12.35% 10.327s 20.81 25.76% 26.170s 32.56 41.04% 57.606s CARSS (200, 10) 8.23 6.38% 7.801s 12.10 12.98% 11.667s 20.84 25.95% 24.418s 32.29 39.88% 49.065s CARSS (500, 20) 8.13 5.08% 33.401s 12.17 13.61% 36.003s 20.58 24.35% 46.409s 31.03 34.41% 1.098m
4.2 Sensitivity Analysis
This segment delves into the relationship between the training loss of the subpath generation model and the problem’s scale and the number of agents involved. The training process is categorized into three groups based on the instance size , the number of agents , and the subproblem scale in the subpath merging phase . Figure 2 illustrates the relationship between the training loss and the number of iterations . Solid lines represent the mean of the loss within each category, while shaded regions depict the fluctuation range in terms of standard deviation. A higher absolute value of the loss implies a greater potential for improvement with more training iterations.
From the graph, we observe that the training loss of the subpath generation model exhibits similar trends across various problem scales. This suggests the stability of the CARSS algorithm’s performance when training on different problem sizes, without encountering training difficulties due to excessively large problem scales. However, as the number of agents or the subproblem scale in the subpath merging phase increases, the absolute value of the loss diminishes and its rate of reduction slows down over the training process. This phenomenon can be attributed to the multi-modal nature of the cooperative multi-agent environment.
![Refer to caption](extracted/5314720/figures/loss_gs.png)
![Refer to caption](extracted/5314720/figures/loss_na.png)
![Refer to caption](extracted/5314720/figures/loss_ss.png)
4.3 Example Solutions
As depicted in Figure 3, we selected an instance with a size of 100 and employed the CARSS algorithm with three distinct configurations, where the number of agents was set to , to solve it using a greedy decoding strategy. In the figure, solid black dots represent vertices in the instance, red solid dots indicate the initial vertices chosen by each agent, and hollow black dots depict isolated vertices not selected by any agent, totaling in number. Different colored solid lines correspond to subpaths of different agents in the final solution, amounting to a total of subpaths, while dashed lines symbolize the edges added to connect all agent subpaths and isolated vertices into a cycle during the subpath merging phase. From the illustration, it becomes apparent that the CARSS algorithm adeptly captures the characteristics of optimal solutions for TSP. Solutions exhibit superior quality with fewer agents, and the traveling salesman’s route demonstrates minimal instances of overlap**. However, as the number of agents increases, a potential decline in algorithm performance can be observed. This might arise from the simplicity in the map** of the vertex index , output by the policy network during the subpath generation phase, to the action at time . In this process, a choice is made to connect the chosen vertex to the nearest end of the subpath, rather than "inserting" the selected vertex into the current subpath, as seen in algorithms like the farthest insertion method. This discrepancy could lead to a decline in performance. This issue is evident in the solution provided by CARSS (100,10) for the loop in the upper right corner of the route, where the corresponding subpath formed by the blue agent shows such behavior.
![Refer to caption](extracted/5314720/figures/solution_gs100_na2.png)
![Refer to caption](extracted/5314720/figures/solution_gs100_na5.png)
![Refer to caption](extracted/5314720/figures/solution_gs100_na10.png)
5 Conclusion
In this paper, we introduced CARSS algorithm, a groundbreaking approach for solving TSP using cooperative MARL. CARSS strategically decomposes the TSP solving process into subpath generation and subpath merging steps, leveraging the power of cooperative MARL to tackle the challenges posed by large-scale instances. By employing attention mechanisms for feature embedding and parameterization, CARSS enhances the agents’ ability to learn and generate high-quality solutions. The independent REINFORCE algorithm facilitates the training of the CARSS model, contributing to its efficiency and effectiveness.
Our contributions to the field are threefold: firstly, the introduction of CARSS, an innovative algorithmic framework that harnesses cooperative MARL for TSP solving; secondly, the integration of attention mechanisms, which significantly elevate the agents’ learning capabilities; and thirdly, the empirical demonstration of CARSS’s superiority over single-agent alternatives. Through comprehensive experiments, we showed that CARSS outperforms conventional approaches in terms of delivering reduced memory consumption, improved scalability, and notable reductions in testing time and optimization gaps for large-scale TSP instances.
As the field of combinatorial optimization and reinforcement learning continues to evolve, CARSS presents a robust strategy that capitalizes on the synergy of multiple agents and attention mechanisms. While our work demonstrates remarkable advancements in tackling TSP, future research could explore the application of CARSS to other combinatorial optimization problems and delve deeper into optimizing the attention mechanisms to further enhance the agents’ learning efficiency. We anticipate that CARSS will play a pivotal role in advancing the capabilities of MARL in addressing complex real-world optimization challenges.
In conclusion, our study underscores the effectiveness of the CARSS algorithm, shedding light on its potential to revolutionize the way we approach TSP and related problems. By combining the strengths of cooperative MARL, attention mechanisms, and subpath synthesis, CARSS represents a significant stride toward efficient and scalable solutions for the TSP.
Acknowledgments
This research was supported by National Key R&D Program of China (2021YFA1000403), the National Natural Science Foundation of China (Nos. 11991022), the Strategic Priority Research Program of Chinese Academy of Sciences (Grant No. XDA27000000) and the Fundamental Research Funds for the Central Universities.
References
- Chvátal et al. [2009] Vašek Chvátal, William Cook, George B. Dantzig, Delbert R. Fulkerson, and Selmer M. Johnson. Solution of a large-scale traveling-salesman problem. In 50 Years of Integer Programming 1958-2008, pages 7–28. Springer Berlin Heidelberg, November 2009. doi:10.1007/978-3-540-68279-0_1. URL https://doi.org/10.1007/978-3-540-68279-0_1.
- Held and Karp [1962] Michael Held and Richard M. Karp. A dynamic programming approach to sequencing problems. Journal of the Society for Industrial and Applied Mathematics, 10(1):196–210, March 1962. doi:10.1137/0110015. URL https://doi.org/10.1137/0110015.
- Bellman [1962] Richard Bellman. Dynamic programming treatment of the travelling salesman problem. Journal of the ACM, 9(1):61–63, January 1962. doi:10.1145/321105.321111. URL https://doi.org/10.1145/321105.321111.
- Rosenkrantz et al. [1974] D. J. Rosenkrantz, R. E. Stearns, and P. M. Lewis. Approximate algorithms for the traveling salesperson problem. In 15th Annual Symposium on Switching and Automata Theory (swat 1974). IEEE, October 1974. doi:10.1109/swat.1974.4. URL https://doi.org/10.1109/swat.1974.4.
- Helsgaun [2000] Keld Helsgaun. An effective implementation of the lin–kernighan traveling salesman heuristic. European Journal of Operational Research, 126(1):106–130, October 2000. doi:10.1016/s0377-2217(99)00284-2. URL https://doi.org/10.1016/s0377-2217(99)00284-2.
- Dorigo and Gambardella [1997] M. Dorigo and L.M. Gambardella. Ant colony system: a cooperative learning approach to the traveling salesman problem. IEEE Transactions on Evolutionary Computation, 1(1):53–66, April 1997. doi:10.1109/4235.585892. URL https://doi.org/10.1109/4235.585892.
- Albrecht and Ramamoorthy [2013] Stefano V. Albrecht and Subramanian Ramamoorthy. A game-theoretic model and best-response learning method for ad hoc coordination in multiagent systems. In Proceedings of the 2013 International Conference on Autonomous Agents and Multi-Agent Systems, AAMAS ’13, page 1155–1156, Richland, SC, 2013. International Foundation for Autonomous Agents and Multiagent Systems. ISBN 9781450319935.
- Mordatch and Abbeel [2018] Igor Mordatch and Pieter Abbeel. Emergence of grounded compositional language in multi-agent populations. In Proceedings of the Thirty-Second AAAI Conference on Artificial Intelligence and Thirtieth Innovative Applications of Artificial Intelligence Conference and Eighth AAAI Symposium on Educational Advances in Artificial Intelligence, AAAI’18/IAAI’18/EAAI’18. AAAI Press, 2018. ISBN 978-1-57735-800-8.
- Lowe et al. [2017] Ryan Lowe, Yi Wu, Aviv Tamar, Jean Harb, Pieter Abbeel, and Igor Mordatch. Multi-agent actor-critic for mixed cooperative-competitive environments. In Proceedings of the 31st International Conference on Neural Information Processing Systems, NIPS’17, page 6382–6393, Red Hook, NY, USA, 2017. Curran Associates Inc. ISBN 9781510860964.
- Samvelyan et al. [2019] Mikayel Samvelyan, Tabish Rashid, Christian Schroeder de Witt, Gregory Farquhar, Nantas Nardelli, Tim G. J. Rudner, Chia-Man Hung, Philip H. S. Torr, Jakob Foerster, and Shimon Whiteson. The starcraft multi-agent challenge. In Proceedings of the 18th International Conference on Autonomous Agents and MultiAgent Systems, AAMAS ’19, page 2186–2188, Richland, SC, 2019. International Foundation for Autonomous Agents and Multiagent Systems. ISBN 9781450363099.
- Christianos et al. [2020] Filippos Christianos, Lukas Schäfer, and Stefano V. Albrecht. Shared experience actor-critic for multi-agent reinforcement learning. In Proceedings of the 34th International Conference on Neural Information Processing Systems, NIPS’20, Red Hook, NY, USA, 2020. Curran Associates Inc. ISBN 9781713829546.
- Dhamankar et al. [2020] Gauraang Dhamankar, Jose R. Vazquez-Canteli, and Zoltan Nagy. Benchmarking multi-agent deep reinforcement learning algorithms on a building energy demand coordination task. In Proceedings of the 1st International Workshop on Reinforcement Learning for Energy Management in Buildings & Cities, RLEM’20, page 15–19, New York, NY, USA, 2020. Association for Computing Machinery. ISBN 9781450381932. doi:10.1145/3427773.3427870. URL https://doi.org/10.1145/3427773.3427870.
- Kurach et al. [2020] Karol Kurach, Anton Raichuk, Piotr Stanczyk, Michal Zajac, Olivier Bachem, Lasse Espeholt, Carlos Riquelme, Damien Vincent, Marcin Michalski, Olivier Bousquet, and Sylvain Gelly. Google research football: A novel reinforcement learning environment. In The Thirty-Fourth AAAI Conference on Artificial Intelligence, AAAI 2020, The Thirty-Second Innovative Applications of Artificial Intelligence Conference, IAAI 2020, The Tenth AAAI Symposium on Educational Advances in Artificial Intelligence, EAAI 2020, New York, NY, USA, February 7-12, 2020, pages 4501–4510. AAAI Press, 2020. URL https://ojs.aaai.org/index.php/AAAI/article/view/5878.
- Bard et al. [2020] Nolan Bard, Jakob N. Foerster, Sarath Chandar, Neil Burch, Marc Lanctot, H. Francis Song, Emilio Parisotto, Vincent Dumoulin, Subhodeep Moitra, Edward Hughes, Iain Dunning, Shibl Mourad, Hugo Larochelle, Marc G. Bellemare, and Michael Bowling. The hanabi challenge: A new frontier for ai research. Artificial Intelligence, 280:103216, 2020. ISSN 0004-3702. doi:https://doi.org/10.1016/j.artint.2019.103216. URL https://www.sciencedirect.com/science/article/pii/S0004370219300116.
- Vinyals et al. [2015] Oriol Vinyals, Meire Fortunato, and Navdeep Jaitly. Pointer networks. In NIPS, 2015.
- Bello et al. [2016] Irwan Bello, Hieu Pham, Quoc V. Le, Mohammad Norouzi, and Samy Bengio. Neural combinatorial optimization with reinforcement learning. ArXiv, abs/1611.09940, 2016.
- Khalil et al. [2017] Elias Boutros Khalil, Hanjun Dai, Yuyu Zhang, Bistra N. Dilkina, and Le Song. Learning combinatorial optimization algorithms over graphs. In NIPS, 2017.
- Kool et al. [2018] Wouter Kool, Herke van Hoof, and Max Welling. Attention, learn to solve routing problems! In International Conference on Learning Representations, 2018.
- Bresson and Laurent [2021] Xavier Bresson and Thomas Laurent. The transformer network for the traveling salesman problem. ArXiv, abs/2103.03012, 2021.
- Joshi et al. [2020] Chaitanya K. Joshi, Quentin Cappart, Louis-Martin Rousseau, Thomas Laurent, and Xavier Bresson. Learning tsp requires rethinking generalization. ArXiv, abs/2006.07054, 2020.
- Zhang et al. [2020] Ke Zhang, Fang He, Zhengchao Zhang, Xi Lin, and Meng Li. Multi-vehicle routing problems with soft time windows: A multi-agent reinforcement learning approach. Transportation Research Part C: Emerging Technologies, 121:102861, December 2020. doi:10.1016/j.trc.2020.102861. URL https://doi.org/10.1016/j.trc.2020.102861.
- Zong et al. [2022] Zefang Zong, Meng Zheng, Yong Li, and Depeng **. Mapdp: Cooperative multi-agent reinforcement learning to solve pickup and delivery problems. In AAAI Conference on Artificial Intelligence, 2022.
- Vaswani et al. [2017] Ashish Vaswani, Noam M. Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N. Gomez, Lukasz Kaiser, and Illia Polosukhin. Attention is all you need. ArXiv, abs/1706.03762, 2017.
- Sutton et al. [1999] Richard S Sutton, David McAllester, Satinder Singh, and Yishay Mansour. Policy gradient methods for reinforcement learning with function approximation. Advances in neural information processing systems, 12, 1999.
- Kwon et al. [2020] Yeong-Dae Kwon, **ho Choo, Byoungjip Kim, Iljoo Yoon, Seungjai Min, and Youngjune Gwon. Pomo: Policy optimization with multiple optima for reinforcement learning. ArXiv, abs/2010.16011, 2020.
- Williams [1992] Ronald J. Williams. Simple statistical gradient-following algorithms for connectionist reinforcement learning. Machine Learning, 8(3-4):229–256, May 1992. doi:10.1007/bf00992696. URL https://doi.org/10.1007/bf00992696.
- Kingma and Ba [2015] Diederik P. Kingma and Jimmy Ba. Adam: A method for stochastic optimization. In Yoshua Bengio and Yann LeCun, editors, 3rd International Conference on Learning Representations, ICLR 2015, San Diego, CA, USA, May 7-9, 2015, Conference Track Proceedings, 2015. URL http://arxiv.longhoe.net/abs/1412.6980.
- Rabe and Staats [2021] Markus N. Rabe and Charles Staats. Self-attention does not need o(n2) memory. ArXiv, abs/2112.05682, 2021.