NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

A Deep Reinforcement Learning Algorithm Using Dynamic Attention Model for Vehicle Routing Problems

Bo Peng, Jiahai Wang, Zizhen Zhang

Abstract

Recent research shows that machine learning has the potential to learn better heuristics than those designed by humans for solving combinatorial optimization problems. Deep neural networks are used to characterize input instances for constructing feasible solutions incrementally. Recently, an attention model was proposed to solve routing problems. In this model, the state of an instance is represented by node features that are fixed over time. However, the state of an instance changes according to the decisions made at different construction steps, and node features should be updated correspondingly. Therefore, this paper presents a dynamic attention model with a dynamic encoder-decoder architecture, which enables the model to explore node features dynamically and exploit hidden structure information effectively at different construction steps. This paper focuses on the challenging NP-hard vehicle routing problem (VRP). Experiments indicate that our model outperforms previous methods and shows good generalization performance.

Introduction

The Vehicle Routing Problem (VRP) is a fundamental NP-hard challenge in combinatorial optimization. It involves determining the most efficient set of routes for a fleet of vehicles to deliver goods to a specific set of customers, subject to capacity constraints. Traditionally, this has been solved using exact algorithms, which struggle with scalability, or hand-crafted heuristics that require significant domain expertise.

The VRP problem instance and a corresponding solution.

Recently, "Learning to Optimize" approaches using Deep Reinforcement Learning (DRL) have emerged. These models use neural networks to learn heuristics automatically. However, existing state-of-the-art models, such as the standard Attention Model (AM), often treat the problem as a static graph. They compute node embeddings once at the beginning and use them throughout the entire construction process. This approach fails to capture how the "state" of the problem evolves as customers are visited and vehicle capacity changes.

Methodology: The Dynamic Attention Model (AM-D)

To address the limitations of static embeddings, we propose the Dynamic Attention Model (AM-D). This model utilizes a dynamic encoder-decoder architecture based on the Transformer framework.

Comparison of encoder-decoder architectures for (a) language translation and (b) routing problems.

Dynamic Encoder-Decoder Architecture

The core innovation is the re-encoding of the graph. While a standard encoder creates fixed embeddings for each node (based on coordinates and demand), AM-D re-encodes the remaining unvisited nodes whenever a vehicle returns to the depot to begin a new route.

  1. Structural Masking: During re-encoding, nodes that have already been served are masked out. This forces the attention mechanism to focus exclusively on the "new" sub-problem formed by the remaining customers, effectively capturing the updated graph topology.
  2. Decoder Context: At each construction step, the decoder uses a context vector—representing the current node, the graph average, and the remaining vehicle capacity—to select the next node to visit.
  3. Training: The model is trained using the REINFORCE algorithm with a greedy rollout baseline to minimize variance and accelerate convergence.

By treating the remaining unvisited nodes as a fresh instance, the model can exploit the simplified structure of the "tail end" of the problem, which is inherently easier to solve than the original complex graph.

Experimental Results

We evaluated AM-D on synthetic VRP instances of varying sizes: VRP20, VRP50, and VRP100. Customers were randomly distributed in a unit square, with demands and vehicle capacities scaled appropriately.

Performance and Efficiency

AM-D consistently outperformed the vanilla Attention Model and other RL-based baselines. On VRP100, AM-D achieved an optimality gap of 4.79%, a significant improvement over the 7.34% gap of the standard AM. When combined with a simple 2OPT local search refinement, the gap further decreased to 3.96%.

While the dynamic re-encoding increases training time (approximately 250 hours for VRP100), the inference speed remains highly competitive. Solving a VRP20 instance takes only 0.29 milliseconds, making the model suitable for real-time logistics applications where rapid decision-making is critical.

Generalization

A key strength of AM-D is its generalization capability. Because the model learns to solve the "remaining" portion of a problem, a model trained on 100 nodes performs effectively on smaller instances (20 or 50 nodes), as it views them as the final stages of a larger routing task.

Conclusion

The Dynamic Attention Model demonstrates that updating node representations to reflect the evolving state of a combinatorial problem significantly improves solution quality. By re-encoding the graph at strategic intervals, AM-D captures structural information that static models miss. Future work will explore more flexible triggers for re-encoding and extend the model to handle more complex real-world constraints, such as time windows and stochastic demands.

Summary updated

BibTeX
@inproceedings{peng2019deep,
  author = {Bo Peng and Jiahai Wang and Zizhen Zhang},
  title = {{A Deep Reinforcement Learning Algorithm Using Dynamic Attention Model for Vehicle Routing Problems}},
  booktitle = {ISICA},
  year = {2019},
  url = {https://openreview.net/forum?id=LIx6Y0OHj8q},
}
Figure