Adaptive Calculation Method for Power System Operation Modes Based on LLM Agent
By introducing an adaptive calculation method based on LLM Agent in the power system, using the LLM model and multi-agent framework for trend calculation and parameter adjustment, the complexity of power system operation mode adjustment is solved, and more efficient and reliable adaptive calculation of power system operation mode is achieved.
Patent Information
- Application Number
- CN202510296078.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-13
- Publication Date
- 2025-07-01
- Estimated Expiration
- 2045-03-13
AI Technical Summary
It is difficult for the prior art to effectively adjust the operating mode of the power system, especially in the face of complex new power systems and large-scale renewable energy access, resulting in the complex and inefficient flow calculation and parameter adjustment process.
An adaptive calculation method for the operation mode of the power system based on LLM Agent is proposed, and the adaptive calculation and adjustment of the power system is realized using the LLM model, multiple Agents, memory system modules, Prompt modules and tool modules in the LLM Agent framework.
By enhancing the adaptability and accuracy of the trend calculation and adjustment strategy, the adaptive calculation and adjustment process guided by natural language is realized, and the adaptability and decision-making accuracy to the operating form of the new power system is improved, exceeding the experience limitations of existing operating personnel, and ensuring the reliable operation of the system.
Smart Images

Figure CN119813228B_ABST
Abstract
Description
Background Art
[0002] With the accelerated promotion of the construction of the new power system, the inherent complexity of the power system has increased sharply. Considering risks in planning and operation and requiring better adaptability to the generalized environment, conventional analysis and decision-making methods face serious challenges. The starting point of power system operation mode calculation is power flow calculation, and its boundary conditions usually include power injection and switchable discrete quantities (such as shunt capacitors, reactors, etc.). The mathematical essence is the numerical solution problem of a system of non-linear algebraic equations. When the power flow calculation results are not ideal, such as many voltage magnitude violations and branch power violations, etc., to reverse-derive adjustment measures (forming new boundary conditions), it usually relies on manual repeated power flow calculations to obtain a reasonable operation mode.
[0003] Optimal power flow adjusts the parameters of various control devices in the system from the perspective of optimal operation. Under the constraints of meeting the normal power balance of nodes and the non-violation of key physical quantities, it searches for the optimal state transfer through information guidance such as gradients or heuristic rules. Its optimization process is not a traditional boundary condition adjustment, which obscures the physical meaning of the adjustment process and cannot make full use of expert experience. Power flow calculation itself is a numerical solution problem of a system of non-linear algebraic equations. The existence of solutions, the sensitivity of initial values, and the high-dimensional solution space structure are all basic problems that have not been effectively solved, making reliable optimization face more challenges. Nowadays, with the large-scale access of renewable energy to the power system, new operation forms have emerged, and new operation scenarios and the underlying laws need to be recognized and experience accumulated, making the adjustment calculation of power system operation modes increasingly difficult. Summary of the Invention
[0004] To solve the above problems in the prior art, that is, the problem that it is relatively difficult to adjust and calculate the operation mode of the power system in the prior art, in the first aspect, the present invention proposes a method for adaptively calculating the operation mode of the power system based on an LLM Agent, which is applied to the LLM Agent framework. The LLM Agent framework includes an LLM model, multiple Agents, and;
[0005] A memory system module, including a short-term memory module and a long-term memory module. The short-term memory module is used to provide short-term memory support for the Agent. The long-term memory module integrates a knowledge base, and historical interaction data and historical optimization records are stored in the knowledge base. The long-term memory module provides long-term memory support for multiple Agents based on the knowledge base;
[0006] A Prompt module, used to adjust the output and optimization behavior of the LLM model;
[0007] The tool module includes a power flow calculation tool, an API interface, and an RAG module. The power flow calculation tool is used to support the Agent in performing data analysis and calculating the state of the power system. The API interface is used to support multiple Agents in interacting with external data sources. The RAG module is used to provide a retrieval service for the LLM model;
[0008] The method includes:
[0009] Obtain the task requirements of the power system;
[0010] Input the task requirements into the LLM model in the LLM Agent framework. The LLM model is used to parse the input task requirements, determine the task objectives, constraints, and action sets, and split the task requirements into multiple subtasks according to the task objectives and action sets, and determine the Agents for executing each subtask;
[0011] Determine the output of the LLM model, and allocate multiple subtasks to the power flow calculation Agent and the parameter adjustment Agent in the LLM Agent framework by calling the task management Agent in the LLM Agent framework;
[0012] Call the power flow calculation Agent and the parameter adjustment Agent to execute each subtask assigned by the task management Agent. Among them, the power flow calculation Agent executes the power flow calculation of the power system and determines the power flow calculation result by calling the power flow calculation tool. The parameter adjustment Agent iteratively adjusts the power system according to the power flow calculation result by calling the RAG module until the power system meets the constraints.
[0013] In some preferred embodiments, the step of calling the power flow calculation Agent and the parameter adjustment Agent to execute each subtask assigned by the task management Agent includes:
[0014] Call the power flow calculation Agent to perform an initial power flow calculation on the power system by expanding the node load of the power system, and determine the first calculation result, which is received by the parameter adjustment Agent;
[0015] Call the parameter adjustment Agent to determine the reactive power compensation strategy according to the first calculation result, and correct the power system according to the reactive power compensation strategy. The reactive power compensation strategy is transmitted to the power flow calculation Agent;
[0016] Invoke the power flow calculation Agent, and according to the reactive power compensation strategy, perform power flow calculation on the power system after voltage adjustment again, and determine the second calculation result;
[0017] Repeatedly invoke the parameter adjustment Agent, and according to the second calculation result, determine whether the power system meets the constraint conditions;
[0018] If it is determined that the power system does not meet the constraint conditions, then repeatedly invoke the power flow calculation Agent to perform iterative correction on the power system until the power system meets the preset constraint conditions.
[0019] In some preferred embodiments, the step of invoking the parameter adjustment Agent to determine the reactive power compensation strategy according to the first calculation result includes:
[0020] Invoke the parameter adjustment Agent to synchronously obtain the current voltage state of the power system;
[0021] According to the current voltage state, determine whether the power system meets the preset constraint conditions;
[0022] If it is determined that the power system does not meet the preset constraint conditions, then determine the reactive power compensation strategy according to the first calculation result.
[0023] In some preferred embodiments, the step of determining the reactive power compensation strategy according to the first calculation result includes:
[0024] Determine an initial adjustment strategy according to the current voltage state of the power system;
[0025] Invoke the RAG module, and according to the initial adjustment strategy and the first calculation result, determine the reactive power compensation strategy, wherein the RAG module retrieves according to the first calculation result by using a preset knowledge graph database to optimize the initial adjustment strategy to obtain the reactive power compensation strategy.
[0026] In some preferred embodiments, the RAG module retrieves by using a preset knowledge graph database and generates a retrieval result. Before retrieval, the RAG module divides the documents in the preset knowledge graph database into multiple text blocks, and converts the text blocks into vector representations through a preset encoding model, satisfying the following formula:
[0027] ;
[0028] In the formula, q is the query vector, and di is the knowledge base vector;
[0029] When the RAG module performs retrieval, according to a preset similarity scoring criterion, the top k most relevant knowledge base vector sets Dk are determined from the knowledge base vectors as the retrieval result, where k > 0.
[0030] In some preferred embodiments, the RAG module inputs the retrieval result into the LLM model of the LLM Agent framework, and the LLM model generates a reply for optimizing the initial adjustment strategy according to the retrieval result, including:
[0031] Taking the retrieved knowledge base vector set Dk and the query vector q as conditional inputs into the LLM model, and the LLM model generates a corresponding reply according to the conditional inputs:
[0032] ;
[0033] In the formula, G is the LLM model, and y is the reply generated by the LLM model.
[0034] In some preferred embodiments, the LLM Agent framework further includes an information recording Agent, which is used to record the working data of each Agent, and the working data is uploaded by the information recording Agent to a preset database, and the preset database is used to store the state of the power system and adjustment actions;
[0035] The state of the power system is specifically:
[0036] S(P(L1, L2,...), R(LP1, LP2,...));
[0037] In the formula, P is the input of power flow calculation, L1 and L2 are input parameter matrices, R is the power flow calculation result, and LP1 and LP2 are the output power flow states;
[0038] The adjustment action is specifically:
[0039] A(I, V);
[0040] In the formula, I is the position of the modified parameter, and V is the modified value.
[0041] In some preferred embodiments, the LLM Agent framework further includes an information recording Agent, the LLM Agent framework further includes an information recording Agent, which is used to record the working data of each Agent, and the working data is uploaded by the information recording Agent to a preset database;
[0042] The preset database is used to store the state of the power system and adjustment actions:
[0043] The state of the power system, S ( P ( L 1, L 2, ...), R ( LP 1, LP 2, ...)),
[0044] In the formula, P is the input of power flow calculation, L1 and L2 are input parameter matrices, R is the power flow calculation result, and LP1 and LP2 are the output power flow states;
[0045] The adjustment action, A(I, V) ,
[0046] In the formula, I is the position of the modified parameter, and V is the modified value.
[0047] In the second aspect of the present invention, an adaptive calculation device for the operation mode of a power system based on an LLM Agent is proposed, including:
[0048] A data acquisition module for acquiring the task requirements of the power system;
[0049] A data input module for inputting the task requirements into the LLM model in the LLM Agent framework, where the LLM model is used to parse the input task requirements, determine the task objectives, constraint conditions, and action sets, and split the task requirements into multiple subtasks according to the task objectives and action sets, and determine the Agents for executing each subtask;
[0050] A data output module for determining the output of the LLM model, and allocating the multiple subtasks to the power flow calculation Agent and the parameter adjustment Agent in the LLM Agent framework by calling the task management Agent in the LLM Agent framework;
[0051] A data adjustment module for calling the power flow calculation Agent and the parameter adjustment Agent to execute each subtask assigned by the task management Agent. Among them, the power flow calculation Agent executes the power flow calculation of the power system and determines the power flow calculation result by calling the power flow calculation tool, and the parameter adjustment Agent iteratively adjusts the power system according to the power flow calculation result by calling the RAG module until the power system meets the constraint conditions.
[0052] In the third aspect of the present invention, an electronic device is proposed, including:
[0053] At least one processor; and,
[0054] A memory communicatively connected to at least one of the processors; wherein,
[0055] The memory stores instructions executable by the processor, and the instructions are used to be executed by the processor to implement the method described in the first aspect.
[0056] In a fourth aspect of the present invention, a computer-readable storage medium is proposed. The computer-readable storage medium stores computer instructions, and the computer instructions are used to be executed by the computer to implement the method described in the first aspect.
[0057] Advantages of the present invention:
[0058] The power system operation mode adaptive calculation method based on LLM Agent proposed by the present invention utilizes the reasoning ability of the LLM large language model to enhance the adaptability of the power flow calculation adjustment strategy, and ensures the accuracy of the power flow calculation by invoking the power flow calculation module through multiple agents, thereby realizing an adaptive calculation and adjustment process guided by natural language. In addition, due to the introduction of the Retrieval Augmented Generation (RAG) technology in the calculation adjustment process to obtain external knowledge base and database information, the understanding ability of the multi-agent framework for the operation laws of the power system and the decision-making accuracy are further improved. The present invention gives full play to the advantages of the large language model in logic and natural language processing, and integrates with traditional power flow calculation tools to form a closed loop for adjusting boundary conditions according to the power flow calculation results. It can not only enhance the adaptability to the operation form of the new power system, but also discover new adjustment modes by mining potential operation modes, transcend the experience limitations of existing operators, automatically identify and adapt to new operation modes, dynamically adjust the power flow calculation strategy, and quickly respond to various emergencies to ensure the reliable operation of the system. Description of the Drawings
[0059] By reading the detailed description of the non-restrictive embodiments with reference to the following drawings, other features, objects, and advantages of the present application will become more apparent:
[0060] Figure 1 is a schematic flowchart of a power system operation mode adaptive calculation method based on LLM Agent proposed by an embodiment of the present invention;
[0061] Figure 2 is a general schematic diagram of an adaptive solution mechanism for an LLM Agent framework proposed by an embodiment of the present invention;
[0062] Figure 3It is a schematic diagram of an LLM Agent framework proposed in an embodiment of the present invention;
[0063] Figure 4 It is a schematic diagram of the workflow of an LLM Agent framework proposed in an embodiment of the present invention;
[0064] Figure 5 It is a schematic diagram of the working mechanism of RAG proposed in an embodiment of the present invention;
[0065] Figure 6 It is a schematic diagram of the result of an adaptive calculation device for the operation mode of a power system based on an LLM Agent proposed in an embodiment of the present invention;
[0066] Figure 7 It is a schematic diagram of the structure of a computer system of a server for implementing the method, device, and electronic device embodiments of the present application. Detailed implementation manners
[0067] The present application will be further described in detail below with reference to the accompanying drawings and embodiments. It can be understood that the specific embodiments described herein are only used to explain the related invention and are not intended to limit the invention. Additionally, it should be noted that, for the sake of convenience of description, only parts related to the relevant invention are shown in the drawings.
[0068] It should be noted that, without conflict, the embodiments in the present application and the features in the embodiments can be combined with each other. The present application will be described in detail below with reference to the drawings and embodiments.
[0069] The present invention provides an adaptive calculation method for the operation mode of a power system based on an LLM Agent, which is applied to an LLM Agent framework. The LLM Agent framework includes an LLM model and multiple Agents. The multiple Agents at least include a task management Agent, a power flow calculation Agent, and a parameter adjustment Agent; and
[0070] A memory system module, including a short-term memory module and a long-term memory module. The short-term memory module is used to provide short-term memory support for the Agent. The long-term memory module integrates a knowledge base, and historical interaction data and historical optimization records are stored in the knowledge base. The long-term memory module provides long-term memory support for the multiple Agents based on the knowledge base;
[0071] A Prompt module, which is used to adjust the output and optimization behavior of the LLM model;
[0072] The tool module includes a power flow calculation tool, an API interface, and a RAG module. The power flow calculation tool is used to support the Agent in performing data analysis and calculating the state of the power system. The API interface is used to support multiple Agents in interacting with external data sources. The RAG module is used to provide retrieval services for the LLM model;
[0073] To more clearly illustrate the above method, the following will be combined with Figure 1 Each step in the embodiment of the present invention will be described in detail. Please refer to Figure 1 , the first embodiment of the present invention provides a method for adaptively calculating the operation mode of a power system based on an LLM Agent, including:
[0074] Step S10, obtaining the task requirements of the power system;
[0075] In this embodiment, the task requirements of the power system refer to the operation adjustment requirements of the power system at the global level, including but not limited to the adjustment requirements of the power system at the levels of power generation, transmission, distribution, and distribution coordination. Specifically, by optimizing and adjusting the power flow distribution of the power system, the overall efficiency of the power system can be effectively improved while preventing line overload.
[0076] In this embodiment, the preset constraint conditions are used to represent the boundary conditions during the adjustment of the power system, specifically including the constraint ranges of various grid parameters in the power system. Based on the limitations of these constraint conditions, it is possible to avoid arbitrary modification and adjustment of the parameters of the power system by each intelligent agent in the subsequent steps.
[0077] Step S20, inputting the task requirements into the LLM model in the LLM Agent framework. The LLM model is used to parse the input task requirements, determine the task objectives, constraint conditions, and action sets, and split the task requirements into multiple subtasks according to the task objectives and action sets, and determine the Agents for executing each subtask;
[0078] It should be noted that in this embodiment, the power system is adaptively adjusted and calculated in combination with the LLM Agent framework. Please refer to Figure 2 , Figure 2 The overall schematic diagram of the adaptive solution mechanism of the LLM Agent framework in this embodiment is shown. It consists of two major parts:
[0079] The first part is the LLM Agents framework. The planning, thinking, and memory functions of the LLM endow the intelligent agent with the abilities of perception, reasoning, decision-making, and self-evolution. Through these abilities, the intelligent agent can understand the task requirements and make dynamic adjustments, so as to achieve efficient processing of complex power system tasks;
[0080] The second part is the modeling and simulation requirements of the power system. The agent adjusts the power flow calculation and parameter optimization in real time according to the operation data and task objectives of the power system. The adaptability of the LLM Agents framework enables it to automatically execute complex tasks, while ensuring the agent's resistance to disturbances, intelligent task processing, and high interpretability of the decision-making process. Through the deep integration of the agent and the power system, the framework can adapt to the changing operating conditions of the power system, automatically complete complex tasks, and provide transparent and interpretable decision-making support.
[0081] It is easy to understand that the LLM Agent framework includes an LLM (Large Language Model) and multiple agents. The planning, thinking, and memory functions of the LLM endow the agent with the abilities of perception, reasoning, decision-making, and self-evolution. Furthermore, based on the above abilities, the agent can understand the task requirements and make dynamic adjustments, so as to achieve the efficient processing of complex power system tasks.
[0082] Furthermore, please refer to Figure 3 , Figure 3 which is a schematic diagram of the LLM Agent framework provided in this embodiment. As shown in Figure 3 , in this embodiment, the LLM model analyzes and decomposes the task requirements, so as to split the total task requirements into multiple subtasks. Specifically, the LLM model decomposes the global operation adjustment requirements into several executable subtasks through its powerful natural language understanding and generation capabilities. Each subtask is responsible for being executed by the corresponding agent, and the LLM is also responsible for planning the logical relationship and execution order between each subtask to ensure the coordination and efficiency of the overall calculation process.
[0083] After the task decomposition is completed, the LLM model assigns these tasks to the corresponding agents. The above agents each have different functions and task execution capabilities, and are respectively responsible for specific subtasks such as reactive power compensation, power flow calculation, control parameter adjustment, information recording and feedback. During the execution of the subtasks, the agent calls external tools such as power flow calculation codes, optimization algorithms, and database query interfaces to perform corresponding calculation operations. In addition, the agent can not only interact with external tools through the API, but also dynamically generate and repair codes to ensure the smooth progress of the calculation tasks.
[0084] Step S30, determine the output of the LLM model, and allocate the multiple subtasks to the power flow calculation agent and the parameter adjustment agent of the LLM Agent framework by calling the task management agent of the LLM Agent framework;
[0085] It should be noted that based on the LLM Agent framework, after splitting complex task requirements into subtasks, the overall task requirements are completed through the collaboration of multiple Agent intelligent agents. Each intelligent agent can not only execute its specific task, but also adjust the calculation in an overall way by sharing calculation results and natural language interaction and collaboration.
[0086] Specifically, the LLM Agent framework includes but is not limited to a task management Agent, a power flow calculation Agent, and a parameter adjustment Agent, where:
[0087] The task management Agent, as the core of the multi-agent system, is responsible for task requirement parsing, goal setting, clarification of control parameters and constraint conditions, and decomposes the task into subtasks for other intelligent agents to execute. Specifically, the management Agent receives and parses the task requirements, which indicate the adjustment goal, control parameters, and related constraint conditions. Based on the parsing results, the management Agent decomposes the task into several subtasks, clarifies the execution order and specific requirements of each subtask. These subtasks include reactive power compensation setting, power flow calculation, result verification, etc. The management Agent also ensures that each intelligent agent accurately understands the task goal and its expected output.
[0088] The parameter adjustment Agent, based on real-time feedback, independently formulates a voltage adjustment strategy, determines whether the node voltage exceeds the limit, and sets the initial reactive power compensation value. According to the power flow calculation results, the parameter adjustment Agent optimizes the reactive power compensation strategy through the RAG technology, gradually reduces the number of iterations, and achieves efficient adjustment.
[0089] The power flow calculation Agent is responsible for performing power flow calculations, executing the power flow calculation code, and outputting the calculation results. If an error occurs, the LLM can also be used to repair the code to ensure the accuracy of the calculation. Specifically, the power flow calculation Agent receives the reactive power compensation value provided by the parameter adjustment Agent, executes the preset power flow calculation code, and calculates the adjusted power grid operation state. If an error occurs during the power flow calculation process, the power flow calculation Agent will automatically generate a correction code using the code repair function of the LLM and re-execute it to ensure the accuracy of the calculation.
[0090] Step S40, call the power flow calculation Agent and the parameter adjustment Agent to execute each subtask assigned by the task management Agent. Among them, the power flow calculation Agent executes the power flow calculation of the power system and determines the power flow calculation results by calling the power flow calculation tool, and the parameter adjustment Agent iteratively adjusts the power system according to the power flow calculation results by calling the RAG module until the power system meets the constraint conditions.
[0091] Specifically, please refer to Figure 4 , Figure 4 which is a schematic diagram of the workflow of the LLM-Agent framework provided in this embodiment. As Figure 4 shown, the management Agent first receives and parses the task requirements, clarifies the adjustment objectives, control parameters, and constraint conditions, and decomposes the task into subtasks and assigns them to each intelligent agent for execution. The power flow calculation Agent expands the node load and performs the initial power flow calculation, outputting the basic data. Subsequently, the parameter adjustment Agent obtains the current voltage status, determines whether there is a node voltage violation. If so, it sets the reactive power compensation strategy and corrects the voltage. The power flow calculation Agent performs the adjusted power flow calculation according to the compensation value and repairs the code through the LLM to ensure accurate calculation if there are errors. The parameter adjustment Agent evaluates the effectiveness of the compensation strategy based on the calculation results. If the voltage is still over-limit, it continues to iterate until all constraint conditions are met. Finally, the information recording Agent records the iterative data to ensure the integrity and traceability of the adjustment process and provide support for subsequent strategy optimization.
[0092] More specifically, in this embodiment, the steps of calling the power flow calculation Agent and the parameter adjustment Agent to execute each subtask assigned by the task management Agent specifically include:
[0093] Calling the power flow calculation Agent to perform the initial power flow calculation on the power system by expanding the node load of the power system, determining the first calculation result, which is received by the parameter adjustment Agent; calling the parameter adjustment Agent to determine the reactive power compensation strategy according to the first calculation result, and correcting the power system according to the reactive power compensation strategy, and the reactive power compensation strategy is transmitted to the power flow calculation Agent; calling the power flow calculation Agent to perform the power flow calculation on the power system after voltage adjustment again according to the reactive power compensation strategy and determining the second calculation result; repeatedly calling the parameter adjustment Agent to determine whether the power system meets the preset constraint conditions according to the second calculation result; if it is determined that the power system does not meet the preset constraint conditions, repeatedly call the power flow calculation Agent to perform iterative correction on the power system until the power system meets the preset constraint conditions.
[0094] In this embodiment, the preset constraint conditions are used to indicate whether the power system meets specific adjustment expectations in the current adjustment mode. Preferably, the index of whether the voltage of each node in the power system exceeds the limit can be used as the above-mentioned constraint condition.
[0095] For example, first, the power flow calculation Agent expands the node load and performs the initial power flow calculation, outputting the preliminary power flow calculation results as the basic data for subsequent adjustments. Then, the parameter adjustment Agent obtains the voltage state of the current power grid system and determines whether there is a node voltage over-limit phenomenon (i.e., the above-mentioned preset constraint condition). If an over-limit is detected, the parameter adjustment Agent will set the reactive power compensation strategy and perform voltage correction through reactive power compensation. Subsequently, the power flow calculation Agent receives the reactive power compensation value provided by the parameter adjustment Agent, executes the preset power flow calculation code, and calculates the adjusted power grid operating state. If an error occurs during the power flow calculation process, the power flow calculation Agent will automatically generate a corrected code using the code repair function of the LLM and re-execute it to ensure the accuracy of the calculation. Finally, the parameter adjustment Agent evaluates the effectiveness of the compensation strategy based on the power flow calculation results and determines whether the node voltage is still over-limit. If there is still an over-limit, it returns to the above steps to continue iterative adjustment... until the system constraint conditions are met and the target optimization adjustment is completed.
[0096] More specifically, call the parameter adjustment Agent, and determine the reactive power compensation strategy according to the first calculation result, including:
[0097] Call the parameter adjustment Agent to obtain the current voltage state of the power system; according to the current voltage state, determine whether the power system meets the preset constraint conditions; if it is determined that the power system does not meet the preset constraint conditions, then determine the reactive power compensation strategy according to the first calculation result.
[0098] Among them, the LLM Agent framework also includes a RAG module. The determining the reactive power compensation strategy according to the first calculation result specifically includes: determining an initial adjustment strategy according to the current voltage state of the power system; calling the RAG module, and determining the reactive power compensation strategy according to the initial adjustment strategy and the first calculation result, where the RAG module optimizes the initial adjustment strategy using a preset knowledge graph database according to the first calculation result to obtain the reactive power compensation strategy.
[0099] In this embodiment, when formulating the reactive power compensation strategy of the power system, according to the currently obtained power flow calculation results, use the RAG technology to query the indication graph database, perform feature judgment according to the power flow calculation results, determine the state according to the features satisfied by the data, and then select the modification operation that should be executed for this state to formulate the adjustment strategy for the next round.
[0100] More specifically, the RAG module retrieves and generates retrieval results using a preset knowledge graph database. Before retrieval, the RAG module divides the documents in the preset knowledge graph database into multiple text chunks and converts the text chunks into vector representations through a preset encoding model, satisfying the following formula:
[0101] ;
[0102] In the formula, q is the query vector, and di is the knowledge base vector;
[0103] When the RAG module performs retrieval, according to a preset similarity scoring criterion, the top k most relevant knowledge base vector sets Dk are determined in the knowledge base vectors as the retrieval results, where k > 0.
[0104] Furthermore, please refer to Figure 5 , Figure 5 which is a schematic diagram of the RAG working mechanism provided in this embodiment. As shown in Figure 5 , the working process of the RAG is divided into a retrieval stage and a generation stage. In the retrieval stage, the RAG pre-divides the documents in the preset knowledge graph database into text chunks and uses an encoding model to convert the text chunks into vector representations. During retrieval, the input query is also encoded into a vector representation. Based on cosine similarity, the similarity between the query vector and the knowledge base vector is calculated to perform information matching, thereby outputting the retrieval results.
[0105] In the generation stage of the RAG module, the RAG module inputs the retrieved relevant text chunks (knowledge base vector set) and the query input as conditions into the LLM model. The LLM model generates the answer that best meets the query context by evaluating all possible generated responses and combining the retrieved knowledge. The finally output response is an intelligent generation and optimization of the retrieved content to ensure that the result is not only accurate but also rich in context logic.
[0106] Taking the retrieved knowledge base vector set Dk and the input query q as condition inputs, the LLM generates a response according to the condition inputs:
[0107] ;
[0108] In the formula, y represents the generated response, G represents the above LLM model, and the LLM selects the one with the highest conditional probability as the optimal response by evaluating all possible generated responses. The optimal response is the most likely and optimal answer generated under the given conditions (i.e., the retrieved knowledge base vector set Dk and the input query q):
[0109] ;
[0110] In the preset knowledge graph database, the knowledge graph is represented in the form of a triple G(Gs, Gd, R), where Gs(Ns, Es) represents the knowledge graph schema graph, Ns and Es represent the nodes and edges of the schema graph respectively, Gd(Nd, Ed) represents the knowledge graph data graph, Nd and Ed represent the nodes and edges of the data graph respectively, and R is the connection between the two layers of the knowledge graph, representing the relationship between concepts and entities. A knowledge graph structure is established for the database in the form of "state" - "operation" - "state", where "state" represents the power grid operation parameters, "operation" represents the modification action, and the form of "state" - "operation" - "state" represents the transformation of the power grid operation state.
[0111] More specifically, the LLM Agent framework further includes an information recording Agent, which is used to record the power flow calculation results and reactive power compensation strategies of the power flow calculation Agent and the parameter adjustment Agent during the iterative adjustment of the power system. The power flow calculation results and reactive power compensation strategies are uploaded by the information recording Agent to a preset database;
[0112] The preset database is used to record the state and adjustment actions of the power system, specifically including:
[0113] The state of the power system, such as:
[0114] S(P(L1, L2,...), R(LP1, LP2,...)), where P is the input of the power flow calculation, L1 and L2 are the input parameter matrices, R is the output of the power flow calculation, and LP1 and LP2 are the output power flow states;
[0115] The adjustment action, A(I, V), where I is the position of the modified data and V is the modified value.
[0116] Specifically, the local database consists of actual data and data stored by the information recording Agent. The formal description of the power flow adjustment problem is:
[0117] The current state of the power grid is represented as S(P(L1, L2,...), R(LP1, LP2,...)), where P represents the input of the power flow calculation, L1 and L2 are the input parameter matrices, such as power grid component parameters like nodes and branches; R represents the output of the power flow calculation, and LP1 and LP2 are the output power flow states, such as node voltages and powers. The adjustment action is to modify the power grid parameters, that is, the reactive power compensation amount of each node, represented by A(I, V), where I represents the position of the modified data and V represents the modified value. During the actual adjustment process, the power grid parameters restricted by the constraint conditions need to have a constraint range defined to prevent the agent from making arbitrary modification operations.
[0118] Based on the above embodiments, the power system operation mode adaptive calculation method proposed by the present invention based on the LLM Agent utilizes the reasoning ability of the large language model to enhance the adaptability of the power flow calculation adjustment strategy, and ensures the accuracy of the power flow calculation by invoking the power flow calculation module through multiple agents, so as to realize the adaptive operation mode calculation and adjustment process guided by natural language. The retrieval augmented generation (RAG) technology is introduced in the calculation and adjustment process to obtain external knowledge base and database information, further improving the understanding ability and decision-making accuracy of the multi-agent framework for the operation laws of the power system. The present invention gives full play to the advantages of large language in logic and natural language processing, combines industry knowledge enhancement, and integrates with traditional power flow calculation tools to form a closed loop for boundary condition adjustment according to the power flow calculation results. It can not only enhance the adaptability to the operation form of the new power system, but also discover new adjustment modes by mining potential operation modes, transcend the experience limitations of existing operators, automatically identify and adapt to new operation modes, dynamically adjust the power flow calculation strategy, and quickly respond to various emergencies to ensure the reliable operation of the system.
[0119] In the above embodiments, although each step is described in the above sequential order, those skilled in the art can understand that in order to achieve the effects of this embodiment, different steps do not have to be executed in such an order, and they can be executed simultaneously (in parallel) or in a reversed order, and these simple changes are within the protection scope of the present invention.
[0120] The second embodiment of the present invention proposes a power system operation mode adaptive calculation device based on the LLM Agent. Among them, the power system operation mode adaptive calculation device based on the LLM Agent can be a software module. The software module includes several instructions, which are stored in the memory. The processor can access this memory and call the instructions for execution to complete the power system operation mode adaptive calculation method based on the LLM Agent described in each of the above embodiments. In some embodiments, the power system operation mode adaptive calculation device based on the LLM Agent can also be built by hardware devices. For example, the power system operation mode adaptive calculation device based on the LLM Agent can be built by one or more than two chips. Each chip can work in coordination with each other to complete the power system operation mode adaptive calculation method based on the LLMAgent described in each of the above embodiments. For another example, the power system operation mode adaptive calculation device based on the LLM Agent can also be built by various logic devices, such as being built by a general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), a single-chip microcomputer, an ARM (Acorn RISC Machine), or other programmable logic devices, discrete gate or transistor logic, discrete hardware components, or any combination of these components.
[0121] Please refer to Figure 6 , Figure 6 The structure diagram of the power system operation mode adaptive calculation device based on the LLM Agent is shown as follows. As shown in the figure, the power system operation mode adaptive calculation device based on the LLM Agent further includes:
[0122] A data acquisition module 210, configured to acquire the task requirements of the power system;
[0123] A data input module 220, configured to input the task requirements into the LLM model in the LLM Agent framework. The LLM model is used to parse the input task requirements, determine the task objectives, constraint conditions, and action sets, and split the task requirements into multiple subtasks according to the task objectives and action sets, and determine the Agents for executing each subtask;
[0124] A data output module 230, configured to determine the output of the LLM model, and allocate the multiple subtasks to the power flow calculation Agent and the parameter adjustment Agent of the LLM Agent framework by calling the task management Agent of the LLM Agent framework;
[0125] A data adjustment module 240 is configured to call the power flow calculation Agent and the parameter adjustment Agent to execute each subtask assigned by the task management Agent. Among them, the power flow calculation Agent executes the power flow calculation of the power system and determines the power flow calculation result by calling the power flow calculation tool, and the parameter adjustment Agent iteratively adjusts the power system according to the power flow calculation result by calling the RAG module until the power system meets the constraint conditions.
[0126] Those skilled in the art can clearly understand that for the convenience and simplicity of description, the specific working processes and related descriptions of the above-described devices can refer to the corresponding processes in the foregoing method embodiments and will not be elaborated herein.
[0127] The third embodiment of the present invention provides an electronic device, including:
[0128] At least one processor; and a memory communicatively connected to at least one of the processors; wherein the memory stores instructions executable by the processor, and the instructions are used to be executed by the processor to implement the above-mentioned method for adaptively calculating the operation mode of a power system based on LLM Agent.
[0129] The fourth embodiment of the present invention provides a computer-readable storage medium storing computer instructions for being executed by a computer to implement the above-mentioned method for adaptively calculating the operation mode of a power system based on LLM Agent.
[0130] Those skilled in the art can clearly understand that for the convenience and simplicity of description, the specific working processes and related descriptions of the above-described electronic device and computer-readable storage medium can refer to the corresponding processes in the foregoing method embodiments and will not be elaborated herein.
[0131] Those skilled in the art should be able to realize that the modules and method steps of each example described in combination with the embodiments disclosed herein can be implemented by electronic hardware, computer software, or a combination of both. The programs corresponding to the software modules and method steps can be placed in a random access memory (RAM), internal memory, read-only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, removable disk, CD-ROM, or any other form of storage medium known in the technical field. To clearly illustrate the interchangeability of electronic hardware and software, the composition and steps of each example have been generally described according to functions in the above description. Whether these functions are executed in the form of electronic hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered to exceed the scope of the present invention.
[0132] Reference is made below to Figure 7 , which shows a schematic structural diagram of a computer system of a server for implementing the method, system, and device embodiments of the present application. Figure 7 The server shown is only an example and should not impose any limitations on the functions and usage scope of the embodiments of the present application.
[0133] As Figure 7 shown, the computer system includes a central processing unit (CPU, Central Processing Unit) 301, which can perform various appropriate actions and processes according to the program stored in the read-only memory (ROM, Read Only Memory) 302 or the program loaded from the storage section 308 into the random access memory (RAM, Random Access Memory) 303. In the random access memory 303, various programs and data required for system operation are also stored. The central processing unit 301, read-only memory 302, and random access memory 303 are connected to each other through a bus 304. The input / output (I / O, Input / Output) interface 305 is also connected to the bus 304.
[0134] The following components are connected to the input / output interface 305: an input section 306 including a keyboard, a mouse, etc.; an output section 307 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc. and a speaker, etc.; a storage section 308 including a hard disk, etc.; and a communication section 309 including a network interface card such as a LAN (Local Area Network) card, a modem, etc. The communication section 309 performs communication processing via a network such as the Internet. A drive 310 is also connected to the input / output interface 305 as needed. A removable medium 311 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc. is mounted on the drive 310 as needed so that a computer program read therefrom is installed into the storage section 308 as needed.
[0135] In particular, according to embodiments of the present disclosure, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product that includes a computer program carried on a computer-readable medium, and the computer program includes program code for performing the methods shown in the flowcharts. In such an embodiment, the computer program can be downloaded and installed from a network through the communication section 309, and / or installed from the removable medium 311. When the computer program is executed by the central processing unit 301, the above-described functions defined in the methods of the present application are performed. It should be noted that the computer-readable medium described above in the present application can be a computer-readable signal medium or a computer-readable storage medium or any combination of the two. A computer-readable storage medium can be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the above. More specific examples of the computer-readable storage medium can include, but are not limited to: an electrical connection having one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present application, a computer-readable storage medium can be any tangible medium that contains or stores a program that can be used by or in conjunction with an instruction execution system, apparatus, or device. And in the present application, a computer-readable signal medium can include a data signal propagated in a baseband or as part of a carrier wave, in which the computer-readable program code is carried. Such a propagated data signal can take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. A computer-readable signal medium can also be any computer-readable medium other than a computer-readable storage medium, which can send, propagate, or transmit a program for use by or in conjunction with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium can be transmitted with any appropriate medium, including but not limited to: wireless, wire, optical fiber cable, RF, etc., or any suitable combination of the above.
[0136] Computer program code for performing the operations of this application can be written in one or more programming languages or combinations thereof. The above-mentioned programming languages include object-oriented programming languages such as Java, Smalltalk, C++, and also include conventional procedural programming languages such as the "C" language or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, executed as a stand-alone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer can be connected to the user's computer through any kind of network, including a local area network (LAN) or a wide area network (WAN), or it can be connected to an external computer (for example, by using an Internet service provider to connect through the Internet).
[0137] The flowcharts and block diagrams in the accompanying drawings illustrate the possible architectures, functions, and operations of systems, methods, and computer program products according to various embodiments of this application. In this regard, each block in the flowchart or block diagram can represent a module, a program segment, or a part of code that contains one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the blocks may occur in a different order than that marked in the accompanying drawings. For example, two consecutive blocks shown may actually be executed substantially in parallel, and they can sometimes be executed in the reverse order, depending on the functions involved. It should also be noted that each block in the block diagram and / or flowchart, and the combination of blocks in the block diagram and / or flowchart, can be implemented by a dedicated hardware-based system for performing the specified functions or operations, or can be implemented by a combination of dedicated hardware and computer instructions.
[0138] The terms "first", "second", etc. are used to distinguish similar objects, rather than to describe or represent a specific order or sequence. The term "comprising" or any other similar term is intended to cover non-exclusive inclusion, so that a process, method, article, or device / equipment that includes a series of elements not only includes those elements, but also includes other elements not explicitly listed, or also includes elements inherent in these processes, methods, articles, or devices / equipment.
[0139] So far, the technical solution of the present invention has been described in conjunction with the preferred embodiments shown in the accompanying drawings. However, it is easy for those skilled in the art to understand that the protection scope of the present invention is obviously not limited to these specific embodiments. Without departing from the principle of the present invention, those skilled in the art can make equivalent changes or substitutions to the relevant technical features, and the technical solutions after these changes or substitutions will fall within the protection scope of the present invention.
Claims
1. An adaptive calculation method for power system operation mode based on LLM Agent, characterized in that: Applied to the LLMAgent framework, the LLM Agent framework includes an LLM model, multiple Agents, and; A memory system module, including a short-term memory module and a long-term memory module, wherein the short-term memory module is used to provide short-term memory support for the Agent, and the long-term memory module is integrated with a knowledge base, wherein the knowledge base stores historical interaction data and historical optimization records, and the long-term memory module provides long-term memory support for multiple Agents based on the knowledge base; Prompt module, used to adjust the output and optimization behavior of the LLM model; A tool module, including a power flow calculation tool, an API interface and a RAG module. The power flow calculation tool is used to support the Agent to perform data analysis and power system status calculation. The API interface is used to support multiple Agents to interact with external data sources. The RAG module is used to provide retrieval services for the LLM model. The method comprises: Obtain mission requirements for power systems; Input the task requirements into the LLM model in the LLM Agent framework, the LLM model is used to parse the input task requirements, determine the task objectives, constraints and action sets, and split the task requirements into multiple subtasks according to the task objectives and action sets, and determine the Agent used to execute each subtask; Determine the output of the LLM model, and allocate the plurality of subtasks to the power flow calculation agent and parameter adjustment agent of the LLM Agent framework by calling the task management agent of the LLM Agent framework; Calling the power flow calculation agent and the parameter adjustment agent to execute each subtask assigned by the task management agent, wherein the power flow calculation agent executes the power flow calculation of the power system and determines the power flow calculation result by calling the power flow calculation tool, and the parameter adjustment agent iteratively adjusts the power system according to the power flow calculation result by calling the RAG module until the power system meets the constraint condition; The calling of the power flow calculation agent and the parameter adjustment agent to execute each subtask assigned by the task management agent includes: Calling the power flow calculation agent, performing an initial power flow calculation on the power system by expanding the node load of the power system, and determining a first calculation result, wherein the first calculation result is received by the parameter adjustment agent; calling the parameter adjustment agent, determining a reactive power compensation strategy according to the first calculation result, and correcting the power system according to the reactive power compensation strategy, wherein the reactive power compensation strategy is transmitted to the power flow calculation agent; Calling the power flow calculation Agent, performing power flow calculation again on the power system after voltage adjustment according to the reactive power compensation strategy, and determining a second calculation result; Repeatedly calling the parameter adjustment Agent to determine whether the power system meets the constraint condition according to the second calculation result; If it is determined that the power system does not meet the constraint condition, the power flow calculation Agent is repeatedly called to iteratively correct the power system until the power system meets the preset constraint condition.
2. The method according to claim 1, characterized in that The calling the parameter adjustment agent to determine a reactive power compensation strategy according to the first calculation result includes: Calling the parameter adjustment Agent to synchronously obtain the current voltage state of the power system; According to the current voltage state, determining whether the power system meets preset constraint conditions; If it is determined that the power system does not satisfy the preset constraint condition, the reactive power compensation strategy is determined according to the first calculation result.
3. The method according to claim 2, characterized in that The step of determining the reactive power compensation strategy according to the first calculation result includes: Determining an initial adjustment strategy according to a current voltage state of the power system; Call the RAG module to determine the reactive power compensation strategy according to the initial adjustment strategy and the first calculation result, wherein the RAG module searches a preset knowledge graph database according to the first calculation result to optimize the initial adjustment strategy and obtain the reactive power compensation strategy.
4. The method according to claim 3, characterized in that The RAG module uses a preset knowledge graph database to search and generate search results. Before searching, the RAG module divides the documents in the preset knowledge graph database into multiple text blocks, and converts the text blocks into vector representations through a preset encoding model, satisfying the following formula: ; In the formula, q is the query vector and di is the knowledge base vector; When performing a search, the RAG module determines the top k most relevant knowledge base vector sets D in the knowledge base vectors according to the preset similarity scoring criteria. k As a result of the search, k is greater than 0.
5. The method according to claim 4, characterized in that The RAG module inputs the search results into the LLM model of the LLMAgent framework, and the LLM model generates a response for optimizing the initial adjustment strategy according to the search results, including: The retrieved knowledge base vector set D k and query vector q as conditions to input into the LLM model, and the LLM model generates a corresponding reply according to the condition input: ; Where G is the LLM model, and y is the response generated by the LLM model.
6. The method according to claim 1, characterized in that The LLM Agent framework further includes an information recording Agent, which is used to record the working data of each Agent. The working data is uploaded by the information recording Agent to a preset database, and the preset database is used to store the state and adjustment actions of the power system; The state of the power system is specifically: S(P(L1, L2, ...), R(LP1, LP2, ...)); Where P is the input of power flow calculation, L1 and L2 are input parameter matrices, R is the power flow calculation result, LP1 and LP2 are the output power flow states; The adjustment action is specifically: A(I, V); Where I is the position of the modified parameter, and V is the modified value.
7. An LLM Agent-based adaptive calculation device for power system operation mode, applied to the method described in any one of claims 1 to 6, characterized in that: include: Data acquisition module, used to obtain the task requirements of the power system; A data input module, used to input the task requirements into the LLM model in the LLM Agent framework, the LLM model is used to parse the input task requirements, determine the task objectives, constraints and action sets, and split the task requirements into multiple subtasks according to the task objectives and action sets, and determine the Agent used to execute each subtask; A data output module, used for determining the output of the LLM model, and allocating the plurality of subtasks to the power flow calculation agent and parameter adjustment agent of the LLM Agent framework by calling the task management agent of the LLM Agent framework; A data adjustment module is used to call the power flow calculation agent and the parameter adjustment agent to execute each subtask assigned by the task management agent, wherein the power flow calculation agent executes the power flow calculation of the power system and determines the power flow calculation result by calling the power flow calculation tool, and the parameter adjustment agent iteratively adjusts the power system according to the power flow calculation result by calling the RAG module until the power system meets the constraint condition.
8. An electronic device, characterized in that: include: at least one processor; as well as, a memory communicatively connected to at least one of the processors; wherein, The memory stores instructions that can be executed by the processor, and the instructions are used to be executed by the processor to implement the method according to any one of claims 1 to 6.
9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, and the computer instructions are used to be executed by the computer to implement the method according to any one of claims 1 to 6.
Citation Information
Patent Citations
AI intelligent agent and DAO driven power grid dispatching method
CN117411180A
Multi-agent cooperation method and system
CN118917632A