Skip to content
Preprint

Optimization and Constraint Modeling using LLMs with a Retrieval Augmented Generation Process

Jun 2026 · 0 citations · 18 references
Computer Science

TL;DR

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.

Abstract

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.

View source

Similar papers

Preprint Jul 2026

IR2Solve: Structured Intermediate Representations for Cost-Efficient Optimization Autoformulation

Large language models (LLMs) can translate natural-language optimization problems into solver-ready formulations, but direct code generation is brittle: schema, indexing, and semantic errors can cause compilation failures, infeasible models, or incorrect objectives, while iterative repair, search, and multi-agent workflows increase inference cost. We present IR2Solve, an intermediate-representation-first autoformulation pipeline that uses a single semantic LLM call to produce a schema-constrained ModelIR, followed by two deterministic stages: verification and IR-to-solver compilation. ModelIR explicitly represents sets, parameters, variables, objectives, and constraints using restricted Python-like expression strings. A concrete scalar-constraint convention represents finite per-index constraint families as individual entries, reducing free-index and implicit-quantification errors while simplifying downstream verification and compilation. Across six cleaned optimization benchmarks, IR2Solve achieves strong objective correctness and remains competitive with recent optimization-modeling systems. A controlled ablation on 153 IndustryOR and ComplexLP instances shows sequential gains from the structured IR interface, the scalar-constraint instruction, and deterministic verification. On a matched ten-instance cost panel, IR2Solve uses one semantic call per instance, whereas Chain-of-Experts and SAC-Opt use 8 and 39 calls per instance and consume 3.3 and 22.9 times the token volume of IR2Solve, respectively. These results show that structured intermediate representations, combined with deterministic post-generation processing, provide a practical accuracy-cost trade-off for LLM-based optimization autoformulation.

Penglin Zhu, Linhai Zhang, Jungang Xu et al. · 0 citations
Preprint Jul 2026

OptGraph: Large Language Models Enhanced Evolutionary Optimization Via Graph Retrieval-Augmented Generation

OptGraph is the first optimization agentic workflow that introduces graph retrieval-augmented generation (GraphRAG) and first constructs reusable experience as a typed graph, capturing the relationships among modeling patterns, problem formalization, implementation details, and error corrections.

Xianchao Xiu, Jianhao Li, Huangyue Chen et al. · 1 citation
Conference Jul 2026

KG-Augmented LLM for Efficient and Correct Dockerfile Generation

Container images are fundamental to cloud deployment, with their build instructions (e.g., Dockerfiles) critically impacting the efficiency and stability of cloud service. Manually authoring these instructions is error-prone, while Large Language Models (LLMs) lack the domain knowledge to generate both correct and optimized Dockerfiles reliably. This problem may cause runtime failures, prolonged deployment times and increased storage overhead. This paper introduces a novel knowledgeenhanced approach to automate Dockerfile generation. First, we construct a Dockerfile Instructions Knowledge Graph (DIKG) by analyzing a large corpus, capturing complex dependencies among images, packages, and commands. Leveraging DIKG, we design DKRAG, a retrieval-augmented generation system that guides an LLM to interpret user requirements and produce semantically accurate instructions. The output is further optimized via log-based repair and static dependency-aware refactoring for correctness, layer sharing, and minimal image size. Comprehensive experiments show our approach significantly improves the generation accuracy while also reducing build time and storage overhead compared to state-of-the-art methods.

Kun Wang, Yao Wu, Hao Fan et al. · 0 citations
Preprint Jul 2026

LLM-Guided Evolutionary Search for Constraint Model Reformulation to Improve Solver Efficiency

Combinatorial problems appear in numerous industrial applications. A common approach is to formulate these problems as declarative constraint models that can subsequently be compiled to and solved by a range of back-end solvers. Recent work shows that Large Language Models (LLMs) can produce correct models from natural language, but even a correct model can be expensive to solve because performance remains sensitive to modelling choices. In this work, we investigate whether LLMs can automate performance-oriented model reformulation. Inspired by Automatic Heuristic Design (AHD), we use an evolutionary framework in which an LLM proposes candidate reformulations that are verified and benchmarked against the user-defined baseline model. We compare AHD-adapted search strategies that control which prior attempts, instructions, and measured feedback enter each prompt. Existing retention strategies prioritize recency or performance, but do not explicitly diversify the context. To cover this gap, we introduce Profile-Diverse Retention (PDR), which applies Maximal Marginal Relevance (MMR) to instance-level runtime vectors to retain behaviourally diverse attempts. We systematically evaluate the strategies on eight CSPLib problems using validation-based final model selection. The results show that: (i) iterative reformulation can produce substantial held-out speedups; (ii) strategies that keep the retained context diverse outperform those that retain only recent or the fastest attempts; and (iii) validation-based selection improves the held-out speedup of every strategy.

Kostis Michailidis, Dimos Tsouros, Nguyen Dang et al. · 0 citations