Enhanced federated learning-based contrast enhanced energy consumption time sequence prediction method and system
By strengthening the contrastive enhancement energy consumption time series prediction method of federated learning, and using LSTM and DDPG algorithms to dynamically generate aggregation weights, the problem of insufficient prediction accuracy and privacy protection of multi-source heterogeneous data is solved, and high-precision building energy consumption prediction is achieved.
Patent Information
- Application Number
- CN202511735611.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-11-25
- Publication Date
- 2026-02-10
AI Technical Summary
Existing building energy consumption prediction methods struggle to handle the temporal dependencies of multi-source heterogeneous data and fail to meet privacy protection requirements. Traditional federated learning methods lack prediction accuracy under non-independent and identically distributed data, making it difficult to balance global generalization performance with personalized and accurate prediction.
A contrastive reinforcement-based energy consumption time series prediction method based on reinforcement federated learning is adopted. The basic model is built through LSTM, the server performs contrastive learning feature alignment, and the DDPG reinforcement learning algorithm is used to dynamically generate aggregate weights. The global model is optimized by combining the contrastive learning loss function and the dynamic aggregation mechanism.
It achieves high-precision building energy consumption prediction, adapts to non-independent and identically distributed data, meets privacy protection requirements, balances the prediction performance of massive data and a small amount of key data, and improves prediction accuracy and stability.
Smart Images

Figure CN121502169A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of building energy consumption prediction, in particular to a comparative enhancement energy consumption time series prediction method and system based on reinforcement federated learning. BACKGROUND
[0002] Building energy consumption prediction is the core of intelligent energy management and energy-saving operation. Traditional methods mainly rely on centralized data collection and modeling, such as physical mechanism models or statistical learning models, such as ARIMA and SVR. However, these methods are difficult to handle multi-source heterogeneous data, such as sensor data and meteorological data, and time series dependence characteristics, and cannot meet the privacy protection requirements. With the development of machine learning technology, deep learning methods such as LSTM have shown excellent performance in time series prediction, but most of them are still based on centralized training, which has data sharing barriers.
[0003] As a distributed training paradigm, federated learning can protect data privacy to some extent through local training and parameter aggregation. Existing federated learning methods, such as FedAvg, still have significant limitations in dealing with the actual scenario of building energy consumption prediction. First, due to the differences in function, climate and other factors in different building areas, the energy consumption data presents typical non-independent and identically distributed characteristics. Traditional fixed aggregation strategies are easily dominated by clients with large data volumes, resulting in a serious lack of prediction accuracy for global models in key areas with small data volumes but volatile trends that significantly affect overall energy consumption. Second, these methods use simple models on the client side, which have limited ability to capture the inherent complex long-time series dependence characteristics of energy consumption data. Third, there is a lack of a mechanism to dynamically adjust the aggregation weight and optimization target according to the real-time performance and data characteristics of the client, making it difficult to effectively balance global generalization performance and personalized accurate prediction. SUMMARY
[0004] The present application provides a comparative enhancement energy consumption time series prediction method and system based on reinforcement federated learning, which has high precision and the beneficial effect of adapting to non-independent and identically distributed data, solving the problems of serious lack of prediction accuracy and difficulty in effectively balancing global generalization performance and personalized accurate prediction mentioned in the background technology.
[0005] The present application provides the following technical solutions: a comparative enhancement energy consumption time series prediction method and system based on reinforcement federated learning, wherein the comparative enhancement energy consumption time series prediction method based on reinforcement federated learning comprises the following steps: S1, obtaining a multi-source building energy consumption dataset and performing data preprocessing to construct a formatted input sequence; S2, each client establishes a basic model based on LSTM to capture and process the output sequence, and extracts the hidden state as a time series feature representation; S3, the server compares the time sequence feature representation of each client with the corresponding base model to perform contrastive learning feature alignment to alleviate non-independent and identically distributed; S4, the server uses a DDPG reinforcement learning algorithm to dynamically generate aggregation weights according to the client performance indicators and base model parameter statistical characteristics; The server weights and aggregates the base model parameters uploaded by each client according to the dynamic aggregation weights to update the global model; S5, repeating steps S2 to S4 until the global model converges, and obtaining the final global model; The final global model is distributed to each client to perform building energy time series prediction.
[0006] As an optional solution of the contrast-enhanced energy time series prediction method based on reinforcement federated learning, wherein the contrastive learning feature alignment method comprises: Upload the time sequence feature representation to the server to generate corresponding local features and construct negative samples; The server generates corresponding global features based on each base model to construct positive samples; The positive samples and negative samples reduce the distribution difference between local features and global features based on a contrastive learning loss function.
[0007] As an optional solution of the contrast-enhanced energy time series prediction method based on reinforcement federated learning, wherein the contrastive learning loss function formula is: Wherein, is the time sequence feature representation of the i-th client, is the feature generated by the global model, is the negative sample set, is the cosine similarity function, is the temperature coefficient.
[0008] As an optional solution of the contrast-enhanced energy time series prediction method based on reinforcement federated learning, wherein step S4 further comprises: The model performance indicators uploaded by each client are used as state input to output dynamic aggregation weights; The server weights and aggregates the model parameters uploaded by each client according to the dynamic aggregation weights to obtain the global model; Wherein, the dynamic aggregation weights are also used to adjust the contrastive learning loss intensity in local training of each client, that is, the local total loss function is: Wherein, is the prediction loss, which is used to drive personalized fitting, For the contrastive learning loss, used to drive global alignment, For dynamic adjustment The coefficient of balance. The coefficient of balance.
[0009] As an optional solution of the contrast-enhanced energy time series prediction method based on reinforcement federated learning, wherein: the DDPG reinforcement learning algorithm includes state, action and reward; The state is real-time performance, including local validation loss, gradient norm and feature entropy of each client; The action is a spatially continuous aggregation weight; The reward is the energy prediction accuracy, which is the improvement degree of the determination coefficient R 2 Or mean square error MSE of the global model on the validation set; According to the real-time performance of each client, the optimal aggregation weight is outputted, so as to maximize the optimization of the global model.
[0010] As an optional solution of the contrast-enhanced energy time series prediction method based on reinforcement federated learning, wherein: the aggregation weight vector is dynamically adjusted according to the aggregation weight vector, and individual optimization is realized; The dynamic adjustment method includes: The client uploads the local model and features; The server runs the DDPG reinforcement learning algorithm, and generates the aggregation weight based on the client performance index; The server calculates the of each client; The server sends the to the corresponding client; The client uses the to calculate the total loss and update the LSTM parameters in the next round of local training; Repeat iteration until convergence, and obtain the final global model.
[0011] As an optional solution of the contrast-enhanced energy time series prediction method based on reinforcement federated learning, wherein: the Wherein, is the contrastive learning loss weight used by the kth client in local training, is the aggregation weight allocated to the kth client in this round of federated aggregation, is a mapping function used to convert the aggregation weight into the contrastive learning loss weight k is the client number, and there are a total of k buildings.
[0012] As an optional embodiment of the contrastive enhanced energy consumption time-series prediction method based on reinforcement federated learning described in this invention, wherein: the method for performing building energy consumption time-series prediction includes: Each client loads the final global model on its local device; The client collects recent historical data, constructs a standardized input sequence to obtain features, and preprocesses the features using the same standardized parameters as in the training phase to ensure consistent distribution. Perform multi-step prediction and output the standardized energy consumption value.
[0013] As an optional scheme of the contrastive enhanced energy consumption time series prediction method based on reinforcement federated learning described in this invention, the data preprocessing method includes: Obtain multi-source building energy consumption datasets by processing public datasets; Initial data is generated by cleaning the multi-source building energy consumption dataset; Feature extraction is performed on the initial data; The extracted features are standardized to obtain time interval parameters, data preprocessing parameters, model-related parameters, and multidimensional data parameters.
[0014] This invention also provides a system for applying a contrastive enhancement energy consumption time series prediction method based on reinforcement federated learning, comprising: Each client includes a data preprocessing module, an LSTM local training module, a contrastive learning optimization module, and a prediction execution module. The server includes a feature broadcasting module, a contrast sample construction module, a reinforcement learning aggregation module, and a global model management module; The client and server interact with model parameters and timing characteristics through a secure communication protocol, and the original data does not leave the local machine. The reinforcement learning aggregation module is used to dynamically generate aggregate weights based on client performance and drive global model updates; The contrastive learning optimization module is used to introduce feature alignment constraints in local training to alleviate the Non-IID problem.
[0015] The present invention has the following beneficial effects: 1. This contrastive enhancement energy consumption time series prediction method based on reinforcement federated learning integrates federated learning, LSTM time series modeling, contrastive learning feature alignment, and reinforcement learning dynamic aggregation to build a privacy-preserving and high-precision energy consumption prediction system. Through the collaborative work of each module, it can achieve intelligent prediction of energy consumption data of multi-source heterogeneous buildings.
[0016] 2. This contrastive energy consumption time series prediction method based on reinforcement federated learning optimizes parameters through federated iteration during the training phase and uses a global model to make multi-step predictions on historical sequences during the prediction phase. Furthermore, based on the federated learning framework, the original data does not need to be shared; only model parameters are exchanged, which meets the data privacy and compliance requirements in smart buildings and improves data privacy protection.
[0017] 3. This contrastive enhancement energy consumption time series prediction method based on reinforcement federated learning effectively balances the prediction performance of massive data and small amount of key data through contrastive learning and dynamic aggregation. This invention not only maintains stable high accuracy in areas with sufficient data, but also significantly improves prediction accuracy in areas with scarce but key data, effectively solving the performance imbalance problem under Non-IID data. Attached Figure Description
[0018] Figure 1 This is a schematic diagram of the overall method flow of the present invention.
[0019] Figure 2 This is a schematic diagram of the LSTM network of the present invention.
[0020] Figure 3 This is a schematic diagram of reinforcement learning according to the present invention.
[0021] Figure 4 This is a schematic diagram of the overall operational framework of the present invention. Detailed Implementation
[0022] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0023] Example 1 Please see Figures 1-4 Furthermore, a contrastive enhancement energy consumption time series prediction method based on reinforcement federated learning is disclosed, comprising the following steps: S1. Obtain multi-source building energy consumption dataset and perform data preprocessing to construct a formatted input sequence; S2. Each client establishes a basic model based on LSTM to capture and process the output sequence, and extracts the hidden state as a temporal feature representation. S3. The server learns feature alignment by comparing the temporal feature representations of each client with the corresponding base model to alleviate non-independent and identically distributed features. S4. The server uses the DDPG reinforcement learning algorithm to dynamically generate aggregate weights based on client performance metrics and statistical features of basic model parameters. The server weights and aggregates the basic model parameters uploaded by each client according to the dynamic aggregation weight, and updates the global model accordingly. S5. Repeat steps S2 to S4 until the global model converges and obtain the final global model. The final global model is then distributed to each client to perform time-series predictions of building energy consumption.
[0024] Data preprocessing methods include: Obtain multi-source building energy consumption datasets by processing public datasets; Initial data was generated by cleaning the multi-source building energy consumption dataset; Feature extraction is performed on the initial data; The extracted features are standardized to obtain time interval parameters, data preprocessing parameters, model-related parameters, and multidimensional data parameters.
[0025] Data was collected from multi-source building energy consumption datasets (such as ASHRAE), including energy consumption records, meteorological information, and building attributes. A formatted input sequence was constructed through data cleaning, feature engineering (such as time feature extraction and outlier handling), and standardization.
[0026] The client uses an LSTM network as a local model to capture the temporal dependencies of energy consumption data. The LSTM processes the input sequence through gating mechanisms (forget gate, input gate, output gate) to generate hidden state representations for prediction and feature alignment.
[0027] Contrastive learning is introduced into local training, using global model features as positive samples and other client features as negative samples. The InfoNCE loss function is used to reduce the difference between local and global feature distributions, thus alleviating the problem of non-independent and identically distributed features.
[0028] The server-side employs the DDPG reinforcement learning algorithm, dynamically generating aggregated weight vectors based on client performance metrics and statistical features of model parameters. This enables personalized aggregation. Simultaneously, it aggregates the weight vector. The weight vector used to adjust the contrastive learning loss (dynamic Mechanism), balancing global and local optimization.
[0029] In the federated learning framework, the entire lifecycle is divided into two phases. During the training phase, multiple rounds of communication occur, with the client and server collaborating to optimize the global model, including LSTM, contrastive learning, and reinforcement aggregation. During the prediction deployment phase, after training terminates, the finally converged global model is distributed to each client for inference only, without updating parameters. This phase does not involve data uploading, gradient exchange, or privacy leakage, adhering to the principle of data remaining within its domain. The specific steps are as follows: S201. Load the global model. The server will send the final version of the global model, i.e. the aggregated LSTM parameters, to all participating building clients. Each client loads the model on its local device (such as an edge server or building management system). The model structure is a standard LSTM network (consistent with the training time), and the input is historical energy consumption and related features. S202. Prepare the input sequence. The client collects recent historical data and constructs a standardized input sequence: The length of the sliding window (e.g., 24 hours); It is a vector containing energy consumption, meteorological, and time characteristics; All features should be preprocessed using the same standardized parameters (such as mean and variance) as those used in the training phase to ensure consistent distribution. S203. Perform multi-step prediction using direct multi-output prediction. Direct multi-output prediction means the model receives the historical input sequence all at once and directly outputs the predicted values for multiple future time steps, rather than iterating step-by-step. The formula is: The length of the historical window (e.g., the past 24 hours); To predict the step size, the number of neurons in the output layer (e.g., in the next 6 / 12 / 24 hours). For mapping functions implemented by neural networks (such as LSTM); This represents the actual energy consumption at that moment. Furthermore, calculating the loss function requires calculating the total error over H time points, as shown in the formula: For example, for instance: During the training phase, each client constructs samples locally: Input: Standardized energy consumption plus meteorological and temporal characteristics over the past 24 hours (L=24 hours); Tag: Future H = Actual energy consumption value over 24 hours; The LSTM output layer is set to have 24 neurons; Local loss ; During federated aggregation, the entire LSTM parameters (including multiple output heads) are aggregated. During the prediction deployment phase, the client loads the global model, inputs the data from the most recent 24 hours, and directly outputs the energy consumption curve for the next 24 hours without the need for loop calls.
[0030] S204. Output future energy consumption value. The model output is a standardized energy consumption value. The client uses the destandardized parameters (such as standard deviation and mean) saved during the training phase to restore it to the real unit (kWh).
[0031] The results can be directly used for energy dispatching (such as early start / stop of air conditioning), abnormal power consumption alarms, carbon emission accounting, and electricity cost prediction.
[0032] By utilizing high-quality global LSTM models obtained through federated training, high-precision, low-latency, and multi-step energy consumption predictions can be achieved locally in each building while fully protecting privacy, thus supporting smart energy decision-making.
[0033] In summary, parameter optimization is achieved through federated iterations during the training phase, while the prediction phase uses a global model to perform multi-step predictions on historical sequences. Furthermore, based on the federated learning framework, raw data does not need to be shared; only model parameters are exchanged, thus meeting data privacy and compliance requirements in smart buildings and improving data privacy protection.
[0034] In summary, the specific implementation process of this invention is as follows: First, data preparation is performed by obtaining building energy consumption data from public datasets (such as ASHRAE), which are then cleaned, feature extracted, and standardized to construct a time-series input matrix. Next, the model training phase begins. This phase is based on a federated learning framework, deploying LSTM models locally on each client for time-series feature extraction and prediction. Simultaneously, a contrastive learning mechanism is introduced to align local and global feature distributions, reducing the impact of non-independent and identically distributed data. On the server side, a reinforcement learning algorithm is used to dynamically generate aggregated weight vectors. Optimize global model parameters, and simultaneously aggregate weight vectors Dynamically adjust the weight vector of the contrastive learning loss for each client. (dynamic The mechanism enables personalized optimization. The training process is iterative until a preset number of rounds are reached. Finally, the prediction and deployment phase begins, where the trained global model is loaded, and multi-step predictions are performed on the input historical energy consumption sequence to output future energy consumption values.
[0035] It is worth noting that experiments on the ASHRAE dataset show that this method outperforms baseline methods (such as FedAvg and FedAdam) in terms of MSE, MAE, and R2. The MSE is reduced to 4293.63, and the R2 is improved to 0.81, significantly improving the accuracy and stability of energy consumption prediction. See the overall performance comparison of different methods below: Method name MSE RMSE MAE [R 2 ]] NRMSE Fedavg 5309.59 50.36 34.18 0.75 0.097 Fednova 5474.49 51.41 37.14 0.73 0.100 Medianavg 5519.50 50.91 36.16 0.74 0.095 Fedadam 4516.10 48.88 35.51 0.73 0.106 Fedyogi 4691.87 48.71 35.91 0.75 0.099 FedCTR 4293.63 44.49 31.49 0.81 0.081 The method in this embodiment supports real-time prediction and can be applied to scenarios such as grassroots energy management, helping to optimize energy conservation in smart buildings.
[0036] It should be noted that, in addition, the ablation experiment results show that removing any module from reinforcement learning dynamic aggregation, contrastive learning feature alignment, or dynamic λ mechanism will significantly reduce the overall performance of the model in both the whole and key regions, which fully demonstrates the integrity of the technical solution of this invention and the necessity of the collaborative work of each module.
[0037] Example 2 This embodiment is an improvement upon embodiment 1. For details, please refer to [link / reference]. Figures 1-4 Methods for contrastive learning feature alignment include: The temporal feature representation is uploaded to the server to generate corresponding local features, and negative samples are constructed. The server generates corresponding global features based on each base model and constructs positive samples. Positive and negative samples are compared using a contrastive learning loss function to reduce the difference between the distribution of local and global features.
[0038] Because the feature spaces extracted by LSTMs from different buildings may be inconsistent, the global model may become ineffective due to averaging. Therefore, contrastive learning is introduced, using the InfoNCE loss function to bring positive samples closer together and push away negative samples. Positive and negative sample construction (during each round of communication): Positive samples: Features from the current client compared to features generated by the global model; Negative samples: Features of the current client compared to features uploaded by other clients.
[0039] The formula for the contrastive learning loss function is: in, Let i be the temporal characteristics representation of the i-th client. Features generated for the global model For the negative sample set, Let cosine similarity function be used. This is the temperature coefficient.
[0040] By combining positive and negative samples and using a contrastive learning loss function, local features are forced to align with global semantics, thereby improving cross-building generalization ability.
[0041] The S4 step also includes: The model performance metrics uploaded by each client serve as state inputs, which are then used to output dynamic aggregate weights. The server performs weighted aggregation of model parameters uploaded by each client based on dynamic aggregation weights to form a global model; The dynamic aggregation weights are also used to adjust the contrastive learning loss intensity for each client during local training; that is, the local total loss function is: in, To predict the loss, which is used to drive personalized fitting. To contrast the learning loss used to drive global alignment, For dynamic adjustment and The balance coefficient.
[0042] By comparing and dynamically aggregating data, the predictive performance of massive amounts of data and limited amounts of key data is effectively balanced. This invention not only maintains stable high accuracy in areas with sufficient data (Area1, Area2), but also significantly improves prediction accuracy in areas with scarce but key data (Area3), effectively solving the performance imbalance problem under Non-IID data.
[0043] Example 3 This embodiment is an improvement upon embodiment 2. For details, please refer to [link / reference]. Figures 1-4 The DDPG reinforcement learning algorithm includes state, action, and reward; The status is presented in real time, including the local validation loss, gradient norm, and feature entropy of each client; Actions are spatially continuous aggregate weights; The reward is the accuracy of energy consumption prediction, used as the coefficient of determination R of the global model on the validation set. 2 Or the degree of improvement in mean squared error (MSE); Dynamic decisions are made based on the real-time performance of each client to output the optimal aggregate weight, thereby maximizing the optimization of the global model; The comparative learning loss weight vectors of each client are dynamically adjusted based on the aggregated weight vector to achieve personalized optimization. Dynamic adjustment methods include: The client uploads the local model and features; The server runs the DDPG reinforcement learning algorithm to generate aggregate weights based on client performance metrics. The server calculates for each client. ; The server will Send to the corresponding client; The client will use this in the next round of local training. Calculate the total loss and update the LSTM parameters; Repeat the iterations until convergence to obtain the final global model.
[0044] Client in, The contrastive learning loss weights used by the k-th client during local training. Let k be the aggregation weight assigned to the k-th client in this round of federated aggregation. This is a mapping function used to aggregate weights. Transform into contrastive learning loss weights k is the client number, and there are a total of k buildings.
[0045] Methods for implementing time-series building energy consumption forecasting include: Each client loads the final global model on its local device; The client collects recent historical data, constructs a standardized input sequence to obtain features, and preprocesses the features using the same standardized parameters as in the training phase to ensure consistent distribution. Perform multi-step prediction and output the standardized energy consumption value.
[0046] This embodiment uses the ASHRAE Great Energy Predictor public dataset as a foundation to construct a federated learning system comprising 20 heterogeneous buildings (such as office buildings, shopping malls, and schools). Each building acts as a client, locally storing its historical hourly energy consumption data, corresponding meteorological information (temperature, humidity, wind speed, solar radiation), and building attributes (area, usage type). The server is deployed in the cloud and is responsible for coordinating training and aggregation. Data preprocessing and local model building: Each client cleans the raw data, removing outliers (such as negative energy consumption and mutation points) and extracting time features (hours, days of the week, and whether it is a holiday). Input sequence length (L=24) (past 24 hours), prediction step size (H=24) (future 24 hours). The local model uses a two-layer LSTM with 64 hidden units and a 24-dimensional fully connected output layer, directly outputting multi-step prediction results.
[0047] The federal training process is as follows: The system executes the following iterative process, totaling 100 rounds of communication: S301. The server initializes the global LSTM model and broadcasts it to all clients.
[0048] S302. At the start of each round, the client loads a copy of the current global model to generate positive samples for comparative learning.
[0049] S303. The client performs 5 epochs of training locally, with the loss function being: in, This represents the hidden state of the last layer of the local LSTM. This refers to the features generated by the global model for the same input; The initial value is 0.1. It is 0.5; S304. The client uploads three pieces of information to the server: Updated local model parameters ; MSE loss on the current validation set; Gradient L2 norm and feature entropy (used for state construction).
[0050] S305. After the server collects all client information, it executes the DDPG agent decision: Status: Concatenate the MSE, gradient norm, and feature entropy of each client to form a 60-dimensional vector; Action: The DDPG Actor network outputs 20-dimensional raw logits, which are then processed by Softmax to obtain aggregated weights. ; Bonus: Calculate using the new aggregation model on a common validation set (simulating regional average load). The reward is for this round. The difference from the previous round; The DDPG Critic network updates by minimizing the TD error, while the Actor network updates by ascending the policy gradient. Each round of soft updates for the target network ; Step S306: The server calculates the dynamic comparison weights. That is, the higher the aggregation weight, the weaker the comparison constraint.
[0051] S307. The server distributes the new global model to each client, and the next round begins.
[0052] After training, the server distributes the final global model to the edge devices of each building. For example, if an office building inputs the data from the most recent 24 hours at 23:00 on April 5, 2025, the model directly outputs a 24-hour energy consumption prediction curve from 00:00 to 23:00 on April 6, 2025, for use in optimizing the scheduling of the air conditioning system.
[0053] On the ASHRAE dataset, compared to baselines such as FedAvg, FedProx, and MOON, the method in this embodiment (FedCTR) reduces MSE by 18.7% under Non-IID partitioning, and achieves lower R-values for small sample buildings (<1000 records). 2 The improvement reached 25.3%; convergence was achieved with a reduction of approximately 30% in the number of communication rounds. This invention improves the global model's accuracy and personalization capabilities through a collaborative mechanism of reinforcement learning dynamic aggregation and contrastive learning feature alignment.
[0054] Example 4 This invention also provides a system for applying a contrastive enhancement energy consumption time series prediction method based on reinforcement federated learning, comprising: Each client includes a data preprocessing module, an LSTM local training module, a contrastive learning optimization module, and a prediction execution module. The server includes a feature broadcasting module, a contrast sample construction module, a reinforcement learning aggregation module, and a global model management module. In this process, the client and server interact with model parameters and timing characteristics through a secure communication protocol, and the raw data does not leave the local machine. The reinforcement learning aggregation module is used to dynamically generate aggregate weights based on client performance and drive global model updates; The contrastive learning optimization module is used to introduce feature alignment constraints during local training to alleviate the Non-IID problem.
[0055] By integrating federated learning, LSTM temporal modeling, contrastive learning feature alignment, and reinforcement learning dynamic aggregation, a privacy-preserving, high-precision energy consumption prediction system is constructed. This method includes the following core modules: data preprocessing, local temporal model training, contrastive learning feature alignment, reinforcement learning-driven dynamic aggregation and parameter tuning, and global prediction deployment. These modules work collaboratively to achieve intelligent prediction of energy consumption data from multi-source, heterogeneous buildings.
[0056] It should be noted that, in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such process, method, article, or apparatus.
[0057] The above description is only a preferred embodiment of the present invention. It should be noted that for those skilled in the art, several improvements and modifications can be made without departing from the technical principles of the present invention, and these improvements and modifications should also be considered within the scope of protection of the present invention.
Claims
1. A contrastive enhancement energy consumption time-series prediction method based on reinforcement federated learning, characterized in that, Includes the following steps: S1. Obtain multi-source building energy consumption dataset and perform data preprocessing to construct a formatted input sequence; S2. Each client establishes a basic model based on LSTM to capture and process the output sequence, and extracts the hidden state as a temporal feature representation. S3. The server compares and learns feature alignment based on the temporal feature representations of each client with the corresponding base model to alleviate non-independent and identically distributed features. S4. The server uses the DDPG reinforcement learning algorithm to dynamically generate aggregate weights based on client performance metrics and statistical features of basic model parameters. The server weights and aggregates the basic model parameters uploaded by each client according to the dynamic aggregation weight, and updates the global model. S5. Repeat steps S2 to S4 until the global model converges and obtain the final global model. The final global model is then distributed to each client to perform time-series predictions of building energy consumption.
2. The contrastive enhancement energy consumption time series prediction method based on reinforcement federated learning according to claim 1, characterized in that, The method for contrastive learning feature alignment includes: The time-series feature representation is uploaded to the server to generate corresponding local features, and negative samples are constructed. The server generates corresponding global features based on each base model and constructs positive samples. The positive and negative samples are compared using a contrastive learning loss function to reduce the difference between the distribution of local and global features.
3. The contrastive enhancement energy consumption time series prediction method based on reinforcement federated learning according to claim 2, characterized in that, The formula for the contrastive learning loss function is: in, Let i be the temporal characteristics representation of the i-th client. Features generated for the global model For the negative sample set, Let cosine similarity function be used. This is the temperature coefficient.
4. The contrastive enhancement energy consumption time series prediction method based on reinforcement federated learning according to claim 2, characterized in that, The S4 step also includes: The model performance metrics uploaded by each client serve as state inputs, which are then used to output dynamic aggregate weights. The server performs weighted aggregation of the model parameters uploaded by each client based on dynamic aggregation weights to form a global model; The dynamic aggregation weights are also used to adjust the contrastive learning loss intensity of each client during local training, i.e., the local total loss function is: in, To predict the loss, which is used to drive personalized fitting. To contrast the learning loss used to drive global alignment, For dynamic adjustment and The balance coefficient.
5. The contrastive enhancement energy consumption time series prediction method based on reinforcement federated learning according to claim 4, characterized in that: The DDPG reinforcement learning algorithm includes states, actions, and rewards; The state is a real-time representation, including the local validation loss, gradient norm, and feature entropy of each client; The action is a spatially continuous aggregate weight; The reward is the energy consumption prediction accuracy, used as the coefficient of determination R of the global model on the validation set. 2 Or the degree of improvement in mean squared error (MSE); Dynamic decisions are made based on the real-time performance of each client to output the optimal aggregate weight, thereby maximizing the optimization of the global model.
6. The contrastive enhancement energy consumption time series prediction method based on reinforcement federated learning according to claim 4, characterized in that: Based on the aggregated weight vector, the contrastive learning loss weight vector of each client is dynamically adjusted to achieve personalized optimization; The dynamic adjustment method includes: The client uploads local models and features; The server runs the DDPG reinforcement learning algorithm to generate aggregate weights based on client performance metrics. The server calculates for each client. ; The server will Send to the corresponding client; The client will use this in the next round of local training. Calculate the total loss and update the LSTM parameters; Repeat the iterations until convergence to obtain the final global model.
7. The contrastive enhancement energy consumption time series prediction method based on reinforcement federated learning according to claim 6, characterized in that: The client in, The contrastive learning loss weights used by the k-th client during local training. Let k be the aggregation weight assigned to the k-th client in this round of federated aggregation. This is a mapping function used to aggregate weights. Transform into contrastive learning loss weights k is the client number, and there are a total of k buildings.
8. The contrastive enhancement energy consumption time series prediction method based on reinforcement federated learning according to claim 7, characterized in that: The method for performing time-series prediction of building energy consumption includes: Each client loads the final global model on its local device; The client collects recent historical data, constructs a standardized input sequence to obtain features, and preprocesses the features using the same standardized parameters as in the training phase to ensure consistent distribution. Perform multi-step prediction and output the standardized energy consumption value.
9. The contrastive enhancement energy consumption time series prediction method based on reinforcement federated learning according to claim 8, characterized in that, The data preprocessing method includes: Obtain multi-source building energy consumption datasets by processing public datasets; Initial data is generated by cleaning the multi-source building energy consumption dataset; Feature extraction is performed on the initial data; The extracted features are standardized to obtain time interval parameters, data preprocessing parameters, model-related parameters, and multidimensional data parameters.
10. A system applying the contrastive enhanced energy consumption time series prediction method based on reinforcement federated learning as described in any one of claims 1-9, characterized in that, include: Each client includes a data preprocessing module, an LSTM local training module, a contrastive learning optimization module, and a prediction execution module. The server includes a feature broadcasting module, a contrast sample construction module, a reinforcement learning aggregation module, and a global model management module; The client and server interact with model parameters and timing characteristics through a secure communication protocol, and the original data does not leave the local machine. The reinforcement learning aggregation module is used to dynamically generate aggregate weights based on client performance and drive global model updates; The contrastive learning optimization module is used to introduce feature alignment constraints in local training to alleviate the Non-IID problem.
