Automated Prompt Engineering for Cost-Effective Code Generation Using Evolutionary Algorithms

Large Language Models (LLMs) have seen increasing use in various software development tasks, especially in code generation. The most advanced recent methods attempt to incorporate feedback from code execution into prompts to help guide LLMs in generating correct code in an iterative process. While effective, these methods could be costly due to numerous interactions with the LLM and extensive token usage. To address this issue, we propose an alternative approach named E volutionary P rompt Eng i neering for C ode ( EPiC ), which leverages a lightweight evolutionary algorithm to refine the original prompts into improved versions that generate high-quality code, with minimal interactions with the LLM. Our evaluation against state-of-the-art (SOTA) LLM-based code generation agents shows that EPiC not only achieves up to 5% improvement in pass@k but is also 1.2–10 times more cost-effective than the baselines.

Authors

Institutions

Publication Details

Journal
ACM Transactions on Software Engineering and Methodology
Published
2026-03-28
DOI
https://doi.org/10.1145/3805704
Primary Topic
Software Engineering Research
Type
article
Field-Weighted Citation Impact
0.00
Controls
|||
ALL TIME
JAN
FEB
MAR
APR
MAY
JUN
JUL
AUG
SEP
OCT
article

Automated Prompt Engineering for Cost-Effective Code Generation Using Evolutionary Algorithms

Hamed Taherkhani, Hung Viet Pham, Melika Sepidband, Song Wang et al.
ACM Transactions on Software Engineering and Methodology
Software Engineering Research
article

Automated Prompt Engineering for Cost-Effective Code Generation Using Evolutionary Algorithms

Hamed Taherkhani, Hung Viet Pham, Melika Sepidband, Song Wang, Hadi Hemmati
article en

Abstract

Large Language Models (LLMs) have seen increasing use in various software development tasks, especially in code generation. The most advanced recent methods attempt to incorporate feedback from code execution into prompts to help guide LLMs in generating correct code in an iterative process. While effective, these methods could be costly due to numerous interactions with the LLM and extensive token usage. To address this issue, we propose an alternative approach named E volutionary P rompt Eng i neering for C ode ( EPiC ), which leverages a lightweight evolutionary algorithm to refine the original prompts into improved versions that generate high-quality code, with minimal interactions with the LLM. Our evaluation against state-of-the-art (SOTA) LLM-based code generation agents shows that EPiC not only achieves up to 5% improvement in pass@k but is also 1.2–10 times more cost-effective than the baselines.

ACM Transactions on Software Engineering and Methodology
York University (CA)
Industry, innovation and infrastructure
Openalex Percentile: Top 3%
Software Engineering Research
AI Navigator

Ask Laika to Summarize, Analyze, and Connect papers live on the map.

Summarize Papers & Methodologies

Extract key findings, datasets, and comparative methods across publications.

Benchmark Rankings & Visual Analytics

Rank top research institutions, authors, funders, topics, and journals by Field-Weighted Citation Impact (FWCI) and paper volume with instant charts.

Connect Distant Disciplines

Bridge topological clusters on the map to find hidden collaborative intersections.

Automated Prompt Engineering for Cost-Effective Code Generation Using Evolutionary Algorithms — Hamed Taherkhani, Hung Viet Pham, et al. · ACM Transactions on Software Engineering and Methodology (2026) | TGRS Research Map | TGRS