Optimizing Prompt Sequences using Monte Carlo Tree Search for LLM-Based Optimization
Organizations: The George Washington University · United States Military Academy
Abstract
Mathematical optimization is a core tool in engineering, operations research, and data science, but modeling real problems remains difficult and time-consuming. In practice, an expert must work with clients to translate informal domain descriptions into precise objectives, constraints, and solver-ready code; small mistakes in this process can lead to infeasible, nonconvex, or suboptimal formulations, and the iterative process is often slow. Large language models (LLMs) could automate this translation from natural language to optimization code, but standard prompting often fails on realistic tasks: it struggles with long, structured task descriptions, mishandles constraints, and produces infeasible, non-convex, or non-executable programs. We introduce Monte Carlo Tree Search for Reasoning Decomposition Plans (MCTS-RDP), which performs pre-hoc test-time scaling by searching over decomposition plans and their resulting programs before committing to the final output. MCTS-RDP treats plan construction as a sequential decision problem: given a problem description, it decomposes the task descriptions into logical components and generates candidate plan steps for each component. Monte Carlo Tree Search (MCTS) then explores and refines Reasoning Decomposition Plans (RDPs) prior to code synthesis, balancing exploration and exploitation across alternative plan sequences. Each candidate plan is rolled out into executable code, executed, and scored with an execution-grounded evaluator measuring executability, constraint satisfaction, and solution quality; this feedback is backpropagated through the search tree to guide subsequent search. Across wireless optimization tasks and the NL4OPT and NLP4LP benchmarks, MCTS-RDP consistently outperforms strong baselines, improving execution success, reward, stability, and optimality attainment.
Figures & tables
| Method | Base Model | Code Execution Success Rate | Reward (Out of 10) SD | Constraint Satisfied | Optimality Attained | Avg Tokens Used | Avg End-to-End Time (s) |
|---|---|---|---|---|---|---|---|
| MCTS - RDP | GPT-5 | 100.00% | 9.56 1.41 | 100.00% | 92.00% | 7517 | 100.26 |
| Gemini-2.5-Pro | 100.00% | 9.59 1.46 | 98.00% | 91.00% | 7247 | 39.72 | |
| Optimus | GPT-5 | 80.00% | 7.25 4.44 | 76.00% | 69.00% | 32130 | 350.72 |
| Gemini-2.5-Pro | 90.00% | 7.69 4.02 | 82.00% | 66.00% | 43298 | 272.26 | |
| Self-Refine | GPT-5 | 100.00% | 9.31 1.52 | 97.00% | 77.00% | 5722 | 80.42 |
| Gemini-2.5-Pro | 100.00% | 9.52 1.48 | 97.00% | 79.00% | 6550 | 42.05 |
| Method | Base Model | Code Execution Success Rate | Reward (Out of 10) SD | Constraint Satisfied | Optimality Attained | Avg Tokens Used | Avg End-to-End Time (s) |
|---|---|---|---|---|---|---|---|
| MCTS - RDP | GPT-5 | 100.00% | 9.47 1.37 | 97.52% | 78.10% | 7158 | 70.08 |
| Gemini-2.5-Pro | 100.00% | 9.51 1.59 | 97.52% | 76.45% | 6940 | 38.28 | |
| Optimus | GPT-5 | 72.73% | 6.09 4.81 | 66.53% | 55.79% | 29273 | 328.00 |
| Gemini-2.5-Pro | 92.56% | 8.41 3.53 | 88.02% | 69.42% | 38182 | 244.68 | |
| Self-Refine | GPT-5 | 100.00% | 9.40 1.52 | 97.93% | 78.10% | 4527 | 66.57 |
| Gemini-2.5-Pro | 100.00% | 9.44 1.80 | 94.21% | 74.38% | 6333 | 37.57 |
| Method | Code Execution Success Rate | Reward (Out of 10) SD | Optimality Attained | Avg Tokens Used | ||||
| Problem Difficulty | Easy | Hard | Easy | Hard | Easy | Hard | Easy | Hard |
| MCTS-RDP | 98.00% | 70.00% | 9.11 0.43 | 6.75 3.89 | 92.00% | 66.00% | 67,825 | 171,915 |
| Self-Refine | 90.00% | 18.00% | 8.66 3.26 | 0.10 1.89 | 78.00% | 0.00% | 1,242 | 4,416 |
| Chain-of-Thought | 92.00% | 14.00% | 5.78 4.38 | -0.30 1.67 | 54.00% | 4.00% | 3,077 | 4,755 |
| GPT-4 Baseline | 72.00% | 0.00% | 4.75 1.29 | -1.00 0.00 | 58.00% | 0.00% | 736 | 525 |
| GPT-3.5-turbo Baseline | 76.00% | 0.00% | 4.36 4.35 | -1.00 0.00 | 42.00% | 0.00% | 768 | 552 |
| Metric | Overall ( ) | Optimal ( ) | Suboptimal ( ) |
|---|---|---|---|
| Within-evaluator Boolean agreement | |||
| Executed | |||
| Constraint satisfied | — | — | |
| Ground-truth match | |||
| Scalar reward variation | |||
| Mean within-trace SD | |||
| Method | Mean Reward | Best-of-3 Reward | Mean Optimality | Success@ | Avg. Tokens |
|---|---|---|---|---|---|
| One-shot | 9.09 | 9.52 | 75.0% | 78.0% | 13,788 |
| MCTS-RDP | 8.53 | 9.63 | 66.3% | 82.0% | 64,584 |
| MCTS-RDP-10 | 9.16 | 9.60 | 74.0% | 78.0% | 19,595 |
| Method | Code Execution Success Rate | Reward (Out of 10) SD | Constraint Satisfied | Optimality Attained | Avg Tokens Used |
|---|---|---|---|---|---|
| MCTS-RDP-10 | 100.00% | 9.67 1.19 | 98.00% | 96.00% | 7133 |
| MCTS-RDP-20 | 100.00% | 9.58 1.29 | 98.00% | 96.00% | 8956 |
| MCTS-RDP-30 | 100.00% | 9.61 1.24 | 100.00% | 96.00% | 10215 |
| MCTS-RDP-40 | 100.00% | 9.32 1.53 | 98.00% | 87.00% | 12195 |
| MCTS-RDP-50 | 100.00% | 9.65 1.00 | 98.00% | 95.00% | 13956 |
| Method | Code Execution Success Rate | Reward Avg (Out of 10) | Constraint Satisfied | Optimality Attained | Avg Tokens Used | Avg End-to-End Time (s) |
|---|---|---|---|---|---|---|
| MCTS-RDP (search-then-apply) | 100.00% | 9.47 1.37 | 97.52% | 78.10% | 7158 | 70.08 |
| w/o MCTS (Decomposition-only) | 99.59% | 8.28 2.73 | 95.45% | 60.74% | 20359 | 297.98 |
| w/o MCTS + w/o decomposition (one-shot) | 98.76% | 9.21 1.97 | 97.52% | 76.03% | 4545 | 59.41 |
Appendix figures & tables7 assets
Supplementary material from the paper’s appendix.
Appendix
| Setting | Value |
|---|---|
| GPT-5 temperature | |
| Gemini temperature | |
| Execution timeout | s |
| Ground-truth tolerance | |
| UCT exploration constant | |
| MCTS simulations per SEARCH instance |
Natural Language to Optimization Modeling
Natural language to optimization modeling translates human requirements into formal mathematical models and solver-ready code.
See all 74 papers