Understanding Failure Patterns in LLM-Based Mathematical Optimization Modeling

Ryoichi Takase, Xian Yeow Lee, Hikaru Tomonari, Masaya TsunokakearXiv 2026

TL;DR

Ask an LLM to write code for a complex industrial scheduling problem, and it might hand you a program that runs without crashing, finds a mathematically valid answer, and is still completely wrong. By dissecting optimization modeling into three distinct skills—math reasoning, coding for solvers, and domain rules—researchers mapped out why LLMs fail at operations research. Their verdict: we’ve gotten pretty good at teaching models how to write code that executes, but silent formulation errors remain the ultimate boss fight.

What Problem Does This Paper Address?

Every day, factories, airlines, and power grids rely on mathematical optimization—like Linear Programming (LP) and Mixed-Integer Linear Programming (MILP)—to schedule crews and route supplies under strict safety and regulatory rules. Building these mathematical models from scratch takes serious human expertise, making it hard to scale.

Naturally, researchers have tried using Large Language Models (LLMs) to translate plain-English problem descriptions directly into solver-ready code. While promising on toy problems, LLMs struggle in industrial-scale settings. Most past research has focused purely on nudging overall accuracy numbers upward. Here, the authors ask a more diagnostic question: when LLMs fail at optimization, how exactly do they break?

In practice, failures fall into three buckets: non-executable code (syntax or API bugs), infeasible formulations (impossible constraints where no solution exists), and feasible but incorrect solutions (the code runs and outputs an answer, but solves the wrong math problem). Because formulation, domain rules, and coding are all tangled together in the final script, figuring out what went wrong is notoriously tricky.

Methods

To untangle these errors, the authors break end-to-end optimization modeling down into three core skills:

  1. Mathematical Reasoning: Translating informal text into formal decision variables, objectives, and constraints.
  2. Solver Usage: Knowing the specific Python APIs (like PySCIPOpt) and syntax needed to write executable code.
  3. Domain Knowledge: Incorporating real-world operational rules so the math actually reflects reality.
Figure 1: Overview of the three-step data construction pipeline.

Instead of treating data generation as a monolith, they built a three-step synthetic pipeline using gpt-oss-120b alongside automated feedback from an optimization solver:

  • Step 1 (Reasoning): Prompting the LLM to generate problems, math formulations, and code, using the solver to filter out unsolvable ones.
  • Step 2 (Solver Usage): Taking non-executable code and running iterative debugging loops using solver error messages to capture common API mistakes and fixes.
  • Step 3 (Domain Knowledge): Taking infeasible problems, refining them with realistic operational rules, and iteratively scaling up their complexity.

Finally, they used off-the-shelf LLMs as diagnostic probes on these datasets, and fine-tuned Qwen3 models (1.7B, 4B, and 32B via GRPO reinforcement learning and rejection sampling) to run ablation studies—removing one data type at a time to see how failure modes shifted.

Datasets

Starting from the s1-1.1 seed dataset, the authors generated three specialized datasets (reserving 5%–8% of each for testing):

  • Math-Opt Reasoning (32K samples): Comparable in difficulty and reasoning length to standard benchmarks.
  • Solver Usage (4K samples): Focused heavily on API interactions and code debuggability.
  • Domain Knowledge (8K samples): Complex, scaled-up problems heavy on operational constraints.

For evaluation, they tested their fine-tuned models against five existing optimization benchmarks: ComplexOR, IndustryOR, ComplexLP, NLP4LP, and NL4Opt.

Key Insights and Ideas

  • Different skills trigger different crashes: When diagnostic LLMs were tested on the new datasets, distinct error profiles emerged. The Solver Usage dataset triggered the highest rate of non-executable code, while the Domain Knowledge dataset burned through way more "thinking tokens" and triggered the highest rate of infeasible models.
  • The illusion of working code: Fine-tuning on all three components successfully teaches LLMs not to crash—non-executable errors drop noticeably. However, feasible but incorrect solutions ("Wrong Objective") remain the dominant failure mode.
  • Silent failures scale with complexity: The harder the benchmark, the more likely an LLM is to write plausible-looking code that runs cleanly and returns an answer to the wrong problem—usually due to a subtly dropped constraint or misstated objective. Execution-based validation (simply checking if the solver runs) is blind to this.

Key Results

  • Diagnostic Trends: Across off-the-shelf models (gpt-oss 120B/20B and Qwen3 32B/8B), Math-Opt Reasoning yielded accuracy (~20%–33% on Qwen3-32B and gpt-oss-120b) similar to existing benchmarks. In contrast, accuracy plummeted to ~10%–12% on Solver Usage and Domain Knowledge, even as Qwen3-32B expanded its reasoning budget to ~10,000 thinking tokens on the domain tasks.
Accuracy and thinking-token usage on Qwen3-32B across standard benchmarks (gray) vs. Math-Opt Reasoning (red), Solver Usage (blue), and Domain Knowledge (orange).
  • Ablation Findings: Fine-tuning Qwen3 (1.7B and 4B) on the combined dataset consistently delivered the best overall performance across all five standard benchmarks. Dropping the Solver Usage data caused non-executable outputs to spike, confirming its role as syntax glue.
  • Persistent Formulation Gap: Even when scaling up to a 32B parameter model fine-tuned with GRPO (Qwen3-32B-GRPO) or evaluating frontier models (gpt-5.2, gpt-4.1), "Wrong Objective" errors towered over timeouts, infeasibility, and syntax crashes on complex tasks like IndustryOR and ComplexLP. (Note: The text references specific ablation numbers in "Tables 1 and 2", though those tables are omitted from the 5-page preprint).

Limitations and Future Work

The authors are candid about two main hurdles. First, while removing certain data components shifts error rates, the exact causal relationships between dataset mixtures and failure modes aren't always clean or consistent—the three skills remain tightly entangled in practice. Second, current data-centric pipelines rely heavily on solver execution for filtering and supervision. Because a solver can't tell you if a mathematically valid model actually matches what the user asked for in English, near-correct formulations slip right through. Future reliability breakthroughs will require new dataset designs that explicitly verify constraint completeness, boundary conditions, and structural equivalence—teaching LLMs to spot the subtle difference between code that runs and math that is right.

Summary updated

Abstract

Industrial optimization involves complex constraints, making optimization modeling difficult to automate. Large language models (LLMs) have been explored for generating optimization models from natural language, but their reliability in end-to-end settings remains limited, often producing non-executable, infeasible, or feasible but incorrect solutions. In this work, we study failure modes in LLM-based optimization modeling by decomposing the process into three components: mathematical reasoning, solver usage, and domain knowledge, and constructing datasets that target each aspect. Using these datasets, we analyze how different components relate to errors and find that they are associated with different types of failure, although these relationships are not always strong or consistent. Furthermore, while combining these components improves execution reliability, feasible but incorrect solutions remain the dominant failure mode, suggesting a remaining gap between executability and correctness. These findings highlight limitations of current dataset designs and suggest the importance of data that better capture constraint completeness and formulation accuracy to enhance reliability.
BibTeX
@misc{takase2026understanding,
  author = {Ryoichi Takase and Xian Yeow Lee and Hikaru Tomonari and Masaya Tsunokake},
  title = {{Understanding Failure Patterns in LLM-Based Mathematical Optimization Modeling}},
  year = {2026},
  eprint = {2611.33351},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2611.33351},
}
Figure