LangNCO: Compiling Natural-Language Constraints into Inference-Time Interventions for Neural Combinatorial Optimization
Organizations: Panasonic Connect Co., Ltd.
Abstract
Neural combinatorial optimization (NCO) rapidly produces high-quality solutions for problem structures encountered during training, but operational requirements may change after deployment and be communicated in natural language. We propose LangNCO, a framework that compiles instance-specific requirements into structured inference-time interventions for a frozen NCO solver, without changing the pretrained policy's architecture, learned input representation, or parameters. A pretrained LLM serves as a replaceable semantic front end, translating each requirement into a schema-validated domain-specific language (DSL) rule set. A deterministic Rule Executor applies the rules as nonexpansive hard action masks. Because local masking prevents immediate violations but does not ensure that a complete feasible continuation remains reachable, Critical-Offset Decoding extracts rule-referenced critical nodes and reallocates part of a fixed rollout budget to multi-strength biased rollouts. Using controlled task-specific language to isolate solver adaptation from open-ended language robustness, we evaluate a CVRP policy on road closures, time windows, vehicle assignments, visit-order requirements, all pairwise combinations, and twelve additional constraint types. LangNCO achieves 100% feasibility on the four primary datasets with mean reference gaps of 1.63--3.26%, 97.33--100% feasibility when separately generated rules are composed for pairwise constraints, and 98.67% feasibility across the additional constraints. These results demonstrate modular post-training adaptation of a frozen NCO solver through inspectable language-derived rules, without retraining.
Figures & tables
| Road | Time | Vehicle | Order | |||||
| Method | Feas. | Gap | Feas. | Gap | Feas. | Gap | Feas. | Gap |
| LLMCoSolver | 36.33% | 5.70% | 13.67% | 4.42% | 2.00% | 0.58% | 0.00% | – |
| Direct GPT-5 | 95.00% | 35.02% | 79.67% | 120.01% | 95.33% | 40.39% | 95.67% | 32.04% |
| NCO w/o intervention | 37.33% | 2.65% | 11.00% | 1.63% | 1.00% | 2.56% | 1.33% | 1.47% |
| LangNCO-Gemma4 | 100.00% | 1.63% | 100.00% | 1.89% | 100.00% | 2.53% | 100.00% | 3.26% |
| LangNCO-GPT-5 | 100.00% | 1.63% | 100.00% | 1.89% | 100.00% | 2.68% | 100.00% | 2.97% |
| Road | Time | Vehicle | Order | |||||
| Strategy | Feas. | Gap | Feas. | Gap | Feas. | Gap | Feas. | Gap |
| NCO greedy | 100.00% | 3.19% | 99.67% | 4.47% | 75.33% | 5.64% | 75.00% | 7.69% |
| NCO greedy + 1 sample | 100.00% | 2.28% | 99.67% | 3.83% | 77.33% | 5.26% | 83.67% | 6.56% |
| Critical-Offset greedy | 100.00% | 3.15% | 100.00% | 3.52% | 100.00% | 4.56% | 100.00% | 6.81% |
| NCO sampling | 100.00% | 1.64% | 99.67% | 2.19% | 87.67% | 3.33% | 97.00% | 3.52% |
| Critical-Offset sampling | 100.00% | 1.63% | 100.00% | 1.89% | 100.00% | 2.53% | 100.00% | 2.85% |
| Combination | Feasible (Ours / Ref.) | Gap |
|---|---|---|
| Road + Time | 300 / 300 | 2.25% |
| Road + Vehicle | 300 / 300 | 3.14% |
| Road + Order | 300 / 300 | 3.94% |
| Time + Vehicle | 300 / 300 | 4.01% |
| Time + Order | 292 / 289 | 5.18% |
| Vehicle + Order | 294 / 297 | 6.77% |
Appendix figures & tables16 assets
Supplementary material from the paper’s appendix.
Appendix
| Field | Contents |
|---|---|
| num_nodes | Number of nodes, including the depot. |
| vehicle_capacity | Homogeneous vehicle capacity . |
| instruction | Natural-language statement of unique visits, capacity, Euclidean-distance minimization, and output format. |
| input | Node IDs, coordinates, demands, and the two nearest neighbors and distances used as LLM heuristic features. |
| output | LKH-3 routes and total distance. |
| Component | Abstract role |
|---|---|
| Target | Selects the candidate actions affected by a constraint. |
| State guard | Determines whether the constraint is active for a decoder state. |
| Candidate predicate | Evaluates the constraint separately for each candidate action. |
| Effect | Removes matched actions or restricts the feasible set to matched actions. |
| Path | Used | Not used |
|---|---|---|
| Learned initial embedding | Depot/customer coordinates and customer demand | Time windows, service time, backhaul demand, open-route flag, distance limit, natural language, or DSL tokens |
| Learned step context | Current-node embedding and available load | Current time, vehicle index, full visit sequence, or remaining distance |
| Decoder interface | Combined base/rule mask, critical-node lookup, and | Natural-language or DSL tokens and raw values referenced by guards |
| Environment and Rule Executor | Visit state, time/travel state, vehicle ID, capacity, and other state needed to evaluate a mask | Any learned-parameter update |
| Setting | Gemma4 | GPT-5 |
|---|---|---|
| Identifier | gemma4:31b-it-q8_0 | Azure deployment gpt-5 |
| Runtime/API | Ollama | Azure OpenAI API, 2025-01-01-preview |
| Quantization | 8 bit | Managed API (not applicable) |
| Temperature | 0.0 | Default |
| Top- /top- | Ollama defaults | Defaults |
| Context length | 8,192 tokens ( OLLAMA_CONTEXT_LENGTH=8192 ) | Managed by API; not configured |
| Method/component | Model or implementation | Inference setting |
|---|---|---|
| LangNCO | Frozen RouteFinder | Critical-Offset Decoding; eight dihedral augmentations; all POMO starts; 100 samples per start and augmentation; decoder temperature 1.0; 90 ordinary and ten offset-guided samples. |
| Direct GPT-5 | Azure OpenAI gpt-5 | One-shot prompt; one response per instance; 128,000 maximum completion tokens; medium reasoning; default temperature; no retry; regex and JSON route parsing. |
| LLMCoSolver | Retrained Qwen2.5-7B-based model | Two-nearest-neighbor augmentation; best of eight; temperature 0.7; top- 0.9; 3,000 maximum new tokens; selection by base-CVRP reward. |
| NCO w/o intervention | Same frozen RouteFinder | No rule; augmented multi-start greedy decoding; eight augmentations and all POMO starts. |
| LKH-3 reference | Road wrapper | RUNS=10 ; seed zero; closed edge cost ten times the maximum instance edge. |
| OR-Tools reference | Routing Solver | PCI for Time/Vehicle/Order and GCA for Pairwise; guided local search; 600 seconds per instance. |
| Stage | Seed or selection rule |
|---|---|
| Primary and Additional generation | 1234 for every task. |
| Pairwise construction | Join the two primary instances by index; no new sampling. |
| Additional subset | Proportional size strata; first source instances within each stratum. |
| Gemma4 rule generation | Seed 0 and temperature 0.0. |
| GPT-5 rule generation / Direct GPT-5 | No reproducible fixed seed. |
| LangNCO NCO sampling | Seed for instance . |
| Item | Configuration |
|---|---|
| CPU | Intel Xeon w9-3575X, 44 cores / 88 threads |
| GPU | NVIDIA RTX PRO 6000 Blackwell Max-Q, 96 GB |
| Memory | 512 GiB |
| OS | Ubuntu 24.04 |
| Python | 3.12 |
| Ollama | 0.30.8 |
| Method | Feasible | Gap [%] | Objective |
|---|---|---|---|
| LLMCoSolver | 300/300 (100.00%) | ||
| Direct GPT-5 | 277/300 (92.33%) | ||
| NCO w/o intervention | 300/300 (100.00%) | ||
| LangNCO (empty rule) | 300/300 (100.00%) |
| Dataset | Method | Feasible | Gap [%] | Objective |
|---|---|---|---|---|
| Road | LLMCoSolver | 109/300 (36.33%) | ||
| Road | Direct GPT-5 | 285/300 (95.00%) | ||
| Road | NCO w/o intervention | 112/300 (37.33%) | ||
| Road | LangNCO-Gemma4 | 300/300 (100.00%) | ||
| Road | LangNCO-GPT-5 | 300/300 (100.00%) | ||
| Time | LLMCoSolver | 41/300 (13.67%) |
| Dataset | Generator | End-to-end [ms] | Rule generation [ms] | Validate + compile [ms] | NCO solve [ms] |
|---|---|---|---|---|---|
| Road | Gemma4 | ||||
| Road | GPT-5 | ||||
| Time | Gemma4 | ||||
| Time | GPT-5 | ||||
| Vehicle | Gemma4 | ||||
| Vehicle | GPT-5 |
| Dataset | Strategy | Feasible | Gap [%] | Objective | Time [ms] |
|---|---|---|---|---|---|
| Road | NCO greedy (noaug + single start) | 300/300 (100.00%) | |||
| Road | NCO greedy (noaug) | 300/300 (100.00%) | |||
| Road | NCO greedy | 300/300 (100.00%) | |||
| Road | NCO greedy + 1 sample | 300/300 (100.00%) | |||
| Road | NCO sampling | 300/300 (100.00%) | |||
| Road | Critical-Offset greedy | 300/300 (100.00%) |
| Dataset | Reference gap [%] at offset-strength spacing | ||||
|---|---|---|---|---|---|
| 0.05 | 0.10 | 0.20 | 0.50 | ||
| Road | 0.05 | – | – | ||
| 0.10 | – | ||||
| 0.20 | |||||
| 0.50 | |||||
| Time | 0.05 | – | – | ||
| Dataset | Generator | Representation | Feasible | Failure | Gap [%] |
|---|---|---|---|---|---|
| Road | Gemma4 | DSL | 300/300 (100.00%) | 0 | 1.63 |
| Road | Gemma4 | Python | 300/300 (100.00%) | 0 | 1.63 |
| Road | GPT-5 | DSL | 300/300 (100.00%) | 0 | 1.63 |
| Road | GPT-5 | Python | 300/300 (100.00%) | 0 | 1.63 |
| Time | Gemma4 | DSL | 300/300 (100.00%) | 0 | 1.89 |
| Time | Gemma4 | Python | 289/300 (96.33%) | 11 | 1.89 |
| Combination | Method | Feasible | Gap vs. GCA [%] | Objective |
|---|---|---|---|---|
| Road + Time | OR-Tools (GCA) | 300/300 (100.00%) | – | |
| Road + Time | Separate | 300/300 (100.00%) | ||
| Road + Time | Joint | 297/300 (99.00%) | ||
| Road + Vehicle | OR-Tools (GCA) | 300/300 (100.00%) | – | |
| Road + Vehicle | Separate | 300/300 (100.00%) | ||
| Road + Vehicle | Joint | 300/300 (100.00%) |
| Combination | Feasibility [%] | |||||
|---|---|---|---|---|---|---|
| PCI | LCI | PMCA | GCA | SV | AT | |
| Road + Time | 100.00 | 100.00 | 100.00 | 100.00 | 100.00 | 100.00 |
| Road + Vehicle | 100.00 | 100.00 | 100.00 | 100.00 | 24.67 | 73.67 |
| Road + Order | 98.67 | 98.67 | 8.33 | 100.00 | 9.33 | 11.67 |
| Time + Vehicle | 99.00 | 96.33 | 99.67 | 100.00 | 22.33 | 73.33 |
| Time + Order | 90.00 | 86.67 | 7.33 | 96.33 | 6.67 | 13.00 |
| Constraint type | NCO w/o intervention | LangNCO-Gemma4 |
|---|---|---|
| First delivery | 0/50 (0.00%) | 50/50 (100.00%) |
| Visit position | 4/50 (8.00%) | 50/50 (100.00%) |
| Arrival capacity reserve | 33/50 (66.00%) | 50/50 (100.00%) |
| Heavy-delivery limit | 5/50 (10.00%) | 50/50 (100.00%) |
| Minimum service interval | 1/50 (2.00%) | 50/50 (100.00%) |
| Depot closure | 17/50 (34.00%) | 50/50 (100.00%) |
Neural Combinatorial Optimization
Neural combinatorial optimization uses neural networks to find high-quality solutions to discrete problems such as routing, scheduling, and graph partitioning.
See all 137 papers