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

An Agentic Framework with LLMs for Solving Complex Vehicle Routing Problems

Ni Zhang, Zhiguang Cao, Jianan Zhou, Cong Zhang, Yew-Soon Ong

TL;DR

This paper introduces AFL, a fully autonomous, multi-agent LLM framework that writes complete, executable Python solvers for complex Vehicle Routing Problems (VRPs) from scratch. By breaking the coding process into manageable subtasks and using specialized agents to write, review, and debug the code, AFL achieves a 100% success rate in generating feasible solutions, matching the performance of heavily hand-crafted algorithms without needing human intervention.

What Problem Does This Paper Address?

Vehicle Routing Problems (VRPs)—like figuring out the optimal delivery routes for a fleet of Amazon trucks—are notoriously difficult combinatorial optimization tasks. In the real world, they come with a dizzying array of constraints: time windows, vehicle capacities, electric battery limits, and mixed pickup/delivery requirements.

Historically, solving a new VRP variant required operations research experts to spend months designing custom mathematical models or heuristics. While recent Machine Learning (ML) methods help, they still require manual tweaking for new constraints. Some researchers have tried using Large Language Models (LLMs) to write VRP solvers automatically, but these attempts usually fall into two traps: they either rely heavily on external solvers (like OR-Tools) which causes integration bugs, or they fail to handle complex constraints, resulting in generated code that crashes or produces invalid routes. The authors tackle this by asking: Can we build an LLM framework that reads raw problem files and reliably writes a fully self-contained, bug-free solver from scratch?

Methods

The authors propose the Agentic Framework with LLMs (AFL). Instead of asking an LLM to write a solver in one shot, AFL decomposes the pipeline into three subtasks, managed by four specialized LLM agents:

  1. Generation Agent (GA): Writes the initial text and code.
  2. Judgment Agent (JA): Acts as a strict code reviewer and constraint checker.
  3. Revision Agent (RA): Fixes issues flagged by the JA.
  4. Error Analysis Agent (EAA): Reads Python tracebacks to debug runtime crashes.
The Agentic Framework with LLMs (AFL) pipeline, detailing the three subtasks: Problem Description, Code Generation, and Solution Derivation.

The pipeline flows through three stages:

  • Problem Description: The agents read the raw .vrp text file, extract the domain knowledge, and explicitly list the constraints, inputs, and objectives.
  • Code Generation: The agents write a "destroy-insert" heuristic solver step-by-step. (Destroy-insert is a standard routing algorithm that iteratively ruins a piece of a route and tries to stitch it back together more efficiently). The JA and RA iteratively review and refine each function (e.g., distance calculation, route initialization, constraint validation) before moving to the next.
  • Solution Derivation: The generated Python code is executed. If it crashes, the EAA analyzes the error, and the RA/JA loop steps back in to patch the bug until the code runs successfully.

Datasets

The framework was evaluated on a massive suite of 60 VRP variants, making it one of the most comprehensive evaluations of an LLM for routing. This includes:

  • 48 standard benchmarks (CVRP, VRPTW, Open Routes, Multi-Depot, etc.) using 1,000-instance datasets.
  • 8 practical Electric VRPs (ECVRPTW) based on the Schneider et al. (2014) benchmark.
  • 4 classical routing problems in broader settings: TSPLIB (Traveling Salesman), ATSP (Asymmetric TSP), ACVRP, and SOP (Sequential Ordering Problem).
  • CVRPLib-XXL to test scalability on massive instances (up to 16,000+ customers).

Key Insights and Ideas

  • Agentic Collaboration is Non-Negotiable: Ablation studies show that without the Judgment and Revision agents, the LLM frequently hallucinates constraints and spits out broken code. The iterative "write-check-fix" loop is the secret sauce that makes LLM code generation viable for strict mathematical optimization.
  • Self-Containment Beats External Solvers: By forcing the LLM to write the entire heuristic in Python rather than just writing a script that calls an external library, the system actually understands the constraints better. It avoids the misalignment bugs that plague systems trying to blindly prompt OR-Tools.
  • Direct from Raw Data: AFL doesn't need a human to translate the problem into a neat prompt. It reads the raw, standardized .vrp text files directly, figures out the constraints (e.g., "this instance has time windows and battery limits"), and builds the solver accordingly.

Key Results

  • Unprecedented Trustworthiness: AFL achieved a 0% Runtime Error Rate and a 100% Success Rate (producing feasible solutions) across the tested variants. For context, competing LLM methods like SGE and DRoC had massive error rates of 94.1% and 82.4%, respectively.
  • Highly Competitive Performance: On standard benchmarks, AFL's generated solvers perform within a 3% gap of the state-of-the-art, human-engineered HGS-PyVRP solver. On complex Electric VRPs, it outperforms standard ACO (Ant Colony Optimization) and Greedy heuristics.
Performance comparison of AFL against state-of-the-art solvers across various VRP variants and instance sizes.
  • Speed: It takes the framework approximately 30 minutes to generate a fully working, debugged solver for a brand new VRP variant—a fraction of the time it would take a human expert.

Limitations and Future Work

  • Performance Ceiling: While highly competitive, the generated solvers do not yet surpass the absolute best human-designed solvers (like HGS) on heavily studied, conventional problems like the standard CVRP. The authors view this as an acceptable trade-off for full automation.
  • Future Directions: The authors plan to incorporate evolutionary search strategies to help the LLM explore different algorithmic designs. They also want to optimize the generated code not just for route efficiency (objective value), but for computational execution speed.

Summary updated

BibTeX
@inproceedings{zhang2026agentic,
  author = {Ni Zhang and Zhiguang Cao and Jianan Zhou and Cong Zhang and Yew-Soon Ong},
  title = {{An Agentic Framework with LLMs for Solving Complex Vehicle Routing Problems}},
  booktitle = {International Conference on Learning Representations},
  year = {2026},
  url = {https://openreview.net/forum?id=BMOgYw4EhQ},
}
Figure