Improving Generalization of Deep Reinforcement Learning-based TSP Solvers

Wenbin Ouyang, Yisen Wang, Shaochen Han, Zhejian Jin, Paul Weng

Abstract

The Traveling Salesman Problem (TSP) is a fundamental NP-hard combinatorial optimization challenge. While deep reinforcement learning (DRL) has emerged as a promising method for learning fast heuristics, existing models often suffer from a significant "generalization gap," where performance degrades sharply when applied to problem sizes larger than those seen during training. This paper introduces MAGIC, a DRL framework designed for robust generalization. By combining a Graph Neural Network (GNN) architecture with interleaved local search heuristics and stochastic curriculum learning, MAGIC produces policies that generalize to 1000-city problems even when trained on instances with only 50 cities. Experimental results demonstrate that MAGIC achieves a superior balance of solution quality and computational efficiency compared to existing learning-based solvers.

Introduction

The Traveling Salesman Problem (TSP) requires finding the shortest possible route that visits a set of cities exactly once and returns to the origin. While exact solvers like Concorde provide optimal solutions, their computational cost becomes prohibitive as the number of cities ($N$) increases. Recent research has focused on using Deep Learning to learn heuristics that can approximate solutions much faster.

However, a persistent issue in the field is the generalization gap: a model trained on 20-city problems often fails to maintain accuracy on 1000-city problems. Current solutions tend to fall into two categories: those that generalize well but are computationally slow (e.g., using Monte Carlo Tree Search) and those that are fast but scale poorly. MAGIC aims to bridge this gap by providing high-quality solutions with fast execution and robust scaling capabilities.

Methodology

The MAGIC framework is defined by its unique architecture and training regime, summarized by its acronym components:

Architecture (M, A, G)

Unlike previous models that rely on complex LSTMs to encode the sequence of visited cities, MAGIC utilizes a simplified and more efficient encoder-decoder structure:

  • Encoder: A Graph Neural Network (GNN) captures the global topology of all cities, while a Multilayer Perceptron (MLP) encodes the state of the current city. This design recognizes that the spatial relationships between all cities are more critical than the specific order of previously visited cities.
  • Decoder: A standard Attention mechanism is employed to output a probability distribution over the remaining unvisited cities.
The MAGIC architecture comprising an encoder (GNN and MLP), an attention-based decoder, and a sampling process.

Training Strategy (I, C)

  • Interleaved Local Search (I): This is the core innovation of the framework. During training, the RL policy generates a tour that is immediately refined using a "Combined Local Search" (a mixture of random 2-opt and a novel "Local Insertion" heuristic). The model is updated based on the length of this improved tour, encouraging the policy to find "easy-to-fix" solutions that synergize with local optimizers.
  • Stochastic Curriculum Learning (C): To improve scaling, the training difficulty (number of cities) increases over time. The authors use a shifting normal distribution to sample problem sizes between 10 and 50 cities throughout the training epochs.
  • Policy Rollout Baseline: A simple, efficient baseline is used within the REINFORCE algorithm to reduce gradient variance without significant computational overhead.

Experimental Results

The model was evaluated on synthetic 2D Euclidean TSP instances. While training was limited to instances of $N=10$ to $N=50$, evaluation was conducted on both small-scale (TSP20-100) and large-scale (TSP200-1000) instances to test generalization.

Generalization and Efficiency

MAGIC demonstrates a superior trade-off between solution quality (the "gap" to the optimal solution) and computation time. On the most challenging TSP1000 benchmark, MAGIC achieved a gap of 10.49% relative to the optimal solution. In contrast, other popular DRL models like GPN exhibited gaps exceeding 63% or failed to scale entirely.

Performance comparison on large-scale TSP instances (TSP200, TSP500, TSP1000), highlighting MAGIC's generalization capabilities.

While some MCTS-based models achieve slightly smaller gaps, MAGIC is significantly faster. For example, on TSP500, MAGIC processes 128 instances in approximately 208 seconds, whereas MCTS-based approaches can take over 350 seconds for the same task.

Discussion and Conclusion

The success of MAGIC stems from the synergy between reinforcement learning and local search. By training the model to cooperate with a fast optimizer rather than seeking perfection in isolation, the framework learns to provide a high-quality "skeleton" that can be quickly polished. Ablation studies confirmed that every component—including the interleaved search and the curriculum learning—is essential for maintaining performance on large-scale problems.

Future work may involve extending this training procedure to other combinatorial optimization problems, such as the Vehicle Routing Problem (VRP), and further refining the GNN architecture to better capture complex spatial topologies in even larger instances.

Summary updated

BibTeX
@inproceedings{ouyang2021improving,
  author = {Wenbin Ouyang and Yisen Wang and Shaochen Han and Zhejian Jin and Paul Weng},
  title = {{Improving Generalization of Deep Reinforcement Learning-based TSP Solvers}},
  booktitle = {SSCI},
  year = {2021},
  url = {https://openreview.net/forum?id=bO2GGUQpAG},
}
Figure