English

Grammar-Aware Literate Generative Mathematical Programming with Compiler-in-the-Loop

Programming Languages 2026-05-29 v2 Artificial Intelligence

Abstract

Mathematical programming is widely employed across various sectors - such as logistics, energy, and workforce planning - to model and solve industrial optimisation problems, but its use requires substantial domain expertise. Large language models offer a promising way to translate natural-language problem descriptions into optimisation models, yet existing approaches are costly and generally produce models written in general-purpose computer code (e.g. Python), which can be difficult to inspect, validate, and reuse. In this work, we introduce SyntAGM, a system that generates optimisation models in a readable algebraic modelling language through an iterative generate-compile-assess-revise loop. SyntAGM leverages PyOPL, an OPL-like modelling language compiler designed to provide actionable feedback for iterative model repair. To obtain a valid PyOPL model that matches the problem description, SyntAGM mobilises compiler feedback and an LLM-based alignment judge. In addition, it combines in-context exposure to the target language grammar, and few-shot retrieval of modelling exemplars. Across multiple benchmarks, SyntAGM achieves a more favourable cost-quality trade-off compared to established prompting baselines.

Keywords

Cite

@article{arxiv.2601.17670,
  title  = {Grammar-Aware Literate Generative Mathematical Programming with Compiler-in-the-Loop},
  author = {Roberto Rossi and Steven D. Prestwich},
  journal= {arXiv preprint arXiv:2601.17670},
  year   = {2026}
}

Comments

18 pages, 7 figures

R2 v1 2026-07-01T09:18:54.043Z