LLM-Guided Evolutionary Search for Constraint Model Reformulation to Improve Solver Efficiency

Kostis Michailidis, Dimos Tsouros, Nguyen Dang, Tias GunsarXiv 2026

TL;DR

This paper introduces an evolutionary framework that leverages Large Language Models (LLMs) to automatically reformulate constraint programming models for drastically improved solver efficiency. By introducing Profile-Diverse Retention (PDR)—a strategy that uses instance-level runtimes to keep the LLM's prompt context behaviorally diverse—and incorporating a dedicated validation step, the authors achieve substantial speedups across various combinatorial problems while significantly reducing LLM API costs.

What Problem Does This Paper Address?

Constraint Programming (CP) is a powerful paradigm used to solve complex combinatorial problems like scheduling, routing, and industrial configuration. While recent advances show that LLMs are remarkably good at generating correct and executable CP models from natural language descriptions, correctness does not equal efficiency.

In CP, minor modeling choices (such as how variables are defined or how constraints are formulated) can alter a solver's runtime by orders of magnitude. Human experts routinely perform "model reformulation" to optimize performance, but automating this process has long been a challenge. Prior automated attempts have largely focused on simply appending simple constraints (called streamliners) to an existing model. This paper tackles the more ambitious goal of whole-model reformulation—allowing an LLM to completely rethink variable viewpoints, encodings, and global constraints to optimize solver efficiency.

Methods

The authors propose an iterative, evolutionary search loop driven by an LLM (specifically DeepSeek V4 Flash) acting as the optimization engine.

Figure 1: Iterative model reformulation. B: baseline; Dtr, Dval, Dtest: training, validation, test sets. At iteration t ≤T, the generator proposes model mt with rationale ρt, evaluates it on Dtr, and updates history Ht with evaluator feedback Et; strategy σ then selects context Rt+1 from Ht for the next iteration. The final model is chosen on Dval after search terminates. PDR exemplifies the search strategies compared.

The core workflow operates as follows:

  1. Prompting: The LLM is provided with a baseline model, task instructions, and a selection of prior attempts (the context).
  2. Generation: The LLM proposes a new reformulated model along with a natural-language rationale.
  3. Evaluation: An automated evaluator checks the code for syntactic correctness, verifies solution validity against the baseline, and benchmarks its execution time across a set of training instances.
  4. Feedback Loop: The history is updated with the new model's performance data.

Profile-Diverse Retention (PDR)

The key algorithmic innovation lies in how the framework selects which prior attempts to show the LLM in the next prompt. Traditional evolutionary strategies look only at recency (the last $k$ attempts) or quality (the fastest $k$ attempts). The authors argue this causes the LLM to stall in local optima.

To fix this, they introduce PDR. PDR characterizes each model by its "behavioral profile"—a vector of its normalized log-runtimes across all training instances. It then applies Maximal Marginal Relevance (MMR) to select prior attempts that are not only fast but also behaviorally distinct from one another. This explicitly forces the LLM to explore diverse modeling paradigms.

Validation-Based Selection

Unlike typical Automatic Heuristic Design pipelines that simply return the best performer on the training set, this framework introduces a separate validation step. Candidates that perform well on training data are re-evaluated on a validation set to protect against overfitting before the final model is selected.

Datasets

The framework was evaluated on eight classic combinatorial satisfaction problems sourced from CSPLib:

  • Car Sequencing (Problem 1)
  • Vessel Loading (Problem 8)
  • Social Golfer (Problem 10)
  • Balanced Incomplete Block Design (BIBD, Problem 28)
  • Balanced Academic Curriculum (BACP, Problem 30)
  • Error-Correction Codes (ECC, Problem 36)
  • Covering Arrays (Problem 45)
  • Tail Assignment (Problem 115)

For each problem, instances were carefully partitioned into training, validation, and test sets using a runtime-stratified protocol to ensure a balanced distribution of problem difficulty.

Key Insights and Ideas

  • Context Diversity Beats Raw Quality: Showing the LLM a diverse set of past attempts (even slightly slower ones that took a completely different approach) prevents it from making superficial syntax tweaks and encourages it to discover entirely new variable viewpoints or global constraints.
  • Code Overfits Just Like Machine Learning: Code optimized purely on a small training set frequently overfits to those specific instances. Introducing a validation-based selection step is vital to filter out brittle models that degrade on unseen test data.
  • Whole-Model Reformulation > Additive Streamlining: Completely rewriting the model allows the LLM to implement advanced techniques (like automatic tabulation or complex symmetry breaking) that provide significantly higher speedups than merely appending extra constraints to a poor baseline.

Key Results

  • Substantial Speedups: Across 240 experimental runs, the evolutionary search successfully found faster, valid models in the majority of cases. PDR achieved the highest aggregate geometric mean speedup of 2.26x across all problems.
  • Massive Outliers: On specific problems, the speedups were massive. For instance, one PDR run on covering arrays achieved a staggering 250.7x speedup by discovering a highly effective canonical enumeration prefix that acted as a powerful symmetry breaker.
Figure 2: Held-out test speedup by problem and strategy, ordered by each problem’s GM across all runs. Each bar is the GM over the three repetitions, and the interval shows the geometric standard deviation.
  • Validation is Essential: As shown in the chart below, validation-based final model selection consistently improved the held-out test speedup for every single strategy evaluated, effectively mitigating training-set overfitting.
Figure 5: Held-out speedup when selecting the final model by validation or keeping the final training incumbent.
  • Cost Efficiency: Because PDR reuses structured history effectively, it leverages modern LLM KV-caching. This allowed PDR to deliver the highest overall speedups at a 27% lower API cost compared to naive random sampling.

Limitations and Future Work

While promising, the authors note several limitations that pave the way for future research:

  • Scope of Evaluation: The study was restricted to a single LLM (DeepSeek V4 Flash), a single solver configuration (OR-Tools CP-SAT on a single core), and focused entirely on satisfaction problems rather than optimization problems (which involve minimizing/maximizing an objective function).
  • Profile Metrics: PDR currently measures behavioral diversity solely through runtime vectors. The authors suggest that incorporating richer, solver-specific feedback—such as propagation counts, conflict counts, or search-tree depth—could provide a much stronger signal for behavioral diversity.

Summary updated

BibTeX
@misc{michailidis2026llm,
  author = {Kostis Michailidis and Dimos Tsouros and Nguyen Dang and Tias Guns},
  title = {{LLM-Guided Evolutionary Search for Constraint Model Reformulation to Improve Solver Efficiency}},
  year = {2026},
  eprint = {2607.28268},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2607.28268},
}
Figure