Optimization Modeling via Semantic Anchored Alignment
Yansen Zhang, Qingcan Kang, Yujie Chen, Yufei Wang, Xiongwei Han, Tao Zhong, Mingxuan Yuan, Chen Ma
TL;DR
The paper addresses semantic gaps in LLM-generated optimization models by introducing SAC-Opt, a backward semantic anchor–driven correction framework that aligns problem semantics with generated code through iterative refinement. It extracts structured problem data, translates it into modular code, reconstructs semantics from the code, and uses semantic consistency checks to selectively correct only mismatched components, followed by solver-based debugging if needed. Empirically, SAC-Opt achieves an average accuracy improvement of 7.8% across seven public datasets, with as much as 21.9% gains on ComplexLP, demonstrating strong generalization across models and tasks. This approach enhances fidelity and robustness in automated optimization modeling without extra supervision, offering a scalable path for reliable real-world deployments.
Abstract
Large language models (LLMs) have opened new paradigms in optimization modeling by enabling the generation of executable solver code from natural language descriptions. Despite this promise, existing approaches typically remain solver-driven: they rely on single-pass forward generation and apply limited post-hoc fixes based on solver error messages, leaving undetected semantic errors that silently produce syntactically correct but logically flawed models. To address this challenge, we propose SAC-Opt, a backward-guided correction framework that grounds optimization modeling in problem semantics rather than solver feedback. At each step, SAC-Opt aligns the original semantic anchors with those reconstructed from the generated code and selectively corrects only the mismatched components, driving convergence toward a semantically faithful model. This anchor-driven correction enables fine-grained refinement of constraint and objective logic, enhancing both fidelity and robustness without requiring additional training or supervision. Empirical results on seven public datasets demonstrate that SAC-Opt improves average modeling accuracy by 7.8\%, with gains of up to 21.9\% on the ComplexLP dataset. These findings highlight the importance of semantic-anchored correction in LLM-based optimization workflows to ensure faithful translation from problem intent to solver-executable code.
