TLDR: A new framework called AFL (Agentic Framework with LLMs) is proposed to fully automate the solution of complex Vehicle Routing Problems (VRPs). It uses specialized AI agents to break down the problem into three manageable subtasks: problem description, code generation, and solution derivation. AFL extracts knowledge directly from raw inputs, generates self-contained code, and achieves high reliability and feasibility, outperforming existing LLM-based methods and showing competitive results against traditional algorithms on a wide range of VRPs.
Solving complex Vehicle Routing Problems (VRPs) has long been a significant challenge, often requiring extensive human expertise to interpret problem statements and design specialized algorithms. While Large Language Models (LLMs) have shown promise in automating these tasks, existing methods still struggle with full autonomy, often leading to errors and impractical solutions.
A new approach, the Agentic Framework with LLMs (AFL), aims to overcome these limitations by achieving complete automation from the initial problem instance to the final solution. AFL is designed to directly extract knowledge from raw inputs and generate self-contained code, eliminating the need for handcrafted modules or external solvers. This framework significantly enhances trustworthiness by breaking down the entire process into three manageable subtasks, each handled by a team of four specialized agents.
How AFL Works: A Collaborative Agent System
The AFL framework operates through a coordinated interaction of four distinct agents, ensuring cross-functional consistency and logical soundness throughout the problem-solving pipeline:
-
Generation Agents (GA): These agents are responsible for creating the initial problem descriptions and generating the necessary code functions. They translate the VRP instance into a clear, structured problem statement and then progressively build the solver code.
-
Judgment Agents (JA): Acting as critical evaluators, Judgment Agents assess the validity and correctness of the descriptions and code produced by the Generation Agents. They identify inconsistencies, syntactic errors, and logical flaws, providing feedback for improvement.
-
Revision Agents (RA): Based on the feedback from the Judgment Agents, Revision Agents refine and correct the problem descriptions and code. This iterative process ensures that the generated artifacts meet all requirements and constraints.
-
Error Analysis Agents (EAA): Exclusively active during the solution derivation phase, these agents diagnose the root causes of any execution errors. They provide detailed explanations and suggestions, guiding the Revision Agents in making targeted code corrections.
The problem-solving process is divided into three main subtasks:
1. Problem Description: The GA extracts domain knowledge from the raw VRP instance (in VRPLib format) to generate a comprehensive problem description. This includes identifying the problem type, its constraints, required inputs, expected outputs, and the optimization objective. The JA and RA then iteratively review and refine this description until it is accurate and consistent.
2. Code Generation: AFL adopts a unified destroy-insert heuristic for VRPs, which is flexible enough to handle complex variants. The GA generates interdependent functions (like `read_vrp`, `distance`, `cost`, `initial`, `destroy`, `insert`, `validate`, and `main`) sequentially. After each function is generated, the JA and RA collaborate to validate and refine the code, ensuring it adheres to all constraints and requirements before moving to the next function.
3. Solution Derivation: Once the complete VRP solver code is generated, it is executed. If runtime errors occur, the EAA steps in to analyze the error, providing insights and suggestions for the RA to revise the code. This iterative debugging continues until the code produces a feasible solution. The validated problem description and code are then stored for future reuse, improving efficiency.
Also Read:
- Adaptive Search: How Reinforcement Learning Powers Intelligent AI Agents
- LaGAT: A Hybrid AI Approach for Efficient Robot Pathfinding in Crowded Environments
Performance and Trustworthiness
Extensive experiments on 60 complex VRPs, including standard benchmarks and practical electric VRP variants, have validated AFL’s effectiveness and generality. The framework demonstrates competitive performance against meticulously designed traditional and neural algorithms, often achieving results within a 3% gap of state-of-the-art solvers on many standard problems.
Crucially, AFL significantly outperforms existing LLM-based baselines in both code reliability and solution feasibility. It achieves a 0% runtime error rate (RER) and a 100% success rate (SR) across all tested VRP variants, a stark contrast to other LLM-based methods that often struggle with execution errors and infeasible solutions. This highlights AFL’s superior trustworthiness in generating robust and correct VRP solvers.
The agentic design, particularly the collaborative roles of the Judgment and Revision Agents, proved essential in maintaining accurate problem descriptions and ensuring the reliability of the generated code and solutions. AFL also shows broad applicability, successfully tackling problems like the Asymmetric Traveling Salesman Problem (ATSP), Asymmetric Capacitated Vehicle Routing Problem (ACVRP), and the Sequential Ordering Problem (SOP).
While AFL’s performance may not always surpass highly specialized, decades-old state-of-the-art solvers for well-studied problems, this is considered an acceptable trade-off given its full automation and generality. The framework represents a significant step towards more autonomous and adaptive optimization systems, potentially democratizing access to advanced optimization techniques for non-expert users. Future work aims to integrate evolutionary search strategies to further enhance code quality and search efficiency. For more details, you can read the full research paper here.


