LMask: Learn to Solve Constrained Routing Problems with Lazy Masking

Tianyou Li, Haijun Zou, Jiayuan Wu, Zaiwen Wen · DOI

Introduction

Routing problems, such as the Traveling Salesman Problem (TSP), are foundational in logistics and supply chain management. While standard versions are well-studied, real-world applications often involve "hard" constraints—for example, a delivery must happen within a specific time window (TSPTW) or a ship must respect draft limits based on its load (TSPDL). Traditional solvers like Integer Linear Programming (ILP) become exponentially slow as constraints grow complex, while heuristic methods require manual tuning by experts.

LMask is a novel neural framework designed to solve these complex routing problems by introducing a "LazyMask" decoding algorithm. By combining an adaptive backtracking mechanism with a specialized embedding that tracks search history, LMask addresses the "feasibility dilemma" of neural constructive solvers—where a single bad choice leads to an unrecoverable dead end—achieving state-of-the-art feasibility rates and solution quality.

Methodology

The authors introduce three main innovations to the standard transformer-based encoder-decoder architecture to enable robust constraint handling:

  1. LazyMask Decoding: Instead of calculating a computationally expensive perfect "feasibility mask" upfront, LMask uses an "overestimation set" of possible moves. If the decoder hits a dead end, it backtracks to the previous step, marks the failed node as invalid (refining the mask "lazily"), and attempts a different path.
  2. Refinement Intensity Embedding (RIE): Standard neural solvers are often "memoryless" regarding their search path. RIE encodes the "search trace"—how many times a step has been refined—directly into the model. This allows the transformer to "know" it is currently recovering from a failure, resolving ambiguity when the model state looks identical across different attempts.
  3. Informed Initialization: To improve search efficiency, LMask utilizes Single-Step (SSL) or Two-Step Lookahead (TSL) to prune obviously impossible moves before decoding begins.
The LMask framework (top) and the LazyMask decoding process (bottom).

During training, the model employs Reinforcement Learning with an $\ell_1$ penalty for constraint violations, guiding the policy toward the feasible region even when the backtracking budget is constrained for speed.

Experimental Evaluation

The model was evaluated on several challenging benchmarks, including synthetic TSPTW and TSPDL datasets (50 and 100 nodes), the classic Dumas et al. benchmark, and a large-scale 500-node scalability test.

LMask sets a new high bar for neural constructive solvers across several metrics:

  • Feasibility: On "Hard" TSPTW-100 tasks, LMask achieved a 0.00% instance infeasibility rate, significantly outperforming previous state-of-the-art neural methods like PIP-D, which failed on 6.60% of instances.
  • Solution Quality: LMask consistently found shorter routes (smaller "Gap") than other neural methods. On TSPDL-100, it reduced the optimality gap to 4.24%, compared to over 10% for competitors.
  • Scalability: In tests with 500 nodes, LMask maintained a 0% infeasibility rate and a low 0.53% gap, while traditional solvers like OR-Tools failed to find any feasible solutions within the time limit.
Performance comparison on synthetic TSPTW datasets showing LMask's superior feasibility and objective gaps.

Key Insights and Conclusion

The core philosophy of LMask is that "laziness is efficiency." By only refining the mask when a path fails, the system saves massive amounts of computation while still guaranteeing a feasible solution (given sufficient backtracking budget). Theoretical analysis confirms that LMask will always find a feasible solution if one exists (given $R = \infty$) and that its probabilistic model converges toward optimal solutions as entropy regularization decreases.

While currently demonstrated on TSP variants, the "lazy masking" logic presents a promising path for more general combinatorial optimization problems. Future work may focus on closing the small remaining performance gap between LMask and the most powerful (though significantly slower) traditional exact solvers.

Summary updated

BibTeX
@inproceedings{li2026lmask,
  author = {Tianyou Li and Haijun Zou and Jiayuan Wu and Zaiwen Wen},
  title = {{LMask: Learn to Solve Constrained Routing Problems with Lazy Masking}},
  booktitle = {International Conference on Learning Representations},
  year = {2026},
  url = {https://openreview.net/forum?id=zsNUc2iMzp},
}
Figure