Table of Contents
Fetching ...

Peering Inside the Black Box: Uncovering LLM Errors in Optimization Modelling through Component-Level Evaluation

Dania Refai, Moataz Ahmed

TL;DR

This work addresses the challenge of diagnosing errors in LLM-generated optimization formulations by introducing a component-level evaluation framework that goes beyond global solution metrics. It defines metrics for constraint precision/recall, decision-variable precision/recall, obj-RMSE, cons-RMSE, and a standard optimality gap, plus efficiency measures, and applies six prompting strategies to three LLMs across four optimization problems. The key finding is that constraint coverage and accurate constraint behavior (low Cons-RMSE) drive solver success, with GPT-5 consistently delivering solver-ready formulations, particularly under CoT, self-consistency, and modular prompting. This diagnostic framework enables targeted improvements in NLP-to-optimization pipelines and has practical implications for deploying LLMs in decision-support and automated modeling workflows.

Abstract

Large language models (LLMs) are increasingly used to convert natural language descriptions into mathematical optimization formulations. Current evaluations often treat formulations as a whole, relying on coarse metrics like solution accuracy or runtime, which obscure structural or numerical errors. In this study, we present a comprehensive, component-level evaluation framework for LLM-generated formulations. Beyond the conventional optimality gap, our framework introduces metrics such as precision and recall for decision variables and constraints, constraint and objective root mean squared error (RMSE), and efficiency indicators based on token usage and latency. We evaluate GPT-5, LLaMA 3.1 Instruct, and DeepSeek Math across optimization problems of varying complexity under six prompting strategies. Results show that GPT-5 consistently outperforms other models, with chain-of-thought, self-consistency, and modular prompting proving most effective. Analysis indicates that solver performance depends primarily on high constraint recall and low constraint RMSE, which together ensure structural correctness and solution reliability. Constraint precision and decision variable metrics play secondary roles, while concise outputs enhance computational efficiency. These findings highlight three principles for NLP-to-optimization modeling: (i) Complete constraint coverage prevents violations, (ii) minimizing constraint RMSE ensures solver-level accuracy, and (iii) concise outputs improve computational efficiency. The proposed framework establishes a foundation for fine-grained, diagnostic evaluation of LLMs in optimization modeling.

Peering Inside the Black Box: Uncovering LLM Errors in Optimization Modelling through Component-Level Evaluation

TL;DR

This work addresses the challenge of diagnosing errors in LLM-generated optimization formulations by introducing a component-level evaluation framework that goes beyond global solution metrics. It defines metrics for constraint precision/recall, decision-variable precision/recall, obj-RMSE, cons-RMSE, and a standard optimality gap, plus efficiency measures, and applies six prompting strategies to three LLMs across four optimization problems. The key finding is that constraint coverage and accurate constraint behavior (low Cons-RMSE) drive solver success, with GPT-5 consistently delivering solver-ready formulations, particularly under CoT, self-consistency, and modular prompting. This diagnostic framework enables targeted improvements in NLP-to-optimization pipelines and has practical implications for deploying LLMs in decision-support and automated modeling workflows.

Abstract

Large language models (LLMs) are increasingly used to convert natural language descriptions into mathematical optimization formulations. Current evaluations often treat formulations as a whole, relying on coarse metrics like solution accuracy or runtime, which obscure structural or numerical errors. In this study, we present a comprehensive, component-level evaluation framework for LLM-generated formulations. Beyond the conventional optimality gap, our framework introduces metrics such as precision and recall for decision variables and constraints, constraint and objective root mean squared error (RMSE), and efficiency indicators based on token usage and latency. We evaluate GPT-5, LLaMA 3.1 Instruct, and DeepSeek Math across optimization problems of varying complexity under six prompting strategies. Results show that GPT-5 consistently outperforms other models, with chain-of-thought, self-consistency, and modular prompting proving most effective. Analysis indicates that solver performance depends primarily on high constraint recall and low constraint RMSE, which together ensure structural correctness and solution reliability. Constraint precision and decision variable metrics play secondary roles, while concise outputs enhance computational efficiency. These findings highlight three principles for NLP-to-optimization modeling: (i) Complete constraint coverage prevents violations, (ii) minimizing constraint RMSE ensures solver-level accuracy, and (iii) concise outputs improve computational efficiency. The proposed framework establishes a foundation for fine-grained, diagnostic evaluation of LLMs in optimization modeling.
Paper Structure (28 sections, 25 equations, 10 figures, 7 tables)

This paper contains 28 sections, 25 equations, 10 figures, 7 tables.

Figures (10)

  • Figure 3: Taxonomy of evaluation metrics.
  • Figure 4: The main phases of the adopted methodology.
  • Figure 5: Prompting techniques for guiding LLMs in optimization formulation.
  • Figure 6: Radar chart comparison of model performance across four benchmark optimization problems. Each axis represents an evaluation metric: Constraint precision (Cons-P), constraint recall (Cons-R), decision variable precision (DV-P), decision variable recall (DV-R), optimality gap (Optimality), objective RMSE (Obj-RMSE), constraint RMSE (Cons-RMSE), and efficiency (Latency, input tokens, output tokens). Higher values indicate better performance.
  • Figure 7: Heatmap of prompt effectiveness across problems. Each cell shows the aggregated performance score (0–100%) for each problem–prompt pair. Darker shades indicate better performance, with P3, P5, and P6 showing the highest overall scores.
  • ...and 5 more figures