Load prediction method and device based on intelligent agent, equipment and storage medium
By autonomously constructing and training a load forecasting network using an intelligent agent, and utilizing an improved transformer network and a multi-task forecasting head, the problem of low efficiency in existing load forecasting methods is solved, and a highly efficient and automated load forecasting process is achieved.
Patent Information
- Application Number
- CN202511057925.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-30
- Publication Date
- 2025-11-04
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.
A load forecasting method based on intelligent agents is adopted. The intelligent agent responds to user instructions to read data from the database, determines whether an existing model exists, and if not, constructs and trains a load forecasting network. It then uses an improved transformer network and a multi-task forecasting head to make predictions, reducing human intervention through autonomous decision-making and data processing.
By enabling intelligent agents to autonomously complete the entire process of data reading, model training, and deployment, manual intervention is reduced, load forecasting efficiency is improved, labor costs are reduced, and automated and efficient load forecasting is achieved.
Smart Images

Figure CN120896129A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of load forecasting, and in particular to a load forecasting method and device based on an agent, an equipment and a storage medium. BACKGROUND
[0002] Load forecasting gradually integrates machine learning and artificial intelligence technology. Machine learning methods, such as support vector machine (SVM), random forest (RF), etc., provide a new way of thinking for modeling complex load change patterns. Subsequently, deep learning models (such as long short-term memory network LSTM, convolutional neural network CNN, etc.) have rapidly become the mainstream technology in the field of load forecasting due to their superior performance in processing large-scale nonlinear data and mining complex features. However, the existing load forecasting methods mainly rely on manual construction of network models and training of models to obtain load forecasting models, which involves more human intervention and is less efficient. SUMMARY
[0003] The present application provides a load forecasting method and device based on an agent, an equipment and a storage medium, which can improve the efficiency of load forecasting and reduce human intervention.
[0004] Therefore, the present application provides a load forecasting method based on an agent, which comprises the following steps:
[0005] The agent reads target data from a database in response to a load forecasting instruction of a user, wherein the target data comprises load data, weather data and date data;
[0006] The agent determines whether there is an existing load forecasting model corresponding to the load forecasting instruction in a model library;
[0007] If there is, the existing load forecasting model is called to perform load forecasting based on the target data, and a load forecasting result is outputted;
[0008] If there is not, a load forecasting network is constructed according to the load forecasting instruction, a training tool is called to train the load forecasting network, a load forecasting model is obtained, the load forecasting model is called to perform load forecasting based on the target data, and a load forecasting result is outputted.
[0009] Optionally, the step of constructing a load forecasting network according to the load forecasting instruction comprises the following steps:
[0010] The load forecasting instruction is parsed to obtain a load forecasting task;
[0011] When the load forecasting task is single-task prediction, an improved transformer network and a single-task prediction head are constructed to obtain a single-task load forecasting network;
[0012] When the load prediction task is a multi-task prediction, an improved transformer network and a multi-task prediction head are constructed to obtain a multi-task load prediction network.
[0013] The improved transformer network is a transformer network in which a feedforward network is replaced by a target network layer.
[0014] Optionally, the load prediction model is obtained by training the load prediction network using a training tool, including:
[0015] The historical data includes historical load data, historical weather data, and historical date data.
[0016] The load prediction network is trained using a training tool and the historical data, and a loss value is calculated based on the load prediction value and the actual load value of the load prediction network during training.
[0017] The load prediction model is tested using the test set, and the network parameters of the load prediction model are adjusted based on the test results.
[0018] When the load prediction network is a single-task load prediction network, the loss value is calculated according to the following formula:
[0019]
[0020] where N is the number of samples, y i is the actual load value of the i-th sample, is the predicted load value of the i-th sample.
[0021] When the load prediction network is a multi-task load prediction network, the loss value is calculated according to the following formula:
[0022]
[0023] where T is the number of tasks, is the loss weight of task j, L j is the loss value of task j; M is the number of expert networks, n s is the number of features processed by the s-th expert network; n j is the number of features processed by the j-th expert network, g(x) is the output value of the gating network, representing the selection weight of the input x to each expert network.
[0024] Optionally, the method further comprises:
[0025] The agent calls a deployment module to export the load prediction model into an ONNX format, a TorchScript format or a TensorFlow SavedModel format, and deploys it as a RESTful interface to access the power system.
[0026] Optionally, the method further comprises:
[0027] The agent determines whether data preprocessing is needed for the target data, and if so, calls a data preprocessing tool to preprocess the target data, and if not, executes the subsequent steps.
[0028] The second aspect of the present application provides an agent-based load prediction device, comprising:
[0029] A data reading unit is configured to read target data from a database in response to a user's load prediction instruction, the target data including load data, weather data and date data.
[0030] A model training and load prediction unit is configured to determine whether a corresponding existing load prediction model exists in a model library according to the load prediction instruction, and if so, to call the existing load prediction model to perform load prediction based on the target data and output a load prediction result, and if not, to construct a load prediction network according to the load prediction instruction, call a training tool to train the load prediction network, obtain a load prediction model, call the load prediction model to perform load prediction based on the target data, and output a load prediction result.
[0031] Optionally, the device further comprises:
[0032] A deployment unit is configured to export the load prediction model into an ONNX format, a TorchScript format or a TensorFlow SavedModel format, and deploy it as a RESTful interface to access the power system.
[0033] Optionally, the device further comprises:
[0034] A data preprocessing unit is configured to determine whether data preprocessing is needed for the target data, and if so, to call a data preprocessing tool to preprocess the target data, and if not, to trigger the model training and load prediction unit.
[0035] The third aspect of the present application provides an electronic device, the device comprising a processor and a memory;
[0036] The memory is configured to store program code and transmit the program code to the processor;
[0037] The processor is configured to execute the agent-based load forecasting method according to the instructions in the program code.
[0038] The fourth aspect of the present application provides a computer-readable storage medium for storing program code, which, when executed by a processor, implements the agent-based load forecasting method according to any one of the first aspect.
[0039] From the above technical solutions, the present application has the following advantages:
[0040] The agent-based load forecasting method of the present application calls an open-source large model with code generation and task planning capabilities to build an intelligent agent that can autonomously perform the entire process from data reading, model training, load forecasting, visualization display to system deployment. The intelligent 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. BRIEF DESCRIPTION OF DRAWINGS
[0041] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the drawings needed in the embodiment or prior art description will be briefly introduced below. Obviously, the drawings in the following description are only some embodiments of the present application, and those skilled in the art can obtain other drawings according to these drawings without creative labor.
[0042] Figure 1 A flowchart of an agent-based load forecasting method provided by an embodiment of the present application;
[0043] Figure 2 A structure diagram of a transformer network provided by an embodiment of the present application;
[0044] Figure 3 A structure diagram of a target network layer provided by an embodiment of the present application;
[0045] Figure 4 A structure diagram of a load forecasting network provided by an embodiment of the present application;
[0046] Figure 5 A structure diagram of an agent-based load forecasting device provided by an embodiment of the present application. DETAILED DESCRIPTION
[0047] In order for those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be described clearly and completely below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative labor are within the scope of protection of the present application.
[0048] For ease of understanding, please refer to Figure 1 The embodiment of the present application provides a load prediction method based on an agent, which comprises the following steps:
[0049] Step 110, the agent reads target data from the database in response to the user's load prediction instruction, the target data including load data, weather data and date data;
[0050] The embodiment of the present application selects a basic large model as the core reasoning model of the agent, and the large model has the abilities of local natural language understanding, code generation, logical reasoning and instruction execution planning. The present application adopts a language agent (LangChain) or an automatic agent (AutoGen) framework, takes the large model as the master agent, and defines a series of function tools (Tool) as external modules that can be called by the agent, forming a working mechanism of large model scheduling + tool execution. The embodiment of the present application preferably uses LangChain to define task execution tools, which specifically include:
[0051] Data preprocessing tool: used for data cleaning, normalization, time feature coding, etc. of the load data, weather data and date data read from the database;
[0052] Model training tool: supporting multiple modeling methods, which can be automatically selected and trained according to user demand;
[0053] Prediction and visualization tool: performing model reasoning, outputting future load prediction sequence, and generating prediction and real load comparison chart;
[0054] Deployment tool: the trained model can be deployed as a server interface for online use;
[0055] Document generation tool: automatically generating prediction report or model evaluation document.
[0056] By designing high-quality system prompt words as initialization instructions for large models, the task range and available tools are clearly defined. Users can send instructions through natural language, and the agent automatically analyzes and gradually plans the task. After receiving the load forecasting instruction, the agent first analyzes the load forecasting instruction, obtains the load forecasting task in the instruction, automatically reads and identifies the data types in the database, reads the target data (including load data, weather data, and date data) from the database, then calls the data processing tool to complete data cleaning, missing value processing, time feature encoding, etc., and caches the intermediate results to 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 not, it constructs a load forecasting network according to the load forecasting instruction, calls the training tool to train the load forecasting network, obtains the 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 target (such as predicting the load in the next 24 hours) by analyzing the load forecasting instruction, determines whether there is a corresponding load forecasting model in the model library, and if there is an existing load forecasting model in the model library, it calls the existing load forecasting model to perform load forecasting based on the target data. If there is no corresponding load forecasting model in the model library, it calls the model training tool, selects the appropriate model structure according to the data dimension and time characteristics, and trains it, automatically records the model parameters and training results, and saves the trained load forecasting model to the model library.
[0059] The agent analyzes the load forecasting instruction to obtain the load forecasting task; when the load forecasting task is single-task prediction, it constructs an improved transformer network and a single-task prediction head to obtain a single-task load forecasting network; when the load forecasting task is multi-task prediction, it constructs an improved transformer network and a multi-task prediction head to obtain a multi-task load forecasting network; wherein the improved transformer network is an improved transformer network obtained by replacing the feedforward network in the transformer network with a target network layer; the target network layer includes a gating network, multiple expert networks, and a feature fusion network.
[0060] The structure of the transformer network is as shown in Figure 2 The improved transformer network includes the following structures:
[0061] 1) Input embedding layer, used for position embedding encoding of load data, weather data and time characteristics, converting all input data into high-dimensional vector representation, obtaining feature vectors with position information. The position embedding encoding formula is:
[0062]
[0063]
[0064] In the formula, pos represents the position, i is the dimension index, d model is the transformer network dimension.
[0065] 2) Self-attention layer: The self-attention mechanism in the Transformer network allows the model to focus on information at other time steps at each time step, capturing long-term dependencies. Query (Query), Key (Key) and Value (Value) are calculated for each time step input, then weighted and summed by attention score to obtain new feature representation:
[0066]
[0067]
[0068] In the formula, Q, K, V are query matrix, key matrix, value matrix respectively; W Q , W K , W V are query weight parameters, key weight parameters, value weight parameters respectively, and X is the position vector.
[0069] 3) Multi-head attention mechanism: In order to enable the model to capture features in different subspaces, a multi-head self-attention mechanism is used. The model will calculate attention in multiple subspaces in parallel and connect the results to enhance the model's feature expression ability.
[0070]
[0071]
[0072] In the formula, W O is the weight parameter, and is the parameter to be trained.
[0073] 4) Feed-forward neural network layer: After each time step, a feed-forward neural network is used to further extract features and increase the model's nonlinear ability. In some layers of the Transformer (such as layers 2, 4, and 6), the original FFN (Feed-Forward Network, i.e. feed-forward neural network) is replaced by the target network layer:
[0074]
[0075] where S(x) is the top-k expert networks selected by the router, g i (x) is the weight of the i-th expert network, F i (x) is 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, which is called routing. The router is a lightweight gating network responsible for selecting the top-k expert networks according to the input feature x:
[0077]
[0078] where W r is the parameter to be trained.
[0079] 5) Layer normalization and residual connection: In order to improve the stability and training efficiency of the model, layer normalization and residual connection are added after each self-attention layer and feedforward layer.
[0080] 6) Encoder: Build a multi-layer encoder, each layer contains a multi-head self-attention layer and a feedforward neural network layer, to extract deeper feature information layer by layer.
[0081] 7) Decoder: In time series prediction, encoder-decoder structure can be used for multi-step prediction. The encoder extracts sequence features, and the decoder converts the encoded information into future load prediction.
[0082] The agent supports single-task prediction and multi-task prediction. When the user needs to implement single-task load prediction (such as predicting the load situation of a certain area), the agent connects a single-task prediction head after the improved transformer network; when the user needs to implement multi-task load prediction (such as predicting the load situation of multiple areas or multiple time granularities), the agent connects a multi-task prediction head after the improved transformer network. Please refer to Figure 4The shared encoder can be used to generate multiple decoders for multiple prediction areas or time granularities, realize area load linkage prediction, and improve modeling efficiency. The multi-task learning structure in the application includes a shared Transformer encoder part and multiple task-specific decoders or prediction heads. Each prediction head corresponds to a specific load prediction task, such as load prediction of different areas or prediction of different time scales (such as hourly, daily, and weekly). This structure can extract general features in the shared layer while retaining the differences between tasks, improving the model's ability to adapt to complex multi-source data. Each expert network is an independent neural network that learns a certain aspect of the input features. For example, one expert network may specialize in predicting the load of a specific area, and another expert may learn to respond to load changes under specific weather conditions. The specific task of the expert network and the mode it processes are automatically selected by the gating network.
[0083] The agent calls the training tool to train the load prediction network to obtain a load prediction model, specifically including:
[0084] Obtain historical data from the power system database, generate a training set and a test set according to the historical data, and the historical data includes historical load data, historical weather data, and historical date data;
[0085] Call the training tool to train the load prediction network through the historical data, calculate the loss value according to the load prediction value and the load true value of the load prediction network during training, update the network parameters of the load prediction network through the loss value, and obtain the trained load prediction model;
[0086] Test the load prediction model through the test set, and adjust the network parameters of the load prediction model according to the test result;
[0087] When the load prediction network is a single-task load prediction network, the calculation formula of the loss value of the single task is:
[0088]
[0089] In the formula, N is the number of samples, y i is the load true value of the i-th sample, is the load prediction value of the i-th sample;
[0090] When the load prediction network is a multi-task load prediction network, the calculation formula of the loss value is:
[0091]
[0092] In the formula, T is the number of tasks, is the loss weight of task j, L jLoss value for task j; M is the number of expert networks, n s Number of features processed by the s-th expert network; n j Number of features processed by the j-th expert network, Expert network regularization loss, g(x) is the output value of the gating network, representing the selection weight of input x for each expert network. This loss function includes task loss, load balancing and sparsification loss, and routing regularization term. By calculating the load balancing and sparsification loss, adding the expert load balancing regularization term, it prevents some expert networks from being idle for a long time; through the routing regularization term to constrain the output of the gating network, ensure that the allocation of expert networks is both sparse and balanced, so as to improve the training efficiency and model robustness.
[0093] The training data is input into the model, and the predicted value is calculated by forward propagation. The loss of the predicted value and the true value is calculated. The model parameters are updated by the back propagation algorithm. Repeat the above steps until the training process converges or reaches the set training round. In the training process, the loss functions of multiple prediction tasks are optimized at the same time, such as the load prediction error of multiple regions or multiple time scales. The entire model is trained jointly through weighted summation, realizing information sharing and collaborative improvement between different tasks.
[0094] In the training process, the validation set is used to evaluate the model performance, and the hyperparameters (such as the number of layers, the number of attention heads, etc.) are adjusted to avoid overfitting. After the model training is completed, it is applied to the test set, and the evaluation indicators (such as MSE, MAE, RMSE, etc.) are calculated to measure the final performance of the model. In the evaluation process, the indicators are calculated for each subtask (such as each region or time scale), and the model structure and weight distribution are adjusted according to the comprehensive performance to ensure the collaborative optimization of the main task and the auxiliary task. In the process of model training and evaluation, the performance of each subtask can be monitored through the following indicators:
[0095] Load prediction error of each region: for example, evaluate the load prediction error (such as MSE, MAE) of each area, help the model understand which area's load prediction is more difficult.
[0096] Prediction error of different time scales: for example, the error evaluation of hourly, daily, and weekly load prediction. Standard regression error indicators such as MSE or RMSE can be used.
[0097] Inter-task correlation: for example, by calculating the correlation between subtasks (such as based on mutual information or correlation coefficient between data) to evaluate the linkage between tasks, so as to decide whether to optimize the collaboration between tasks through shared network layers.
[0098] These indicators are monitored regularly during training and used to optimize task weights and network architecture through a comprehensive score feedback. For sub-tasks that perform well (e.g., regions or time scales with low load prediction errors), higher weights can be given.
[0099] During training, the agent can perform hyperparameter tuning on the improved Transformer network, including adjusting the number of attention heads, the number of layers, the dimension of hidden layers, the learning rate, the batch size, etc., 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 will dynamically adjust the hyperparameters of the model based on performance indicators such as loss value (Loss), accuracy, prediction error (MSE, RMSE, MAE, etc.), and the progress of the task. For example:
[0100] When the training speed is slow, the batch size of the training data can be increased to speed up the calculation of the gradient.
[0101] When the convergence process is too slow or oscillatory, the batch size of the training data can be reduced, and the update frequency of the model can be increased to enhance the robustness of the model.
[0102] When the validation error is high, the agent can choose to reduce the number of layers or reduce 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 to enable the model to learn more features.
[0104] After the model training is completed, the agent automatically calls the load prediction model to perform multi-step prediction for future time periods and generates comparison graphs (predicted values vs. actual values) using visualization tools. In power load prediction, multi-step prediction is usually required (e.g., predicting the load for the next 24 hours based on historical input data for multiple time steps). Existing techniques use an autoregressive approach, where the predicted value is used as input to continue predicting the next time step. However, using the Encoder-Decoder structure of the Transformer in this application, multiple future time step predictions can be directly output, avoiding the error accumulation problem caused by rolling prediction.
[0105] In actual use, users can have multiple rounds of dialogue with the agent to request modifications to the data window length, select other models, or optimize the accuracy of a sub-task, and the agent can analyze the instructions and automatically reconstruct the training process.
[0106] The agent provides sustainable learning capabilities, triggering a retraining process when the model performance decreases or external data changes (e.g., climate anomalies), 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 format, TorchScript format or TensorFlow SavedModel format, and deploy it as a RESTful interface to access the power system. The trained load forecasting agent can also be deployed on a server by encapsulating it as a RESTful interface (using Flask, FastAPI, etc.) and combining it with model export formats such as ONNX and TorchScript to access the scheduling system or monitoring platform, enabling real-time data input, prediction result output and visual display, and supporting dynamic scheduling and load optimization of the power grid system.
[0108] The agent-based load forecasting method of the present application uses an open-source large model with code generation and task planning capabilities to build an agent that can autonomously perform the entire process from data reading, model training, load forecasting, visualization, and system deployment. 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] The present application uses Python to develop the interface of the load forecasting platform and langchain and large models to construct an agent that can be used to handle load forecasting tasks. Using an agent for load forecasting has many advantages over traditional methods, mainly in terms of automation, data processing efficiency, model adaptability, and decision-making intelligence. The autonomous decision-making module can automatically complete data preprocessing (such as missing value filling and outlier detection), feature generation (such as extracting trend items and periodic items through time series decomposition), model training and optimization (such as automatically searching for the optimal hyperparameters). The environment perception module can obtain external data (such as weather forecasts and power grid operating conditions) in real time, and dynamically adjust model parameters or switch prediction strategies through reinforcement learning or meta-learning.
[0110] Agent-based load forecasting has stronger data processing and modeling capabilities. Through the data acquisition module, it actively acquires multi-source data (such as real-time data from Internet of Things devices, geographic information data, and user behavior data). Real-time data from Internet of Things devices usually refers to real-time data from power systems or smart devices (such as smart meters, sensors, appliances, and smart sockets). These data contain the operating conditions of the power grid, load fluctuations, and energy consumption of devices. Their functions include:
[0111] Real-time load monitoring: Internet of Things devices provide real-time power usage, allowing the model to reflect current load fluctuations within a short period of time and make immediate 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 historical data trends and improving the accuracy of short-term load forecasting.
[0113] Anomaly Detection: Through device data, anomalies in the power grid or device operation (such as faults, device overloads, user abnormal 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 from smart meters can help predict changes in device and user-level load; sensor data (such as temperature, humidity) can help the model identify and adjust load change trends, especially in hot or cold weather.
[0115] Geographical information data refers to information about the power grid, devices, buildings, and other geographical features. This data includes power distribution networks, user distribution, and geographical area characteristics. Its functions include:
[0116] Spatial Correlation Analysis: By analyzing load data in different geographical areas (such as different cities, neighborhoods, or even floors), the model can capture spatial load differences. For example, the load patterns in urban centers may differ from those in suburban areas. By combining geographical information data, the model can adaptively adjust the prediction to improve spatial accuracy.
[0117] Regional Feature Analysis: Certain regions may have specific load behaviors (such as commercial, residential, industrial areas, etc.). Geographical information data helps the model understand the differences between these regions and customize prediction models for each region based on load data.
[0118] Weather-Geography Correlation Analysis: By combining geographical information data with weather information, the model can identify the sensitivity of different regions to weather changes. For example, areas with higher elevations may experience greater load fluctuations in cold weather, while areas with lower elevations may be less affected.
[0119] By combining geographical information data, the model can distinguish between load demands in different regions under different time and weather conditions, thereby improving spatial accuracy in multi-zone load forecasting.
[0120] User Behavior Data refers to information about users' power consumption patterns, device usage habits, and daily routines. This data mainly includes users' daily behavior, power usage habits, family structure, device usage, and load changes on weekdays and weekends. Its functions include:
[0121] Load demand pattern recognition: By analyzing the user's electricity usage habits (such as seasonal fluctuations, holiday consumption patterns, etc.), the model can better understand and predict the user's electricity demand at a specific time period. For example, some users may use a large amount of electricity during the morning and evening peak hours, while others may have larger fluctuations on weekdays or weekends.
[0122] Behavior-driven prediction adjustment: Changes in user behavior (such as the addition of new appliances, changes in work or life patterns) can affect their electricity consumption. By combining user behavior data, the model can update predictions in real-time to reflect the impact of these changes on the load, avoiding prediction biases based on past data.
[0123] High-precision personalized prediction: By mining individual user electricity data, the model can make personalized predictions, tailoring load predictions to different user groups. In particular, in smart grids, personalized predictions can help reduce power waste and load peaks.
[0124] For example, by collecting user appliance usage data through a smart home system, we can provide energy consumption information about various appliances in the home, helping to predict load fluctuations at different time periods or special events (such as holidays).
[0125] The multi-source data obtained can be used to mine the non-linear relationships between data using deep learning architectures such as Transformers and Graph Neural Networks. The automated process greatly reduces human intervention, and non-experts can monitor the prediction process through a visual interface (such as drag-and-drop data input, viewing model explanation results). Bayesian deep learning or generative adversarial networks (GAN) can be used to output probability prediction results, and a risk assessment module can be used to generate confidence intervals for load fluctuations. Bayesian deep learning is a method that introduces Bayesian inference into deep learning models, allowing the model to output not only the predicted value but also the uncertainty. This means that the model will not only give a point estimate (such as a load prediction value), but also give a confidence or uncertainty of the prediction result. A generative adversarial network is a deep learning framework that typically consists of a generator and a discriminator. The goal of the generator is to generate outputs that closely approximate real data, while the goal of the discriminator is to distinguish between the data generated by the generator and the real data. Through adversarial training, GANs can generate samples that closely approximate real data. In load prediction, GANs can be used to generate the probability distribution of load data, enriching the information of the model's prediction. The agent can automatically select the appropriate load prediction model according to the task requirements and adjust the model architecture according to the characteristics of the input data, automatically output the most suitable prediction for the current situation, and automatically analyze the results of the prediction. Moreover, it does not require experienced engineers to operate.
[0126] Please refer to Figure 5The embodiment of the application further provides a load prediction device based on an agent, comprising:
[0127] The data reading unit 210 is configured to read target data from a database in response to a load prediction instruction of a user, wherein the target data comprises load data, weather data and date data;
[0128] The model training and load prediction unit 220 is configured to determine whether there is an existing load prediction model corresponding to the load prediction instruction in the model library; if there is, the existing load prediction model is called to perform load prediction based on the target data, and a load prediction result is output; if there is not, a load prediction network is constructed according to the load prediction instruction, a training tool is called to train the load prediction network, a load prediction model is obtained, the load prediction model is called to perform load prediction based on the target data, and a load prediction result is output.
[0129] As a further improvement, the device further comprises:
[0130] The deployment unit is configured to export the load prediction model into an ONNX format, a TorchScript format or a TensorFlowSavedModel format, and deploy the load prediction model into a RESTful interface to access a power system.
[0131] As a further improvement, the device further comprises:
[0132] The data preprocessing unit is configured to determine whether data preprocessing is needed for the target data; if so, a data preprocessing tool is called to perform data preprocessing on the target data; if not, the model training and load prediction unit is triggered.
[0133] The embodiment of the application further provides an electronic device, which comprises a processor and a memory;
[0134] The memory is configured to store program code and transmit the program code to the processor;
[0135] The processor is configured to execute the load prediction method based on an agent in the foregoing method embodiments according to instructions in the program code.
[0136] The embodiment of the application further provides a computer readable storage medium, which is configured to store program code, and the program code is executed by a processor to implement the load prediction method based on an agent in the foregoing method embodiments.
[0137] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working process of the device and the unit described above can refer to the corresponding process in the foregoing method embodiments, which will not be described herein.
[0138] The terms "first", "second", "third", "fourth" and the like in the description of this application and in the claims, if any, are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It is to be understood that the terms so used are interchangeable under appropriate circumstances such that the descriptive terms used herein are to be interpreted in the context as exercised by those of ordinary skill in the art and according to the doctrine of equivalents. Furthermore, there is no intention, whatsoever, to limit the scope of the present embodiments to the contents of the written description unless otherwise specifically stated to that effect.
[0139] It should be understood that, in this application, "at least one" means one or more, "multiple" means two or more. "And / or" is used to describe the relationship between associated objects, which means that there can be three relationships, for example, "A and / or B" can represent three cases: only A exists, only B exists, and A and B exist at the same time, where A and B can be singular or plural. The character " / " generally represents an "or" relationship between the associated objects. "At least one of the following" or similar expressions means any combination of these items, including any combination of single or multiple items. For example, at least one 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 several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only illustrative, for example, the division of the units is only a logical function division, and actual implementation can have another division manner, for example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the coupling or direct coupling or communication connection between the displayed or discussed units can be indirect coupling or communication connection through some interfaces, devices or units, which can be electrical, mechanical or other forms.
[0141] The units described as separate components can or can not be physically separated, and the components shown as units can or can not be physical units, i.e. they can be located in one place or distributed on multiple network units. Part or all of the units can be selected according to actual needs to achieve the purpose of the present embodiment.
[0142] In addition, each of the functional units in the various embodiments of the present application can be integrated in one processing unit, or each unit can be physically present separately, or two or more units can be integrated in one unit. The integrated unit can be realized in the form of hardware or in the form of a software functional unit.
[0143] The integrated unit, if realized in the form of a software functional unit and sold or used as an independent product, can be stored in a computer readable storage medium. Based on such understanding, the technical solutions of the present application, essentially or in part, or all or part of the technical solutions can be embodied in the form of a software product. The computer software product is stored in a storage medium, and includes a number of instructions for executing all or part of the steps of the methods described in the various embodiments of the present application by a computer device (which can be a personal computer, a server, or a network device, etc.). The aforementioned storage medium includes various media that can store program codes, such as a U disk, a mobile hard disk, a read-only memory (English full name: Read-Only Memory, English abbreviation: ROM), a random access memory (English full name: Random Access Memory, English abbreviation: RAM), a magnetic disk or an optical disk.
[0144] The above-described embodiments are only used to illustrate the technical solutions of the present application, rather than limit them; although the present application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that they can still modify the technical solutions recorded in the foregoing embodiments, or make equivalent replacements for some of the technical features; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present 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.
2. The agent-based load forecasting method according to claim 1, characterized in that, 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.
3. The agent-based load forecasting method according to claim 2, characterized in that, The step of calling the training tool to train the load forecasting network to obtain the 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. When the load forecasting network is a single-task load forecasting network, the formula for calculating the loss value is: 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; When the load forecasting network is a multi-task load forecasting network, the formula for calculating the loss value is: 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.
4. 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.
5. 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.
6. 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.
7. The agent-based load prediction device according to claim 6, 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.
8. The agent-based load prediction device according to claim 6, 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.
9. 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-5 according to the instructions in the program code.
10. 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-5.
Citation Information
Patent Citations
Load prediction method and device, electronic equipment and readable storage medium
CN112200366A
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