CRAFT: Constrained Route planning with Adaptive Framework and Template-based code generation
Organizations: University of California, Riverside
Abstract
Everyday routing requests are rarely a point-to-point shortest path. A driver may need to visit stops, sometimes in a fixed order, under time budgets or distance limits, and perhaps recharge their EV car along the way. Each combination is a distinct routing problem that classically requires its own algorithm, so no fixed solver covers the space of queries users may ask. This paper presents CRAFT, which takes a constrained routing query as free text and returns a route that satisfies the user's requirements on a real road network. An LLM parses the query and generates four search functions, which a generic graph-search engine executes on the road network. We formalize the underlying problem as State-Expanded RCSP (SE-RCSP), which extends resource-constrained shortest paths (RCSP) with non-additive state such as node-dependent resets and discrete progress tracking. We evaluate CRAFT on 2,600 natural-language queries over California road networks against two baselines, analyzing correctness, constraint violations, long-distance scalability, and semantic POI filtering.
Figures & tables
| POIs | Route cost | ||||
|---|---|---|---|---|---|
| Problem | Obj. | Constr. | Obj. | Constr. | Related work |
| Shortest path | ✓ | [ 2 , 31 ] | |||
| RCSP | ✓ | ✓ | [ 5 , 7 , 8 , 32 , 9 , 10 , 33 ] | ||
| Routing with stops | ✓ | ✓ | (✓) | [ 14 , 11 , 13 , 34 ] | |
| Itinerary planning | ✓ | (✓) | ✓ | [ 16 , 17 , 19 ] | |
| CRAFT | ✓ | ✓ | ✓ | ✓ | this paper |
| Field | Value |
|---|---|
| query_id | example_query_1 |
| source | v1 |
| destination | v10 |
| objective | minimize_distance |
| poi_category | [park, restaurant] |
| poi_filters | [{description: ‘playground for kids’}, {cuisine: ‘thai’}] |
| Field | Value |
|---|---|
| query_id | example_query_1 |
| route | [v1, v4, v5, v8, v7, v9, v10] |
| poi_stops | [{type: charger, node: v4}, |
| {type: park, node: v7}, | |
| {type: restaurant, node: v9}] | |
| objective(normalized to meters) | 27358.8 |
| Query set | Count | Family | |
| Main | |||
| Q1 | EV Routing [ 20 , 21 ] | 200 | RP |
| “What’s the shortest route from to ? I’m at 12% of a 250-mile battery.” | |||
| Q2 | EV + Ordered [ 20 , 11 ] | 200 | RP |
| “I need the shortest route from to with 20% charge: a pharmacy first and then a bank, with no leg over 5 miles.” | |||
| Q3 | Unordered POI [ 14 ] | 200 | RP |
| Objective | Battery | Stops | Order | Distance | Highway | Time | Filters | |
|---|---|---|---|---|---|---|---|---|
| Q1 | distance | ✓ | ||||||
| Q2 | distance | ✓ | ✓ | ✓ | ✓ | |||
| Q3 | time | ✓ | ✓ | |||||
| Q4 | distance | ✓ | ✓ | ✓ | ||||
| Q5 | POIs | ✓ | ✓ | |||||
| Q6 | time | ✓ | ✓ |
| Correct | Incorrect | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| Model | System | EV Routing | EV+Ordered | Unord. POI | Ordered POI | POI Collect. | T-Inf | Total | Error | F-Inf | Viol |
| Flash Lite | LLM | 89 | 20 | 32 | 8 | 51 | 0 | 200 | 616 | 1 | 183 |
| LLMAP | 92 | 79 | 170 | 52 | 27 | 0 | 420 | 20 | 153 | 407 | |
| CRAFT | 200 | 185 | 181 | 124 | 172 | 49 | 911 | 38 | 20 | 31 | |
| GPT-4.1 | LLM | 98 | 19 | 13 | 11 | 123 | 1 | 265 | 542 | 0 | 193 |
| LLMAP | 92 | 80 | 174 | 48 | 27 | 0 | 421 | 2 | 171 | 406 | |
| Model | Template | #Q | LLM | LLMAP | CRAFT | Failed |
|---|---|---|---|---|---|---|
| Flash Lite | EV Routing | 200 | 89 | 92 | 200 | 0 |
| EV + Ordered | 200 | 1 | 28 | 185 | 14 | |
| Unordered POI | 200 | 1 | 38 | 179 | 4 | |
| Ordered POI | 200 | 1 | 32 | 124 | 68 | |
| POI Collection | 200 | 27 | 4 | 168 | 18 | |
| Total | 1000 | 119 | 194 | 856 | 104 |
| Model | System | Correct | Fail | Infeas | Viol | First-rank |
|---|---|---|---|---|---|---|
| Flash Lite | LLM | 134 | 625 | 10 | 231 | 19 |
| LLMAP | 757 | 0 | 24 | 219 | 279 | |
| CRAFT | 761 | 48 | 180 | 11 | 695 | |
| GPT-4.1 | LLM | 150 | 580 | 78 | 192 | 11 |
| LLMAP | 775 | 0 | 3 | 222 | 188 | |
| CRAFT | 924 | 24 | 51 | 1 | 846 |
| Template | Gemini Flash Lite | GPT-4.1 | gpt-oss-20b |
|---|---|---|---|
| EV Routing | 0.62% | 0.24% | 0.27% |
| EV + Ordered | 0.77% | 0.61% | 1.40% |
| Ordered POI | 0.10% | 0.10% | 0.33% |
| Unordered POI | 2.21% | 1.34% | 1.39% |
| POI Collection | 6.98% | 1.40% | 14.98% |
| Correct | Incorrect | |||||
|---|---|---|---|---|---|---|
| Model | Route | T-Inf | Total | Error | F-Inf | Viol |
| Flash Lite | 151 | 22 | 173 | 2 | 18 | 7 |
| GPT-4.1 | 114 | 20 | 134 | 1 | 51 | 14 |
| gpt-oss-20b | 99 | 19 | 118 | 16 | 24 | 42 |
| Phrase | Role | AUC | Kept at |
|---|---|---|---|
| an art museum | test | 0.91 | 100.0 |
| a history museum | test | 0.89 | 100.0 |
| a theme park attraction | test | 0.85 | 90.4 |
| an upscale fine-dining restaurant | calib. | 0.81 | 97.2 |
| a cafe that roasts its own coffee | calib. | 0.80 | 100.0 |
| a park with sports fields | calib. | 0.65 | 95.2 |
| Success (%) | Search (s), med. | States, med. | ||||
|---|---|---|---|---|---|---|
| Model | Long | Opt | Long | Opt | Long | Opt |
| Flash Lite | 94.5 | 96.0 | 3.6 | 0.6 | 678k | 102k |
| GPT-4.1 | 75.0 | 92.5 | 3.1 | 0.5 | 584k | 101k |
| gpt-oss-20b | 71.6 | 87.3 | 3.1 | 0.5 | 594k | 98k |
Vehicle Routing
Vehicle routing studies how to assign and sequence trips for fleets while meeting capacity, time, energy, and service constraints.
See all 149 papers