Active power distribution network power flow optimization method based on large language model
By using a heuristic algorithm automatic generation mechanism driven by a large language model, the complexity and low design efficiency of the optimal power flow problem in active distribution networks are solved, generating a high-precision power flow calculation algorithm that improves solution efficiency and robustness.
Patent Information
- Application Number
- CN202511158454.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-08-19
- Publication Date
- 2025-12-23
- Estimated Expiration
- 2045-08-19
AI Technical Summary
Traditional numerical analysis methods suffer from poor convergence and low computational efficiency in the optimal power flow problem of active distribution networks. Intelligent algorithms are prone to getting trapped in local optima and have slow solution speeds. Furthermore, existing algorithm designs rely on professional knowledge and are time-consuming.
A heuristic algorithm automatic generation mechanism driven by a large language model is adopted. By constructing structured prompt words, multiple heuristic algorithm search modules are generated. Combined with evaluation and iterative update modules, an evolutionary strategy is used to adaptively evolve the algorithm, ultimately generating a high-precision active distribution network power flow optimization algorithm.
It realizes the automatic design of highly targeted algorithms for active distribution network power flow optimization, significantly shortens the algorithm development cycle, improves solution efficiency and robustness, and can guarantee accuracy in non-convex, high-dimensional complex scenarios.
Smart Images

Figure CN121192707A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The application belongs to the field of intelligent optimization of power systems, and particularly relates to an active distribution network power flow optimization method based on a large language model. BACKGROUND
[0002] With the transformation of global energy structure towards low carbonization and intelligentization, the penetration rate of distributed renewable energy represented by photovoltaic and wind power in distribution networks is rapidly increasing. The "passive, one-way, static" operation mode of traditional distribution networks has been difficult to adapt to the complexity and uncertainty brought by high proportion of distributed energy access. Active distribution networks (ADN) realize bidirectional power flow management, dynamic scheduling and network reconstruction by integrating distributed power sources, energy storage systems and controllable loads, and become an important development direction of modern power systems.
[0003] Among them, the optimal power flow research is an indispensable part of active distribution network planning and operation, and its specific meaning is to adjust the control variables in the distribution network to make the optimal power flow distribution of a certain optimization target (such as operation cost, network loss, etc.) optimal under the condition of ensuring safe and stable operation of the system. However, due to the great change in the operation characteristics of ADN compared with traditional distribution networks, the OPF (Optimal Power Flow) problem faces new challenges: the large number of multi-source inverters makes the power flow distribution present strong nonlinear characteristics; the intermittency of distributed energy sources further aggravates the time-varying nature of the system state; and bidirectional power flow further increases the difficulty of analysis and modeling. Therefore, the traditional numerical analysis method often has poor convergence and low calculation efficiency; the intelligent algorithm simplifies the simulation process of complex constraints, but is easy to fall into local optimum and slow in solving speed; and the improved algorithm often needs a lot of time and professional knowledge for design.
[0004] At the same time, a large number of large language models (LLM) represented by GPT-4 and DeepSeek have emerged and gradually matured, bringing new ideas for the design of intelligent algorithms. It not only makes breakthrough progress in traditional natural language processing tasks such as text generation and language translation, but also achieves excellent results in the more difficult field of algorithm design and optimization, with strong versatility and adaptability. In the field of power systems, it has achieved preliminary application results in load forecasting, fault diagnosis and safety assessment, and has shown great application potential. SUMMARY
[0005] To solve the problems in the prior art, the application provides an active distribution network power flow optimization method based on a large language model.
[0006] The technical scheme of the application is as follows:
[0007] The application discloses an active power distribution network power flow optimization method based on a large language model, comprising:
[0008] 1) Obtain the topology and equipment parameter data of the active power distribution network to be subjected to power flow optimization, and establish an active power distribution network optimal power flow problem model;
[0009] 2) Construct a structured prompt word and input it into the large language model to guide the large language model to output a plurality of heuristic algorithm search modules meeting the active power distribution network optimal power flow requirements, combine each heuristic algorithm search module with a preset evaluation module and an iterative updating module, and obtain a plurality of heuristic algorithms;
[0010] 3) Input the active power distribution network optimal power flow problem model of step 1) into each heuristic algorithm to obtain the output of each distributed energy source of the active power distribution network, and then calculate the result of the objective function in the optimal power flow problem model; calculate the error between the result of the objective function under each heuristic algorithm and the theoretical optimal solution of the active power distribution network optimal power flow problem model, sort the error results from small to large, and retain the first n heuristic algorithms with the smallest error;
[0011] 4) Construct an evolutionary strategy prompt word, and use the large language model to perform algorithm self-adaptive evolution on the retained heuristic algorithms to obtain N new heuristic algorithms;
[0012] 5) Repeat steps 3) to 4) until a preset number of rounds is reached, output the heuristic algorithm with the smallest error from the theoretical optimal solution in step 3), and obtain the required output of each distributed energy source of the active power distribution network, thereby completing the active power distribution network power flow optimization.
[0013] Further, in step 2), the structured prompt word is input into the large language model multiple times to obtain a plurality of heuristic algorithm search modules, wherein the large language model receives one structured prompt word and outputs one heuristic algorithm search module;
[0014] The search module is the core content of the heuristic algorithm, which is used to receive the candidate solution (i.e., the output of each distributed energy source) of the optimal power flow problem in the current iteration process, and then search and output a new solution meeting the problem constraints; wherein, in step 1), a penalty function of the heuristic algorithm is also designed, the evaluation module is used to judge the output of the search module in combination with the penalty function and the objective function in the active power distribution network optimal power flow problem model, and generate fitness; the iterative updating module is based on the result of the evaluation module to filter, retain or replace the output of the search module, thereby forming the input of the heuristic algorithm search module in the next iteration.
[0015] Compared with the prior art, the application has the following beneficial effects:
[0016] The application has the beneficial effect that through the large language model driven heuristic algorithm automatic generation mechanism, the high pertinence algorithm automatic design of the self-defined problem scene and the high precision active power distribution network power flow optimization are realized. The problems that the existing active power distribution network complex optimal power flow problem solving is complex, the heuristic algorithm design efficiency is low, and the design is highly dependent on expert experience are overcome. The generated power flow calculation algorithm can significantly shorten the algorithm development cycle and improve the solving efficiency and robustness of non-convex and high-dimensional complex scenes on the premise of ensuring accuracy. At the same time, the application has important significance for exploring the deep application mode of large language model in the professional calculation field of power system, and provides a new idea for solving complex problems of power system. BRIEF DESCRIPTION OF DRAWINGS
[0017] Figure 1 is a method flowchart of the application;
[0018] Figure 2 is a single-line diagram of a power distribution system in an exemplary example;
[0019] Figure 3 is an algorithm generation process taking evolutionary strategy E2 as an example in an exemplary example;
[0020] Figure 4 is an evolutionary path of the optimal heuristic algorithm generated by the application and its prompt strategy call record in an exemplary example;
[0021] Figure 5 is a summer test day generator output diagram calculated by the heuristic algorithm of the application in an exemplary example;
[0022] Figure 6 is a summer test day node voltage distribution diagram calculated by the heuristic algorithm of the application in an exemplary example;
[0023] Figure 7 is a winter test day generator output diagram calculated by the heuristic algorithm of the application in an exemplary example;
[0024] Figure 8 is a winter test day node voltage distribution diagram calculated by the heuristic algorithm of the application in an exemplary example. DETAILED DESCRIPTION
[0025] The application will be further described and explained with specific embodiments. The embodiments are only exemplary and do not circumscribe the scope of the disclosure. The technical features of each embodiment in the application can be combined accordingly without conflict.
[0026] In view of the deficiencies in the prior art, the present application aims to provide a large language model-based active power distribution network power flow optimization method.The present application provides an automated design framework for heuristic algorithms, which successfully simplifies the algorithm design process of power flow calculation while ensuring calculation accuracy.
[0027] The present application will be described below with reference to the accompanying drawings.
[0028] As Figure 1 shown, it is a method flowchart of the present application, and the large language model-based active power distribution network power flow optimization method of the present application can be summarized as "problem modeling, algorithm generation, precision evaluation, algorithm updating and algorithm iterative evolution" five steps:
[0029] Step 1: Problem modeling
[0030] According to the network topology and line parameters of the active power distribution network to be optimized, as well as the connection relationship between each distributed energy and node in the active power distribution network and the device information of each distributed energy, the objective function and constraint condition of optimal power flow are designed, and the optimal power flow problem model of the active power distribution network is established, and a penalty function of the heuristic algorithm is also designed. Among them, the objective function of optimal power flow needs to be set according to the actual situation, such as cost optimization, network loss optimization or multi-objective optimization and other forms. Among them, the line parameters of the active power distribution network mainly include resistance, reactance, capacitance, conductance and line length, which are usually calculated by multiplying the unit length parameter by the total length of the line.
[0031] In a specific embodiment of the present application, the modified IEEE33 node power distribution system is selected as a test case, and the distribution of various types of distributed resources is as shown in Figure 2 The photovoltaic power generation is configured at bus #13, #18, #22, #25 and #29, the wind power generation is configured at bus #33, the gas turbine is configured at bus #16, and the energy storage (device) is configured at bus #11, #21, #24 and #31. In order to reflect the time characteristics of new energy and energy storage in the power distribution network, the calculation period is selected as 1 day, and one day is divided into 24 sections. The wind power generation, photovoltaic power generation and load data are all from the Belgian power grid. Among them, the load data is the total load of the region, including industrial load, residential load, etc.
[0032] The detailed information of the active power distribution network and the distributed energy is imported through the standardized XML file, and the constraint conditions of the distributed resources, the objective function of the optimal power flow and the penalty function of the heuristic algorithm are designed. The pandapower tool is combined to realize the modeling of the active power distribution network optimal power flow problem.
[0033] The active distribution network in this case involves devices including energy storage, renewable energy batteries, and controllable distributed power sources. The modeling of each device can be added to the optimization model in the form of constraints, i.e.:
[0034] (1) DES (Distributed Energy Storage) is a flexible resource in the distribution network, and its core function is to achieve peak clipping and valley filling, smooth renewable energy fluctuations, and participate in system frequency modulation through energy time shifting and power fast response. When modeling this type of device, dynamic characteristics need to be considered, and the following formula represents the charge and discharge power constraints of the energy storage:
[0035] -P DESi,N ≤P DESi,t ≤P DESi,N ,DES i ∈Ω DES
[0036] where P DESi,N represents the rated active power of the DES connected to node i; P DESi,t represents the charge and discharge power of the energy storage device connected to node i at time t, P DESi,t > 0 indicates that the energy storage is in charging state, otherwise it indicates that the energy storage is in discharging state; DES i represents the DES connected to node i in the distribution network; Ω DES represents the set of all DESs in the distribution network.
[0037] The state of charge constraint of the energy storage is as follows (to prolong the cycle life of lithium batteries and prevent performance degradation caused by deep discharge, it is usually set to 10% to 90% of the rated capacity):
[0038]
[0039] where, represents the lower limit constraint of the state of charge of the DES connected to node i; represents the state of charge of the DES connected to node i at time t; represents the upper limit constraint of the state of charge of the DES connected to node i.
[0040] The state of charge update equation of the energy storage is as follows:
[0041]
[0042] where, and represent the charging efficiency and discharging efficiency of the DES connected to node i, respectively; represents the rated capacity of the DES connected to node i; Δt represents the time interval of the power flow calculation.
[0043] (2) The output characteristics of RDG (Renewable Distributed Generation) power sources such as wind and solar power are significantly affected by the spatiotemporal distribution of environmental conditions (irradiance, wind speed). In recent years, photovoltaic equipment installed in distribution networks has often been equipped with inverters, which support constant voltage and constant power factor modes, and can provide reactive power support when active power output is low, alleviating the problem of voltage exceeding limits in the distribution network. Their operational constraints include:
[0044]
[0045] In the formula, This represents the active power output of the RDG connected to node i at time t; This represents the upper limit of active power of the RDG connected to node i; The rated capacity of the RDG connected to node i; This represents the reactive power output of the RDG connected to node i at time t; RDG i Represents the RDG connected to node i; Ω RDG This represents the set of all RDGs in the distribution network.
[0046] (3) Controllable Distributed Generation (CDG) sources such as micro gas turbines and diesel generators possess rapid start-up and shutdown capabilities and precise power regulation, making them an important flexible supplementary resource for the distribution network. Furthermore, because CDG sources are typically connected to the distribution network via inverters, they also possess a certain degree of dynamic reactive power regulation capability. Their operational constraints include:
[0047]
[0048] In the formula, and These represent the upper and lower limits of the active power output of the CDG connected to node i, respectively. This represents the active power output of the CDG connected to node i at time t; CDG i Represents the CDG of access node i; Ω CDG This represents the set of CDGs in the distribution network; and These represent the maximum upward and downward ramp power of the CDG connected to node i, respectively; This represents the reactive power output of the CDG connected to node i at time t; This represents the installed capacity of the CDG inverter connected to node i.
[0049] The objective of setting the optimal power flow in the case is to minimize the multi-period comprehensive operation cost of the power distribution network, and the total cost covers the following three parts: main network cost, energy storage device operation cost and controllable distributed power operation cost, corresponding to the first to third terms of the following formula respectively:
[0050]
[0051] In the formula, F represents the objective function; t is the current time; T is the optimization period; Δt represents the time interval of the power flow calculation; c Grid,t is the unit cost of purchasing or selling electricity from the main network at time t; P Grid,t represents the output power of the main network at time t, if P Grid,t < 0 indicates that the power is sufficient, and the power distribution network sells electricity to the main network, at this time c Grid,t is the electricity selling price, otherwise it indicates that the main network transmits electricity to the power distribution network, c Grid,t represents the price of purchasing electricity from the main network; represents the operation cost of the energy storage device of the access node i; represents the charging and discharging power of the energy storage device of the access node i at time t, P DESi,t > 0 indicates that the energy storage is in the charging state, otherwise it indicates that the energy storage is in the discharging state. represents the cost of the controllable distributed power, which can be finely characterized in the form of a quadratic function, as shown in the following formula:
[0052]
[0053] Wherein, a i , b i , c i are the cost coefficients of the CDG of the access node i; represents the active power output of the CDG of the access node i at time t.
[0054] The present application adopts a heuristic algorithm (such as genetic algorithm, particle swarm optimization algorithm) when solving the power flow. Compared with the numerical optimization method, this method is more suitable for the exploration scene of LLM (Large Language Model), and also shows stronger robustness in non-convex and high-dimensional complex problems, with advantages such as easy simulation of complex constraints, less affected by initial values, etc.
[0055] Further, when using a heuristic algorithm, since the algorithm itself does not directly process hard constraints, a penalty function term needs to be explicitly introduced into the objective function to strengthen the execution effect of the state variable constraint condition. Here, a fuzzy decision method is adopted to retain the global search ability of the heuristic algorithm while avoiding the generation of infeasible solutions through "soft constraints". It is specified that λ is an adaptive penalty coefficient, f(x j) is a piecewise linear penalty function based on the constraint variable, the mathematical expression of the penalty function is as follows:
[0056] F' = F + λ
[0057]
[0058] Where F' represents the objective function modified by the penalty function; k represents the adaptive penalty coefficient, which controls the weight of the penalty term in the objective function; x j represents the current value of the jth constrained variable; n represents the number of constrained variables; x min represents the lower limit constraint value of the variable; x max represents the upper limit constraint value of the variable.
[0059] Step 2: Algorithm generation
[0060] By designing structured zero-sample prompt words, drive large language model to generate heuristic algorithm that meets the needs of active power distribution network optimal power flow, break through the efficiency bottleneck of artificial coding;
[0061] (a) Task design:
[0062] Heuristic algorithm can be divided into three parts: search module, evaluation module and iterative update module: search module generates new solutions according to the current candidate solution, which is the core link of the entire heuristic algorithm; The evaluation module combines the objective function and the penalty function to generate fitness, which is used to judge the state of the current solution; The iterative update module filters or retains the candidate solution according to the evaluation result, and performs the next round of search, and multiple iterations are performed until the termination condition is reached to get the optimization result.
[0063] Due to the limitations of LLM in long code generation and professional understanding in the field of electric power, there are problems of low precision and poor executability in directly generating complete optimal power flow algorithm. Here, the core function is decoupled, and the LLM task is focused on the special design of the heuristic search module, that is, to generate a search function whose input is the distributed energy device active / reactive power output and the output is the updated active / reactive power value; Among them, the search function constitutes the search module.
[0064] The remaining modules are given in advance in a preset form to generate a complete executable heuristic algorithm. The evaluation module is set according to the objective function and the penalty function in step one, and the elite reservation mode is adopted in the iterative module.
[0065] (b) Structured prompt word design:
[0066] In order to accurately guide LLM to generate executable and engineering-required heuristic search core function code, here we use a structured prompt word design framework, which includes the following five parts:
[0067] Task description: Briefly describe the background and specific tasks of the active power distribution network optimal power flow problem in simple language. The background refers to the model of the active power distribution network optimal power flow problem, and the specific task refers to generating a heuristic algorithm search module and a natural language description of the heuristic algorithm search module. The natural language description is to enable the LLM to better understand the algorithm idea in the subsequent evolution process and ensure the interpretability of the generated results.
[0068] Input semantic understanding: Specify the input parameters of the heuristic algorithm search module and the physical meaning and implicit constraints of the input parameters.
[0069] Output setting: Specify the function name, output variable name, return value type, and numerical precision of the functions in the generated search module to ensure that the generated Python code interface is standard and can be directly embedded into the complete code.
[0070] Domain knowledge enhancement: LLM lacks professional power system power flow calculation knowledge, so supplement power system professional knowledge as supplementary knowledge embedded prompts to drive LLM to generate more industry-adapted heuristic logic.
[0071] Error recognition mechanism: To improve the success rate of the generated code, pre-set domain safety rules that must be followed or list common code error types.
[0072] (c) Large language model invocation and heuristic algorithm generation:
[0073] Input structured prompts into the large language model to generate search module code and its natural language description that meet the requirements. Combine each heuristic algorithm search module with the pre-set evaluation module and iterative update module to obtain a complete heuristic algorithm. Input structured prompts multiple times into the large language model to obtain multiple heuristic algorithm search modules, i.e., obtain the initial heuristic algorithm population after multiple runs. The large language model receives a structured prompt and outputs a heuristic algorithm search module.
[0074] Model invocation supports both local deployment and API invocation modes, suitable for scenarios with high data security requirements or limited network conditions, and scenarios requiring rapid integration and dynamic allocation of computing resources.
[0075] In terms of model selection, after multiple tests of ChatGPT, DeepSeek, Qwen, and other series of large models and their distilled models, the following experiences are obtained: When computing resources are sufficient, Deepseek-R1 is the best choice; when facing memory limitations, its distilled model DeepSeek-R1-Distill-Llama-70B can well balance efficiency and performance; and for scenarios with high real-time requirements, Deepseek-V3 is recommended for deployment to achieve fast and high-quality code generation.
[0076] Step three: accuracy evaluation
[0077] The active power distribution network optimal power flow problem model of step one is input into each heuristic algorithm to obtain the output of each distributed energy source of the active power distribution network, and the result of the objective function in the optimal power flow problem model is calculated; the error between the result of the objective function under each heuristic algorithm and the theoretical optimal solution of the active power distribution network optimal power flow problem model is sorted from small to large, and the first n heuristic algorithms with the smallest error are retained. The output of each distributed energy source of the active power distribution network is the active power output and the reactive power output of each distributed energy source of the active power distribution network.
[0078] In the present application, in order to optimize the LLM generated heuristic algorithm and the accuracy of power flow calculation, the calculation error is set as the core evaluation index. When the output of each distributed energy source of the active power distribution network is obtained by using the heuristic algorithm, the termination condition of the heuristic algorithm is that the absolute value of the change of the result of continuous five times of iteration calculation is less than 0.1% (i.e. meets ΔC k represents the difference between this iteration result and the last time, C k-1 represents the last iteration result) or reaches the preset maximum number of iterations.
[0079] The theoretical optimal solution of the active power distribution network optimal power flow problem model is obtained by internally calling the Gurobi solver for calculation, and the theoretical optimal solution is the result of the objective function under the theoretical condition.
[0080] Then the error between the result of the objective function under the heuristic algorithm and the theoretical optimal solution of the active power distribution network optimal power flow problem model is obtained by the following formula:
[0081]
[0082] Wherein, f(h) represents the error between the result of the objective function obtained by the heuristic algorithm and the theoretical optimal solution; C heuristic represents the result of the objective function obtained by the heuristic algorithm; C Gurobi represents the theoretical optimal solution.
[0083] Step four: algorithm update
[0084] Since the initial heuristic algorithm generated by the LLM is not good enough, it needs to be further optimized. Inspired by the concept of evolutionary computation (EC), the large language model is used as an intelligent mutation operator to simulate selection, crossover, mutation and other operations through different evolutionary strategies, and the elite reservation strategy is combined to realize the iterative update of the heuristic algorithm.
[0085] Therefore, the specific process of the present step is to construct an evolutionary strategy prompt word and use a large language model to perform algorithm adaptive evolution on the n heuristic algorithms retained in step three to obtain N new heuristic algorithms. The large language model is Deepseek-V3.
[0086] The present application uses Chain-of-Thought (CoT) technology to drive the LLM to perform algorithm mutation and evolution through operations such as selection, crossover, and mutation. The core process is as follows: the n heuristic algorithms selected in step three are used as input to generate a structured reasoning instruction chain through five types of evolutionary guidance prompt strategies, which guide the LLM to understand the parent algorithm logic based on natural language description and specific code, and then generate N innovative variants. The offspring should be the same as the parent, containing the python code of the heuristic algorithm search module and the natural language description. The prompt strategy includes two types of exploration strategy and improvement strategy.
[0087] The exploration strategy selects p heuristic algorithms from the current n heuristic algorithms as reference algorithms and guides the LLM to evolve through crossover operations. Strategy prompt word E1 guides the LLM to generate a new heuristic algorithm that is significantly different from the heuristic algorithm it receives; strategy prompt word E2 guides the LLM to identify the common underlying ideas of the received heuristic algorithms and generate a new heuristic algorithm with new ideas to achieve evolution.
[0088] The improvement strategy selects one heuristic algorithm from the current n heuristic algorithms as a reference algorithm to perform deep optimization of a single heuristic algorithm. Strategy prompt word M1 guides the large language model to modify the structure of the search module of the heuristic algorithm it receives to generate a new heuristic algorithm; strategy prompt word M2 guides the large language model to modify the key parameters of the heuristic algorithm it receives to generate a new heuristic algorithm; strategy prompt word M3 guides the large language model to delete the redundant parts of the search module of the heuristic algorithm it receives to generate a new heuristic algorithm.
[0089] The above algorithm adaptive evolution of the n heuristic algorithms retained in step three using a large language model includes:
[0090] The algorithm idea language description and algorithm implementation code of the retained n heuristic algorithms are obtained, and then the task description, input semantic explanation, and output setting in the structured prompt word of step two, strategy prompt word E1, and any p heuristic algorithms and heuristic algorithm idea language description are input into the large language model to obtain new heuristic algorithms. For n heuristic algorithms, based on the evolutionary strategy prompt word E1, the large language model generates new heuristic algorithms; wherein p is less than n.
[0091] The task description, input semantic interpretation and output setting in the structured prompt word of step two, the strategy prompt word E2 and the language description of the algorithm idea of any p heuristic algorithms are input into the large language model to obtain a new heuristic algorithm. For n heuristic algorithms, based on the evolutionary strategy prompt word E2, n new heuristic algorithms are generated by using the large language model.
[0092] The task description, input semantic interpretation and output setting in the structured prompt word of step two, the strategy prompt word M1 and the language description of the algorithm idea of each heuristic algorithm are input into the large language model to obtain a new heuristic algorithm. For n heuristic algorithms, n new heuristic algorithms are generated by using the large language model based on the evolutionary strategy prompt word M1.
[0093] The task description, input semantic interpretation and output setting in the structured prompt word of step two, the strategy prompt word M2 and the language description of the algorithm idea of each heuristic algorithm are input into the large language model to obtain a new heuristic algorithm. For n heuristic algorithms, n new heuristic algorithms are generated by using the large language model based on the evolutionary strategy prompt word M2.
[0094] The task description, input semantic interpretation and output setting in the structured prompt word of step two, the strategy prompt word M3 and the language description of the algorithm idea of each heuristic algorithm are input into the large language model to obtain a new heuristic algorithm. For n heuristic algorithms, n new heuristic algorithms are generated by using the large language model based on the evolutionary strategy prompt word M3.
[0095] Step five: algorithm iteration evolution
[0096] Steps three to four are repeated until a preset number of rounds is reached, the heuristic algorithm with the smallest error from the theoretical optimal solution in step three is output, the required output of each distributed energy source of the active distribution network is obtained, and the active distribution network power flow optimization is completed.
[0097] Wherein, in the first cycle, the each heuristic algorithm in step three is the plurality of heuristic algorithms obtained in step two. From the second cycle to the end of the cycle, the each heuristic algorithm in step three is the N new heuristic algorithms obtained in step four and the n heuristic algorithms reserved in step three. Specifically, the step inputs the active power distribution network optimal power flow problem model of step 1) into the newly generated N new heuristic algorithms and the n heuristic algorithms reserved in step three, obtains the output of each distributed energy of the active power distribution network calculated by the N+n heuristic algorithms, and calculates the results of the objective functions in the N+n problem models based on this. Then, the errors between each result in the N+n results and the theoretical optimal solution of the active power distribution network optimal power flow problem model are calculated, the error results are sorted from small to large, and the first n heuristic algorithms with the smallest error are reserved.
[0098] Then, based on the evolutionary strategy prompt word, the algorithm adaptive evolution of the n heuristic algorithms is performed by using the large language model, and N new heuristic algorithms are obtained. Steps three-four are repeatedly executed until a preset number of rounds is reached, the heuristic algorithm with the smallest error from the theoretical optimal solution in step three is output, and the output of each distributed energy of the active power distribution network is obtained, and the active power distribution network power flow optimization is completed.
[0099] In a specific embodiment of the application, the heuristic algorithms generated in the previous steps are parent populations, the maximum evolution generation is set to 20 generations, 5 new heuristic algorithms are generated for each prompt strategy in each generation, a total of 25 new heuristic algorithms (N=25) are generated, and finally 5 optimal algorithms are selected to enter the next iteration (n=5). Moreover, considering that the code of the optimal power flow algorithm is generally long, in order to ensure the length of the context range, the prompt strategy p in the evolutionary strategy prompt word E1 and the evolutionary strategy prompt word E2 is set to 3. Taking the evolutionary strategy prompt word E2 as an example, the generation process of the algorithm is as shown in the following figure: Figure 3 That is, from the current 5 heuristic algorithms, 3 algorithms and their natural language descriptions are selected, which are input into the large language model together with the task description, input semantic explanation and output setting in the structured prompt word in step two and the strategy prompt word E2, to obtain a new heuristic algorithm and its natural language description. According to the difference of the selected 3 parents, the process will run times, a total of new heuristic algorithms are generated.
[0100] In the iterative evolution process, the evolution path of the optimal heuristic algorithm and the prompt strategy call record are as shown in the following figure: Figure 4The calculation error can be found to decrease from the initial 3.39% to 0.08%, and the calculation accuracy of the algorithm is improved by an order of magnitude, which verifies the excellent code generation capability of the framework. At the same time, according to the call record of the prompt strategy in the evolution process, it can be found that the four types of strategies E1, E2, M1 and M2 all produce effective improvement schemes, and the multi-strategy cooperative evolution mechanism is effective.
[0101] The heuristic algorithm search module finally generated by the method is based on differential evolution, and the understanding diversity is maintained through adaptive mutation scaling and directional crossover operation, and the cost optimal solution can be quickly converged. Running the heuristic algorithm, the generator output of each node and the node voltage distribution are obtained as shown in Figures 5-8 The results are highly similar to the Gurobi calculation results. The optimal total cost of the summer test day is 11449.26 yuan, with an error of 0.08% compared with the Gurobi result; the optimal total cost of the winter test day is 55930.20 yuan, with an error of 0.03%. Both are within an acceptable range. It is proved that the method can efficiently solve the complex optimal power flow problem of the active distribution network with commercial solver level precision, and provide support for actual engineering deployment.
[0102] Further, in order to verify the advantages of the automatically generated algorithm of the application compared with the traditional manually designed algorithm, the algorithm is compared with three commonly used heuristic algorithms: differential evolution algorithm (Differential Evolution, DE), particle swarm optimization algorithm (Particle Swarm Optimization, PSO), and simulated annealing algorithm (simulated annealing, SA). Table 1 shows the statistical results of each algorithm after running independently for 10 times in the IEEE33 node summer test day scenario. The results show that the code algorithm generated by the application has higher accuracy, better solution stability and faster convergence speed.
[0103] Table 1
[0104]
[0105] The above-described embodiments only express several embodiments of the application, and the description is more specific and detailed, but it cannot be understood as limiting the scope of the application. For ordinary skilled persons in the art, without departing from the concept of the application, a number of modifications and improvements can be made, which are within the protection scope of the application.
Claims
1. A method for active distribution network power flow optimization based on a large language model, characterized in that, include: 1) Obtain the topology and equipment parameter data of the active distribution network to be optimized, and establish an optimal power flow problem model for the active distribution network; 2) Construct structured prompt words and input them into the large language model to guide the large language model to output multiple heuristic algorithm search modules that meet the optimal power flow requirements of the active distribution network. Combine each heuristic algorithm search module with the pre-set evaluation module and iterative update module to obtain multiple heuristic algorithms. 3) Input the optimal power flow problem model of the active distribution network from step 1) into each heuristic algorithm to obtain the output of each distributed energy source in the active distribution network, and then calculate the result of the objective function in the optimal power flow problem model; Calculate the error between the objective function result of each heuristic algorithm and the theoretical optimal solution of the active distribution network optimal power flow problem model, sort the error results from smallest to largest, and retain the top n heuristic algorithms with the smallest error; 4) Construct evolutionary strategy prompts and use a large language model to adaptively evolve the retained heuristic algorithms to obtain N new heuristic algorithms; 5) Repeat steps 3)-4) until the preset number of rounds is reached. Output the heuristic algorithm in step 3) that minimizes the error with the theoretical optimal solution, and obtain the output required by each distributed energy source in the active distribution network to complete the power flow optimization of the active distribution network.
2. The method according to claim 1, characterized in that, In step 1), the topology and equipment parameter data of the active distribution network include the network topology and line parameters of the active distribution network, as well as the connection relationships between each distributed energy source and node in the active distribution network and the equipment information of each distributed energy source.
3. The method according to claim 1, characterized in that, In step 1), the objective function and constraints are designed based on the topology and equipment parameter data of the active distribution network to be optimized, and then the optimal power flow problem model of the active distribution network is established according to the objective function and constraints.
4. The method according to claim 1, characterized in that, In step 2), the structured prompts include task description, input semantic interpretation, output settings, domain knowledge enhancement, and error identification mechanism. The task description includes the problem background and specific task. The problem background refers to the optimal power flow problem model for an active distribution network, and the specific task refers to the generation of the heuristic algorithm search module and its natural language description. The input semantic interpretation refers to the input parameters of the heuristic algorithm search module and their physical meaning and implicit constraints. The output settings specify the function name, output variable name, return value type, and numerical precision of the functions in the generated search module. Domain knowledge enhancement supplements power system expertise. The error identification mechanism refers to security rules or code error types.
5. The method according to claim 1, characterized in that, In step 2), the structured prompt words are input into the large language model multiple times to obtain multiple heuristic algorithm search modules. The large language model receives a structured prompt word once and outputs a heuristic algorithm search module. The search module is the core of the heuristic algorithm. It is used to receive candidate solutions to the optimal power flow problem in the current iteration, and then search for and output new solutions that meet the problem constraints. In step 1), a penalty function for the heuristic algorithm is designed. The evaluation module is used to evaluate the output of the search module by combining the penalty function and the objective function in the active distribution network optimal power flow problem model, and to generate fitness. The iterative update module filters, retains or replaces the output of the search module based on the results of the evaluation module, forming the input of the heuristic algorithm search module in the next iteration.
6. The method according to claim 1, characterized in that, In step 3), when using a heuristic algorithm to obtain the output of each distributed energy source in the active distribution network, the termination condition of the heuristic algorithm is that the absolute value of the change in the calculation results of five consecutive iterations is less than 0.1% or the preset maximum number of iterations is reached. In step 3), the theoretical optimal solution of the optimal power flow problem model of the active distribution network is obtained using the Gurobi solver, wherein the theoretical optimal solution is the objective function result under theoretical conditions; The formula for calculating the error between the objective function results obtained by each heuristic algorithm and the theoretical optimal solution of the active distribution network optimal power flow problem model is as follows: Where f(h) represents the error between the objective function obtained by the heuristic algorithm and the theoretical optimal solution; C heuristic This represents the objective function result obtained by the heuristic algorithm; C Gurobi This represents the theoretically optimal solution.
7. The method according to claim 1, characterized in that, The evolutionary strategy cue words in step 4) include E1, E2, M1, M2, and M3; Specifically, strategy prompt E1 guides the large language model to generate a new heuristic algorithm that is significantly different from the heuristic algorithms it receives; strategy prompt E2 prompts the large language model to identify the common underlying ideas of the received heuristic algorithms and generate a new heuristic algorithm with novel ideas; strategy prompt M1 guides the large language model to modify the structure of the search module of the received heuristic algorithm to generate a new heuristic algorithm; strategy prompt M2 guides the large language model to modify the key parameters of the received heuristic algorithm to generate a new heuristic algorithm; and strategy prompt M3 guides the large language model to remove redundant parts of the search module of the received heuristic algorithm to generate a new heuristic algorithm.
8. The method according to claim 1, characterized in that, In step 4), the heuristic algorithms are adaptively evolved using a large language model, including: obtaining the algorithmic ideas, language descriptions, and implementation code of the remaining n heuristic algorithms. The task description, input semantic interpretation, and output settings from the structured prompts in step 2), along with the policy prompt E1 and any p heuristic algorithms and their algorithmic descriptions, are input into the large language model to obtain a total of [data missing]. A new heuristic algorithm; where p is less than n; The task description, input semantic interpretation, and output settings from the structured prompts in step 2), along with the policy prompt E2 and any p heuristic algorithms and their algorithmic descriptions, are input into the large language model to obtain a total of [data missing]. A new heuristic algorithm; Input the task description, input semantic interpretation, and output settings from the structured prompts in step 2), as well as the strategy prompts M1 and the heuristic algorithm and its algorithmic thought language description into the large language model to obtain a total of n new heuristic algorithms. Input the task description, input semantic interpretation, and output settings from the structured prompts in step 2), as well as the strategy prompts M2 and the heuristic algorithm and its algorithmic thought language description into the large language model to obtain a total of n new heuristic algorithms. Input the task description, input semantic interpretation, and output settings from the structured prompts in step 2), along with the strategy prompts M3 and the heuristic algorithm and its algorithmic thought language description, into the large language model to obtain a total of n new heuristic algorithms.
9. The method according to claim 1, characterized in that, The large language model in step 2) is Deepseek-R1, DeepSeek-R1-Distill-Llama-70B, or Deepseek-V3; The large language model in step 4) is Deepseek-V3.
10. The method according to claim 1, characterized in that, During the first loop, each heuristic algorithm in step 3) is one of the multiple heuristic algorithms obtained in step 2); from the second loop onwards until the end of the loop, each heuristic algorithm in step 3) is one of the N new heuristic algorithms obtained in step 4) and the n heuristic algorithms retained in step 3).
Citation Information
Patent Citations
Training system for telephone switchboard operators using computer central processing unit
CA1065601A
Active power distribution network optimization scheduling model and method considering information system uncertainty
CN108695853A
Distributed photovoltaic power supply site selection optimization method based on power distribution network probabilistic load flow calculation
CN112994017A
Real-time optimal power flow method based on generative pre-training model (GPT) and deep reinforcement learning
CN119647237A
Optimization method and system for optimal power flow of power distribution network
CN119787363A
Cited By
Offshore wind plant multi-type fan arrangement optimization method and device and readable medium
CN122174704A
