Abstract
The existing generative coding of distribution grids modeling and optimization face several issues, like complicated usage or high auto-codes error rates. This paper proposes the OptDisPro, a novel LLM-based multi-agent framework, enabling automatic optimal power flow (OPF) script modeling and solving. Driven by interactive linguistic instruction, it realizes automatic coding for customized requirements and flexibly adaptive heuristic optimization. Specifically, domain expertise and example scripts are encoded into structured prompt sequences to guide OptDisPro and enhance reasoning via Chain-of-Thought (COT). To mitigate LLM hallucinations, a contextual feedback mechanism is introduced, which collects error messages from the run-time environment for self-correction. Furthermore, Adaptive Selection of Multiple Algorithms (ASMA) is applied in the solving process, flexibly selecting heuristic algorithms to decrease the possibility of local optima. According to cases verification in multiple scenarios, the simulation results demonstrate the effectiveness and stability of OptDisPro in OPF problem of distribution network. The results also encourage further exploration of LLM applications in script online self-updating, autonomous OPF problem-solving and intelligent operation within distribution grid.