Optimization and Constraint Modeling using LLMs with a Retrieval Augmented Generation Process
06:00 · August 4, 2026 · arXiv cs.AI RSS

Both optimization modeling and constraint modeling are non-trivial problems requiring deep domain expertise and proficiency in modeling formalism languages. Despite their importance across logistics, healthcare, and supply chain management, current large language models regularly produce structurally inconsistent or incomplete optimization formulations, particularly in combinatorial settings. This paper evaluates whether a Retrieval-Augmented Generation pipeline built on a curated synthetic dataset can meaningfully improve LLM optimization modeling performance. A total of 500 optimization problems were synthesized using seed descriptions from the Text2Zinc dataset and professional personas created using an LLM, specified in JSON and associated with validated Python solver scripts. These problems were encoded in a Chroma vector database. For each inference problem, semantically similar problems were retrieved and used as contextual guidance for a LangChain LLM agent. Three benchmark testbeds were used to evaluate the proposed pipeline under the Qwen 3 30B Instruct model. Accuracy rose from 40% to 72% on NL4OPT, 40% to 56% on MAMO Easy, and 32% to 56% on MAMO Complex. The use of semantically validated synthetic examples greatly improves both solution accuracy and structure. The combination of synthetic dataset generation with retrieval augmentation provides an effective alternative to fine-tuning, suggesting that domain-specific synthetic corpora paired with retrieval augmentation can serve as a practical pathway for deploying LLM-based optimization tools in real-world decision-support contexts without costly model retraining.
Summary
A new Retrieval-Augmented Generation pipeline addresses the persistent difficulty large language models face when translating natural-language descriptions into formally correct optimization and constraint models. The approach constructs a synthetic corpus of 500 problems drawn from Text2Zinc seed descriptions and LLM-generated professional personas. Each entry is stored as a validated JSON specification paired with an executable Python solver script, then indexed in a Chroma vector database.
During inference, a LangChain agent retrieves the most semantically similar stored examples through cosine similarity and supplies them as in-context guidance to the Qwen 3 30B Instruct model. A semantic gateway filters retrieved items before they enter the prompt, reducing noise while preserving structural cues such as variable declarations, constraint patterns, and objective formulations.
Evaluations on three public benchmarks demonstrate consistent gains. Accuracy on NL4OPT rose from 40 % to 72 %, on MAMO Easy from 40 % to 56 %, and on MAMO Complex from 32 % to 56 %. The improvements appear in both syntactic validity and logical completeness of the generated models, suggesting that retrieval of verified problem–solution pairs compensates for gaps in the model’s parametric knowledge of combinatorial structure.
The method offers a modular alternative to fine-tuning. By updating the vector store with additional domain-specific examples, practitioners can extend coverage without retraining the underlying language model, lowering the barrier to deploying LLM-based decision-support tools in logistics, healthcare, and supply-chain applications.
Why it matters
High technical depth and reproducibility make it directly actionable for Dutch researchers in logistics, supply chain, and OR; aligns with NL strengths in ethical AI and SME decision-support tools.




