Abstract
Vehicle Routing Problems (VRPs) in real-world applications often come with various constraints, therefore bring additional computational challenges to exact solution methods or heuristic search approaches. The recent idea to learn heuristic move patterns from sample data has become increasingly promising to reduce solution developing costs. However, using learning-based approaches to address more types of constrained VRP remains a challenge. The difficulty lies in controlling for constraint violations while searching for optimal solutions. To overcome this challenge, we propose a Reinforcement Learning based method to solve soft-constrained VRPs by incorporating the Lagrangian relaxation technique and using constrained policy optimization. We apply the method on three common types of VRPs, the Travelling Salesman Problem with Time Windows (TSPTW), the Capacitated VRP (CVRP) and the Capacitated VRP with Time Windows (CVRPTW), to show the generalizability of the proposed method. After comparing to existing RL-based methods and open-source heuristic solvers, we demonstrate its competitive performance in finding solutions with a good balance in travel distance, constraint violations and inference speed.
Introduction
The Vehicle Routing Problem (VRP) is a fundamental optimization challenge in logistics, requiring the determination of efficient routes for a fleet of vehicles. In real-world scenarios, these problems are rarely defined by distance alone; they are governed by "soft constraints" such as delivery time windows and vehicle capacity limits. Violating these constraints typically incurs financial or operational penalties, making the search for an optimal solution a complex trade-off between travel efficiency and feasibility.
Solving constrained VRPs is NP-hard. While traditional exact methods provide optimal solutions, they are often too computationally intensive for real-time applications. Conversely, hand-crafted heuristics require significant domain expertise. Recent advances in Reinforcement Learning (RL) have attempted to automate heuristic discovery, but many existing models rely on "masking"—simply blocking illegal moves. As shown in the comparison below, masking can be restrictive, potentially leading agents into local optima. This paper addresses these limitations by incorporating Lagrangian relaxation into the RL framework.
Methodology
The proposed framework treats the VRP as a Constrained Markov Decision Process (CMDP) and introduces three key innovations: Lagrangian relaxation, an iterative 2-exchange heuristic, and trajectory shaping.
Lagrangian Relaxation
Instead of treating constraints as hard barriers, they are integrated into the objective function using Lagrangian multipliers ($\lambda$). This transforms the problem into a balancing act where the agent minimizes total distance while $\lambda$ acts as a dynamic "price" for constraint violations. During training, $\lambda$ is updated iteratively to penalize violations based on the agent's performance, providing a smoother gradient signal for learning.
Iterative 2-Exchange Heuristic
Unlike "constructive" approaches that build routes from scratch, this model employs an iterative improvement strategy. The agent begins with an initial solution and learns to identify pairs of nodes to swap (a 2-exchange move) to refine the route. This approach is more robust; whereas a single poor choice in a constructive model can compromise the entire route, an iterative model can correct previous mistakes in subsequent steps.
Trajectory Shaping and Modified Rewards
To navigate the vast search space, the authors implement "post-action rejection," where moves that significantly degrade the solution are rejected with a certain probability during training. Furthermore, a custom reward function ($G_t$) utilizes a max operator over future states, encouraging the agent to prioritize moves that lead to the best possible subsequent configurations rather than just maximizing a simple cumulative average.
Evaluation and Results
The model was evaluated on simulated datasets for three VRP variants: TSPTW, CVRP, and CVRPTW, with problem sizes ranging from $N=20$ to $100$ customers.
Performance and Efficiency
In the TSPTW task ($N=100$), the proposed method achieved an objective value of 52.52, compared to the high-performance LKH3 heuristic's 51.09, while offering significantly faster inference. For the CVRP, the model matched state-of-the-art RL baselines but demonstrated a dramatic increase in speed, performing 10x to 60x faster during inference (e.g., 116 seconds vs. 7200 seconds for $N=100$).
Generalization
A key strength of the learned heuristic is its scale-agnostic nature. Models trained on 50 customers generalized effectively to problems with 20 or 100 customers without requiring retraining. This suggests that the agent learns fundamental patterns of efficient routing and constraint management that are applicable across different problem scales.
Conclusion
By treating constraints as "soft" penalties via Lagrangian relaxation, this RL framework achieves a superior balance between solution quality and computational efficiency. The iterative 2-exchange mechanism provides a robust search strategy that outperforms traditional constructive methods in constrained environments. Future work will explore extending this framework to "hard" constraints and enhancing inter-route optimization to further improve performance in multi-vehicle scenarios.
Summary updated