Grammar-Aware Literate Generative Mathematical Programming with Compiler-in-the-Loop
Roberto Rossi, Steven D. Prestwich
TL;DR
The paper addresses generative mathematical programming by translating natural-language problem descriptions into AML representations using a grammar-aware, compiler-in-the-loop system called SyntAGM. It introduces PyOPL, a compiler with actionable diagnostics, and a rigorously designed loop (generate–compile–assess–revise) that leverages in-context AML grammar and retrieval-augmented exemplars to produce valid PyOPL models and data. A key contribution is the StochasticOR benchmark and a comprehensive cost–latency–accuracy analysis, showing that SyntAGM achieves competitive accuracy with substantially lower token usage and end-to-end latency compared with strong baselines. The work emphasizes readability and auditability through literate modelling and embedded rationale, enabling reuse of artefacts and more principled GenMP workflows with practical implications for scalable, solver-independent modelling.
Abstract
This work investigates generative mathematical programming through the lens of Algebraic Modelling Languages (AMLs) and compiler-guided model synthesis. By leveraging PyOPL, an OPL-like AML compiler that provides detailed syntax diagnostics, we introduce SyntAGM, an end-to-end system that translates natural language problem descriptions into PyOPL models via a generate--compile--assess--revise loop. SyntAGM is grammar-aware thanks to in-context exposure to the PyOPL BNF grammar, and benefits from few-shot retrieval of literate PyOPL model exemplars. To obtain a valid PyOPL model that matches the problem description, SyntAGM mobilises compiler feedback and an LLM-based alignment judge. In a comparative study against established prompting baselines SyntAGM achieves competitive accuracy with superior token, cost, and latency profiles.
