Beyond Objective Equivalence: Constraint Injection for LLM-Based Optimization Modeling on Vehicle Routing Problems
Researchers propose constraint injection, a novel verification technique that detects missing or spurious constraints in LLM-generated optimization code. VRPCoder, an 8B model fine-tuned with this method, achieves 93% accuracy on vehicle routing problems, significantly outperforming GPT and Claude models on constraint-dense combinatorial optimization tasks.
This research addresses a fundamental challenge in applying large language models to operations research: ensuring generated code correctly implements all problem constraints, not just produces correct objective values. Traditional verification methods like differential testing can miss silent constraint violations because non-binding constraints don't affect solution quality on specific test instances. The constraint injection approach uses two complementary probes—feasible instances to catch over-constraint and violation-inducing instances to detect omitted constraints—creating a more robust verification pipeline.
The breakthrough represents an important shift in how LLMs can be applied to combinatorial optimization. Vehicle routing problems serve as an ideal testbed because they combine multiple coupled constraints that interact in complex ways. By incorporating the verification mechanism both during training (via rejection sampling) and fine-tuning (through group relative policy optimization rewards), VRPCoder learns to generate semantically correct solver code rather than superficially valid outputs.
The 93% pass rate and substantial improvements over closed-source models (28 points over Claude-Sonnet, 78 points over prior OR-LLMs) demonstrate that targeted architectural improvements can match or exceed larger, general-purpose models on specialized domains. This matters for enterprises relying on OR solvers for logistics, supply chain, and resource allocation—domains where constraint violations create costly operational failures that objective equivalence cannot catch.
The methodology's reusability across different optimization problem classes suggests broader applications beyond VRPs. Future work likely involves extending constraint injection to other constraint-dense domains and exploring how these techniques integrate with newer LLM architectures and reasoning frameworks.
- →Constraint injection detects both spurious over-constraints and silent constraint omissions that traditional differential testing misses.
- →VRPCoder achieves 93% accuracy on vehicle routing variants, outperforming Claude-Sonnet and Gemini on constraint-dense tasks.
- →Verification mechanisms serve dual roles during training (filtering) and optimization (reward signals), improving model robustness.
- →The approach demonstrates that smaller specialized models can exceed larger general-purpose LLMs on structured optimization problems.
- →Results suggest constraint injection principles could extend to other combinatorial optimization domains beyond vehicle routing.