An agent-based load prediction method, device, equipment and storage medium
By automatically building and training load forecasting models using intelligent agent technology and utilizing improved transformer networks for forecasting, the inefficiency of existing methods is solved, achieving full automation and high efficiency in load forecasting.
Patent Information
- Application Number
- CN202511057925.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-30
- Publication Date
- 2026-11-10
- Estimated Expiration
- 2045-07-30
AI Technical Summary
Existing load forecasting methods mainly rely on manually constructing and training network models, which is inefficient and involves a lot of human intervention.
Employing agent technology, the system responds to load forecasting commands, reads data from the database, automatically builds or calls load forecasting models, and uses an improved transformer network for training and prediction. It supports single-task and multi-task forecasting, reducing human intervention.
It has achieved full automation of load forecasting, reduced labor costs, and improved forecasting efficiency and accuracy. It can autonomously execute the entire process from data reading and model training to system deployment.
Smart Images

Figure CN120896129B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of load forecasting technology, and in particular to a load forecasting method, apparatus, device and storage medium based on intelligent agents. Background Technology
[0002] Load forecasting has increasingly incorporated machine learning and artificial intelligence technologies. Machine learning methods, such as Support Vector Machines (SVM) and Random Forests (RF), have provided new approaches to modeling complex load variation patterns. Subsequently, deep learning models (such as Long Short-Term Memory Networks (LSTM) and Convolutional Neural Networks (CNN)) have rapidly become the mainstream technology in load forecasting due to their superior performance in handling large-scale nonlinear data and mining complex features. However, existing load forecasting methods mainly rely on manually constructing and training network models to obtain load forecasting models, resulting in significant human intervention and low efficiency. Summary of the Invention
[0003] This application provides a method, apparatus, device, and storage medium for intelligent agent-based load forecasting, which can improve load forecasting efficiency and reduce human intervention.
[0004] In view of this, the first aspect of this application provides an agent-based load prediction method, comprising:
[0005] The intelligent agent responds to the user's load forecasting command by reading target data from the database, which includes load data, weather data, and date data.
[0006] The agent determines whether a corresponding existing load prediction model exists in the model library based on the load prediction instruction.
[0007] If it exists, then the existing load forecasting model is invoked to perform load forecasting based on the target data, and the load forecasting result is output.
[0008] If it does not exist, a load forecasting network is constructed according to the load forecasting instruction, the training tool is called to train the load forecasting network to obtain a load forecasting model, the load forecasting model is called to perform load forecasting based on the target data, and the load forecasting result is output.
[0009] Optionally, constructing the load forecasting network according to the load forecasting instruction includes:
[0010] The load forecasting instruction is parsed to obtain the load forecasting task;
[0011] When the load forecasting task is a single-task forecasting task, an improved transformer network and a single-task forecasting head are constructed to obtain a single-task load forecasting network.
[0012] When the load forecasting task is a multi-task forecasting task, an improved transformer network and a multi-task forecasting head are constructed to obtain a multi-task load forecasting network.
[0013] The improved transformer network is obtained by replacing the feedforward network in the transformer network with the target network layer; the target network layer includes a gating network, multiple expert networks and a feature fusion network.
[0014] Optionally, the step of using a training tool to train the load forecasting network to obtain a load forecasting model includes:
[0015] Historical data is obtained from the power system database, and training and test sets are generated based on the historical data, which includes historical load data, historical weather data, and historical date data.
[0016] The training tool is invoked to train the load prediction network using the historical data. The loss value is calculated based on the load prediction value and the actual load value during training. The network parameters of the load prediction network are updated using the loss value to obtain the trained load prediction model.
[0017] The load forecasting model is tested using the test set, and the network parameters of the load forecasting model are adjusted based on the test results.
[0018] When the load forecasting network is a single-task load forecasting network, the formula for calculating the loss value is:
[0019]
[0020] In the formula, N is the sample size, and y i For the i-th sample, the actual load value is... The load forecast value for the i-th sample;
[0021] When the load forecasting network is a multi-task load forecasting network, the formula for calculating the loss value is:
[0022]
[0023] In the formula, T represents the number of tasks. L represents the loss weight for task j. j Let M be the loss value for task j; M be the number of expert networks, n s n represents the number of features processed by the s-th expert network. j Let j be the number of features processed by the j-th expert network. The regularization loss of the expert network is denoted by g(x), which is the output value of the gating network and represents the selection weight of each expert network for the input x.
[0024] Optionally, the method further includes:
[0025] The agent calls the deployment module to export the load prediction model in ONNX, TorchScript, or TensorFlow SavedModel format and deploy it as a RESTful interface to access the power system.
[0026] Optionally, the method further includes:
[0027] The agent determines whether data preprocessing is required for the target data. If so, it calls a data preprocessing tool to preprocess the target data; otherwise, it executes subsequent steps.
[0028] A second aspect of this application provides an agent-based load prediction device, comprising:
[0029] The data reading unit is used to read target data from the database in response to the user's load forecasting command. The target data includes load data, weather data, and date data.
[0030] The model training and load forecasting unit is used to determine whether there is a corresponding existing load forecasting model in the model library according to the load forecasting instruction; if there is, the existing load forecasting model is called to perform load forecasting based on the target data and output the load forecasting result; if there is no, a load forecasting network is constructed according to the load forecasting instruction, the training tool is called to train the load forecasting network to obtain a load forecasting model, the load forecasting model is called to perform load forecasting based on the target data and output the load forecasting result.
[0031] Optional, also includes:
[0032] The deployment unit is used to export the load forecasting model into ONNX format, TorchScript format, or TensorFlow SavedModel format, and deploy it as a RESTful interface to access the power system.
[0033] Optional, also includes:
[0034] The data preprocessing unit is used to determine whether the target data needs to be preprocessed. If so, it calls the data preprocessing tool to preprocess the target data. If not, it triggers the model training and load prediction unit.
[0035] A third aspect of this application provides an electronic device, the device including a processor and a memory;
[0036] The memory is used to store program code and transmit the program code to the processor;
[0037] The processor is configured to execute any of the agent-based load prediction methods described in the first aspect according to the instructions in the program code.
[0038] A fourth aspect of this application provides a computer-readable storage medium for storing program code that, when executed by a processor, implements the agent-based load prediction method according to any one of the first aspects.
[0039] As can be seen from the above technical solutions, this application has the following advantages:
[0040] This application presents an agent-based load forecasting method that constructs an agent capable of autonomously executing the entire process from data reading, model training, load forecasting, visualization, to system deployment by calling an open-source large model with code generation and task planning capabilities. The agent completes the entire process of perception, decision-making, execution, and learning in load forecasting, reducing human intervention, greatly reducing labor costs, and improving load forecasting efficiency. Attached Figure Description
[0041] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0042] Figure 1 A flowchart illustrating an agent-based load prediction method provided in this application embodiment;
[0043] Figure 2 A structural diagram of a transformer network provided in an embodiment of this application;
[0044] Figure 3 A structural diagram of a target network layer provided in an embodiment of this application;
[0045] Figure 4 A structural diagram of a load forecasting network provided in an embodiment of this application;
[0046] Figure 5 This is a schematic diagram of a load prediction device based on an intelligent agent, provided in an embodiment of this application. Detailed Implementation
[0047] To enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present application, and not all embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the scope of protection of the present application.
[0048] For easier understanding, please refer to Figure 1 This application provides an agent-based load prediction method, including:
[0049] Step 110: The agent responds to the user's load forecasting command by reading target data from the database. The target data includes load data, weather data, and date data.
[0050] This application selects a basic large model as the core reasoning model for the intelligent agent. This large model possesses local natural language understanding, code generation, logical reasoning, and instruction execution planning capabilities. This application employs a language agent (LangChain) or automatic agent (AutoGen) framework, using the large model as the controlling intelligent agent, and defines a series of functional tools as external modules that it can call, forming a working mechanism of large model scheduling + tool execution. This application preferably uses LangChain to define task execution tools, specifically including:
[0051] Data preprocessing tools: used to perform data cleaning, normalization, and time feature encoding on load data, weather data, and date data read from the database;
[0052] Model training tools: Support multiple modeling methods and can automatically select and train according to user needs;
[0053] Forecasting and visualization tools: Perform model inference, output future load forecast sequences, and generate a comparison chart of forecast and actual load;
[0054] Deployment tools: These tools can deploy trained models as server-side interfaces for online use.
[0055] Document generation tool: Automatically generates prediction reports or model evaluation documents.
[0056] By designing high-quality system prompts as initialization instructions for the large model, the scope of its tasks and available tools are clearly defined. Users can send instructions via natural language, and the agent automatically parses and plans the task step by step. After receiving the load forecasting instruction, the agent first analyzes the instruction to obtain the load forecasting task, automatically reads and identifies the data types in the database, retrieves the required target data (including load data, weather data, and date data), and then calls data processing tools to complete data cleaning, missing value handling, time feature encoding, and other operations, caching the intermediate results in the memory module.
[0057] Step 120: The agent determines whether there is a corresponding existing load forecasting model in the model library according to the load forecasting instruction; if there is, it calls the existing load forecasting model to perform load forecasting based on the target data and outputs the load forecasting result; if there is no, it constructs a load forecasting network according to the load forecasting instruction, calls the training tool to train the load forecasting network to obtain a load forecasting model, calls the load forecasting model to perform load forecasting based on the target data, and outputs the load forecasting result.
[0058] The agent analyzes the task objective (such as predicting the load for the next 24 hours) by parsing load forecasting instructions, and determines whether a corresponding load forecasting model exists in the model library. If an existing load forecasting model exists, it is invoked to perform load forecasting based on the target data. If no corresponding load forecasting model exists in the model library, the agent uses a model training tool to select an appropriate model structure based on the data dimensions and time characteristics, and trains the model. Simultaneously, the agent automatically records the model parameters and training results, and saves the trained load forecasting model to the model library.
[0059] The agent parses the load forecasting instructions to obtain the load forecasting task. When the load forecasting task is a single-task forecasting task, an improved transformer network and a single-task forecasting head are constructed to obtain a single-task load forecasting network. When the load forecasting task is a multi-task forecasting task, an improved transformer network and a multi-task forecasting head are constructed to obtain a multi-task load forecasting network. The improved transformer network is obtained by replacing the feedforward network in the transformer network with the target network layer. The target network layer includes a gating network, multiple expert networks, and a feature fusion network.
[0060] The structure of a transformer network is as follows: Figure 2 As shown, the improved transformer network includes the following structure:
[0061] 1) The input embedding layer is used to perform location embedding encoding on load data, weather data, and time features. It converts all input data into a high-dimensional vector representation, obtaining a feature vector with location information. The location embedding encoding formula is:
[0062]
[0063]
[0064] In the formula, pos represents the position, i is the dimension index, and d model For the transformer network dimension.
[0065] 2) Self-Attention Layer: The self-attention mechanism in the Transformer network allows the model to focus on information from other time steps at each time step, capturing long-term dependencies. For each time step's input, the query, key, and value are computed, and then weighted and summed using attention scores to obtain a new feature representation.
[0066]
[0067]
[0068] In the formula, Q, K, and V are the query matrix, key matrix, and value matrix, respectively; W Q W K W V These are the query weight parameter, key weight parameter, and value weight parameter, respectively, and X is the position vector.
[0069] 3) Multi-head attention mechanism: To enable the model to capture features from different subspaces, a multi-head self-attention mechanism is used. The model computes attention in parallel across multiple subspaces and concatenates the results, thereby enhancing the model's feature representation capabilities.
[0070]
[0071]
[0072] In the formula, W O Here are the weight parameters, and here are the parameters to be trained.
[0073] 4) Feedforward Neural Network Layer: After each time step, a feedforward neural network is used to further extract features and increase the model's non-linearity. In certain layers of the Transformer (such as layers 2, 4, and 6), the original FFN (Feed-Forward Network) is replaced with the target network layer.
[0074]
[0075] In the formula, S(x) represents the top-k expert networks selected by the router, and g i (x) represents the weights of the i-th expert network, F i (x) represents the i-th expert network.
[0076] Please refer to Figure 3 In the target network layer, each input feature is assigned to several expert networks through a gating network; this process is called routing. A router is a lightweight gating network responsible for selecting the top k expert networks based on the input feature x.
[0077]
[0078] In the formula, W r These are the parameters to be trained.
[0079] 5) Layer normalization and residual connections: In order to improve the stability of the model and training efficiency, layer normalization and residual connections are added after each self-attention layer and feedforward layer.
[0080] 6) Encoder: Construct a multi-layer encoder, each layer containing a multi-head self-attention layer and a feedforward neural network layer, thereby extracting deeper feature information layer by layer.
[0081] 7) Decoder: In time series forecasting, an encoder-decoder architecture can be used for multi-step forecasting. The encoder extracts sequence features, and the decoder converts the encoded information into future load forecasts.
[0082] The agent supports both single-task and multi-task load forecasting. When a user needs to perform single-task load forecasting (such as forecasting the load of a specific area), the agent connects a single-task forecasting head after the improved transformer network. When a user needs to perform multi-task load forecasting (such as forecasting the load of multiple transformer areas or load at multiple time granularities), the agent connects a multi-task forecasting head after the improved transformer network. Please refer to [reference needed]. Figure 4This invention can generate multiple decoders for multiple prediction regions or time granularities based on a shared encoder, enabling coordinated regional load prediction and improving modeling efficiency. The multi-task learning structure in this invention includes a shared Transformer encoder and multiple task-specific decoders or prediction heads. Each prediction head corresponds to a specific load prediction task, such as load prediction for different transformer substations, or prediction at different time scales (e.g., hourly, daily, weekly). This structure can extract common features in the shared layer while preserving the differences between tasks, improving the model's adaptability to complex multi-source data. Each expert network is an independent neural network that specializes in learning a specific aspect of the input features. For example, one expert network might specialize in learning how to predict the load of a specific transformer substation, while another might learn how to respond to load changes under specific weather conditions. The specific task and processing mode of the expert network are automatically selected by the gating network.
[0083] The agent uses a training tool to train the load forecasting network, resulting in a load forecasting model, which includes:
[0084] Historical data is obtained from the power system database, and training and test sets are generated based on the historical data. The historical data includes historical load data, historical weather data, and historical date data.
[0085] The training tool is called to train the load forecasting network using historical data. The loss value is calculated based on the load forecasting value and the actual load value during training. The network parameters of the load forecasting network are updated using the loss value to obtain the trained load forecasting model.
[0086] The load forecasting model is tested using a test set, and the network parameters of the load forecasting model are adjusted based on the test results.
[0087] When the load forecasting network is a single-task load forecasting network, the formula for calculating the loss value of a single task is:
[0088]
[0089] In the formula, N is the sample size, and y i For the i-th sample, the actual load value is... The load forecast value for the i-th sample;
[0090] When the load forecasting network is a multi-task load forecasting network, the formula for calculating the loss value is:
[0091]
[0092] In the formula, T represents the number of tasks. L represents the loss weight for task j. jLet M be the loss value for task j; M be the number of expert networks, n s n represents the number of features processed by the s-th expert network. j Let j be the number of features processed by the j-th expert network. The expert network regularization loss is denoted by g(x), which is the output value of the gating network, representing the selection weight of each expert network for the input x. This loss function includes task loss, load balancing and sparsity loss, and routing regularization. By calculating the load balancing and sparsity loss and adding an expert load balancing regularization term, some expert networks are prevented from remaining idle for extended periods. The routing regularization term constrains the output of the gating network, ensuring that the allocation of expert networks is both sparse and balanced, thereby improving training efficiency and model robustness.
[0093] The training data is input into the model, and the predicted values are calculated through forward propagation. The loss between the predicted and actual values is then calculated. The model parameters are updated using the backpropagation algorithm. These steps are repeated until the training process converges or the set number of training epochs is reached. During training, the loss functions for multiple prediction tasks are optimized simultaneously, such as load prediction errors for multiple regions or time scales. The entire model is jointly trained using a weighted summation method, achieving information sharing and synergistic improvement across different tasks.
[0094] During training, a validation set is used to evaluate model performance, and hyperparameters (such as the number of layers and attention heads) are adjusted to avoid overfitting. After training, the model is applied to a test set, and evaluation metrics (such as MSE, MAE, and RMSE) are calculated to measure the model's final performance. During evaluation, metrics are calculated for each sub-task (such as different regions or time scales), and the model structure and weight allocation are adjusted based on overall performance to ensure synergistic optimization between the main and auxiliary tasks. The performance of each sub-task can be monitored using the following metrics during model training and evaluation:
[0095] Load forecasting error in each region: For example, assessing the load forecasting error (such as MSE, MAE) for each transformer area helps the model understand which regions are more difficult to forecast loads.
[0096] Forecasting errors at different time scales: For example, error assessment for hourly, daily, and weekly load forecasts. Standard regression error metrics such as MSE or RMSE can be used.
[0097] Inter-task correlation: For example, the inter-task linkage can be evaluated by calculating the correlation between sub-tasks (e.g., based on mutual information or correlation coefficients between data), thereby determining whether to optimize inter-task collaboration by sharing a network layer.
[0098] These metrics are monitored periodically during training, and task weights and network structure are optimized through comprehensive scoring feedback. Higher weights can be assigned to subtasks that perform well (such as regions or time scales with lower load prediction errors).
[0099] During training, the agent can fine-tune the hyperparameters of the improved Transformer network, including adjusting the number of attention heads, number of layers, hidden layer dimensions, learning rate, and batch size to achieve optimal performance. Methods such as grid search, random search, or Bayesian optimization can be used to find the optimal combination of hyperparameters. The agent dynamically adjusts the model's hyperparameters based on performance metrics such as loss, accuracy, prediction error (MSE, RMSE, MAE, etc.), and the training progress of the task. For example:
[0100] When training is slow, the batch size of training data can be increased to speed up gradient calculation.
[0101] When the convergence process is too slow or oscillating, the batch size of the training data can be reduced and the update frequency of the model increased, thereby enhancing the robustness of the model.
[0102] When the verification error is high, the agent can choose to reduce the number of layers or the number of hidden units in each layer to reduce the complexity of the model.
[0103] If the training error decreases slowly, the agent can choose to increase the network depth or the number of hidden units, enabling the model to learn more features.
[0104] After the model training is completed, the agent automatically calls the load forecasting model to make multi-step predictions for future time periods and uses visualization tools to generate comparison charts (predicted values vs. actual values). In power load forecasting, multi-step prediction is usually required (e.g., predicting the load for the next 24 hours based on historical input data from multiple past time steps). Existing technologies use autoregressive methods, taking the predicted value as input after each prediction step to continue predicting the next time step. However, by adopting the Transformer Encoder-Decoder structure in this application, the predicted values for multiple future time steps can be directly output, avoiding the error accumulation problem caused by rolling prediction.
[0105] In practical use, users can have multiple rounds of dialogue with the agent, requesting it to modify the data window length, select other models, or optimize the accuracy of a certain subtask. The agent can parse the instructions and automatically reconstruct the training process.
[0106] The agent provides sustainable learning capabilities, triggering a retraining process when model performance deteriorates or external data changes (such as abnormal weather), and can periodically evaluate the actual performance of the deployed model.
[0107] The agent can call the deployment module to export the load forecasting model in ONNX, TorchScript, or TensorFlow SavedModel format and deploy it as a RESTful interface to connect to the power system. Alternatively, the trained load forecasting agent can be deployed on a server by encapsulating it as a RESTful interface (using Flask, FastAPI, etc.), and combined with the model export format (such as ONNX or TorchScript), it can connect to the dispatching system or monitoring platform to achieve real-time data input, forecast result output, and visualization, supporting dynamic dispatching and load optimization of the power grid system.
[0108] This application presents an agent-based load forecasting method that constructs an agent capable of autonomously executing the entire process from data reading, model training, load forecasting, visualization, to system deployment by calling an open-source large model with code generation and task planning capabilities. The agent completes the entire process of perception, decision-making, execution, and learning in load forecasting, reducing human intervention, greatly reducing labor costs, and improving load forecasting efficiency.
[0109] This application utilizes Python to develop the interface of a load forecasting platform and constructs an intelligent agent capable of handling load forecasting tasks using langchain and large models. Using intelligent agents for load forecasting offers several advantages over traditional methods, primarily in automation, data processing efficiency, model adaptability, and intelligent decision-making. The autonomous decision-making module can automatically complete data preprocessing (e.g., missing value imputation, outlier detection), feature generation (e.g., extracting trend and periodic terms through time series decomposition), and model training and optimization (e.g., automatically searching for optimal hyperparameters). The environmental perception module acquires external data in real time (e.g., weather forecasts, power grid operating status), and dynamically adjusts model parameters or switches forecasting strategies using reinforcement learning or meta-learning.
[0110] Load forecasting based on intelligent agents has stronger data processing and modeling capabilities. It actively acquires multi-source data (such as real-time data from IoT devices, geographic information data, and user behavior data) through data acquisition modules. Real-time data from IoT devices typically refers to real-time data from the power system or smart devices (such as smart meters, sensors, home appliances, and smart sockets). This data includes the operating status of the power grid, load fluctuations, and the energy consumption of the devices. Its functions include:
[0111] Real-time load monitoring: IoT devices provide real-time power usage information, enabling models to reflect current load fluctuations in a short period of time and make instant predictions based on the latest data.
[0112] Accurate short-term forecasting: By combining real-time load data, the model can more accurately predict load changes in the next few minutes or hours, avoiding reliance on long-term trends from historical data and improving the accuracy of short-term load forecasting.
[0113] Anomaly detection: By using equipment data, abnormal situations in the operation of the power grid or equipment (such as faults, equipment overloads, abnormal user behavior, etc.) can be detected in a timely manner. The model can adjust the prediction strategy based on these anomalies to improve the robustness of the system.
[0114] For example, data provided by smart meters can help predict load changes at the device and user levels; sensor data (such as temperature and humidity) can help models identify and adjust load change trends, especially during rapid load changes in hot or cold weather.
[0115] Geographic information data refers to information about power grids, equipment, buildings, and other geographical features. This data includes information on power distribution networks, user distribution, and the characteristics of geographical regions. Its uses include:
[0116] Spatial correlation analysis: By analyzing load data from different geographical regions (such as different cities, neighborhoods, or even floors), the model can capture spatial load differences. For example, load patterns may differ between city centers and suburbs. By combining geographic information data, the model can adaptively adjust its forecasts, improving the spatial accuracy of the predictions.
[0117] Regional characteristic analysis: Some regions may have specific load behaviors (such as commercial areas, residential areas, industrial areas, etc.). Geographic information data helps the model understand the differences between these regions, and combined with load data, a customized prediction model is made for each region.
[0118] Weather-Geographic Correlation Analysis: Combining geographic information data with weather information can help models identify the sensitivity of different regions to weather changes. For example, higher-altitude areas may experience greater load fluctuations during cold weather, while lower-altitude areas are less affected.
[0119] By combining geographic information data, the model can distinguish the load demand of different regions under different times and weather conditions, thereby improving the spatial accuracy of forecasts in multi-region load forecasting.
[0120] User behavior data refers to information such as users' electricity consumption patterns, equipment usage habits, and daily routines. This type of data mainly includes users' daily behavior, electricity usage habits, household structure, equipment usage, and load changes between weekdays and weekends. Its uses include:
[0121] Load demand pattern identification: By understanding users' electricity consumption habits (such as seasonal fluctuations and holiday consumption patterns), the model can better understand and predict users' electricity demand during specific time periods. For example, some users may consume a lot of electricity during morning and evening peak hours, while other users may experience larger fluctuations on weekdays or weekends.
[0122] Behavior-driven forecasting adjustments: Changes in user behavior (such as the addition of new appliances or changes in work or lifestyle patterns) can affect their electricity consumption. By combining user behavior data, models can update forecasts in real time to reflect the impact of these changes on the load, avoiding forecast bias based on past data.
[0123] High-precision personalized forecasting: By mining individual users' electricity consumption data, the model can make personalized forecasts, customizing load forecasts for different user groups. Especially in smart grids, personalized forecasting can help reduce electricity waste and load peaks.
[0124] For example, user appliance usage data collected through smart home systems can provide energy consumption information for various appliances in the home, helping to predict load fluctuations at different times or during special events (such as holidays).
[0125] The acquired multi-source data can be used to uncover nonlinear relationships between data using deep learning architectures (such as Transformer and Graph Neural Networks). Automated processes significantly reduce human intervention, allowing non-experts to monitor the prediction process through visual interfaces (such as drag-and-drop data input configuration and viewing model interpretation results). Probabilistic prediction results can be output using Bayesian deep learning or Generative Adversarial Networks (GANs), combined with a risk assessment module to generate confidence intervals for load fluctuations. Bayesian deep learning introduces the idea of Bayesian inference into deep learning models, enabling them to output not only predicted values but also uncertainties. This means the model provides not only a point estimate (e.g., a load forecast) but also the confidence level or uncertainty of the prediction. Generative Adversarial Networks (GANs) are deep learning frameworks typically consisting of a generator and a discriminator. The generator aims to produce outputs that closely approximate real data, while the discriminator aims to distinguish the generated data from real data. Through adversarial training, GANs can generate samples that closely resemble real data. In load forecasting, GANs can be used to generate probability distributions of load data, thereby enriching the information in the model's predictions. The intelligent agent can automatically select the appropriate load forecasting model based on task requirements, adjust the model architecture according to the characteristics of the input data, automatically output the most suitable forecast for the current situation, and automatically analyze the forecast results. Moreover, it does not require experienced engineers to operate.
[0126] Please refer to Figure 5This application also provides an agent-based load prediction device, comprising:
[0127] The data reading unit 210 is used to read target data from the database in response to the user's load forecasting command. The target data includes load data, weather data, and date data.
[0128] The model training and load forecasting unit 220 is used to determine whether there is a corresponding existing load forecasting model in the model library according to the load forecasting instruction; if there is, the existing load forecasting model is called to perform load forecasting based on the target data and output the load forecasting result; if there is no, a load forecasting network is constructed according to the load forecasting instruction, the training tool is called to train the load forecasting network to obtain a load forecasting model, the load forecasting model is called to perform load forecasting based on the target data and output the load forecasting result.
[0129] As a further improvement, the device also includes:
[0130] The deployment unit is used to export the load forecasting model to ONNX, TorchScript, or TensorFlowSavedModel format and deploy it as a RESTful interface to access the power system.
[0131] As a further improvement, the device also includes:
[0132] The data preprocessing unit is used to determine whether data preprocessing of the target data is required. If so, it calls the data preprocessing tool to preprocess the target data. If not, it triggers the model training and load prediction unit.
[0133] This application also provides an electronic device, which includes a processor and a memory;
[0134] The memory is used to store program code and transfer the program code to the processor;
[0135] The processor is used to execute the agent-based load prediction method in the aforementioned method embodiments according to the instructions in the program code.
[0136] This application also provides a computer-readable storage medium for storing program code, which, when executed by a processor, implements the agent-based load prediction method in the aforementioned method embodiments.
[0137] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working process of the above-described apparatus and unit can be referred to the corresponding process in the foregoing method embodiments, and will not be repeated here.
[0138] The terms “first,” “second,” “third,” “fourth,” etc. (if present) in the specification and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. Furthermore, the terms “comprising” and “having,” and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or apparatus that includes a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such process, method, product, or apparatus.
[0139] It should be understood that in this application, "at least one (item)" means one or more, and "more than" means two or more. "And / or" is used to describe the relationship between related objects, indicating that three relationships can exist. For example, "A and / or B" can represent three cases: only A exists, only B exists, and both A and B exist simultaneously, where A and B can be singular or plural. The character " / " generally indicates that the preceding and following related objects are in an "or" relationship. "At least one (item) of the following" or similar expressions refer to any combination of these items, including any combination of single or plural items. For example, at least one (item) of a, b, or c can represent: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, and c can be single or multiple.
[0140] In the several embodiments provided in this application, it should be understood that the disclosed apparatus and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between apparatuses or units may be electrical, mechanical, or other forms.
[0141] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0142] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0143] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions for executing all or part of the steps of the methods described in the various embodiments of this application through a computer device (which may be a personal computer, server, or network device, etc.). The aforementioned storage medium includes: USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, optical disks, and other media capable of storing program code.
[0144] The above-described embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this application.
Claims
1. A load forecasting method based on intelligent agents, characterized in that, include: The intelligent agent responds to the user's load forecasting command by reading target data from the database, which includes load data, weather data, and date data. The agent determines whether a corresponding existing load prediction model exists in the model library based on the load prediction instruction. If it exists, then the existing load forecasting model is invoked to perform load forecasting based on the target data, and the load forecasting result is output. If it does not exist, a load forecasting network is constructed according to the load forecasting instruction, the training tool is called to train the load forecasting network to obtain a load forecasting model, the load forecasting model is called to perform load forecasting based on the target data, and the load forecasting result is output. The step of constructing a load forecasting network according to the load forecasting instructions includes: The load forecasting instruction is parsed to obtain the load forecasting task; When the load forecasting task is a single-task forecasting task, an improved transformer network and a single-task forecasting head are constructed to obtain a single-task load forecasting network. When the load forecasting task is a multi-task forecasting task, an improved transformer network and a multi-task forecasting head are constructed to obtain a multi-task load forecasting network. The improved transformer network is obtained by replacing the feedforward network in the transformer network with the target network layer; the target network layer includes a gating network, multiple expert networks and a feature fusion network. The step of using a training tool to train the load forecasting network to obtain a load forecasting model includes: Historical data is obtained from the power system database, and training and test sets are generated based on the historical data, which includes historical load data, historical weather data, and historical date data. The training tool is invoked to train the load prediction network using the historical data. The loss value is calculated based on the load prediction value and the actual load value during training. The network parameters of the load prediction network are updated using the loss value to obtain the trained load prediction model. The load forecasting model is tested using the test set, and the network parameters of the load forecasting model are adjusted based on the test results.
2. The agent-based load forecasting method according to claim 1, characterized in that, in, When the load forecasting network is a single-task load forecasting network, the formula for calculating the loss value is: In the formula, N For the sample size, y i For the first i The actual load value of each sample. For the first i Load forecast values for each sample; When the load forecasting network is a multi-task load forecasting network, the formula for calculating the loss value is: In the formula, T For the number of tasks, For the task j loss weights, L j For the task j The loss value; M For the number of expert networks, n s For the first s The number of features processed by an expert network; n j For the first j The number of features processed by an expert network For expert network regularization loss, g ( x () is the output value of the gating network, representing the input. x The selection weights for each expert network.
3. The agent-based load forecasting method according to claim 1, characterized in that, The method further includes: The agent calls the deployment module to export the load prediction model in ONNX, TorchScript, or TensorFlow SavedModel format and deploy it as a RESTful interface to access the power system.
4. The agent-based load forecasting method according to claim 1, characterized in that, The method further includes: The agent determines whether data preprocessing is required for the target data. If so, it calls a data preprocessing tool to preprocess the target data; otherwise, it executes subsequent steps.
5. A load prediction device based on intelligent agents, characterized in that, include: The data reading unit is used to read target data from the database in response to the user's load forecasting command. The target data includes load data, weather data, and date data. The model training and load forecasting unit is used to determine whether there is a corresponding existing load forecasting model in the model library according to the load forecasting instruction; if there is, the existing load forecasting model is called to perform load forecasting based on the target data and output the load forecasting result. If it does not exist, a load forecasting network is constructed according to the load forecasting instruction, the training tool is called to train the load forecasting network to obtain a load forecasting model, the load forecasting model is called to perform load forecasting based on the target data, and the load forecasting result is output. The step of constructing a load forecasting network according to the load forecasting instructions includes: The load forecasting instruction is parsed to obtain the load forecasting task; When the load forecasting task is a single-task forecasting task, an improved transformer network and a single-task forecasting head are constructed to obtain a single-task load forecasting network. When the load forecasting task is a multi-task forecasting task, an improved transformer network and a multi-task forecasting head are constructed to obtain a multi-task load forecasting network. The improved transformer network is obtained by replacing the feedforward network in the transformer network with the target network layer; the target network layer includes a gating network, multiple expert networks, and a feature fusion network. The step of using a training tool to train the load forecasting network to obtain a load forecasting model includes: Historical data is obtained from the power system database, and training and test sets are generated based on the historical data, which includes historical load data, historical weather data, and historical date data. The training tool is invoked to train the load prediction network using the historical data. The loss value is calculated based on the load prediction value and the actual load value during training. The network parameters of the load prediction network are updated using the loss value to obtain the trained load prediction model. The load forecasting model is tested using the test set, and the network parameters of the load forecasting model are adjusted based on the test results.
6. The agent-based load prediction device according to claim 5, characterized in that, Also includes: The deployment unit is used to export the load forecasting model into ONNX format, TorchScript format, or TensorFlowSavedModel format, and deploy it as a RESTful interface to access the power system.
7. The agent-based load prediction device according to claim 5, characterized in that, Also includes: The data preprocessing unit is used to determine whether the target data needs to be preprocessed. If so, it calls the data preprocessing tool to preprocess the target data. If not, it triggers the model training and load prediction unit.
8. An electronic device, characterized in that, The device includes a processor and a memory; The memory is used to store program code and transmit the program code to the processor; The processor is configured to execute the agent-based load prediction method according to any one of claims 1-4 according to the instructions in the program code.
9. A computer-readable storage medium, characterized in that, The computer-readable storage medium is used to store program code, which, when executed by a processor, implements the agent-based load prediction method according to any one of claims 1-4.
Citation Information
Patent Citations
Intelligent load prediction method and system for power system
CN117039855A
Power system load prediction model selection method and system and load prediction method
CN118260652A
Resident household electrical appliance electrical load prediction method and device based on deep learning, and medium
CN119965848A
