Table of Contents
Fetching ...

LLMOPT: Learning to Define and Solve General Optimization Problems from Scratch

Caigao Jiang, Xiang Shu, Hong Qian, Xingyu Lu, Jun Zhou, Aimin Zhou, Yang Yu

TL;DR

LLMOPT presents a unified learning-based framework to automatically define and solve general optimization problems from natural language. It introduces a universal five-element formulation (Sets, Parameters, Variables, Objective, Constraints), enhanced by multi-instruction SFT and Kahneman-Tversky-inspired model alignment, plus an auto-testing/self-correction loop. Across six real-world datasets spanning LP, IP, MIP, NP, CO, and MOP, LLMOPT achieves state-of-the-art solving accuracy with an average improvement of 11.08% over prior methods. The approach demonstrates strong generalization, robustness to hallucination, and practical potential for automated optimization in diverse domains.

Abstract

Optimization problems are prevalent across various scenarios. Formulating and then solving optimization problems described by natural language often requires highly specialized human expertise, which could block the widespread application of optimization-based decision making. To automate problem formulation and solving, leveraging large language models (LLMs) has emerged as a potential way. However, this kind of approach suffers from the issue of optimization generalization. Namely, the accuracy of most current LLM-based methods and the generality of optimization problem types that they can model are still limited. In this paper, we propose a unified learning-based framework called LLMOPT to boost optimization generalization. Starting from the natural language descriptions of optimization problems and a pre-trained LLM, LLMOPT constructs the introduced five-element formulation as a universal model for learning to define diverse optimization problem types. Then, LLMOPT employs the multi-instruction tuning to enhance both problem formalization and solver code generation accuracy and generality. After that, to prevent hallucinations in LLMs, such as sacrificing solving accuracy to avoid execution errors, the model alignment and self-correction mechanism are adopted in LLMOPT. We evaluate the optimization generalization ability of LLMOPT and compared methods across six real-world datasets covering roughly 20 fields such as health, environment, energy and manufacturing, etc. Extensive experiment results show that LLMOPT is able to model various optimization problem types such as linear/nonlinear programming, mixed integer programming, and combinatorial optimization, and achieves a notable 11.08% average solving accuracy improvement compared with the state-of-the-art methods. The code is available at https://github.com/caigaojiang/LLMOPT.

LLMOPT: Learning to Define and Solve General Optimization Problems from Scratch

TL;DR

LLMOPT presents a unified learning-based framework to automatically define and solve general optimization problems from natural language. It introduces a universal five-element formulation (Sets, Parameters, Variables, Objective, Constraints), enhanced by multi-instruction SFT and Kahneman-Tversky-inspired model alignment, plus an auto-testing/self-correction loop. Across six real-world datasets spanning LP, IP, MIP, NP, CO, and MOP, LLMOPT achieves state-of-the-art solving accuracy with an average improvement of 11.08% over prior methods. The approach demonstrates strong generalization, robustness to hallucination, and practical potential for automated optimization in diverse domains.

Abstract

Optimization problems are prevalent across various scenarios. Formulating and then solving optimization problems described by natural language often requires highly specialized human expertise, which could block the widespread application of optimization-based decision making. To automate problem formulation and solving, leveraging large language models (LLMs) has emerged as a potential way. However, this kind of approach suffers from the issue of optimization generalization. Namely, the accuracy of most current LLM-based methods and the generality of optimization problem types that they can model are still limited. In this paper, we propose a unified learning-based framework called LLMOPT to boost optimization generalization. Starting from the natural language descriptions of optimization problems and a pre-trained LLM, LLMOPT constructs the introduced five-element formulation as a universal model for learning to define diverse optimization problem types. Then, LLMOPT employs the multi-instruction tuning to enhance both problem formalization and solver code generation accuracy and generality. After that, to prevent hallucinations in LLMs, such as sacrificing solving accuracy to avoid execution errors, the model alignment and self-correction mechanism are adopted in LLMOPT. We evaluate the optimization generalization ability of LLMOPT and compared methods across six real-world datasets covering roughly 20 fields such as health, environment, energy and manufacturing, etc. Extensive experiment results show that LLMOPT is able to model various optimization problem types such as linear/nonlinear programming, mixed integer programming, and combinatorial optimization, and achieves a notable 11.08% average solving accuracy improvement compared with the state-of-the-art methods. The code is available at https://github.com/caigaojiang/LLMOPT.

Paper Structure

This paper contains 32 sections, 40 equations, 8 figures, 11 tables.

Figures (8)

  • Figure 1: An example of the proposed five-element formulation, which provides a structured definition for general optimization problems. Using the five-element formulation as an intermediate step can lead to more accurate solver code and solution.
  • Figure 2: The framework of LLMOPT. Sub-figure (a) shows the data labeling process, where experts and GPT-4 work together to label both the five-element formulation and solver code. Sub-figure (b) shows the learning process, in which multi-instruction supervised fine-tuning and model alignment are employed to learn-to-define and generate code. Sub-figure (c) shows the auto-testing process with self-correction mechanism, which can define and solve optimization problems automatically.
  • Figure 3: The results of the SA metric. Sub-figure (a) compares the SA performance of GPT-4o and the Qwen1.5-14B model with only SFT, showing the potential of learning-based methods. Sub-figures (b), (c) and (d) perform ablation on five-element and KTO. The Mamo Easy and Mamo Complex datasets are abbreviated as Mamo E. and Mamo C., due to space constraints.
  • Figure 4: Comparison of SA and AST between LLMOPT, GPT-4, and ablated versions.
  • Figure 5: Comparison in (a) solving accuracy and (b) execution rate between Qwen1.5 and Qwen2.
  • ...and 3 more figures