ASTOR: Benchmarking and Improving Autoformulation for Soft-Constraint Optimization with a Formal Grammar
Abstract
Real-world decision problems combine two qualitatively different kinds of constraints: requirements that must be satisfied, called hard constraints, and preferences that can be violated, called soft constraints. Because these problems are often posed to decision-makers in natural language, large language models offer a natural tool for assisting with their solution. This has given rise to autoformulation, which focuses on using LLMs to translate natural-language descriptions of decision problems into executable mathematical optimization models. However, this research often neglects soft constraints like those proposed by consumers, managers, and planners, despite the fact that many practical problems require modeling them explicitly. We introduce ASTOR, an inference-time framework that maps a natural-language decision problem to a grammar-guided abstract syntax tree (AST) before deterministically compiling the resulting representation into executable optimization code. We also introduce SoftOR, a unified benchmark of natural language problems which focuses on soft constraint formulations. On SoftOR, ASTOR achieves the best aggregate accuracy among comparable single-request and multi-agent LLM methods while remaining competitive on standard autoformulation benchmarks that include only hard constraints. Code and data are available at https://anonymous.4open.science/r/astor-softor-iclr-E34C/README.md.
Figures & tables
| Component | Objective | Priority Signal | Gold construction | Source Material | |
|---|---|---|---|---|---|
| Nurse Rostering | 15 | Weighted penalty | Explicit | Published optimum | Curtois (2014) ; Curtois and Qu (2014) |
| COMPASS | 85 | Lexicographic | Explicit | Enumeration | Qin et al. (2026) |
| TravelPlanner | 180 | Lexicographic | Modal | Enumeration | Xie et al. (2024) |
| LexiBench | 75 | Lexicographic | Mixed | Enumeration/Solver Code | This work |
| Method | COMPASS | Travel Planner | LexiBench | Overall |
|---|---|---|---|---|
| Direct | 56.5 (5.4) | 75.0 (3.2) | 5.3 (2.6) | 55.0 (2.7) |
| Codegen | 98.8 (1.2) | 76.1 (3.2) | 89.3 (3.5) | 84.7 (1.9) |
| CoT | 95.3 (2.3) | 77.2 (3.1) | 80.0 (4.6) | 82.4 (2.1) |
| ORThought | 96.5 (2.0) | 80.0 (3.0) | 66.7 (5.4) | 81.2 (2.1) |
| CoE | 98.8 (1.2) | 79.4 (3.0) | 89.3 (3.5) | 86.5 (1.8) |
| ASTOR (Ours) | 98.8 (1.2) | 85.0 (2.7) | 92.0 (3.2) | 90.0 (1.6) |
| COMPASS | TravelPlanner | LexiBench | ||||||
|---|---|---|---|---|---|---|---|---|
| Method | Preferences | Tier 2 Strong preferences | Tier 3 Weak preferences | Combined | Tier 1 | Tier 2 | Tiers 3–5 | Combined |
| Direct | 35.0 | 93.8 | 86.2 | 87.4 | 4.5 | 3.3 | 1.5 | 3.5 |
| Codegen | 62.7 | 93.8 | 83.9 | 85.3 | 92.8 | 52.1 | 65.2 | 65.6 |
| CoT | 60.4 | 81.2 | 85.1 | 85.3 | 90.1 | 51.8 | 60.6 | 63.8 |
| ORThought | 60.7 | 93.8 | 83.9 | 85.3 | 73.1 | 38.6 | 50.0 | 52.0 |
| CoE | 62.7 | 100.0 | 87.4 | 88.4 | 94.1 | 50.4 | 68.2 | 66.3 |
| Method | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Direct | +407 | +897 | FAIL | FAIL | FAIL | FAIL | FAIL | FAIL | FAIL | FAIL | FAIL | FAIL | FAIL | FAIL | FAIL |
| Codegen | 0 | 0 | 0 | +1 | +1 | 0 | 0 | +1 | +2 | 0 | 0 | +1 | 0 | +1 | 0 |
| CoT | 0 | 0 | 0 | +1 | +1 | 0 | 0 | +6 | +2 | 0 | 0 | +1 | 0 | +1 | 0 |
| ORThought | 0 | 0 | 0 | +1 | +3 | FAIL | 0 | +1 | +2 | 0 | 0 | +1 | 0 | FAIL | 0 |
| CoE | 0 | 0 | 0 | +1 | +1 | 0 | +1 | +2 | +2 | 0 | 0 | +1 | +2 | +1 | 0 |
| ASTOR | 0 | 0 | 0 | +1 | +1 | +1 | 0 | +2 | +2 | 0 | 0 | +1 | 0 | +4 | 0 |
| Method | Gemini 3.5 Flash Lite | GPT-5 | Gemini 3.1 Pro |
|---|---|---|---|
| Direct | 6.7 (3.7) | 44.4 (7.4) | 33.3 (7.0) |
| Codegen | 44.4 (7.4) | 68.9 (6.9) | 80.0 (6.0) |
| CoT | 17.8 (5.7) | 51.1 (7.5) | 73.3 (6.6) |
| ORThought | 28.9 (6.8) | 68.9 (6.9) | 80.0 (6.0) |
| CoE | 37.8 (7.2) | 68.9 (6.9) | 77.8 (6.2) |
| ASTOR (Ours) | 26.7 (6.6) | 73.3 (6.6) | 80.0 (6.0) |
Appendix figures & tables25 assets
Supplementary material from the paper’s appendix.
Appendix
| Method | ComplexOR | IndustryOR | LogiOR | NLP4LP | Overall |
|---|---|---|---|---|---|
| Direct | 94.4 (5.4) | 75.9 (4.7) | 62.0 (5.0) | 78.1 (2.6) | 74.9 (2.1) |
| Codegen | 88.9 (7.5) | 75.9 (4.7) | 72.8 (4.7) | 87.2 (2.1) | 82.1 (1.8) |
| CoT | 83.3 (8.8) | 75.9 (4.7) | 72.8 (4.7) | 86.8 (2.2) | 81.6 (1.9) |
| ORThought | 83.3 (8.8) | 78.3 (4.5) | 73.9 (4.6) | 85.5 (2.2) | 81.6 (1.9) |
| CoE | 88.9 (7.3) | 80.7 (4.3) | 71.7 (4.7) | 86.4 (2.2) | 82.3 (1.8) |
| ASTOR (Ours) | 94.4 (5.4) | 77.1 (4.6) | 68.5 (4.9) | 87.6 (2.1) | 81.8 (1.8) |
| Instances solved correctly | ASTOR baseline | |||||
| Baseline | Both | ASTOR only | Baseline only | Neither | (%) | 95% CI |
| CoE | 345 | 11 | 13 | 66 | ||
| Codegen | 346 | 10 | 11 | 68 | ||
| Method | Gemini 3.7 Flash (reasoning) | Gemini 3.5 Flash Lite (no reasoning) | GPT-5 (reasoning, medium) | Gemini 3.1 Pro (reasoning) |
|---|---|---|---|---|
| Direct | 78.2 (5.6) | 18.2 (5.2) | 78.2 (5.6) | 78.2 (5.6) |
| Codegen | 81.8 (5.2) | 78.2 (5.6) | 80.0 (5.4) | 80.0 (5.4) |
| CoT | 83.6 (5.0) | 76.4 (5.7) | 65.5 (6.4) | 80.0 (5.4) |
| ORThought | 83.6 (5.0) | 83.6 (5.0) | 85.5 (4.8) | 80.0 (5.4) |
| CoE | 83.6 (5.0) | 80.0 (5.4) | 81.8 (5.2) | 81.8 (5.2) |
| ASTOR (Ours) | 85.5 (4.8) | 78.2 (5.6) | 83.6 (5.0) | 81.8 (5.2) |
| Method | ComplexOR | IndustryOR | LogiOR | NLP4LP |
|---|---|---|---|---|
| ORLM | 77.78 | 32.13 | 15.58 | 67.80 |
| OptiMUS | – | – | – | 69.42 |
| CoE | 55.56 | 40.96 | 34.78 | 75.00 |
| ORThought | 77.78 | 57.83 | 46.01 | 89.02 |
| Method | Nurse Rostering | COMPASS | Travel Planner | LexiBench |
|---|---|---|---|---|
| Direct | 31.8 | 57.6 | 99.0 | 5.3 |
| Codegen | 100.0 | 100.0 | 96.3 | 100.0 |
| CoT | 100.0 | 96.5 | 96.4 | 96.0 |
| ORThought | 86.7 | 97.6 | 97.4 | 78.7 |
| CoE | 100.0 | 100.0 | 97.5 | 100.0 |
| ASTOR (Ours) | 100.0 | 100.0 | 98.8 | 100.0 |
| Placeholder | Source |
|---|---|
| grammar | The grammar reproduced in Appendix C , inserted verbatim from the artifact at runtime. |
| ast_json_schema | The strict JSON response schema, inserted in full at runtime and retained in the artifact rather than repeated in print. |
| benchmark_semantics_contract | The benchmark-specific scoring semantics reproduced below. |
| benchmark_compatibility_contract | The benchmark-specific output interface reproduced below. |
| Setting | Value |
|---|---|
| Provider and model | Gemini 3.7 Flash; Nurse Rostering: Gemini 3.8 Flash |
| Decoding | Temperature ; maximum output 32,768 tokens (65,536 for Nurse Rostering) |
| Thinking | Provider default, except Nurse Rostering, where every route used a 32,768-token thinking budget |
| Sampling | One repeat per instance; seed ; blind prompt mode |
| External tools | Disabled |
| Structured output | Disabled; deterministic validation applied after generation |
| Benchmark | Cohort | Sample | Benchmark | Cohort | Sample |
|---|---|---|---|---|---|
| ComplexOR | 18 | 2 | COMPASS | 85 | 11 |
| IndustryOR | 83 | 10 | TravelPlanner | 180 | 23 |
| LogiOR | 92 | 12 | LexiBench | 75 | 9 |
| NLP4LP | 242 | 31 | Nurse Rostering | 15 | 2 |
| Hard total | 435 | 55 | Soft total | 355 | 45 |
| Component | Objective | Priority Signal | Gold construction | |
|---|---|---|---|---|
| Nurse Rostering | 15 | Weighted penalty | Explicit | Published optimum |
| COMPASS | 85 | Lexicographic | Explicit | Enumeration |
| TravelPlanner | 180 | Lexicographic | Modal | Enumeration |
| LexiBench | 75 | Lexicographic | Mixed | Enumeration/Solver Code |
| Tier | Interpretation | Common cues |
|---|---|---|
| 1 | Hard constraint | must, require, need, essential, mandatory, cannot, non-negotiable, ensure, will not, do not plan, avoid, not via |
| 2 | Strong preference | should, important, intend to, plan to, aiming for |
| 3 | Weak preference | prefer, would like, appreciate, hope, wish, interested in, ideally, open to, prefer not, rather not |
| Decision type | Decision space |
|---|---|
| Atomic | Select one of 12 supplied options. |
| Assembly | Select one element from each of three five-element sets, giving 125 possible combinations. |
| Constructive | Optimize over integer decision variables and an implicitly defined feasible region. |
| Preference structure | Property tested | Difficulty |
|---|---|---|
| Direct priority dominance | One preference level dominates another. | Easy |
| Equal-level feature counting | All preferences have equal priority. | Easy |
| One-high-many-low | Several lower preferences cannot replace one higher preference. | Medium |
| Deep ladder | Preferences form four or five ordered levels. | Hard |
| Sparse transitive ordering | The full order must be inferred from pairwise comparisons. | Hard |
| Published weight | Natural-language phrase |
|---|---|
| 1 | slightly prefers |
| 2 | prefers |
| 3 | strongly prefers |
| 100 | far more serious |
| Method | Hard Constraints Satisfied | Staffing Coverage (under) | Staffing Coverage (over) | Weighted Preference Satisfied |
|---|---|---|---|---|
| Direct | 31.8 | 27.9 | 31.1 | 28.1 |
| Codegen | 100.0 | 94.8 | 97.9 | 88.0 |
| CoT | 100.0 | 94.8 | 97.9 | 87.9 |
| ORThought | 86.7 | 82.3 | 85.2 | 76.2 |
| CoE | 100.0 | 94.8 | 97.9 | 87.9 |
| ASTOR (Ours) | 100.0 | 94.8 | 97.9 | 87.9 |
| Hard-constraint family | Rosters with a violation |
|---|---|
| Working-time bounds | 2/5 |
| Consecutive working-day bounds | 2/5 |
| Forbidden shift successions | 1/5 |
| Weekend limits | 2/5 |
| Consecutive days-off bounds | 2/5 |
| Shift-count limits | 2/5 |
| Method | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Direct | FAIL | FAIL | FAIL | FAIL | FAIL | FAIL | FAIL | FAIL | FAIL | FAIL | FAIL | FAIL | FAIL | FAIL | FAIL |
| Codegen | 0 | 0 | 0 | 0 | 0 | 0 | 0 | FAIL | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
| CoT | 0 | 0 | 0 | 0 | 0 | 0 | FAIL | FAIL | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
| ORThought | 0 | 0 | 0 | 0 | 0 | 0 | FAIL | FAIL | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
| CoE | 0 | 0 | 0 | 0 | 0 | 0 | FAIL | FAIL | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
| ASTOR | FAIL | 0 | 0 | 0 | 0 | 0 | FAIL | 0 | 0 | 0 | 0 | 0 | 0 | 0 | FAIL |
| Dataset | Problem ID | Correction |
|---|---|---|
| ComplexOR | prob_004 | Restored the objective value 250 from the accompanying sample and confirmed it with the reference formulation. |
| IndustryOR | prob_045 | Changed optimal with a null objective to infeasible; the reference scheduling formulation produces an irreducible infeasible subsystem. |
| NLP4LP | prob_002 | Changed optimal with a null objective to infeasible; the required advertising purchases exceed the available budget. |
| NLP4LP | prob_027 | Changed optimal with a null objective to infeasible; the vitamin D requirement is incompatible with the vitamin E upper bound. |
| NLP4LP | prob_050 | Changed optimal with a null objective to infeasible; the heating requirement cannot be met within the electricity limit. |
| NLP4LP | prob_056 | Changed optimal with a null objective to infeasible; the cooking-rate, oil-use, and grill-ordering requirements are incompatible. |
| Dataset | Problem ID | Renamed key(s) |
|---|---|---|
| ComplexOR | prob_005 | roll_width RollWidth , widths Width , orders Orders , num_patterns NumPatterns , num_rolls_width NumRollsWidth |
| ComplexOR | prob_006 | food_set Foods , nutrient_set Nutrients , food_cost Cost , min_food_amount MinAmount , max_food_amount MaxAmount , min_nutrient_amount MinNutrient , max_nutrient_amount MaxNutrient , nutrient_amount NutrientAmount |
| ComplexOR | prob_007 | cost Cost , n_min MinRequirement , n_max MaxRequirement , amt NutrientAmount |
| ComplexOR | prob_008 | jobs Jobs , machines Machines , proces_time ProcesTime |
| ComplexOR | prob_011 | supply Supply , demand Demand , cost ShippingCost , limit Limit |
| ComplexOR | prob_012 | supply Supply , demand Demand , cost Cost , limit Limit |
Natural Language to Optimization Modeling
Natural language to optimization modeling translates human requirements into formal mathematical models and solver-ready code.
See all 76 papers