arXiv:2610.26819cs.CLOct 2026

Manuscript Offprint

arXiv:2610.26819

ASTOR: Benchmarking and Improving Autoformulation for Soft-Constraint Optimization with a Formal Grammar

Amer Goel, Yeganeh Alimohammadi, Andrew Daw

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 here.

1 Introduction

In practical settings, decision-makers often have to balance preferences from many stakeholders, some of which are not always satisfiable. These preferences do not constrain their decisions the same way that a strict requirement might. For example, a hospital manager must assign nurses to cover every shift, but may accommodate preferences to avoid night shifts or maintain consecutive days off. A travel agent must choose hotels and flights that obey the requested destination, but may not always be able to accommodate brand preferences. A shopping agent must obey the consumer's budget, but may choose to suggest a longer delivery date than the one desired. An ideal optimization model must therefore distinguish what must hold from what is preferred to hold, and when preferences conflict, determine which take priority.

Natural language is a familiar way to express these distinctions, and the growing use of large language models (LLMs) makes it an increasingly common interface for decision-making. Consumers use AI tools for shopping and planning [Associated Press, 2025, Shopify, 2026, McKinsey & Company, 2026], while firms are incorporating AI for investments or as retail assistants [The Wall Street Journal, 2026, Reuters, 2026]. These settings often present decision-makers with hard and soft constraints. As a result, LLM autoformulation provides a promising approach for this translation problem. Research in this field often uses LLM prompting or fine-tuning methods to successfully translate natural-language descriptions of real decision problems into solvable mathematical optimization formulations. However, their methods often prioritize only hard formulations [Wei et al., 2022, Deng et al., 2024, Yang et al., 2026] and current benchmarks only test those formulations [Ramamonjison et al., 2022, AhmadiTeshnizi et al., 2024, Xiao et al., 2024, Huang et al., 2025a]. They do not directly test whether a model distinguishes requirements from preferences or preserves the ordering.

Preprint.

among preferences. This leaves an important class of practical decision problems without a strong autoformulation method or evaluation tools.

We address this gap with ASTOR and SoftOR. ASTOR is an inference-time method which prompts an LLM to express a decision problem as an abstract syntax tree generated by a formal grammar, then validates and compiles that representation deterministically into solver code. The constructed grammar is adequate for the class of hard and soft constraint optimization problems considered in this work; see Appendix C. SoftOR is our newly introduced benchmark for evaluating whether models can recover weighted-penalty and lexicographic soft-constraint formulations from natural language. It consists of tasks involving travel planning and scheduling nurses for shifts in a hospital.

Across the 355 SoftOR instances, ASTOR achieves 88.5% solution accuracy, compared with 84.8% for the strongest alternative. It achieves the highest accuracy on three of the four SoftOR datasets, with the nurse scheduling dataset as the only exception. On 435 conventional hard-constraint problems, ASTOR achieves 81.8%, within 0.5 percentage points of the best-performing method.

References (100)

Couldn't load all references. Reload the page to try again.