Controlled Self-Evolution for Algorithmic Code Optimization

Tu Hu, Ronghao Chen, Shuo Zhang, Jianghao Yin, Mou Xiao Feng, Jingping Liu, Shaolei Zhang, Wenqi Jiang, Yuqi Fang, Sen Hu, Huacan Wang, Yi Xu

TL;DR

This paper introduces Controlled Self-Evolution (CSE), a novel framework that significantly boosts the efficiency of AI-driven code optimization. By addressing key limitations in existing methods, CSE discovers more efficient code solutions faster, even with limited computational budgets, outperforming prior approaches across various LLM backbones.

What Problem Does This Paper Address?

Large Language Models (LLMs) have shown impressive capabilities in generating code, but often produce solutions that are "correct yet inefficient." This means they might work, but they don't perform optimally in terms of speed or memory usage. Existing "self-evolution" methods, which iteratively refine code through generate-verify-refine cycles, struggle with this efficiency gap. Their main problems are:

  1. Initialization Bias: They tend to start with solutions that are already in suboptimal regions of the solution space, making it hard to escape and find truly efficient code.
  2. Uncontrolled Evolution: Random changes (mutations and crossovers) are applied without much guidance, leading to inefficient exploration and many failed attempts.
  3. Poor Experience Reuse: They don't effectively learn from past successes or failures, either within a single task or across different tasks, leading to repeated mistakes.

These issues mean that finding highly optimized code requires a huge amount of computational resources, which is often impractical.

Methods

CSE tackles these problems with three core innovations:

  1. Diversified Planning Initialization: Instead of starting with a few similar initial code ideas, CSE generates a set of structurally distinct algorithmic strategies. This broadens the search space from the outset, reducing the chance of getting stuck in a bad starting point. Think of it like exploring fundamentally different approaches (e.g., dynamic programming vs. greedy algorithms) rather than just tweaking the same one.
  2. Genetic Evolution: This component replaces uncontrolled random mutations with feedback-guided operations.
  3. Controlled Mutation: The system identifies specific faulty parts of the code and refines only those parts, keeping the rest of the working code intact. This is like surgically fixing a specific bug without breaking other features.
  4. Compositional Crossover: This allows combining the strengths of different good solutions. For example, if one solution is fast but uses a lot of memory, and another is memory-efficient but slower, crossover can create a new solution that ideally balances both.
  5. Hierarchical Evolution Memory: This system stores and reuses learned experiences at two levels:
  6. Local Memory: Captures successes and failures within the current task, helping to avoid repeating mistakes in that specific problem.
  7. Global Memory: Distills reusable optimization patterns from across different tasks, allowing the system to leverage knowledge gained from solving similar problems in the past.

Datasets

The paper evaluates CSE on EffiBench-X, a benchmark that includes 623 algorithmic problems from popular competitive programming platforms (AtCoder, Codeforces, LeetCode). Each problem comes with strict time and memory limits, and comprehensive test cases. The evaluation focuses on efficiency metrics relative to human-written solutions.

Key Insights and Ideas

  • Diversity is Key from the Start: The initial "planning" phase is crucial. Generating diverse strategies upfront dramatically improves the chances of finding good solutions and avoids getting trapped in local optima.
  • Guided Evolution Beats Randomness: Simply making random changes to code is inefficient. CSE's feedback-guided mutation and crossover allow for more targeted and effective improvements.
  • Learning from Everything Matters: Both successes and failures are valuable. CSE's hierarchical memory system allows it to learn from its own mistakes and leverage knowledge from past problems, accelerating the optimization process.
  • Synergy is Powerful: The real magic happens when all three components (Diversified Planning, Genetic Evolution, and Hierarchical Memory) work together. Removing any one component significantly degrades performance, highlighting their interconnectedness.

Key Results

CSE consistently outperformed all baselines across various LLM backbones (including DeepSeek-V3-0324, Qwen3-235B-A22B, Claude-4.5-Sonnet, and GPT-5) on the EffiBench-X benchmark.

  • CSE achieved higher efficiency metrics (Execution Time, Peak Memory, Memory Integral) compared to direct generation, self-reflection, and other self-evolutionary agents like SE-Agent and AlphaEvolve.
  • It demonstrated significantly faster improvement in early generations and sustained progress throughout the entire evolution budget, indicating better resource utilization.
  • Ablation studies showed that each of CSE's three components is essential, with the memory system providing the largest boost when combined with other modules.

Limitations and Future Work

The authors acknowledge that they have not yet explored how to amortize CSE's iterative optimization process back into the base LLM itself. They suggest a promising future direction is to distill CSE's evolution trajectories into RL-style training to further strengthen the base model for better optimization and higher-quality solutions.

Summary updated

Abstract

Self-evolution methods enhance code generation through iterative "generate-verify-refine" cycles, yet existing approaches suffer from low exploration efficiency, failing to discover solutions with superior complexity within limited budgets. This inefficiency stems from initialization bias trapping evolution in poor solution regions, uncontrolled stochastic operations lacking feedback guidance, and insufficient experience utilization across tasks. To address these bottlenecks, we propose Controlled Self-Evolution (CSE), which consists of three key components. Diversified Planning Initialization generates structurally distinct algorithmic strategies for broad solution space coverage. Genetic Evolution replaces stochastic operations with feedback-guided mechanisms, enabling targeted mutation and compositional crossover. Hierarchical Evolution Memory captures both successful and failed experiences at inter-task and intra-task levels. Experiments on EffiBench-X demonstrate that CSE consistently outperforms all baselines across various LLM backbones. Furthermore, CSE achieves higher efficiency from early generations and maintains continuous improvement throughout evolution. Our code is publicly available at https://github.com/QuantaAlpha/EvoControl.
BibTeX
@misc{hu2026controlled,
  author = {Tu Hu and Ronghao Chen and Shuo Zhang and Jianghao Yin and Mou Xiao Feng and Jingping Liu and Shaolei Zhang and Wenqi Jiang and Yuqi Fang and Sen Hu and Huacan Wang and Yi Xu},
  title = {{Controlled Self-Evolution for Algorithmic Code Optimization}},
  year = {2026},
  eprint = {2601.07348},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2601.07348},
}
Figure