Official implementation for paper "Elevating Large Language Models for Complex Vehicle Routing via Decomposed Retrieval of Constraints (ICLR2025)"
This repository contains an implementation of a Vehicle Routing Problem solver that leverages Large Language Models (LLMs) to generate and refine solution code. The system supports multiple solving methods and can work with different optimization solvers.
- Support for multiple solvers:
- Google OR-Tools
- Gurobi
- Flexible LLM integration (currently supports):
- Claude models (default: claude-3-5-sonnet-20241022)
- GPT models
- Automated code generation and refinement
- Retrieval-augmented generation (RAG)+Self-debug
- Python 3.7+
- OR-Tools or Gurobi solver
- Required Python packages:
- langchain
- anthropic
- openai (for GPT models)
project_directory/
├── main.py # Main execution file with argument parsing
├── chroma_db # Vector store for RAG
├── data # Local data source for retrieval
├── gene_codes # The generated codes by DRoC
├── problems # The VRP benchmark for problem solving
├── DRoC.py # Implementation of DRoC method
├── standard.py # Standard solving method implementation
├── utils.py # Utility functions
└── common.py # Common functions and data structures
-
Clone the repository:
git clone [repository-url] cd [repository-name] -
Install required packages:
pip install -r requirements.txt
-
Set up your API keys in environment variables or in the code:
os.environ["ANTHROPIC_API_KEY"] = "your-key-here" os.environ["OPENAI_API_KEY"] = "your-key-here" # if using GPT models
Run the solver using the command line interface with various configuration options:
python main.py --method DRoC --solver OR-tools --llm claude-3-5-sonnet-20241022--method: Solving method to use (DRoC, standard, or self_debug)--solver: Optimization solver to use (OR-tools or Gurobi)--llm: LLM model to use for code generation--start_idx: Starting index in the dataset--end_idx: Ending index in the dataset--skip_existing: Skip problems that already have generated solutions--output_dir: Directory to save generated code--max_iterations: Maximum number of refinement iterations
-
Run with default settings:
python main.py
-
Use specific solver and LLM:
python main.py --solver Gurobi --llm claude-3-5-sonnet-20241022
-
Process specific range of problems:
python main.py --start_idx 5 --end_idx 10 --skip_existing
-
Custom output directory and iterations:
python main.py --output_dir custom_output --max_iterations 6
The system provides comprehensive evaluation results including:
- Total problems tested
- Success rate
- Runtime error rate
- Lists of successful and failed tasks
Example output:
Evaluation Results:
Total problems tested: 48
Successful solutions: 23 (47.92%)
Runtime errors: 10 (20.83%)
Successful tasks: ['CVRP', 'VRPTW', ...]
Tasks with runtime errors: ['VRPMD', 'PCTSP', ...]
Contributions are welcome! Please feel free to submit pull requests or create issues for bugs and feature requests.
MIT
If you use this code in your research, please cite:
@inproceedings{
droc2025,
title={{DR}oC: Elevating Large Language Models for Complex Vehicle Routing via Decomposed Retrieval of Constraints},
author={Xia Jiang, Yaoxin Wu, Chenhao Zhang, Yingqian_Zhang},
booktitle={The Thirteenth International Conference on Learning Representations},
year={2025},
url={https://openreview.net/forum?id=s9zoyICZ4k}
}- Thanks to the developers of OR-Tools and Gurobi
- Thanks to Anthropic and OpenAI for their LLM APIs