OptimAI: Optimization from Natural Language Using LLM-Powered AI Agents

Raghav Thind, Youran Sun, Ling Liang, Haizhao Yang · DOI

Abstract

OptimAI is a multi-agent framework designed to solve complex optimization problems from natural language descriptions. By implementing a "plan-before-code" strategy and an intelligent debugging scheduler based on reinforcement learning, it bridges the gap between real-world goals and formal mathematical modeling. OptimAI reduces error rates by over 50% compared to previous state-of-the-art methods, demonstrating significant improvements in productivity and robustness across diverse benchmarks.

Introduction

Optimization is a cornerstone of modern engineering, yet translating vague real-world goals into formal mathematical models remains a significant challenge. This "expertise gap" often prevents non-experts from leveraging powerful solvers like Gurobi or CPLEX. While Large Language Models (LLMs) are proficient at general coding, they frequently struggle with the rigid logic and complex constraints of optimization tasks.

Comparison of functional capabilities between OptimAI and existing frameworks.

Existing automated systems often fail because they attempt to generate code immediately or lack the ability to pivot when a strategy proves fundamentally flawed. OptimAI addresses these limitations through a structured pipeline of specialized agents and an adaptive scheduling mechanism.

Methodology

OptimAI breaks the problem-solving process into a pipeline of specialized AI agents, ensuring that planning and critiquing precede final execution.

The OptimAI multi-agent workflow, illustrating the transition from natural language to optimization results.

The Multi-Agent Pipeline

The framework utilizes several distinct agent roles:

  1. Formulator: Translates natural language into a structured mathematical model (variables, objectives, and constraints).
  2. Planner: Suggests high-level strategies and selects the optimal solver (e.g., Pyomo, OR-Tools, or Gekko).
  3. Coder & Code Critic: The Coder generates Python scripts, while the Critic iteratively analyzes execution errors to suggest refinements.
  4. Decider & Verifier: These agents score plan viability and verify that the final output satisfies all original constraints.

UCB-based Debug Scheduling

A standout technical contribution is the UCB-based Debug Scheduling. Treating debugging as a "Multi-Armed Bandit" problem, the system uses the Upper Confidence Bound (UCB) algorithm to decide when to abandon a failing plan and switch to an alternative strategy. This prevents the system from becoming stuck in unproductive debugging loops.

Experimental Results

OptimAI was evaluated across several diverse benchmarks, including NLP4LP, Optibench, and standard libraries like TSPLIB and SelfJSP.

Key Insights

  • Planning and Critiquing: Ablation studies showed that the "Planner" agent is vital, with its removal causing a 5.8x drop in productivity. Similarly, a dedicated "Code Critic" led to a 3.1x increase in productivity.
  • Adaptive Switching: The UCB-based scheduler provided a 3.3x productivity gain by dynamically managing solution strategies.
  • Model Synergy: Mixing different LLMs (e.g., Gemma 2 27B for planning and Llama 3.3 70B for other roles) often outperformed single-model configurations.

Performance Metrics

OptimAI achieved an accuracy of 88.1% on NLP4LP and 82.3% on Optibench. Compared to previous state-of-the-art methods like OptiMUS, OptimAI reduced error rates by 58%. Furthermore, over 99% of the generated code executed successfully without runtime errors.

Limitations and Future Work

The Decider agent, responsible for initial plan selection, currently identifies the successful plan on the first try only 39.7% of the time. Future work will focus on fine-tuning this component using reinforcement learning and scaling the framework to handle complex, industrial-scale optimization projects.

Summary updated

BibTeX
@misc{thind2025optimai,
  author = {Raghav Thind and Youran Sun and Ling Liang and Haizhao Yang},
  title = {{OptimAI: Optimization from Natural Language Using LLM-Powered AI Agents}},
  year = {2025},
  eprint = {2504.16918},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2504.16918},
}
Figure