Table of Contents
Fetching ...

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.

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

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.
Paper Structure (58 sections, 5 equations, 10 figures, 10 tables, 1 algorithm)

This paper contains 58 sections, 5 equations, 10 figures, 10 tables, 1 algorithm.

Figures (10)

  • Figure 1: High-level generate–compile–assess–revise loop of SyntAGM.
  • Figure 2: A GenMP task --- translating the "dynamic lot sizing" problem description into a mathematical programme.
  • Figure 3: A GenMP task --- translating a problem description in the realm of power generation into a mathematical programme.
  • Figure 4: Aircraft Landing Problem description
  • Figure 5: Extract from the erroneous PyOPL model for the ALP generated by the system.
  • ...and 5 more figures