Microgrid energy management optimization method and system based on event planning perception
By constructing small model and large model intelligent agents, combined with multi-scale data prediction and decision-making collaboration modules, the problem of insufficient external event response capability in microgrid energy management is solved, the processing of unstructured information and decision optimization are realized, and the user's electricity comfort and the flexibility of power scheduling are improved.
Patent Information
- Application Number
- CN202510962507.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-14
- Publication Date
- 2025-09-19
- Estimated Expiration
- 2045-07-14
AI Technical Summary
Existing model-free reinforcement learning methods lack the ability to respond to external events in microgrid energy management, resulting in the system's inability to dynamically integrate information in the face of sudden weather changes, electricity price policy adjustments, etc., affecting the flexibility of power dispatch and user comfort.
Build small model intelligent agents and large model intelligent agents, generate real-time decisions with second-level response through small models, use the natural language understanding capabilities and tool functions of large models to generate decisions, and combine multi-scale data prediction modules and decision-making collaboration modules to realize the processing of unstructured information and decision optimization.
It improves the responsiveness of microgrid energy management, optimizes user comfort, reduces unnecessary power consumption, and maintains the reliability and explainability of decisions.
Smart Images

Figure CN120450495B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of smart grid technology, and in particular to a microgrid energy management optimization method and system oriented to event planning perception. Background Art
[0002] Microgrid energy management aims to optimize the dispatch of campus energy systems by coordinating the operation of distributed power sources, energy storage systems, and load devices. It utilizes advanced control strategies and features autonomous operation, intelligent management, and dynamic optimization. By integrating clean energy technologies such as photovoltaic power generation, it significantly improves overall energy utilization efficiency and reduces system energy consumption and carbon emissions, while providing users with more flexible, stable, and reliable energy services. The development of intelligent microgrid energy management technology not only offers significant economic benefits but also serves as a key path to building a new power system and achieving the "dual carbon" goals.
[0003] Model-free reinforcement learning, which learns by directly interacting with the environment without requiring precise modeling, has rapidly become a mainstream research direction in microgrid energy management. However, because reinforcement learning methods require a fixed state space definition during the initial training phase, the system architecture becomes rigid and unable to dynamically integrate information such as outage notices and user travel plans, which have a significant impact on power dispatch. The system also lacks the ability to respond to external events such as sudden weather changes and electricity pricing adjustments. Therefore, a corresponding technical solution is needed to address this issue. Summary of the Invention
[0004] The technical problem to be solved by the embodiments of the present invention is to provide a microgrid energy management optimization method and system for event planning perception, so as to improve the user's electricity comfort and reduce unnecessary power consumption.
[0005] To solve the above technical problems, an embodiment of the present invention proposes a microgrid energy management optimization method based on event planning perception, including:
[0006] Step S1: Build and train a small model agent;
[0007] Step S2: Build a large model agent with tool functions;
[0008] Step S3: The small model agent is used to obtain real-time information of the microgrid and generate real-time decisions; the large model agent is used to generate decisions based on the power dispatch text information corresponding to the microgrid; the environment time step and the instruction time step are aligned, and a coherent real-time decision response is output based on the decisions generated by the small model agent and the large model agent.
[0009] Accordingly, an embodiment of the present invention further provides a microgrid energy management optimization system for event planning perception, comprising:
[0010] Multi-scale data prediction module: collects historical and current state data of the microgrid, uses the collected data to generate time series data using a sliding window approach, and uses a long short-term memory network to predict the values for the next 1, 2, and 6 hours based on the current and historical state data.
[0011] Small model building module: This module defines the state space and action space of the microgrid energy management problem, designs a suitable reward function, and finally builds and trains a small model agent based on the SAC algorithm using the StableBaseline3 library.
[0012] Large model building module: Builds a large model agent with tool functions based on the mainstream base large model and LangChain framework;
[0013] Decision-making collaboration module: The small model agent obtains real-time information of the microgrid and generates real-time decisions; the large model agent generates decisions based on the power dispatch text information corresponding to the microgrid and caches the decisions in the instruction buffer; when the instruction time step is consistent with the current time step of the environment, the decision is integrated with the small model agent to form the final decision.
[0014] The beneficial effects of the present invention are:
[0015] 1) This invention fully utilizes the universal capabilities of large models and the computational speed advantages of small models, providing a new methodological breakthrough for user-centric microgrid energy management.
[0016] 2) This invention uniquely combines the natural language understanding capabilities of large models and utilizes unstructured planning information in microgrid energy management, such as power outage notifications and user travel planning information, to optimize the decision-making of the original intelligent agent in specific scenarios without increasing the response time of additional decisions.
[0017] 3) This invention leverages the large model's language understanding and function call capabilities to create utility functions to define decision generation, ensuring the reliability and interpretability of large model decision generation. Furthermore, this framework allows for the construction and modification of new utility functions, enabling flexible maintenance and expansion of optimization scenarios to adapt to varying energy demands and operational requirements. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] Figure 1 Schematic diagram of decision making according to an embodiment of the present invention. DETAILED DESCRIPTION
[0019] It should be noted that, unless there is a conflict, the embodiments in this application and the features in the embodiments can be combined with each other. The present invention is further described in detail below with reference to the drawings and specific embodiments.
[0020] In the embodiments of the present invention, if there are directional indications (such as up, down, left, right, front, back, etc.), they are only used to explain the relative position relationship and movement status of the various components under a specific posture (as shown in the accompanying drawings). If the specific posture changes, the directional indication will also change accordingly.
[0021] In addition, the terms "first," "second," and so on, used in this disclosure are for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of technical features being referred to. Therefore, features specified as "first" or "second" may explicitly or implicitly include at least one of these features.
[0022] Please refer to Figure 1 The event planning perception-oriented microgrid energy management optimization method of an embodiment of the present invention includes steps S1 to S3.
[0023] Step S1: Build and train a small model agent. The small model agent is responsible for generating real-time decisions with a response time of seconds based on predefined general state information. Specifically, step S1 includes the following steps:
[0024] Step S11: Data collection, obtaining historical status data of a microgrid (such as a home microgrid, etc., hereinafter taking a grid-connected home microgrid including photovoltaic power generation and energy storage as an example), including at least the following information: time series information (month, day, hour, Monday to Sunday), building-level information (indoor temperature, temperature set point, power demand of each appliance, solar power generation, grid power consumption, etc.), regional power consumption information (total regional load, electricity price), and regional weather information (direct sunlight intensity, diffuse sunlight intensity, outdoor temperature, carbon dioxide intensity, etc.).
[0025] Step S12: Multi-scale data prediction. Using the collected data, train an LSTM time series prediction model to predict electricity prices, load, outdoor temperature, direct sunlight intensity, and diffuse sunlight intensity for the next 1, 2, and 6 hours. Specifically, the prediction model construction and training process is as follows:
[0026] Step S121: Model parameter setting. Specify the parameters of the model, including: a) Input dimension, which is determined based on data characteristics For example, if the data contains outdoor temperature, outdoor humidity, and wind speed, the input dimension b) Hidden layer dimension: select the appropriate hidden layer dimension according to the complexity of the prediction task ,like or c) Time step, the default selection is Hours are used as the time step to predict the load for the next 1, 2, and 6 hours. d) Output dimension: Determine the corresponding output dimension based on the goal of predicting the next few hours. For example, to predict the load for the next hour, the output dimension is e) Hyperparameter selection, choose the appropriate learning rate (like ), batch size G and number of training rounds .
[0027] Step S122: Prediction model training. Using the collected data, a sliding window is used to generate time series samples, which are divided into a training set and a validation set. For example, if the input is Hourly data , the output is Hourly data Parameter optimization was performed using the Adam optimizer using the mean squared error (MSE) as the loss function. A validation set was used to monitor model performance and avoid overfitting. Training and validation losses were visualized to ensure model convergence. Finally, the trained model was saved as a file for easy loading, deployment, and subsequent incremental learning.
[0028] Step S13: Using all real-time state information and prediction information for the current step as state inputs, and the power consumption of each electrical device and the charging and discharging of the energy storage as action outputs, the agent is trained using the Soft Actor-Critic (SAC) algorithm. The simulation environment for training can be set up using CityLearn. The specific training process is as follows:
[0029] Step S131: Environment configuration. Load the collected data into CityLearn, and enable CityLearn to load the corresponding data according to the current time step as status information.
[0030] Step S132: Model parameter setting. Use the SAC algorithm from the StableBaseline3 reinforcement learning library for agent training. Specify the following algorithm parameters: 2 hidden layers, 256 hidden layer dimensions, 10,000 experience replay size, 2,000,000 training steps, and a discount rate of 0.99. Keep all other parameters at their default values.
[0031] Step S133: State space and action space definition. The state space includes: time series information (month, day, hour, Monday to Sunday), building-level information (indoor temperature, temperature setpoint, power demand of each appliance, solar power generation, grid power consumption, etc.), regional power consumption information (total regional load, electricity price), and regional weather information (direct sunlight intensity, diffuse sunlight intensity, outdoor temperature, CO2 concentration, etc.). The action space includes: energy storage charging and discharging actions, as well as the power consumption behavior of each appliance. To facilitate training, state values are transformed according to their characteristics: periodic values are transformed using cyclic transformation, discrete values are one-hot encoded, and continuous values are normalized using minimum and maximum values. Action values are scaled to the range [-1, 1], with -1 and 1 representing the rated charge and discharge power.
[0032] Step S134: reward function design. The reward function will take into account both the power consumption comfort and the grid fluctuation characteristics. Specifically, the reward function is expressed as the power consumption comfort reward and grid fluctuation rewards The weighted value of electricity comfort. is calculated as follows: .in, is the target value of the appliance, T is the actual value of the appliance, and c is the limit range. This means that when the appliance is within the set target limit range, the reward is 0, and if it exceeds the limit range, it will be penalized. is calculated as follows: Among them, B i-1 and B i are the carbon emissions at the previous moment and the carbon emissions at the current moment, Indicates the current power consumption. Indicates the total power consumption of the area in the past 24 steps. This represents the grid stability reward Taking into account the carbon emissions between the current step and the previous step The difference between the total power consumption of the area in the past 24 steps and the current net power consumption of the building The final reward value is calculated as: .
[0033] Step S135: During the training process, fine-tune the algorithm hyperparameters and reward weights to ensure that the algorithm converges to the ideal effect.
[0034] Step S2: Build a large-scale intelligent agent for energy management with tool functions. Leveraging the natural language understanding capabilities of the large-scale agent, it receives important information related to home microgrid energy management, invokes the corresponding designed instruction generation function, and generates decisions. Specifically, in step S2, the specific steps for building the large-scale intelligent agent include the following:
[0035] Step S21: Prompt Design: Design prompts to guide the large model to complete the task. Specifically, the prompt template consists of four modules: a) System prompts, which specify that the agent plays the role of a professional expert in home microgrid energy management, responsible for calling corresponding tool functions and generating decision instructions based on received information; b) User input, which receives external text messages; c) Message placeholders, which store contextual dialogue information; and d) Function call placeholders, which store the output generated by function calls.
[0036] Step S22: Create a tool function to design decision optimization rules for some common planning or notification scenarios (such as power outages, travel plans, etc.). Note that the instruction generation of the tool function must comply with the instruction format requirements of the subsequent step S301.
[0037] The following two examples illustrate the process of creating tool functions.
[0038] (1) For example, in the case of a power outage due to line maintenance, obtaining relevant information through a large model and generating a decision to store energy in advance can reduce the inappropriate electricity consumption caused by the power outage. Taking the power outage as an example, if a community has to go out of power for a period of time due to line maintenance, a function can be created based on the following logic. The function takes the start time and end time of the power outage as the function input and generates decision instructions according to the following rules: a) Charge the energy storage n time steps before the power outage begins (n and the specific charging action will be set according to the actual situation); b) Safely shut down the equipment in advance before the power outage; c) After the power outage, use the energy storage to supply power. The generated decision instructions will be loaded into the instruction buffer. Finally, the execution status of the function (successful execution or failure due to parameter non-compliance) will be returned as output in text form.
[0039] (2) For scenarios where a user plans to take a family trip in the next few days due to travel or something, or an industrial park suspends production due to something, the corresponding time period information can be obtained through the large model, and unnecessary electrical appliances can be turned off to reduce unnecessary electricity consumption. Taking family travel as an example, if the owner plans to take a family trip in a certain few days, a function can be created based on the following logic. The function takes the start time and end time of the trip as function input and generates decision instructions according to the following rules: a) Turn off unnecessary equipment after the owner leaves; b) Turn on some equipment, such as air purifiers, air conditioners, etc., n time steps before the owner returns (n and the specific work action will be set according to the actual situation). The generated decision instructions will be loaded into the instruction buffer. Finally, the execution status of the function (successful execution or failure due to parameter non-compliance) will be returned as output in text form.
[0040] Finally, the big model automatically extracts function call parameters based on the plan information in natural language form, calls the corresponding tool functions and generates instructions to ensure the reliability and explainability of the big model's decision generation.
[0041] Step S23: Use a large base model such as DeepSeek-V3, GPT-4o-Mini, combined with the above-mentioned prompt word template and tool function to build an intelligent agent.
[0042] Step S3: Please refer to Figure 1 , obtain real-time information of the home microgrid through the small model intelligent agent and generate real-time decisions; generate decisions based on the power dispatch text information corresponding to the home microgrid through the large model intelligent agent; align the environment time step and the instruction time step, and output a coherent real-time decision response based on the decisions generated by the small model intelligent agent and the large model intelligent agent.
[0043] Step S31: Small model decision. The small model agent will continuously obtain corresponding real-time information based on the state information defined in the training phase and continuously generate real-time decisions.
[0044] Step S32: Instruction Format. Because decision generation is inconsistent with the current time step of the environment, and different planned scenarios optimize different controlled devices, a command buffer is required for processing in conjunction with a unified JSON message format. This format contains the following key-value information: time step, event type, priority, and device control list, which contains the specific controlled devices and their decision actions.
[0045] Step S33: Large-model decision generation and caching. Textual information related to power dispatch is formatted using a prompt word template and then fed into the large-model agent. The agent then calls the corresponding tool function, generates instructions, and stores them in the instruction buffer. All instructions in the instruction buffer are prioritized by time step, with event priority as the second priority (determined by the event).
[0046] Step S34: Instruction call. When the time step of the environment is consistent with the time step of the first instruction in the instruction buffer, the instruction buffer will pop out the first instruction, read the device control action in the control device list, and overwrite the original small model decision.
[0047] This invention combines key information related to power dispatch decisions, utilizes the natural language understanding and reasoning capabilities of the large model, calls the corresponding decision optimization function, and optimizes the suboptimal or erroneous decision-making of the small deep reinforcement learning model due to the rigid information acquisition method. The present invention achieves the explainability and reliability of the large model's decision generation by designing tool functions, and achieves seamless integration of large and small model collaborative decision-making through early asynchronous decision generation and instruction buffering and calling, without adding additional response time. The present invention provides a new technical path for user-centric microgrid energy management.
[0048] The embodiment of the present invention further provides a microgrid energy management optimization system for event planning perception, including:
[0049] Multi-scale data prediction module: collects historical and current state data of the home microgrid, uses the collected data to generate time series data using a sliding window approach, and uses a long short-term memory network to predict its values in the next 1, 2, and 6 hours based on the current and historical state data.
[0050] Small model building module: This module defines the state space and action space of the microgrid energy management problem, designs a suitable reward function, and finally builds and trains a small model agent based on the SAC algorithm using the StableBaseline3 library.
[0051] Large model building module: Builds a large model agent with tool functions based on the mainstream base large model and LangChain framework;
[0052] Decision-making collaboration module: The small model agent obtains real-time information about the home microgrid and generates real-time decisions. The large model agent generates decisions based on the power dispatch text information corresponding to the home microgrid and caches the decisions in the instruction buffer. When the instruction time step is consistent with the current time step of the environment, the decision is integrated with the small model agent's decision to form the final decision.
[0053] The present invention utilizes the natural language understanding and logical reasoning capabilities of a large language model to optimize power dispatch using planning information from the power system and users, improve users' power usage comfort, and reduce unnecessary power consumption.
[0054] While embodiments of the present invention have been shown and described, it will be appreciated by those skilled in the art that various changes, modifications, substitutions, and variations may be made to these embodiments without departing from the principles and spirit of the invention, and that the scope of the invention is defined by the appended claims and their equivalents.
Claims
1. A microgrid energy management optimization method based on event planning perception, characterized in that: include: Step S1: Build and train a small model agent; Step S2: Build a large model agent with tool functions; Step S3: obtaining real-time information of the microgrid through the small model agent and generating real-time decisions; generating decisions based on the power dispatch text information corresponding to the microgrid through the large model agent; Aligning the environment time step with the instruction time step, and outputting a coherent real-time decision response based on the decisions generated by the small model agent and the large model agent; Step S1 includes: Step S11: Acquire historical status data of the microgrid; Step S12: Build an LSTM time series prediction model for prediction, set the prediction model parameters, use the acquired historical status data to train the LSTM time series prediction model, and predict the electricity price, load, outdoor temperature, direct light intensity, and diffuse light intensity for the next 1, 2, and 6 hours; Step S13: Construct a small model agent, take all the real-time state information and prediction information of the current step as state input, and the power consumption actions of each electrical device in the microgrid and the charging and discharging actions of the energy storage as action output, and use the preset deep reinforcement learning algorithm to train the small model agent; Step S13 includes: Step S131: configuring a simulation environment for training; Step S132: Setting parameters of the small model agent; Step S133: Define the state space and action space of the microgrid energy management problem. The state space includes time series information, status information of each electricity user, regional electricity consumption information, and regional weather information. The action space includes the charging and discharging actions of the energy storage and the electricity consumption behavior of each electrical device. Step S134: Design a reward function, which is: ; For the comfort of electricity use, ; Reward for grid fluctuations, ; in, is the target value of the electrical appliance, T is the actual value of the electrical appliance, and c is the limited range; B i-1 and B i are the carbon emissions at the previous moment and the carbon emissions at the current moment, Indicates the current power consumption. Indicates the total power consumption of the area in the past 24 steps; and are the weight coefficients of electricity comfort and grid fluctuation reward respectively; Step S135: Build a small model agent of the deep reinforcement learning algorithm based on the StableBaseline3 library for training, and select the multilayer perceptron as the policy network; Step S136: Fine-tune the hyperparameters and reward weights to complete the construction of the small model agent.
2. The microgrid energy management optimization method based on event planning perception according to claim 1, characterized in that: Step S12 includes: Step S121: Setting prediction model parameters, wherein the prediction model parameters include: a) Input dimension, determined according to data characteristics ; b) Hidden layer dimension: choose the appropriate hidden layer dimension according to the complexity of the prediction task ; c) time step; d) Output dimension: Determine the corresponding output dimension based on the predicted target ; e) Hyperparameter selection, choose the corresponding learning rate , batch size G and number of training rounds ; Step S122: Using the acquired historical status data, a sliding window is used to generate time series samples, which are divided into a training set and a validation set. The training set is used to train the LSTM time series prediction model, and the validation set is used to monitor the performance of the prediction model.
3. The microgrid energy management optimization method based on event planning perception according to claim 1, characterized in that: Step S2 includes: Step S21: setting prompt words for guiding the large model agent to make decisions; Step S22: creating a tool function; Step S23: Use the base large model in combination with the prompt words and tool functions to construct a large model intelligent body.
4. The microgrid energy management optimization method based on event planning perception according to claim 1, characterized in that: Step S3 includes: Step S31: Small model decision-making, the small model agent continuously obtains corresponding real-time information and continuously generates real-time decisions; Step S32: Instruction format, using an instruction buffer and a unified JSON message format for processing; Step S33: Use the power dispatch text information corresponding to the microgrid, format it with a prompt word template, and then input it into the large model agent. The large model agent calls the corresponding tool function to generate instructions and stores them in the instruction buffer; wherein all instructions in the instruction buffer are sorted by time step as the first priority and event priority as the second priority; Step S34: When the time step of the environment is executed to the same time step as the first instruction in the instruction buffer, the instruction buffer pops out the first instruction, reads the device control action in the control device list, and overwrites the decision of the original small model agent.
5. A microgrid energy management optimization system based on event planning perception, characterized in that: The microgrid energy management optimization method for event planning perception according to any one of claims 1 to 4 is adopted, wherein the system includes: Multi-scale data prediction module: collects historical and current state data of the microgrid, uses the collected data to generate time series data using a sliding window approach, and uses a long short-term memory network to predict the values for the next 1, 2, and 6 hours based on the current and historical state data. Small model building module: This module defines the state space and action space of the microgrid energy management problem, designs a suitable reward function, and finally builds and trains a small model agent based on the SAC algorithm using the StableBaseline3 library. Large model building module: Builds a large model agent with tool functions based on the mainstream base large model and LangChain framework; Decision-making collaboration module: The small model agent obtains real-time information of the microgrid and generates real-time decisions; the large model agent generates decisions based on the power dispatch text information corresponding to the microgrid and caches the decisions in the instruction buffer; when the instruction time step is consistent with the current time step of the environment, the decision is integrated with the small model agent to form the final decision.
Citation Information
Patent Citations
Micro-electric-network energy optimization management method based on multi-scale planning and dispatching coupling
CN102609793A
Microgrid energy scheduling method based on double-Q-value network deep reinforcement learning
CN112117760A