G RAPH N EURAL N ETWORK G UIDED L OCAL S EARCH FOR THE T RAVELING S ALESPERSON P ROBLEM
Anonymous authors Paper under double-blind review
A BSTRACT
Solutions to the Traveling Salesperson Problem (TSP) have practical applications to processes in transportation, logistics, and automation, yet must be computed with minimal delay to satisfy the real-time nature of the underlying tasks.
However, solving large TSP instances quickly without sacrificing solution quality remains challenging for current approximate algorithms.
To close this gap, we present a hybrid data-driven approach for solving the TSP based on Graph Neural Networks (GNNs) and Guided Local Search (GLS).
Our model predicts the regret of including each edge of the problem graph in the solution; GLS uses these predictions in conjunction with the original problem graph to find solutions.
Our experiments demonstrate that this approach converges to optimal solutions at a faster rate than three recent learning-based approaches for the TSP.
Notably, we reduce the mean optimality gap on the 100-node problem set from 1.534% to 0.705%, a 2 × improvement.
When generalizing from 20-node instances to the 100-node problem set, we reduce the optimality gap from 18.845% to 2.622%, a 7 × improvement.
I NTRODUCTION
Sixty years ago, the route of a delivery truck would have been fixed well before the truck departed the warehouse.
Today, thanks to the availability of real-time traffic information, and the option to transmit instructions to the driver to add or remove delivery locations on-the-fly, the route is no longer fixed.
Nevertheless, minimizing the length or duration of the route remains an important problem.
This is an instance of the Traveling Salesperson Problem (TSP), and one of a growing number of practical applications which require solving combinatorial optimization problems in real time.
In these problems, there is often a cost attributed to waiting for an optimal solution or hard deadlines at which decisions must be taken.
For example, the driver cannot wait for a new solution to be computed – they may miss their deliveries, or the traffic conditions may change again.
There is a need for general, anytime combinatorial optimization algorithms that produce high-quality solutions under restricted computation time.
This remains challenging for current approaches, as they are specialized for a specific problem (with specific assumptions and constraints), or fail to produce good solutions quickly.
Contributions We present a hybrid data-driven approach for approximately solving the Euclidean
TSP based on Graph Neural Networks (GNNs) and Guided Local Search (GLS), which we demonstrate converges to optimal solutions more quickly than three recent learning based approaches.
We provide the following contributions
: • Our GLS algorithm is guided by the global regret of each edge in the problem graph.
This allows the algorithm to differentiate edges that are very costly to include in the solution from ones that are not so costly, whether or not they are part of the optimal solution.
Thus, using regret allows us to find high-quality, rather than optimal, solutions very quickly.
We are the first to use a measure of global regret, which we define as the cost of enforcing a decision relative to the cost of an optimal solution.
• We make this computationally tractable by approximating regret with a learned representation.
Our GNN-based model operates on the line graph of the problem graph, which allows us to build a network without node features, focusing only on edge weight.
• We present experimental results for our approach and several learning based approaches that are aligned with recent guidelines for computational testing of learning based approaches for the TSP.
Our experiments emphasize the trade-off between solution quality and time.
• We reduce the mean optimality gap on the 50-node problem set from 0.268% to 0.009%, a 30 × times improvement, and on the 100-node problem set from 1.534% to 0.705%, a 2 × improvement.
When generalizing from 20-node instances to the 100-node problem set, we reduce the mean optimality gap from 18.845% to 2.622%, a 7 × improvement.
R ELATED W ORK
The Operations Research (OR) community is responsible for the majority of research in algorithms for solving combinatorial optimization problems.
Concorde (Applegate et al., 2006) is widely regarded as the best exact TSP solver.
As an exact solver, it can guarantee the level of optimality of the solutions it finds.
It uses cutting plane algorithms (Dantzig et al., 1954; Padberg & Rinaldi, 1990; Applegate et al., 2003) and branch-and-cut methods to iteratively prune away parts of search space that will not contain an optimal solution.
LKH-3 (Helsgaun, 2017), and its predecessor, LKH2 (Helsgaun, 2009), are approximate TSP and Capacitated Vehicle Routing Problem (CVRP) solvers based on the κ -opt heuristic (Lin & Kernighan, 1973).
While these solvers do not provide any guarantees, experimentation has demonstrated that they are extremely effective.
Concorde, LKH-2 and
LKH-3 are highly specialized and efficient solvers which can solve challenging TSPs in seconds.
However, practical real-time routing problems often impose constraints on top of the basic TSP or
CVRP problem definitions.
Highly-specialized solvers are difficult to adapt to these new constraints.
Thus, there is a need for general algorithmic frameworks that can produce high-quality solutions with minimal computation time.
To address this, Arnold & S ¨ orensen (2019a) introduce KGLS, a
GLS algorithm for the CVRP that is guided by three engineered features.
They demonstrate that their algorithm can find solutions almost as good as those found by state-of-the-art metaheuristics in a fraction of the time.
Our work also aims to address this gap.
Machine learning offers a way to construct flexible, yet effective combinatorial optimization algorithms.
This area of research has existed for more than three decades (Smith, 1999), yet new neural architectures, especially GNNs, have driven a surge of activity in this area.
As noted by Bengio et al.
(2021); Cappart et al.
(2021), classical combinatorial optimization approaches solve each problem instance in isolation, overlooking the fact that in practice, problems and their solutions stem from related data distributions.
Machine learning offers a way to exploit this observation.
We classify learning based approaches for solving the TSP into the three categories identified by Bengio et al.
(2021); our approach belongs to the second category, described below.
ML alone provides a solution.
These approaches use a machine learning model to output solutions directly from the problem definition.
Vinyals et al.
(2015) propose PtrNet, a sequence-to-sequence model based on LSTMs, which iteratively constructs a solution by outputting the permutation of the input nodes.
They train their model using expert solutions from Concorde.
They use beam search (Reddy, 1977) to produce better solutions than those sampled from their model directly.
Bello et al.
(2016) present a method of training PtrNet without supervision using policy gradients.
Their “active search” method resembles early neural network-based approaches to combinatorial optimization, in which a model was trained online to solve a particular problem instance (Smith, 1999).
This method effectively solves each problem in isolation, thus it does not leverage expertise extracted from distribution of training problem instances.
Kool et al.
(2018) take a similar approach to Bello et al.
but use a Transformer architecture (Vaswani et al., 2017) rather than an LSTM.
Their model can also be seen as a Graph Attention Network (GAT) (Veliˇckovi´c et al., 2017) applied to a complete graph.
Kwon et al.
(2021) also take a similar approach but leverage the symmetry of many combinatorial optimization problems to improve performance.
Joshi et al.
(2019) train a model to produce a heatmap of which edges in the TSP graph are likely to be part of the optimal solution, and reconstruct valid tours using beam search.
Similar to Vinyals et al.
, they train their model using expert solutions from Concorde.
Kool et al.
(2021) extend the work of Joshi et al.
(2019) to VRPs, and use a dynamic programming method to construct tours.
Also in this category, Fu et al.
(2021) train a model to output a heatmap for small TSP instances to and sample small sub-graphs from large instances to construct heatmaps for large instances.
They train their approach using reinforcement learning, and use Monte Carlo tree search (MCTS) to construct valid tours.
ML provides information to an OR algorithm.
Machine learning may not be suitable to solve a combinatorial optimization problem alone.
Instead, it can provide information to augment a combinatorial optimization algorithm.
Deudon et al.
(2018) use a model based on the Transformer architecture to construct solutions iteratively and train it using policy gradients (they take a similar approach to Kool et al., 2018).
They apply a 2-opt local search heuristic to solutions sampled from their model.
In contrast to prior work, we are the first to use a machine learning model to approximate regret .
Furthermore, many previous works that produce predictions on edges (Joshi et al., 2019; Kool et al., 2021; Fu et al., 2021) construct tours using heuristics, whereas to our knowledge, we are the first to use predictions to inform a metaheuristic (GLS).
ML makes decisions within an OR algorithm.
Finally, a machine learning model can be embedded inside a combinatorial optimisation algorithm.
In this paradigm, a master algorithm controls the high-level procedure while repeatedly calling a machine learning model to make lower level decisions.
Dai et al.
(2017) present a model that uses a GNN to learn an embedding of the current partial solution and a DQN (Mnih et al., 2015) to iteratively select nodes to insert using a cheapest insertion heuristic.
They also use an “active search” method when solving the TSP.
Wu et al.
and da Costa et al.
(2020) present policy gradient algorithms to learn policies to apply 2-opt operations to existing feasible solutions.
Wu et al.
(2020) use a Transformer architecture.
da Costa et al.
(2020) use a combination of GCN and RNN modules, and acheive better results.
These approaches can either be seen as end-to-end learning approaches belonging to the first category, or as local search procedures where an ML model decides where to apply an operator.
P RELIMINARIES
Traveling Salesperson Problem We focus on the Euclidean TSP, although our approach can be applied to other routing problems, such as the CVRP.
A problem with n cities, typically denoted
TSP n , is represented as a complete, undirected, weighted graph G =
( V, E ) with n nodes.
The edges E represent connections between cities and are weighted by the Euclidean distance between the adjacent nodes.
A solution, or tour , is a Hamiltonian cycle: a closed path through the graph that visits every node exactly once.
An optimal solution is a cycle of minimum weight.
Regret Regret measures the future cost of an action that also yields an immediate reward, and is typically used to make greedy combinatorial optimization algorithms less myopic.
Generally, regret is computed over a fixed horizon.
For example, Potvin & Rousseau (1993) evaluate the cost of inserting a node in the best versus second-best position when constructing a CVRP solution.
Hassin & Keinan (2008) solve the TSP using regret, allowing a greedy construction heuristic to remove the most recently inserted node.
It is not computationally feasible to calculate regret over a global horizon, for example, for all possible insertion sequences.
However, if it were possible, a greedy algorithm could compute an optimal solution by selecting the lowest regret decision at each step.
Local Search
Local Search (LS) is a general improvement heuristic.
Starting from an initial solution, local search iteratively moves to neighboring solutions that are lower cost than the current solution according to the objective function g ( s ) .
Neighboring solutions are solutions that are reachable from a given solution by applying a certain function, or operator .
The set of all solutions reachable from another solution by applying an operator define the neighborhood of that operator.
The algorithm terminates when all neighboring solutions are inferior to the current solution, meaning the search has reached a local optimum.
Local Search Guided Local Search (GLS) is a metaheuristic that sits on top of LS and allows it to escape local optima (Voudouris & Tsang, 1996).
To apply GLS, the designer must define some aspects of a solution.
When trapped in a local optimum, the algorithm penalizes certain aspects of the current solution which are considered to be unfavorable.
The underlying LS procedure searches using an objective function that is augmented by these penalties, thus it is incentivized to remove heavily penalized aspects from the solution.
The augmented objective function h ( s ) is
[Equation]
where s is a solution, g ( s ) is the objective function, λ is a scaling parameter, i indexes the aspects,
M is the number of aspects, p i is the current number of penalties assigned to aspect i , and I i is an indication of whether s exhibits aspect i , i.e.
[Equation]
For the TSP, aspects of the solution are often defined as the edges in the problem graph.
Therefore,
I i ( s ) indicates if an edge is in the solution s .
Upon reaching a local optimum, which aspects are penalized is determined by a utility function.
The utility of penalising aspect i , util i , is defined as
[Equation]
where s ∗ is the solution at a local optimum, I i ( s ∗ ) indicates if the solution exhibits aspect i , and
c i is the cost of the aspect i .
The cost of an aspect measures how unfavorable it is.
The higher the cost, the greater the utility of penalizing that aspect.
In the context of the TSP, the cost can be the weight of the edge (Voudouris & Tsang, 1999), or a combination of various features (Arnold & S¨orensen, 2019a).
Conversely, the more penalties assigned to that aspect, the lower the utility of penalising it again.
The aspects with the maximum utility are always penalized, which means increasing p i by one.
This penalization mechanism distributes the search effort in the search space, favoring areas where a promise is shown (Voudouris & Tsang, 1996).
We use a variation of the classical GLS algorithm (see Voudouris & Tsang, 1999) that applies alternating optimisation and perturbation phases (see Arnold & S ¨ orensen, 2019a).
During an optimization phase, the local search procedure is guided by the original objective function g .
During a perturbation phase, it is guided by the augmented objection function h .
After an edge is penalized, the local search is applied only on the penalized edge.
That is, only operations that would remove the penalized edge are considered.
This differs from the local search during the optimization phase, which considers all solutions in the neighborhood of the given operator.
The perturbation phase continues until K operations (operations that improve the solution according to the augmented objective function h ) have been applied to the current solution.
These operations perturb the solution enough for the local search to escape a local minimum.
The alternating phases continue until the stopping condition is met.
M ETHOD
Our hybrid method, shown in Figure 1, combines a machine learning model and a metaheuristic.
Our GNN-based model learns an approximation of the global regret of including each edge of the problem graph in the solution.
The metaheuristic, GLS, uses this learned regret conjunction with the original problem graph to quickly find high-quality solutions.
The learned regret allows the algorithm to differentiate between edges which are costly to include in the solution and ones that are not so costly, thus improving its ability to steer the underlying local search procedure out of local minima and towards promising areas of the solution space.
[Figure]
4. G LOBAL R EGRET
We define global regret as the cost of requiring a certain decision to be part of the solution relative to the cost of a globally optimal solution.
Unlike previous heuristics using regret, which calculate the
[Figure]
cost of a decision relative to some fixed number of alternatives (for example, the next best, or two next best options), our regret is measured relative to a global optimal solution .
Decisions that are part of an optimal solution have zero regret, and all other decisions have positive regret.
Mathematically,
[Equation]
where r i is the regret of decision i , g is the objective function, s ∗ i is an optimal solution with i fixed, and s ∗ a globally optimal solution.
With perfect information, a greedy algorithm could construct an optimal solution by sequentially selecting the lowest-regret decisions.
In the TSP, decisions correspond to which edges are included in the solution, thus regret is defined as the cost of requiring that a certain edge be part of the solution.
We posit that using regret is preferable to directly classifying which edges are part of the optimal solution (which is the approach taken by Joshi et al., 2019).
Where classification can produce a probability that the edge is part of optimal solution, regret can differentiate between edges that are very costly to have as part of the solution and ones that are not so costly, whether or not they are part of the optimal solution.
Thus, using regret furthers our goal of finding high-quality, rather than optimal, solutions with minimal computation time.
4. R EGRET A PPROXIMATION M ODEL
Calculating the global regret of an edge in the TSP graph requires solving the TSP itself, which is computationally intractable.
Instead, we aim to learn a function ˆ r ij that approximates the regret of an edge r ij .
We use GNNs to achieve this, as they are universal function approximators that operate on graph-structured data.
Input transformation
Typically, GNNs aggregate messages and store states on the nodes of a graph (Gilmer et al., 2017).
Instead, we input the line graph of the original problem graph into our model.
The line graph L ( G ) of an undirected graph G is a graph such that there exists a node in
L ( G ) for every edge in G , and that for every two edges in G that share a node, there exists an edge between their corresponding nodes L ( G ) .
Figure 2 illustrates this transformation for a simple graph.
The result is that our model aggregates messages and stores states on the edges of the problem graph (the nodes of the line graph).
Primarily, this allows us to build models with no node features, which is advantageous as the edge weights, not the specific node locations, are relevant when solving the TSP.
For a complete, undirected graph G with n nodes, there are n ( n − 1) / 2 nodes and n ( n − 1)( n − 2) edges in L ( G ) .
Thus, although G is complete, L ( G ) can be very sparse.
Model architecture
Our model consists of an embedding layer, several GNN layers, and an output layer.
The embedding layer is an edge-wise fully connected layer that computes d h -dimensional edge embeddings from d x -dimensional edge features.
Node features, if used, are concatenated onto the feature set of the adjacent edges.
The forward pass of the embedding layer is written as
[Equation]
(5) where h 0 ij is the initial embedding of edge ij , W is a learnable weight matrix, x ij are the input features of edge ij (including any node features), and b is a set of learnable biases.
We use d x =and d h = 128 .
The edge embeddings are updated using T message passing layers.
Inspired by the encoder layer of Kool et al.
, each layer consists of multiple sublayers.
The forward pass is given by
[Equation]
where f MHA is a multi-headed GAT layer (Veliˇckovi´c et al., 2017), f FF is a feedforward layer, f BN is batch normalisation (Ioffe & Szegedy, 2015), and ˙ h t +1 u is a hidden state.
The layers do not share parameters.
The GAT layer uses M = 8 heads and dimensionality d h /M
= 16 , and the FF layer uses one hidden sublayer with dimensionality 512 and ReLU activation.
Finally, the output layer is a single edge-wise fully connected layer that computes a one-dimensional output from the d h -dimensional node embeddings computed by the final message passing layer.
This is written as
[Equation]
where ˆ r ij is the output for edge ij and h
Tij is the final embedding of that edge.
4. R EGRET -G UIDED L OCAL S EARCH
We adapt GLS to use regret to solve the TSP, including how the initial solution is built, the local search procedure, and the perturbation strategy.
Our GLS uses alternating optimization and perturbation phases.
During an optimization phase, the local search procedure greedily accepts changes to the solution until it reaches a local minimum.
During a perturbation phase, the algorithm penalizes and attempts to remove edges in the current solution with high regret, thus allowing it to escape local minima while simultaneously guiding it towards promising areas of the solution space, i.e., those with low regret.
Effectively, the regret predictions produced by our model allow our GLS algorithm to undo costly decisions made during the greedy optimization phase.
Initial solution We use a greedy nearest neighbor algorithm to construct an initial solution.
Beginning from the origin node we iteratively select the lowest-regret edge leading to an unvisited node, until all nodes have been visited.
Local Search neighborhoods Our LS procedure uses two solution operators for the TSP, relocate and 2-opt .
It alternates between using either operator, and uses a “best improvement” strategy, meaning that it exhaustively searches the neighborhood corresponding with the current operator and accepts the solution that improves the objective function the most before continuing with the other operator.
The algorithm terminates when no improvement can be found in either neighborhood.
The relocate operator simply changes the position of a single node in the tour.
The 2-opt operator selects two nodes in the tour to swap.
This divides the tour into three segments: an initial segment, an intermediate segment, and a final segment.
The tour is reassembled beginning with the initial segment, the intermediate segment in reverse order, and the final segment.
It is a special case of the κ -opt operator (Lin & Kernighan, 1973), although it was introduced earlier (Croes, 1958).
Perturbation strategy We define the cost of an edge as the predicted regret ˆ r ij of that edge.
The utility of penalizing edge ij , util ij , is therefore defined as
[Equation]
where we remind the reader that s ∗ is the solution at a local optimum, I ij ( s ∗ ) indicates if the solution contains edge ij , and p ij is the number of penalties assigned to that edge.
The edges of maximum utility are penalized.
Afterward, the local search is applied only on the penalized edge.
That is, only operations that would remove the penalized edge are considered.
E XPERIMENTS
We train our model using supervised learning.
It uses a single input feature, edge weight (i.e. the
Euclidean distance between adjacent nodes), to predict the regret of the edges in the problem graph.
Further details of our implementation are found in Appendix A. While further input features could be considered, they come at a computational cost, as seen in Table 4.
In Appendix D, we compare 11 input features, and demonstrate that edge weight is the most important feature when predicting the regret of an edge.
Evaluation We evaluate the trade-off between solution quality and computation time when solving randomly generated TSPs as well as TSPLIB instances 1 .
Where available, we use publicly available implementations and pre-trained models.
There is no publicly available implementation of Arnold & S¨orensen (2019a), so we use the GLS implementation described in section 4.3 with the guides described in their paper.
We compare our approach to the following methods, the first six of which are non-learning based, and the other three are learning based:
Nearest Neighbour 2.
Farthest Insertion 3.
Local Search (as described in section 4.3) 4.
Concorde (Applegate et al., 2006) 5.
LKH-3 (Helsgaun, 2017) 6.
Knowledge-guided local search for the vehicle routing problem (Arnold & S¨orensen, 2019a) 7.
Attention, learn to solve routing problems!
(Kool et al., 2018) 8.
An efficient graph convolutional network technique for the travelling salesman problem (Joshi et al., 2019) 9.
Learning 2-opt heuristics for the traveling salesman problem via deep reinforcement learning (da Costa et al., 2020)
Following Guidelines for the computational testing of machine learning approaches to vehicle routing problems (Accorsi et al., 2021), we conduct two types of experiments.
1) we leave both computation time and solution quality unfixed.
We measure the mean optimality gap and computation time per instance across the entire problem set.
We use implementations as-described.
2) we fix computation time and measure the solution quality, in terms of mean optimality gap and the number of instances solved optimally.
This allows for a direct comparison of approaches that was impossible in the first experiments and previous works.
Where possible, we modified implementations to run continuously until the computation time limit is reached.
We allow up to 10 seconds to solve each problem, including the time required to calculate input features, evaluate a model, or to construct an initial solution.
We evaluate the problem sets one instance at a time, which allows us to accurately measure computation time per instance.
We allow parallelism in the GPU to sample multiple solutions to a single problem at once, where implementations are configured to do so.
We use a common, single CPU and single GPU setup for all experiments.
More details on the experimental setup and the hyperparameters of different approaches are given in Appendix A.
We conduct both types of experiments on three problem sets, TSP20, TSP50, and TSP100, consisting of one thousand 20, 50, and 100-node 2D Euclidean TSP instances, respectively.
We generate the instances by uniform-randomly sampling node locations in the unit square [0 , 1] 2 , which is in line with the methods used by Kool et al.
; Joshi et al.
(2019); da Costa et al.
In the second type of experiment (fixed computation time), we focus on the learning based approaches and keep Concorde as a benchmark.
Furthermore, we evaluate the generalization performance of the learning based approaches from smaller to larger problem sets, and from the randomly generated instances to TSPLIB instances, which are meant to represent real-world problems.
Results The performance of each approach when computation time and solution quality are unfixed is shown in Table 1.
Approaches that are not dominated by others (i.e. they produce higherquality solutions or are faster) are bolded.
These values form a Pareto front for the trade-off between solution quality and computation time.
Non-learning and learning approaches are considered separately.
Our approach always lies on the Pareto front.
These results are visualized in Figure 3 in
Appendix B.1.
To better evaluate this trade-off, the second experiment fixes computation time and measures the solution quality as it evolves over time.
Figure 4 in Appendix B.2 visualizes the performance as a function of time, which provides a rich understanding of the trade-off made by each approach.
Table 2 shows the performance of the learning based approaches after 10 seconds of computation time per instance.
Our approach finds better solutions on average than the other approaches for all problem sets.
Notably, we reduce the mean optimality gap on the 50-node problem set from 0.268% to 0.009%, a 30 × times improvement, and on the 100-node problem set from 1.534% to 0.705%, a
[Table]
2 × improvement.
Joshi et al.
(2019) finds more optimal solutions to the TSP100 problem set, but has worse average performance than our approach.
Our approach finds more optimal solutions to the TSP20 and TSP50 problem sets than the other approaches.
We evaluate the performance of our approach and other learning based approaches when generalizing from smaller instances to larger ones, and from randomly generated instances to TSPLIB instances, which are meant to represent real-world instances.
These results are summarized in Appendix C.1 and Appendix C.2 respectively.
Our approach generalizes well.
Notably, when generalizing from 20-node instances to the 100-node problem set, we reduce the mean optimality gap from 18.845% to 2.622%, a 7 × improvement.
D ISCUSSION
The results presented in Table 1 align with the results presented by Kool et al.
and da Costa et al.
The results presented for Joshi et al.
(2019) differ, due to an implentation error we found in their code (see Appendix A for the correction).
However, our experiments using a fixed computation time to directly compare approaches demonstrate that our approach converges to optimal solutions at a faster rate the compared learning based approaches (Kool et al., 2018; Joshi et al., 2019; da Costa et al., 2020) when solving the Euclidean TSP.
Our approach generalizes to larger problems and to real-world problems better than the other learning based approaches.
This may be as a result of the unique input transformation we apply to the problem graph.
We input the line graph L ( G ) of the problem graph G , which allows the model to aggregate messages and store states on edges rather than nodes.
This allows us to build models
[Table]
without node features, which is advantageous as the edge weights, not the specific node positions, are relevant when solving the TSP.
Including the node positions as features, as done by Kool et al.
; Joshi et al.
(2019); da Costa et al.
(2020) may hinder the learned policy’s ability to generalize.
Deudon et al.
(2018) apply PCA on the node positions before inputting them into their model so they are rotation invariant, yet they do not report generalization performance.
For a Euclidean
TSP problem graph with n nodes, L ( G ) has n ( n − 1) / 2 nodes, meaning that although G is complete, L ( G ) can be very sparse, which may help learning (Cappart et al., 2021).
However, the model consumes more GPU memory than models using the problem graph G .
Many approaches that learn construction heuristics (for example Kool et al., 2018) treat the tour as a permutation of the input nodes.
By considering the solution as a sequence, these approaches miss out on its symmetry: a TSP solution is invariant to the origin city.
Outputting the correct sequence, even when augmented by beam search, becomes increasingly difficult as the number of cities increases.
This has recently been addressed by Kwon et al.
(2021), who leverage the symmetry of the TSP in their approach.
Our model learns the regret of including a given edge in the solution based on its features and those of its neighbors.
This learning task implicitly assumes the symmetry of a TSP solution and leverages the strengths of GNNs.
Our approach is not specific to the TSP, however one disadvantage is that it relies on an explicitly designed local search algorithm.
To apply our framework to another problem, the local search procedure must be modified with operators that are appropriate for that problem.
For example, a local search procedure for the CVRP requires intra-route operators (such as 2-opt and relocate) and inter-route operators.
In future work, our regret approximation model could be combined with a general learned local search algorithm and could be trained end-to-end.
End-to-end training would also remove the need for training set, which becomes cumbersome to produce for larger problems.
C ONCLUSION
We present a hybrid data-driven approach for solving the TSP based on Graph Neural Networks (GNNs) and Guided Local Search (GLS).
To inform GLS, we use a GNN-based model to compute fast, generalizable approximations of the global regret of each edge.
Our model operates on the line graph of the TSP graph, which allows us to build a network that uses edge weight alone as an input feature.
This approach allows our algorithm to escape local minima and find high-quality solutions with minimal computation time.
Finally, we present experimental results for our approach and several recent learning based approaches that emphasize the trade-off between solution quality and computation time.
We demonstrate that our approach converges to optimal solutions at a faster rate than the evaluated learning based approaches.
A I MPLEMENTATION DETAILS
We conduct all computational experiments on virtual machines using a single core of an Intel Xeon
E5-2650 v4 processor, 24 GB of RAM, and a single Tesla P100 GPU with 16 GB of VRAM.
We evaluate the various approaches one-at-a-time, to ensure they do not compete for computational resources.
When evaluating the various approaches, we record actual tours and use a common method of calculating tour cost and optimality gap, as we found that small discrepancies in cost calculations between implementations led to skewed results.
We recommend this approach when comparing different approaches for solving the TSP.
Based on approximately 200,000 TSP solutions, we determined that an absolute threshold of 10 − 7 on the value of the objective function is sufficient to separate optimal and sub-optimal solutions.
We train our model on sets of one hundred thousand 20, 50, and 100-node 2D Euclidean TSP instances.
We generate all instances by uniform-randomly sampling node locations in the unit square [0 , 1] 2 .
We calculate the target output, the regret of including each edge in the solution, according to eq.
We use Concorde to find an optimal solution and LKH-3 with 100 trials and 10 runs to solve find an optimal solution with a given edge fixed.
We empirically validate that this configuration for
LKH-3 is sufficient to find optimal solutions for problems with 100 nodes or less.
We scale the input features and target outputs to a range of [0 , 1] .
We train our model by minimizing the l 2 loss to the target output using the Adam optimizer (Kingma & Ba, 2014) and an exponentially decaying learning rate γ = 10 − 3 × (0 . 99) e , where e is the epoch.
We train the model for 100 epochs with early stopping.
We use a training batch size B = 32 for the 20 and 50-node training sets, and a training batch size of B = 15 for the 100-node training set due to limited GPU memory.
Our model uses T = 3 message passing layers and our GLS algorithm uses K = 20 perturbation moves.
Our approach is implemented using Python 3.8.11, PyTorch 1.9.0 (Paszke et al., 2019), DGL 0.7.1 (Wang et al., 2019), and CUDA 10.2, and is open-source.
We use the open-source implementation of Kool et al.
(2018) with the best configuration, which samples 1280 solutions in parallel.
We use this implementation as-is for experiments where computation time is not fixed.
We modified the implementation to continuously sample 1280 solutions until the computation time limit is reached for experiments where computation time is fixed.
We use the open-source implementation of da Costa et al.
(2020) with the best configuration, which uses 2000 iterations.
We use this implementation as-is for experiments where computation time is not fixed.
We modified the implementation to iterate until the computation time limit is reached for experiments where computation time is fixed.
We used the open-source implementation of Joshi et al.
We found a programming error in their beamsearch implementation that caused invalid tours to be reported.
We modified their implementation to detect invalid tours and discarded them when they are produced.
Our changes are shown in Listing 1.
Therefore, our results may differ from those originally reported by the authors.
Listing 1: Programming error fix for Joshi et al.
(2019) 1 diff --git a/utils/model_utils.py b/utils/model_utils.py 2 index 491b630..
ad554c03 --- a/utils/model_utils.py 4 +++ b/utils/model_utils.py 5 @@ -5,6 +5,12 @@ import torch.nn as nn from utils.beamsearch import * from utils.graph_utils import * 8 9 +def is_valid(tour): 10 + nodes = set(tour) 11 + for n in nodes: 12 + if tour.count(n) !
= 1: 13 + return False 14 + return True 15def loss_nodes(y_pred_nodes, y_nodes, node_cw): """ 18 @@ -143,7 +149,12 @@
def beamsearch_tour_nodes_shortest(y_pred_edges, x_edges_values, beam_size, batc if hyp_len < shortest_lens[idx] and is_valid_tour(hyp_nodes, num_nodes): shortest_tours[idx] = hyp_tours[idx] shortest_lens[idx] =
hyp_len 22return
shortest_tours
+ 24 + shortest_tours_list = shortest_tours.cpu().numpy().tolist() 25 + tour_is_valid =
np.array([is_valid(tour) for tour in shortest_tours_list]) 26 + if not tour_is_valid.all(): 27 + print(shortest_tours, tour_is_valid)
28 + return shortest_tours, tour_is_valid 29 def update_learning_rate(optimizer, lr):
B C OMPARISON TO OTHER APPROACHES B. P ERFORMANCE CHARTS
Following the guidelines in Accorsi et al.
[Figure]
we measure the mean optimality gap and computation time per instance, while both are unfixed.
Figure 3 depicts the performance of the evaluated non-learning and learning based approaches averaged across the entire 20,
[Figure]
and 100-node problem sets.
The axes are scaled so the plots are easily readable.
Results that fall outside the plot limits are shown with an arrow pointing towards the horizontal axis at the mean computation time.
These plots clearly identify Pareto optimal approaches and dominated ones
[Figure]
t
[Figure]
t
[Figure] [Figure]
B. C ONVERGENCE PROFILE CHARTS
We evaluate the solution quality, in terms of mean optimality gap and number of problems solved optimally, as a function of computation time over a fixed computation time.
The resulting convergence profile provides a detailed view of how each approach trades off between solution quality and computation time.
Figure 4 depicts convergence profiles for our approach and several recent learning based approaches, for models trained and evaluated on 20, 50, and 100-node problem instances.
Computation time required to compute input features, evaluate a model
[Figure]
or to construct an initial solution is visible as a gap between the trace and the vertical axis
[Figure]
and is especially noticeable for Joshi et al.
[Figure]
[Figure]
C G ENERALIZATION PERFORMANCE C. G ENERALIZATION TO LARGER INSTANCES
Figure 5 depicts convergence profiles for the learning based approaches when generalizing from smaller problem instances to larger ones.
The plots are arranged in order of increasing difference in size between the training and test problem sets
[Figure]
[Figure]
[Figure] [Figure]
Ours
Concorde
[Figure]
U nd e r r e
v
i e w a s a c on f e r e n ce p a p e r a t
I C L
R
C. G ENERALIZATION TO REAL - WORLD INSTANCES
In many cases there may be insufficient examples of real-world problem instances to train a model, meaning it must be trained on synthetic data.
Therefore, it is important to evaluate this “sim-to-real” transfer.
Table 3 shows mean optimality gap and computation time for the evaluated learning based methods using models trained on random 100-node TSPs and evaluated on TSPLIB instances with 50 to 200 nodes and 2D Euclidean distances (29 instances).
[Table]
0.163±0.000 pr 0.226±0.
0.816±0.
4.378±0.
27.793±0.
39.485±0.
1.228±0.
10.049±0.
0.039±0.000 rat 0.347±0.
2.645±0.
5.559±0.
17.633±0.
32.188±0.
0.123±0.
9.948±0.
0.550±0.000 kroA 0.352±0.
4.017±0.
5.705±0.
28.828±0.
42.095±0.
18.313±0.
10.255±0.
0.728±0.000 kroB 0.352±0.
5.142±0.
5.712±0.
34.686±0.
35.137±0.
1.119±0.
10.317±0.
0.147±0.
kroC 0.352±0.
0.972±0.
5.641±0.
35.506±0.
34.333±0.
0.349±0.
10.172±0.
1.571±0.000 kroD 0.352±0.
2.717±0.
5.621±0.
38.018±0.
25.772±0.
0.866±0.
10.375±0.
0.572±0.000 kroE 0.352±0.
1.470±0.
5.650±0.
26.589±0.
34.475±0.
[Table]
270±
[Table]
216±
[Table]
407±
[Table]
[Table]
[Table]
eil
[Table]
[Table]
[Table]
lin
[Table]
[Table]
[Table]
517±
[Table]
[Table]
867±
[Table]
[Table]
330±
[Table]
[Table]
391±
[Table]
933±
[Table]
[Table]
964±
[Table]
[Table]
564±
[Table]
[Table]
[Table] [Table] 499± [Table]
677±
[Table]
[Table]
146±
[Table]
[Table]
570±
[Table]
322±
[Table]
360±
[Table]
[Table]
000 bier
[Table]
5.908±
[Table]
.242±
[Table]
45.561±
[Table]
[Table]
[Table]
044±
[Table]
[Table]
260±
[Table]
[Table]
[Table]
182±
[Table]
351±
[Table]
39.090±0.
34.436±0.
0.709±0.
10.032±0.
3.519±0.000 pr 0.585±0.
5.064±0.
7.727±0.
58.673±0.
31.056±0.
0.000±0.
10.379±0.
3.387±0.000 pr 0.638±0.
7.641±0.
8.132±0.
55.837±0.
28.913±0.
1.526±0.
10.276±0.
3.581±0.000 ch 0.697±0.
4.584±0.
8.546±0.
49.743±0.
35.497±0.
0.312±0.
10.109±0.
2.113±0.000 kroA 0.695±0.
3.784±0.
8.450±0.
45.411±0.
29.399±0.
0.724±0.
10.331±0.
2.984±0.000 kroB 0.696±0.
2.437±0.
8.573±0.
56.745±0.
29.005±0.
0.886±0.
10.018±0.
3.258±0.000 pr 0.708±0.
7.494±0.
8.632±0.
33.925±0.
29.003±0.
0.029±0.
10.267±0.
3.119±0.000 u 0.764±0.
7.551±1.
9.012±0.
38.338±0.
28.961±0.
0.054±0.
10.428±0.
1.020±0.000 rat 1.114±0.
6.893±0.
11.236±0.
24.968±0.
34.425±0.
0.743±0.
12.295±0.
1.666±0.000 d 1.153±
[Table]
373.020±45.
11.519±0.
62.351±0.
30.864±0.
0.522±0.
12.596±0.
4.772±0.000 kroA 1.150±0.
7.106±0.
11.702±0.
40.885±0.
33.832±0.
1.441±0.
11.088±0.
2.029±0.000 kroB 1.150±0.
8.541±0.
11.689±0.
43.643±0.
31.951±0.
2.064±0.
11.267±0.
2.589±0.
D A NALYSIS OF ADDITIONAL INPUT FEATURES
We evaluate the potential benefit of adding additional features to our regret approximation model.
While more features can help produce better predictions, they come at the cost of additional computation time.
We consider a total of ten additional features, described in Table 4.
We use a Gaussian process-based surrogate model to conduct global sensitivity analysis (Gratiet et al., 2016) of the input features on the validation loss of the model after training.
We assume that better regret predictions will equate to better guidance by the GLS algorithm, ultimately resulting in better performance to the problem sets.
[Table]
k where node j is the k -nearest neighbor of i .
There are two features for a given edge, the rank of i w.r.t.
j and the rank of j w.r.t.
i
[Table]
Θ
[Table] [Table]
If the edge is part of the k -nearest neighbor graph, where k is 0.3 n .
[Table]
If the edge is part of the k -nearest neighbor graph, where k is 0.2 n .
[Table]
If the edge is part of the k -nearest neighbor graph, where k is 0.1 n
[Table]
If the edge is part of the minimum spanning tree, calculated using Prim’s algorithm (Prim, 1957).
[Table]
If the edge is part of solution constructed by the nearest neighbor heuristic.
[Table]
If the edge is part of solution constructed by the nearest insertion heuristic.
[Table]
help produce better predictions, and thus better guidance for the GLS algorithm, they come at the cost of additional computation time.
We semi-randomly sample 100 input feature sets using Latin hypercube sampling (McKay et al., 1979).
We train a model using each of these feature sets for 35 epochs without early stopping and record the final validation loss.
Using these results, we fit a Gaussian process to emulate the mapping between the feature set F = { f 0 , f 1 , . . .
, f 10 } , and the validation loss l achieved by our model after training, where f n indicates whether or not feature n is used.
We then compute Monte-Carlo estimates of the main and total effects of each input feature on the model’s validation loss (Saltelli, 2002).
Our implementation uses Emukit (Paleyes et al., 2019).
Figure 6 depicts the estimated total effect for each input feature.
Edge weight is the most important feature, followed by neighbor rank, depot weight, edge width, and node width.
The remaining features have little to no importance.
We train a model using these top five features on 20-node problems and compare its performance to the equivalent model using edge weight as the only feature when solving the 20, 50, and 100node problem sets.
The performance of both models at the computation time limit is shown in
Table 5.
While the model using additional input features produces slightly more accurate regret predictions, any benefit is cancelled out by the additional time required to compute these features.
Note that the results are slightly different from those reported in Figure 5 due to different training hyperparameters.
10 % N
N g r a p h
N I s o l u t i o n N N s o l u t
i o n 20 % N
N g r a p h 30 % N
N g r a p h
M S T
N o d
e w i d t h
E dg e w i
d t h
D e p o t w e i g h t
N e i g
h b
o u r r a n k
E dg e w e
i g h t 0.
[Figure]
[Table]
input features produces slightly more accurate regret predictions, any benefit is cancelled out by the additional time required to compute these features.