RP-DQN: An application of Q-Learning to Vehicle Routing Problems

Ahmad BdeirEqual contribution Simon BoederX Tim Dernedde^()X Kirill TkachukX Jonas K. Falkner Lars Schmidt-Thieme

University of Hildesheim, 31141 Hildesheim, Germany

In this paper we present a new approach to tackle complex routing problems with an improved state representation that utilizes the model complexity better than previous methods. We enable this by training from temporal differences. Specifically Q-Learning is employed. We show that our approach achieves state-of-the-art performance for autoregressive policies that sequentially insert nodes to construct solutions on the CVRP. Additionally, we are the first to tackle the MDVRP with machine learning methods and demonstrate that this problem type greatly benefits from our approach over other ML methods.

§ INTRODUCTION

Routing problems are very important in business and industry applications. Finding the best routes for delivery vehicles, finding the best pick up order of trading goods in a warehouse or the optimal machine paths in a manufacturing factory are just a few examples for such problems. Due to their importance, many of these problems have been thoroughly studied and the traditional operations research community has identified a wide variety of problem types including various constraints and developed many heuristics for solving these [Balas, 1989, Christofides, 1979, Bräysy and Gendreau, 2005, Bertsimas and Van Ryzin, 1991, Beasley, 1983, Braun, 1990, Christofides et al., 1981]. Recently, the Machine Learning (ML) community has proposed to learn heuristics with models instead of handcrafting them. The main advantage of ML methods is that once initially trained, they can solve new problem instances very quickly, while traditional heuristics solve every problem individually which in the general case takes up significantly more time.

As optimal labeled solutions are expensive or intractable to compute, usually Reinforcement Learning (RL) is employed to optimize these models. Specifically, various forms of the REINFORCE [Williams, 1992] algorithm were applied [Bello et al., 2016, Nazari et al., 2018, Kool et al., 2019, Falkner and Schmidt-Thieme, 2020]. A recent method by Kool et al., 2019 has proven to find good solutions on a variety of problem types including the capacitated vehicle routing problem (CVRP). Their architecture consists of an encoder and decoder setup that constructs the tour sequentially. The encoder computes a representation of the graph and its nodes and is run once in the beginning of the tour construction. Then the decoder is applied on the embeddings repeatedly to add nodes to the solution until the tour is finished. This method is limited to static node features, since the encoder is applied only once. Using dynamic features, and hence a more rich representation, would require the encoder to be run at every step. This quickly becomes memory-expensive when using REINFORCE, as all intermediate representations have to be stored over the whole episode in order to execute backpropagation.

Motivated by this limitation, we propose a model that enables the use of dynamic features in the encoder. Encoder and decoder are then applied in every step. To make this memory-feasible, we optimize our model with a temporal-difference algorithm. When learning only on single transitions, the intermediate representations do not have to be stored for the whole episode. Specifically, we will use Q-Learning [Mnih et al., 2015].

We show that the improved state representation leads to performance improvements on the CVRP. Additionally, we show that our approach is more sample efficient which can be an important factor when environments become more complex and expensive to compute. Finally, we show, when extending to more complicated problems like the Multiple Depot Vehicle Routing Problem (MDVRP), the improved state representation is of even greater importance. As to our knowledge we are the first to explore the MDVRP with RL-methods, thus we extended the model by Kool et al., 2019 to solve the MDVRP and compare to our approach and several established OR-methods.

§ RELATED WORK

The operations research community has studied a plenitude of different routing problems over the last 70 years. Various different soft and hard constraints, objective functions and other problem properties like stochasticity have been considered and many optimal and heuristic solution approaches with and without formal guarantees were proposed. As a comprehensive overview in this context is not possible the following related work will focus on the ML literature. We refer the reader to a survey by Toth and Vigo, 2014.

Machine Learning has largely considered two approaches for solving routing problems. The first one autoregressively inserts one node at a time from a partial tour until a solution is complete. Vinyals et al., 2015 proposed the Pointer-Network and used this approach to tackle the TSP. Their model was learnt from optimal examples. As these are expensive, Bello et al., 2016, Nazari et al., 2018 proposed approaches that used RL for optimization. Specifically, variants of REINFORCE [Williams, 1992] were employed and the problem catalogue was extended to the CVRP. Kool et al., 2019 then proposed an encoder-decoder model based on the Transformer architecture and showed that good solutions can be learnt for various related problem types for instances with up to 100 nodes. Falkner and Schmidt-Thieme, 2020  proposed an extension to incorporate time windows. While both also use variants of REINFORCE, Khalil et al., 2017 built a graph model based on S2V optimized with Q-Learning. Instead of directly inserting the predicted next node, they choose its position with a best insertion heuristic. However their results on the TSP were only comparable with simpler constructive heuristics like farthest insertion [Rosenkrantz et al., 2009]. The autoregressive approaches have considered different search algorithms to use during inference, like Sampling, Beam Search and Active Search.

The second paradigm that was considered with ML approaches is the use of improvement heuristics. They operate on initial solutions and improve these repeatedly. Usually local search is applied. Traditionally, Meta-heuristics like Large-Neighbourhood Search (LNS) or Guided-Local Search (GLS) are used in conjunction with local search operators like 2-opt to avoid local minima. Various Meta-heuristics and local operators are implemented in Perron and Furnon, 2019. ML approaches here range from only learning the initial solution and then applying a traditional method [Zhao et al., 2020] to learning to perform local search [Wu et al., 2020, Chen and Tian, 2019].

Other approaches that do not fit these two categories include constructing a tour non-autoregressively by predicting a heatmap of promising edges with a graph convolutional neural network [Joshi et al., 2019], augmenting traditional dynamic programming approaches for Routing with deep learning [Kool et al., 2021] and changing the action space from nodes to full tours and solving the sub-problem of the best route to insert [Delarue et al., 2020].

§ PROBLEM DEFINITION

We consider two problem variants in this paper: the CVRP and the MDVRP.

§.§.§ CVRP

The problem can be described by a graph $G(N, E)$, where $N = C \cup D$ is the set of nodes consisting of customers $C = \{1,...,n\}$ and one depot $D=\{n+1\}$. Each customer $c \in C$ has a positive demand $d$. We assume a complete graph, thus the set of edges $E$ contains an edge $e_{i,j}$ representing the distance for every pair of nodes $(i, j) \in N$.  We also assume a fleet of homogeneous vehicles $K$ having the same maximum Capacity $Q$ with no restriction on the fleet size. For a valid solution all customers have to be visited exactly once. All routes must start and end at the depot. For all routes the total sum of demands must satisfy the maximum vehicle capacity. As an objective we want to minimize the total sum of distances. This formulation is also used by other works like [Kool et al., 2019, Bello et al., 2016]. Note however that other formulations with limited, heterogeneous vehicles or other objective functions are possible.

§.§.§ MDVRP

The MDVRP generalizes this problem by allowing for multiple depots $D=\{n+1, ..., n+m\}$. We require that every vehicle ends at the same depot that it has started but the model is allowed to decide at which depot a vehicle should start. Again note that other problem formulations are possible. Vehicles could be fixed and set to certain depots or allowed to return to any depot instead of the one they started for instance.

§ METHOD

We base our architecture on the model by Kool et al., 2019. First we present the original model and then show which adaptions our new approach makes as well as how solutions are constructed for the CVRP and MDVRP and how the model is optimized.

§.§ Original Attention-Model

The attention model [Kool et al., 2019] solves routing problems using an encoder-decoder architecture and learns a policy model $\pi$ that autoregressively inserts one node at a time until a solution is complete.

§.§.§ Encoder

The encoder takes the set of nodes $N$ consisting of the customer nodes and the depot node and creates an embedding of each node. The node features consist of the coordinates and the demand. These features are considered static, meaning they don't change during decoding. Thus the node embeddings are calculated once at the beginning of the episode and are reused at each step.

The encoder creates initial node embeddings $h_i$ by applying a node-wise linear projection, scaling up every node to the embedding dimension $h_{dim}=128$. $h_i$ represents the $i$-th node embedding. To differentiate between the depot node and the customer nodes, weights are not shared and two projections are learned.

\begin{equation}
h_i^{(0)}=W^{\mathrm{node}} n_i+b^{\mathrm{node}}
\end{equation}

\begin{equation}
h_0^{(0)}=W^{\mathrm{depot}} n_0+b^{\mathrm{depot}}
\end{equation}

These embeddings are then updated through $L$ attention blocks (AB):

\begin{equation}
H^{(L)}=\mathrm{AB}_L (…(\mathrm{AB}_1 (H^{(0)} )))
\end{equation}

where  $H$ is a concatenation of the initial embeddings, and $L=3$ for VRPs. Every block AB consists of a multi-head self-attention layer (MHA) [Vaswani et al., 2017], a node-wise feed-forward layer (FF), along with batch normalization (BN) [Ioffe and Szegedy, 2015] and skip connections (skip).

\begin{equation}
\mathrm{AB}(H^{(l)} )=\mathrm{BN}\,({\mathrm{FF^{skip}}} \,(\mathrm{BN}\,(\mathrm{MHA^{skip}} \,(H^{(l-1)} ))))
\end{equation}

where the MHA layer uses 8 heads. The $\mathrm{FF^{skip}}$ layer has one sublayer with ReLU activation and an intermediate dimension of size 512.

\begin{equation}
\mathrm{FF^{skip}}(h_i) = W_2\, \mathrm{max}(0, W_1h_i+b_1) + b_2 + h_i
\end{equation}

§.§.§ Decoder

The decoder is run at every timestep $t$ and parametrizes a probability distribution over all the nodes. It takes a context $C^{(t)}=[h^{\mathrm{graph}};c^{(t)};h^{\mathrm{last}}]$ as input, where $h^{\mathrm{graph}}$ is the mean of the node embeddings, $c^{(t)}$ is the current vehicle capacity and $h^{\mathrm{last}}$ refers to the node embedding of the last position. This context is transformed with another MHA layer, where the context only attends to nodes that are feasible in this timestep. This is done with a mask $M$. Note that the context is the query and the node embeddings are the keys of this layer. In contrast the encoder computes the self attention between all pairs of nodes. The decoder instead only computes attention between context and node embeddings to arrive at a transformed context $\hat{C}^{(t)}$. This avoids the memory quadratic complexity of the MHA-layer.

\begin{equation}
\hat{C}^{(t)} = \mathrm{MHA}\,(C^{(t)}, H, M)
\label{eq:inner masking}
\end{equation}

Now, compatibility scores $u_i$ between the transformed context and the nodes are calculated as in a Single-Head Attention (SHA) mechanism where the context is again the query:

\begin{equation}
u_i = \frac{W^q\hat{C}^{(t)}W^kh_i}{\sqrt{d_k}}
\end{equation}

This gives a single value for each node and infeasible nodes are masked with $-\infty$. To arrive at the final probabilities, a softmax is applied. For more details, we refer the reader to the original paper by Kool et al., 2019.

§.§ RP-DQN

Architecture overview

Most of the models complexity is in the encoder, however it only considers the static components of the problem. The dynamic information that can be used in the context is quite constrained. The original model has very limited access to information about which nodes have already been visited or are infeasible due to other constraints. The only time this information is passed is in equation <ref> with an inner masking that prevents attention from infeasible nodes to the context. We feel that using dynamic node features in the encoder makes the model more expressive and utilizes its complexity better. However, in that case the encoder has to be executed in every step. As discussed already, to make this memory feasible, our model is optimized with Q-Learning. Thus, our model also has to output Q-values instead of probabilities and therefore we get rid of the softmax. The inner masking is also not needed anymore and we omit it completely.

Now, the four dynamic features $\mu_i^{(t)},\rho_i^{(t)},\tau_i^{(t)},\phi_i^{(t)}$ represent boolean variables that indicate whether at timestep $t$ the node $i$ has already been inserted in the tour, cannot currently be inserted due to capacity constraints, represents the current position of the vehicle or in the multi-depot case represents the current depot.

\begin{align}
\mu_i^{(t)} &=
\begin{cases}
1 & \text{if } i\in \mathcal{R}^{(t)} \\
0 &\text{otherwise}
\end{cases} \\[0.5cm]
\tau_i^{(t)} &=
\begin{cases}
1 & \text{if } i\in \mathcal{R}^{(t)} \wedge i\notin \mathcal{R}^{(t-1)} \\
0 &\text{otherwise}
\end{cases}
\end{align}

\begin{align}
\rho_i^{(t)} &=
\begin{cases}
1 & \text{if } d_i^{(t)} > c^{(t)} \\
0 &\text{otherwise}
\end{cases}\\[0.5cm]
\phi_i^{(t)} &=
\begin{cases}
1 & \text{if } i \text{ is active depot} \\
0 &\text{otherwise}
\end{cases}
\end{align}

$\mathcal{R}^{(t)}$ is the set of customer nodes that have been visited at time $t$. Then the set of node features for the CVRP includes $[x_i, y_i, d_i^{(t)},\mu_i^{(t)},\rho_i^{(t)},\tau_i^{(t)}]$, where $x_i$ and $y_i$ are the coordinates of node $i$ and $d_i^{(t)}$ is the demand. $d_i^{(t)} = 0$ for nodes that have been served at timestep $t$. In the MDVRP case, $\phi_i^{(t)}$ is also added to the set of node features. The rest of the architecture stays the same. Although it potentially could be simplified, we opted to stay close to the original architecture. We show that performance improvements come mainly through our better state representation. Our model is called Routing Problem Deep Q-Network (RP-DQN). An architecture overview can be seen in Figure <ref>.

§.§.§ MDVRP Decoding

For the MDVRP we expand the context by the current depot embedding. This is done for our model as well as for our extension of the model by Kool et al., 2019 to the MDVRP. Next we describe the decoding procedure. In the first step the model has not selected any node yet. We mask all customers and force it to select a depot. This depot becomes the current depot and the model selects nodes until it chooses to come back to the current depot. We don't allow for back to back depot selection and the model cannot come back to a different depot than it started from. After a route is completed the model can start another route by choosing the next depot and the procedure is repeated until all customers are inserted. The Q-values of infeasible actions are masked with $-\infty$.

§.§.§ Q-Learning

To optimize our model we implemented Double DQN [Mnih et al., 2015, Hasselt et al., 2016] with $N$-step returns and a prioritized replay buffer [Schaul et al., 2015]. We found $N=1$ to work best. For exploration, we experimented with Boltzman-Exploration [Sutton and Barto, 2018] with decaying softmax temperature and $\epsilon$-Greedy with decaying $\epsilon$. In the end we used $\epsilon$-Greedy and linearly decayed the rate over half of the total training episodes. Although Boltzman-Exploration initially speeds up the convergence, the model also plateaus at slightly higher costs than with $\epsilon$-Greedy.

§ EXPERIMENTS

§.§ Baselines

For the CVRP we differentiate baselines from four different categories. The first category includes specialized solvers. Gurobi [Gurobi Optimization, 2021] was used in Kool et al., 2019 as an optimal solver for the CVRP. This becomes intractable for instances with more than 20 customers, thus the highly optimized LKH3 [Helsgaun, 2017] was employed by Kool et al., 2019 alternatively. It transforms constrained problems into TSPs via penalty functions and other means and then solves those heuristically. The second category consist of ML approaches that construct solutions sequentially and use greedy inference. We compare our model with the approaches by Kool et al., 2019, Nazari et al., 2018, Falkner and Schmidt-Thieme, 2020. The third category also includes ML based approaches with sequential construction, but this time using sampling or beam search inference. We compare with the same models as in the previous category. Our model, Kool et al., 2019 and Falkner and Schmidt-Thieme, 2020 use sampling while Nazari et al., 2018 uses beam search. The last category encompasses improvement heuristics that use local search. We include it for completeness sake. They operate on an initial solution and improve it iteratively by selecting solutions in the neighborhood. OR-Tools [Perron and Furnon, 2019] is a classical approach using meta-heuristics while Wu et al., 2020 is a machine learning approach. For the MDVRP, no ML baselines are available. Thus, we adapt the model by Kool et al., 2019 to support MDVRP and train it ourselves. We set up the decoding procedure and context as for our model. For a traditional baseline we stick to Google OR-Tools as it provides a flexible modeling framework. However OR-Tool does not provide an out of the box MDVRP solver, thus we use the CVRP framework and simulate the MDVRP by setting different starting and finishing points to the vehicles.

§.§ Data

For the training of the model we will generate data. We will create data with $|C| = {20,50,100}$ and train a model for each of these. In the main experiments, the problem size stays the same for training and testing. Additionally, we conducted a generalization study that shows how the models perform on different problem sizes, which can be seen in Appendix <ref>. Since the data can be generated unlimitedly, we will use every problem instance only once and generate new data after every episode. Note that the data can be generated with various different properties. For instance, the customers can have a special alignment in grids or star-like structures, be sampled uniformly or according to some other distribution. In order to compare, our data generation follows Nazari et al., 2018. Their dataset is used by most of the ML literature. For testing we have used the exact test set that was provided by Nazari et al., 2018 for each problem size. It consists of 10,000 instances that were generated with the same properties as the training data. It uses the euclidean distance. Demands $d \in [1,9]$ are sampled uniformly. Coordinates are sampled uniformly from the unit square. Vehicles have capacity 30, 40 and 50 depending on the problem size. For the MDVRP we generate the data in the same fashion and create our own test set.

§.§ CVRP Results

Table <ref> shows that our approach outperforms all other models that construct the solution by sequentially selecting nodes. This applies for both greedy and sampling inference. Only the improvement method by Wu et al., 2020 achieves better results. However, improvement heuristics operate on an initial solution and will try to improve this repeatedly. It has been shown that these approaches scale to better final performance when given a better initial starting solution [Zhao et al., 2020]. Thus better approaches to find initial solutions like ours can be used to kick-start improvement methods like OR-Tools or the machine learning approach by Wu et al., 2020. We also notice that our percentage gain increases with the problem size, stressing the importance of dynamic features for larger, real world problems. Appendix <ref> gives a more detailed comparison including the timings of some of the methods.

CVRP Results

2c|6*[1.6em]Method     6cProblem Size
2c|   2c20   2c50   2c100

2c|   Mean   Gap %   Mean   Gap %   Mean   Gap %
1l2[-2pt]Specialized Solver   	1l|Gurobi						   6.1	   0.00	   -	   -	   -	   -

1l   												1l|LKH3								   6.14	   0.66	   10.38	   0.00	   15.65	   0.00

1l3[-14pt]Sequential Policy (Greedy)   	1l|RP-DQN	   6.36	   4.26	   10.92	   5.20	   16.59	   6.01

1l   																	1l|Kool			   6.4	   4.92	   10.98	   5.78	   16.8	   7.35

1l   																	1l|Falkner			   6.47	   6.07	   11.44	   10.21	   -	   -

1l   																	1l|Nazari			   6.59	   8.03	   11.39	   9.73	   17.23	   10.10

1l3[-2pt]Sequential Policy (Sampling/Beam search)   	1l|RP-DQN (1024s)	   6.24	   2.30	   10.59	   2.02	   16.11	   2.94

1l   															1l|Kool (1280s)			   6.25	   2.46	   10.62	   2.31	   16.23	   3.71

1l   															1l|Falkner (1280s)			   6.26	   2.62	   10.84	   4.43	   -	   -

1l   															1l|Nazari (10bs)			   6.4	   5.41	   11.31	   8.96	   17.16	   9.65

1l2[-1pt]Local Search   	1l|Wu (5000 steps)							   6.12	   0.33	   10.45	   0.67	   16.03	   2.43

1l   											1l|OR-Tools								   6.43	   5.41	   11.31	   8.96	   17.16	   9.65

§.§ MDVRP Results

In Table <ref> an even greater lift as for the CVRP can be seen. The model by Kool et al., 2019 reaches only subpar performance when the problem size increases. We attribute the results to the more powerful state representation of our model. We assume that this has more impact on the MDVRP as it is a more complicated problem than the CVRP. We also want to highlight that training our model is much more memory efficient compared to the standard model by Kool et al., 2019.

MDVRP Results

3*[-5pt]Method     6cProblem Size
2c20   2c50   2c100

Mean   Gap %   Mean   Gap %   Mean   Gap %
RP-DQN - Greedy   5.48   2.62   8.04   4.15   11.99   4.08

Kool - Greedy   5.68   6.37   8.84   14.51   13.17   14.32

RP-DQN - Sampling 1024   5.34   0.00   7.72   0.00   11.52   0.00

Kool - Sampling 1024   5.42   1.50   8.11   5.05   12.15   5.47

OR-Tools   6.74   26.23   9.02   16.84   12.92   12.15

§.§ Learning Curves

In Figure <ref> we exemplify the learning behavior of both models on the MDVRP with 50 customers run on the same hardware. Due to the use of a buffer, the sample efficiency is improved greatly. While this is less important for simple environments, it has significant impact for problems that are more expensive to compute. For routing, this can include environments with more hard and soft constraints, stochastic components and objective functions that trade-off multiple goals. Figure <ref> shows that the learning of our model starts off slower, however we always converge significantly faster.

tick style=draw=none,
title=MDVRP50 – Wall Clock Time,
ylabel=Mean Cost,

grid = major,
major grid style=line width=.2pt,draw=gray!50,
axis lines=left,
axis line style=-,
every axis plot/.append style=line width=2pt,
xtick = 0,20,...,100,
[on background layer]
[dashed,fill=gray!6,opacity=1, draw=none] (axis cs:0,8) rectangle (axis cs:87.1,10);

[color=myblue1] table [x=hours ,y=Value, col sep=comma, each nth point=1, mark=none] kool.csv;
[color=myred1] table [x=hours ,y=Value, col sep=comma, each nth point=1, mark=none] ours.csv;
[dashed] (axis cs:0,8) rectangle (axis cs:87.1,10);

no markers,
axis background/.style=fill=gray!6,
tick style=draw=none,
grid = major,
major grid style=line width=.2pt,draw=gray!50,
axis lines=left,
axis line style=-,
width=- - ,
every axis plot/.append style=line width=2pt,
xtick = 0,20,...,100,
[color=myblue1] table [x=hours ,y=Value, col sep=comma, each nth point=1, mark=none] kool.csv;
[color=myred1] table [x=hours ,y=Value, col sep=comma, each nth point=1, mark=none] ours.csv;

[fill=white, dashed]let 1 = (current axis.south west), 2 = (current axis.north east) in (1-,1-)rectangle (2+, 2+);
no markers,
label style=font=, align=right,
y tick label style=at=(yticklabel cs:-0.05,0),
anchor=near yticklabel,
inner sep=0pt,,
ticklabel style = font=,
axis background/.style=fill=gray!6,
tick style=draw=none,
grid = major,
major grid style=line width=.2pt,draw=gray!50,
axis lines=left,
axis line style=-,
width=- - +10,
every axis plot/.append style=line width=2pt,
xtick = 0,20,...,100,

[color=myblue1] table [x=hours ,y=Value, col sep=comma, each nth point=1, mark=none] kool.csv;
[color=myred1] table [x=hours ,y=Value, col sep=comma, each nth point=1, mark=none] ours.csv;

no markers,
tick style=draw=none,
title=MDVRP50 – Samples,
xlabel=Samples (in Mio),

grid = major,
major grid style=line width=.2pt,draw=gray!50,
axis lines=left,
axis line style=-,
every axis plot/.append style=line width=2pt,
xtick = 0,20,...,130,
legend entries=Kool et al., RP-DQN,
legend cell align=left,
legend style = at=(axis cs:130,25),anchor=north east,

[color=myblue1] table [x expr=samples*1e-6 ,y=Value, col sep=comma, each nth point=1, mark=none] kool.csv;
[color=myred1] table [x expr=samples*1e-6 ,y=Value, col sep=comma, each nth point=1, mark=none] ours.csv;

Learning Curves for the MDVRP with 50 customers comparing the wall clock time and sample efficiency.

§ CONCLUSION

In this paper we present a new approach to tackle complex routing problems based on learning from temporal differences, specifically through Q-Learning, when optimizing autoregressive policies that sequentially construct solutions by inserting one node at a time for solving routing problems. We showed that this learning procedure allows the incorporation of dynamic node features, enabling more powerful models which lead to state-of-the-art performance on the CVRP for autoregressive policies. Additionally, the sample efficiency is greatly improved. Although our model still falls short of specialized solvers like LKH3 and improvement methods, it is useful to find very good initial solutions. Future work could include combining powerful initial solution finders like RP-DQN with improvement heuristics.
We also demonstrated that the dynamic components become more important for the MDVRP, a problem type that was not explored with RL before. We assume that this holds for other more complicated problem types like CVRP with time windows. Future work could include extending our model to these problem types. Further, more work is needed to improve generalizability. This could include training on broader distributions and building automatic data generators from real life datasets.

§.§.§ Acknowledgement

This work is co-funded via the research project L2O[<https://www.ismll.uni-hildesheim.de/projekte/l2o_en.html>] funded by the German Federal Ministry of Education and Research (BMBF) under the grant agreement no. 01IS20013A and the European Regional Development Fund project TrAmP[<https://www.ismll.uni-hildesheim.de/projekte/tramp.html>] under the grant agreement no. 85023841.

§ RUNTIME COMPARISON

Reporting the runtime is difficult as it can differ in order of magnitudes due to implementation differences (C++ vs Python) and hardware. Kool et al., 2019 thus decided to report the runtime over the complete test set of 10,000 instances. Other literature like Wu et al., 2020 has followed them. We feel that this adds another layer of obscurity over the runtime comparison as they then decided to parallelize over multiple instances. ML approaches were parallelized via batch computation. Most traditional methods are single threaded CPU applications. They were parallelized over instances by launching more threads if the CPU has them available. We feel that for practical applications if enough instances have to be solved for instance parallelization to be useful, the corresponding hardware can be bought. More important is the time it takes to solve a single instance or alternatively the time it takes to solve the 10,000 instances when not parallelizing over instances. In Table <ref> we collect some timings reported by the literature and our own. Note that the timings are not directly comparable due to the discussed reasons. Also note that most methods have some way of trading performance and time off. Beam Searches can have bigger width, more solutions can be sampled and improvement methods can make more steps. Additionally, none of the methods will improve indefinitely but hit diminishing returns instead. Thus there are more and less reasonable spots to trade-off. Ultimately however, this is also application dependent. Reporting full trade-off curves for all of the methods is not possible.

CVRP Results and Timings to solve all 10,000 instances

3*[-4pt]Method     6cProblem Size
2c20   2c50   2c100

Mean   Time    Mean   Time    Mean   Time
Gurobi			   6.1	   -	   -	   -	   -	   -

LKH3			   6.14	   (2h$\ssymbol{1}$)	   10.38	   (7h$\ssymbol{1}$)	   15.65	   (13h$\ssymbol{1}$)
RP-DQN – Greedy			   6.36	   (3s$\ssymbol{2}$/10min$\ssymbol{8}$)		   10.92	   (14s$\ssymbol{2}$/30min$\ssymbol{8}$)	   16.59	   (50s$\ssymbol{2}$/78min$\ssymbol{8}$)

Kool – Greedy			   6.4	   (1s$\ssymbol{2}$)	   10.98	   (3s$\ssymbol{2}$)	   16.8	   (8s$\ssymbol{2}$)

RP-DQN – 1024s	   6.24	   (52m$\ssymbol{7}$)		   10.59	   (5h$\ssymbol{7}$)	   16.11	   (15h$\ssymbol{7}$)

Kool – 1280s	   6.25	   (6m$\ssymbol{7}$)	   10.62	   (28m$\ssymbol{7}$)	   16.23	   (2h$\ssymbol{7}$)
Wu (5000 steps)    6.12	   (2h$\ssymbol{2}$)		   10.45	   (4h$\ssymbol{2}$)	   16.03	   (5h$\ssymbol{2}$)

OR-Tools		   6.43	   (2m$\ssymbol{3}$)		   11.31	   (13m$\ssymbol{3}$)	   17.16	   (46m$\ssymbol{3}$)

* $\ssymbol{1}$32 instances were solved in parallel on two CPUs [Kool et al., 2019].

* $\ssymbol{2}$Time for solving many instances in parallel through GPU batch computation.

* $\ssymbol{3}$Time reported by Wu et al., 2020. Only one Thread.

* $\ssymbol{7}$Time for solving one instance at a time.

* $\ssymbol{8}$Time for solving one instance at a time on CPU

Our method is extremely quick in greedy and then takes more time the more samples are used. This behaviour is respectively the same for the Kool model although our model expectedly takes more time as the encoder is run at every step. 15 hours for the size 100 model with sampling seems high, however consider that one instance was solved at a time, thus a single instance still only takes less than 6 seconds. The only two methods that have better results are LKH3 and Wu et al., 2020's improvement approach. For both the time was only reported with a high degree of instance parallelization, thus it should be expected that our model takes less time than them on a fair single instance comparison.

Additionally, 1024 samples is already at a point on the trade-off curves where there are negligible performance improvements as can be seen in figure <ref>.

every tick label/.append style=font=
every axis label/.append style=font=
every axis title/.append style=font=

/pgf/number format/1000 sep=,
scale only axis,
xlabel=Number of Samples,
axis x line=bottom,
axis y line=box,
xmin=, xmax=,
ymin=6.2, ymax=6.6,
xtick = 1,250,500, ..., 1500,
every axis plot/.append style=line width=1.5pt,

ytick = 6.2,6.4,6.6,
axis lines=left,
axis line style=-,

[color=myred1, mark=pentagon*, mark options=scale=1,solid,] 			table [x=samples, y=mean, col sep=semicolon, each nth point=1,] tradeoff20.csv;
[color=myred1, mark=none, dashed, domain=-100:1600, samples=2] 6.36;

scale only axis,
ylabel=Mean Tour Cost,
axis x line=none,
axis y line=box,
xmin=, xmax=,
ymin=10.55, ymax=11.1,
every axis plot/.append style=line width=1.5pt,

axis lines=left,
axis line style=-,

[color=myblue1, mark=pentagon*, mark options=scale=1,solid,] 			table [x=samples, y=mean, col sep=semicolon, each nth point=1,] tradeoff50.csv;
[color=myblue1, mark=none, dashed, domain=-100:1600, samples=2] 10.92;

scale only axis,
title=Trade-Off Curve,
axis x line=none,
axis y line*=box,
xmin=, xmax=,
ymin=16, ymax=16.8,

every axis plot/.append style=line width=1.5pt,

axis lines=left,
axis line style=-,
[color=mygreen1, mark=pentagon*, mark options=scale=1,solid,] 			table [x=samples, y=mean, col sep=semicolon, each nth point=1,] tradeoff100.csv;
[color=mygreen1, mark=none, dashed, domain=-100:1600, samples=2] 16.59;

[dotted] (a.north west) – (b.south west);

[dotted] (b.north west) – (c.south west);

/pgf/number format/1000 sep=,
align = center,
scale only axis,

at=($(a.south east)+(2cm,0)$),
anchor = south west,

title=Trade-Off Curve,
xlabel=Number of Samples,
ylabel=Cost Improvement %,
height=0.4 ,

axis lines=left,
axis line style=-,

every axis plot/.append style=line width=1.5pt,
xtick = 1,250,500, ..., 1500,

legend entries=Sampling CVRP20, Greedy CVRP20, Sampling CVRP50, Greedy CVRP50, Sampling CVRP100, Greedy CVRP100,
legend cell align=left,
legend style = at=(axis cs:1500,0),anchor=south east,font=,

[color=myred1, mark=pentagon*, mark options=scale=1,solid,] 			table [x=samples, y=normalized, col sep=semicolon, each nth point=1,] tradeoff20.csv;
[color=myred1, mark=none, dashed, domain=-100:1600, samples=2] 2.453823368;

[color=myblue1, mark=pentagon*, mark options=scale=1,solid,] 			table [x=samples, y=normalized, col sep=semicolon, each nth point=1,] tradeoff50.csv;
[color=myblue1, mark=none, dashed, domain=-100:1600, samples=2] 0.748010618;

[color=mygreen1, mark=pentagon*, mark options=scale=1,solid,] 			table [x=samples, y=normalized, col sep=semicolon, each nth point=1,] tradeoff100.csv;
[color=mygreen1, mark=none, dashed, domain=-100:1600, samples=2] 0.685569965;

This figure shows how much additional samples improve the solution quality.

§ GENERALIZATION STUDY

This study tests the ability to generalize. All models were trained on one size and tested on instances between 20 and 200 nodes. Figure <ref> shows the percentage gap to the best model from both inference settings.

align = center,
tick style=draw=none,
title=MDVRP Generalization
Greedy Inference,
xlabel=Number of Customers,
ylabel=Percentage Gap to best model,
grid = major,
major grid style=line width=.2pt,draw=gray!50,
axis lines=left,
axis line style=-,

every axis plot/.append style=line width=1.5pt,
xtick = 20,50,100,200,

[color=myred3, mark=pentagon*, mark options=scale=1,solid,] 			table [x=Dataset Size, y=Ours20 g, col sep=semicolon, each nth point=1,] generalization_mdvrp.csv;
[color=myred2, mark=square*, mark options=scale=1,solid,] 			table [x=Dataset Size, y=Ours50 g, col sep=semicolon, each nth point=1] generalization_mdvrp.csv;
[color=myred1, mark=triangle*, mark options=scale=1,solid,]  			table [x=Dataset Size, y=Ours100 g, col sep=semicolon, each nth point=1] generalization_mdvrp.csv;
[color=myblue3, dashed, mark=pentagon*, mark options=scale=1,solid,] 	table [x=Dataset Size, y=kool20 g, col sep=semicolon, each nth point=1,] generalization_mdvrp.csv;
[color=myblue2, dashed, mark=square*, mark options=scale=1,solid,] 	table [x=Dataset Size, y=kool50 g, col sep=semicolon, each nth point=1,] generalization_mdvrp.csv;
[color=myblue1, dashed, mark=triangle*, mark options=scale=1,solid,] 	table [x=Dataset Size, y=kool100 g, col sep=semicolon, each nth point=1, ] generalization_mdvrp.csv;

align = center,
tick style=draw=none,
title=MDVRP Generalization
xlabel=Number of Customers,
grid = major,
major grid style=line width=.2pt,draw=gray!50,
axis lines=left,
axis line style=-,

every axis plot/.append style=line width=1.5pt,
xtick = 20,50,100,200,

legend entries=RP-DQN 20, RP-DQN 50, RP-DQN 100, Kool 20, Kool 50, Kool 100,
legend cell align=left,
legend style = at=(axis cs:20,40),anchor=north west,font=, draw=none, fill=none,

[fill=white, draw=none] (axis cs:20.43,39.94) rectangle (axis cs:115, 17);
[color=myred3, mark=pentagon*, mark options=scale=1,solid,] 			table [x=Dataset Size, y=Ours20 s, col sep=semicolon, each nth point=1,] generalization_mdvrp.csv;
[color=myred2, mark=square*, mark options=scale=1,solid,] 			table [x=Dataset Size, y=Ours50 s, col sep=semicolon, each nth point=1] generalization_mdvrp.csv;
[color=myred1, mark=triangle*, mark options=scale=1,solid,]  			table [x=Dataset Size, y=Ours100 s, col sep=semicolon, each nth point=1] generalization_mdvrp.csv;
[color=myblue3, dashed, mark=pentagon*, mark options=scale=1,solid,] 	table [x=Dataset Size, y=kool20 s, col sep=semicolon, each nth point=1,] generalization_mdvrp.csv;
[color=myblue2, dashed, mark=square*, mark options=scale=1,solid,] 	table [x=Dataset Size, y=kool50 s, col sep=semicolon, each nth point=1,] generalization_mdvrp.csv;
[color=myblue1, dashed, mark=triangle*, mark options=scale=1,solid,] 	table [x=Dataset Size, y=kool100 s, col sep=semicolon, each nth point=1, ] generalization_mdvrp.csv;

This figure shows the generalization to different problem sizes.

urlstyle[Balas, 1989]
Balas, E.: The prize collecting traveling salesman problem. Networks
19(6), 621–636 (1989)

[Beasley, 1983]
Beasley, J.E.: Route first—cluster second methods for vehicle routing. Omega
11(4), 403–408 (1983)

[Bello et al., 2016]
Bello, I., Pham, H., Le, Q.V., Norouzi, M., Bengio, S.: Neural combinatorial
optimization with reinforcement learning. CoRR  (2016),

[Bertsimas and Van Ryzin, 1991]
Bertsimas, D.J., Van Ryzin, G.: A stochastic and dynamic vehicle routing
problem in the euclidean plane. Operations Research 39(4), 601–615

[Braun, 1990]
Braun, H.: On solving travelling salesman problems by genetic algorithms. In:
International Conference on Parallel Problem Solving from Nature, pp.
129–133, Springer (1990)

[Bräysy and Gendreau, 2005]
Bräysy, O., Gendreau, M.: Vehicle routing problem with time windows, part
: Route construction and local search algorithms. Transportation
science 39(1), 104–118 (2005)

[Chen and Tian, 2019]
Chen, X., Tian, Y.: Learning to perform local rewriting for combinatorial
optimization. In: Advances in Neural Information Processing Systems, vol. 32,
Curran Associates, Inc. (2019)

[Christofides, 1979]
Christofides, N.: Combinatorial optimization. A Wiley-Interscience Publication

[Christofides et al., 1981]
Christofides, N., Mingozzi, A., Toth, P.: Exact algorithms for the vehicle
routing problem, based on spanning tree and shortest path relaxations.
Mathematical programming 20(1), 255–282 (1981)

[Delarue et al., 2020]
Delarue, A., Anderson, R., Tjandraatmadja, C.: Reinforcement learning with
combinatorial actions: An application to vehicle routing. In: Advances in
Neural Information Processing Systems, vol. 33, pp. 609–620, Curran
Associates, Inc. (2020)

[Falkner and Schmidt-Thieme, 2020]
Falkner, J.K., Schmidt-Thieme, L.: Learning to solve vehicle routing problems
with time windows through joint attention  (2020),

[Gurobi Optimization, 2021]
Gurobi Optimization, L.: Gurobi optimizer reference manual  (2021)

[Hasselt et al., 2016]
Hasselt, H.v., Guez, A., Silver, D.: Deep reinforcement learning with double
q-learning. In: Proceedings of the Thirtieth AAAI Conference on Artificial
Intelligence, p. 2094–2100, AAAI'16, AAAI Press (2016)

[Helsgaun, 2017]
Helsgaun, K.: An extension of the Lin-Kernighan-Helsgaun
solver for constrained traveling salesman and vehicle routing problems
(2017), 10.13140/RG.2.2.25569.40807

[Ioffe and Szegedy, 2015]
Ioffe, S., Szegedy, C.: Batch normalization: Accelerating deep network training
by reducing internal covariate shift. In: Proceedings of the 32nd
International Conference on Machine Learning, Proceedings of Machine Learning
Research, vol. 37, pp. 448–456, PMLR, Lille, France (2015)

[Joshi et al., 2019]
Joshi, C.K., Laurent, T., Bresson, X.: An efficient graph convolutional network
technique for the travelling salesman problem. CoRR  (2019),

[Khalil et al., 2017]
Khalil, E., Dai, H., Zhang, Y., Dilkina, B., Song, L.: Learning combinatorial
optimization algorithms over graphs. In: Advances in Neural Information
Processing Systems, vol. 30, Curran Associates, Inc. (2017)

[Kool et al., 2021]
Kool, W., van Hoof, H., Gromicho, J., Welling, M.: Deep policy dynamic
programming for vehicle routing problems  (2021),

[Kool et al., 2019]
Kool, W., van Hoof, H., Welling, M.: Attention, learn to solve routing
problems! In: International Conference on Learning Representations (2019)

[Mnih et al., 2015]
Mnih, V., Kavukcuoglu, K., Silver, D., Rusu, A.A., Veness, J., Bellemare, M.G.,
Graves, A., Riedmiller, M., Fidjeland, A.K., Ostrovski, G., Petersen, S.,
Beattie, C., Sadik, A., Antonoglou, I., King, H., Kumaran, D., Wierstra, D.,
Legg, S., Hassabis, D.: Human-level control through deep reinforcement
learning. Nature 518(7540), 529–533 (2015), ISSN 00280836,

[Nazari et al., 2018]
Nazari, M.R., Oroojlooy, A., Snyder, L., Takac, M.: Reinforcement learning for
solving the vehicle routing problem. In: Advances in Neural Information
Processing Systems, vol. 31, Curran Associates, Inc. (2018)

[Perron and Furnon, 2019]
Perron, L., Furnon, V.: OR-Tools 7.2  (2019)

[Rosenkrantz et al., 2009]
Rosenkrantz, D.J., Stearns, R.E., Lewis, P.M., Shukla, S.K.: An analysis of
several heuristics for the traveling salesman problem, pp. 45–69. Springer
Netherlands, Dordrecht (2009)

[Schaul et al., 2015]
Schaul, T., Quan, J., Antonoglou, I., Silver, D.: Prioritized experience replay
(2015), <http://arxiv.org/abs/1511.05952>

[Sutton and Barto, 2018]
Sutton, R.S., Barto, A.G.: Reinforcement Learning: An Introduction. The MIT
Press, second edn. (2018)

[Toth and Vigo, 2014]
Toth, P., Vigo, D.: Vehicle Routing: Problems, Methods, and Applications,
Second Edition. No. 18 in MOS-SIAM Series on Optimization, SIAM (2014), ISBN

[Vaswani et al., 2017]
Vaswani, A., Shazeer, N., Parmar, N., Uszkoreit, J., Jones, L., Gomez, A.N.,
Kaiser, L.u., Polosukhin, I.: Attention is all you need. In: Advances in
Neural Information Processing Systems, vol. 30, Curran Associates, Inc.

[Vinyals et al., 2015]
Vinyals, O., Fortunato, M., Jaitly, N.: Pointer networks. In: Advances in
Neural Information Processing Systems, vol. 28, Curran Associates, Inc.

[Williams, 1992]
Williams, R.J.: Simple statistical gradient-following algorithms for
connectionist reinforcement learning. Machine Learning 8(3-4),
229–256 (1992)

[Wu et al., 2020]
Wu, Y., Song, W., Cao, Z., Zhang, J., Lim, A.: Learning improvement heuristics
for solving routing problems (2020),

[Zhao et al., 2020]
Zhao, J., Mao, M., Zhao, X., Zou, J.: A hybrid of deep reinforcement
learning and local search for the vehicle routing problems. IEEE Transactions
on Intelligent Transportation Systems pp. 1–11 (2020),