A method and system for predicting energy consumption in office buildings
By decomposing the energy load of office buildings into modal components and extracting their cooperative relationships and spatiotemporal characteristics using GCN and Transformer models, the nonlinearity and dynamic characteristics of energy consumption prediction in traditional methods are solved, and more accurate energy consumption prediction is achieved.
Patent Information
- Application Number
- CN202510685367.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-27
- Publication Date
- 2025-11-14
- Estimated Expiration
- 2045-05-27
AI Technical Summary
Traditional energy consumption forecasting methods struggle to accurately capture the nonlinear and dynamic characteristics of building energy consumption, neglecting the synergistic effects between different loads and the influence of external factors. In particular, their forecasting accuracy is insufficient when facing sudden events and multi-scale changes.
The load is decomposed into multiple modal components, and their collaborative energy consumption relationship is modeled through a graph convolutional network (GCN). The spatiotemporal features are extracted using a Transformer model, and a graph structure is constructed for prediction by combining dynamic time warping and self-attention mechanisms.
It improves the ability to predict future energy consumption trends, better captures the multi-scale characteristics and complex correlations of energy consumption sequences, and provides more accurate prediction results, especially with higher stability and accuracy when facing complex and ever-changing energy consumption scenarios.
Smart Images

Figure CN120217609B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of energy consumption prediction technology for office buildings, and specifically to a method and system for predicting energy consumption in office buildings. Background Technology
[0002] With the escalating energy crisis and heightened environmental awareness, energy consumption forecasting for office buildings has become a crucial means of energy conservation and emission reduction. Traditional energy consumption forecasting methods largely rely on statistical analysis of historical data, making it difficult to accurately capture the nonlinear and dynamic characteristics of building energy consumption. In recent years, deep learning technology has made significant progress in the field of time series forecasting, especially Graph Convolutional Neural Networks (GCNs) and Transformer models, which have demonstrated outstanding performance in handling complex sequence data.
[0003] Building energy consumption is typically comprised of various loads (such as electricity, air conditioning, lighting, and equipment), and these loads have complex synergistic energy consumption relationships. For example, lighting and air conditioning loads may have a synergistic relationship during office hours; that is, when lighting load increases, air conditioning load may also increase, especially in summer or winter, where changes in lighting and air conditioning loads are often interdependent. Traditional models such as ARIMA and linear regression usually model the energy consumption sequence as a whole, ignoring the interaction and dynamic coupling characteristics between these different loads. This approach makes it difficult for these models to accurately capture the synergistic effects between loads, leading to significant deviations between predicted results and actual energy consumption. Moreover, building energy consumption is not only affected by historical energy consumption data but also closely related to external factors (such as weather data and equipment operating status). These external factors play an important role in predicting building energy consumption, especially the significant impact of weather changes on air conditioning load. High temperatures usually lead to a sharp increase in air conditioning load, while low temperatures may trigger changes in heating load. However, existing models typically rely solely on historical energy consumption data and lack the ability to effectively integrate multi-source data. The limitations of this single data source significantly restrict the prediction accuracy of traditional models when faced with changes in the external environment. Building energy consumption sequences typically contain two types of significant features: one is a highly regular component, such as periodic electricity consumption (e.g., daily load fluctuations of air conditioning systems); the other is a highly random component, such as sudden electricity consumption (e.g., energy consumption fluctuations caused by the activation of temporary equipment or special activities). While existing models, such as Long Short-Term Memory (LSTM) networks, can handle some long- and short-term dependencies, they still face difficulties in handling sudden high fluctuations, especially when these irregular changes cannot be effectively learned from past sequences. Their accuracy is often lower than predictions for the regular components. Building energy consumption data exhibits significant multi-scale characteristics, encompassing changes at different time scales, such as hourly fluctuations, daily periodic fluctuations, weekly periodic fluctuations, and seasonal variations. These multi-scale characteristics reflect the dynamic changes in building energy consumption across different time ranges and can significantly impact short-term fluctuations and long-term trends. Traditional models, such as LSTM, while advantageous in capturing long-term dependencies, are primarily modeled based on a single time scale and cannot effectively handle the combined effects of seasonal fluctuations and daily periodic variations. Similarly, while GRU networks are highly efficient, they also face similar challenges, unable to simultaneously adapt to differences in electricity consumption patterns between summer and winter, as well as other periodic fluctuations. This makes it difficult for traditional models to provide accurate results in building energy consumption prediction, especially in scenarios with multi-scale characteristics. Summary of the Invention
[0004] To address the shortcomings of existing technologies in effectively modeling the synergistic effects between different energy-consuming loads, this invention proposes an energy consumption prediction method and system for office buildings. By decomposing the load into multiple sets of modal components corresponding to typical spectral characteristics of different power consumption principles, and using GCN to find the synergistic energy consumption relationships of each set of loads, the prediction accuracy is improved, thereby solving the problems existing in the prior art.
[0005] A method for predicting energy consumption in office buildings includes the following steps:
[0006] Collect the load sequences of different energy-using equipment in the current office building;
[0007] The load sequence of different energy-using equipment is decomposed into multiple modal components, and the sample entropy of each modal component is calculated. Based on the sample entropy of each modal component, the corresponding modal components are recombined. Each recombined modal component is used as a node, and the temporal similarity between each modal component is calculated using dynamic time warping. The temporal similarity is used as the edge between nodes to construct a graph structure.
[0008] The graph structure is input into the GCN-Transformer model, and the spatial features of the nodes in the graph structure are extracted using the graph convolution operation of the GCN. The spatial features of the nodes are then input into the Transformer model, and the temporal features of the spatial features are extracted by introducing a self-attention mechanism to obtain the spatiotemporal features. By inputting the spatiotemporal features into the fully connected layer, the predicted energy consumption value for a future period of time is obtained.
[0009] Furthermore, the similarity between modal components is obtained through Dynamic Time Warping (DTW). Specifically, it includes the following steps:
[0010] Define X and Y as two modal component sequences of length . T :
[0011] Calculate each time step i , j Euclidean distance between This yields a cost matrix of size T×T; where, x i Is sequence X in the th order? i The value of each time step; y j Is sequence Y in the th order? j The value of each time step;
[0012] For each point ( i , j ), calculate its minimum cumulative distance:
[0013] ;
[0014] in, Indicates moving from above to ( i , j The cumulative distance of ) Indicates moving from the left to ( i , j The cumulative distance; Indicates moving from the diagonal to ( i , j The cumulative distance of each point is calculated step by step. i , j )of ,until ;
[0015] Then the sequence between X and Y is obtained. DTW The distance is: .
[0016] Furthermore, the extraction of spatial features of nodes in the graph structure using the graph convolution operation of the Graph Convolutional Network (GCN) is expressed as follows:
[0017] ;
[0018] in, Indicates the first l The node feature matrix of the layer; Indicates the first l The layer's weight matrix is used to perform linear transformations on the nodes; It is a degree matrix, which is a matrix composed of the diagonal elements of the adjacency matrix A; It is an activation function; the adjacency matrix A is formed by... composition, Represented as: ;in, To set a threshold; For Laplace matrix, .
[0019] Furthermore, the step of inputting the spatial features of the nodes into the Transformer model and extracting the temporal features of these spatial features by introducing a self-attention mechanism specifically includes the following steps:
[0020] Output Extracting temporal dependencies from the input Transformer: Since the Transformer requires location information, the input sequence of the Transformer is represented as follows: ,in , It is a positional encoding, represented as: , t For the current time step, dThe total dimension of the input features;
[0021] In a multi-head attention layer, the input features Generate query, key, and value matrices through linear transformations;
[0022] Calculate the self-attention weights based on the query, key, and value matrix, and then compute the multi-head attention output in parallel based on these weights. ;
[0023] The multi-head attention output is residually concatenated with the input sequence to obtain features. ;
[0024] Will The input is processed in a feedforward network to obtain features. ;
[0025] The obtained features and After residual connection and layer normalization, the final temporal features extracted by the Transformer are obtained. .
[0026] Furthermore, the load sequence is decomposed into multiple modal components using variational mode decomposition, specifically including the following steps:
[0027] Constructing a mathematical model for variational mode decomposition:
[0028] ;
[0029] in For each modal component, It is the first k One modal component; The center frequencies of each modal component are... It is the first k The center frequency corresponding to each mode; It is the Dirac function; K The number of decomposition levels; j 1 represents the imaginary unit; * represents the test paper operator; The original signal; k Represents positive integers;
[0030] By introducing a penalty factor and Lagrange multiplication operators The mathematical model of variational mode decomposition is transformed into:
[0031] ;
[0032] In the formula For Lagrange multipliers, As a penalty factor;
[0033] The variational mode decomposition model is solved through iterative optimization; in each iteration, the model is updated. And the center frequency, until convergence, to obtain the final result. and the corresponding center frequency.
[0034] Furthermore, calculating the sample entropy for each modal component specifically includes the following steps:
[0035] Each modal component is grouped into a set of dimensions according to its index. m vector subsequences: ,in, Each modal component is composed of N A time series consisting of data points;
[0036] Define vector subsequence With another vector subsequence Distance between is the absolute value of the maximum difference among the corresponding elements of the two; where, w Representing a subsequence The starting position index, s Represents another subsequence The starting position index;
[0037] For a given ,statistics and The distance between them is less than or equal to the similarity threshold. r of s The number, and recorded as , , ;for From the first w Starting from a subsequence, others m The distance between the dimensional subsequence and the threshold is less than or equal to the threshold. r The number is defined as ;
[0038] Calculate all average The average value Represent any two m dimensional sequence at threshold r The probability of a match;
[0039] Increase dimensionality to m +1, calculate and Distance less than or equal to r The number of them is denoted as , ; Calculate from the first wStarting from a subsequence, the others... m+ The distance between a 1-dimensional subsequence and it is less than or equal to a threshold r The number is denoted as ;
[0040] Calculate all average The average value Represent any two m +1 dimension sequence at threshold r The probability of a match;
[0041] Then the sample entropy Represented as:
[0042] ;
[0043] In the formula: m For sequence dimensions; N This represents the number of samples.
[0044] Furthermore, the reorganization of the corresponding modal components based on the sample entropy of each modal component specifically includes:
[0045] The number of samples contained in each modal component of different frequency features is defined as follows: N p Extracting the first from multiple different subsequences i Each sample component samp i Then we get N p The silhouette coefficient SC of each sample Np Represented as:
[0046] ;
[0047] in, i Represents positive integers, 1 ≦ i ≦ N p ; a i Indicates a specific sample samp i The average distance between the sample and other similar samples; b i For the sample samp i The average distance between the sample points of different categories that exclude themselves;
[0048] according to N p The silhouette coefficients of each sample are recombined using a weighted average method across all modal components of the same cluster. The energy of each modal component is defined as: ;
[0049] For each cluster group Normalized weights are calculated based on energy: ;in, j It is a positive integer. It is the first k The energy of each modal component It is the first i Energy of each modal component; This represents the modal component in its respective cluster group. Weight within;
[0050] The recombined modal components are then represented as follows: .
[0051] The present invention also includes an office building energy consumption prediction system, comprising:
[0052] The data acquisition module is used to collect the load sequences of different energy-using equipment in the current office building;
[0053] The graph structure construction module is used to decompose the load sequence of different energy-using devices into multiple modal components, calculate the sample entropy of each modal component, reorganize the corresponding modal components based on the sample entropy of each modal component, use each reorganized modal component as a node, use dynamic time warping to calculate the temporal similarity between each modal component, use the temporal similarity as the edge between nodes, and construct the graph structure.
[0054] The prediction module is used to input the graph structure into the GCN-Transformer model, extract the spatial features of the nodes in the graph structure using the graph convolution operation of the Graph Convolutional Network (GCN), input the spatial features of the nodes into the Transformer model, and extract the temporal features of the spatial features by introducing a self-attention mechanism to obtain the spatiotemporal features. By inputting the spatiotemporal features into the fully connected layer, the predicted energy consumption value for a future period of time is obtained.
[0055] This invention provides a method for predicting energy consumption in office buildings, which has the following beneficial effects:
[0056] This invention models the collaborative energy consumption relationships between modal components using a computational graph convolutional network (GCN). It reorganizes the modal components based on sample entropy, treating each reorganized modal component as a node in a graph structure. Dynamic time warping is used to calculate the temporal similarity between modal components, ensuring the model can automatically identify implicit associations and thus enhance its ability to predict future energy consumption trends. Graph convolution operations are used to extract spatial features between nodes, effectively capturing the collaborative energy consumption relationships between modal components. This spatial modeling capability enables the model to identify complex associations between different modal components. Simultaneously, the Transformer model enhances its temporal dependency modeling capability through its self-attention mechanism, enabling it to globally focus on long-term trends and periodic changes in historical load data, thereby better capturing long-range dependencies in energy consumption sequences. This combination of spatial and temporal features allows the model to more comprehensively capture the multi-scale characteristics of energy consumption sequences. Especially when facing complex and variable energy consumption scenarios, the model can simultaneously consider spatial collaboration and temporal dependency, providing more accurate prediction results. Attached Figure Description
[0057] Figure 1 This is a flowchart of the office building energy consumption prediction method in an embodiment of the present invention;
[0058] Figure 2 This is a diagram of the Transformer model framework in an embodiment of the present invention. Detailed Implementation
[0059] The technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments.
[0060] This invention proposes an energy consumption prediction method for office buildings based on sequence component recombination (GCN-Transformer) using sample entropy. It decomposes loads with different power consumption principles into a set of modal components with typical spectral characteristics using analytical frequency division technology, and utilizes GCN to find the coordinated energy consumption relationship of each load group, thereby improving prediction accuracy. Figure 1 As shown, the method specifically includes the following steps:
[0061] S1, Data Acquisition.
[0062] Data Collection: Obtain energy consumption data, also known as time-series load data or load series, from energy monitoring systems, smart meters, or related energy management platforms. This data may include energy consumption values for electricity, gas, water, etc., at different time scales (e.g., hourly, daily, monthly). Ensure the data covers a sufficiently long time period to capture various patterns of change in energy consumption data.
[0063] S2, Data Preprocessing:
[0064] Data cleaning: Removing noise and missing values. For missing values, the mean can be used. filling( For data points, n (number of data points), or linear interpolation formula ( t For the time points corresponding to the missing values, and For adjacent time points, and Methods such as (data values at corresponding time points).
[0065] Data standardization: Min-Max standardization: ,in x The original data, and These are the minimum and maximum values in the dataset, respectively.
[0066] Z-score standardization: , It is the mean of the dataset. That is the standard deviation.
[0067] Data partitioning: The dataset is divided into training, validation and test sets in a ratio of 70%:15%:15% to ensure that the data distribution of each subset is similar.
[0068] S3. Sequence decomposition and recombination:
[0069] (1) Load sequence decomposition: The original energy consumption sequence is decomposed into multiple modal components with typical spectral characteristics using variational mode decomposition (VMD) technology. Variational mode decomposition is a signal processing method that can effectively improve the stationarity of time series with high complexity and strong nonlinearity, and decompose them into relatively stationary subsequences containing multiple different frequency scales.
[0070] Constructing a mathematical model for variational mode decomposition:
[0071] ;
[0072] in For each modal component, It is the first k One modal component; The center frequencies of each modal component are... It is the first k The center frequency corresponding to each mode; It is the Dirac function; K The number of decomposition levels; j 1 represents the imaginary unit; * represents the test paper operator; The original signal; k Represents a positive integer; in the specific solution process, the center frequency of each modal component is obtained through iterative calculation based on the principle of minimizing the sum of modal bandwidths, thereby achieving the separation of each modal component.
[0073] (2) By introducing a penalty factor and Lagrange multiplication operators This transforms the constrained problem into an unconstrained variational problem.
[0074] ;
[0075] In the formula For Lagrange multipliers, This is a penalty factor.
[0076] K is a key parameter in variational mode decomposition. A K value that is too small will lead to under-decomposition and mode confusion; conversely, a K value that is too large will lead to over-decomposition, generating redundant modes and increasing the computational burden of prediction. To improve the accuracy of K parameter settings, this invention proposes a mode number determination method based on center frequency. The rationality of K's value is evaluated by observing the change in the center frequency of newly generated components as the mode number K increases.
[0077] (3) Solve the variational mode decomposition model through iterative optimization; in each iteration, update And the center frequency, until convergence, to obtain the final result. and the corresponding center frequency.
[0078] (4) Sequence component reconstruction based on sample entropy: The number of modal components obtained from load sequence decomposition is usually large, and the modal components usually have a certain degree of similarity. Predicting each modal component separately will significantly increase the model training time cost and amplify the prediction error. Therefore, this invention introduces sample entropy (SE) to quantify the complexity of each modal component obtained from load sequence decomposition, and uses it as the basis for modal component reconstruction. When the number of samples is limited, the sample entropy of each modal component is calculated as follows:
[0079] Each modal component is composed of N A time series consisting of data points, with each modal component grouped into a set of dimensions according to its index. m vector subsequences: ,in, ;
[0080] Define vector subsequence With another vector subsequence Distance between It is the absolute value of the maximum difference among the corresponding elements of the two:
[0081] ;
[0082] In the formula, w Representing a subsequence The starting position index, s Represents another subsequence The starting position index (and w different);
[0083] For a given ,statistics and The distance between them is less than or equal to the similarity threshold. r of s ( , The number of ) and recorded as ;for , Defined as:
[0084] ;
[0085] Indicates from the first w Starting from a subsequence, how many other subsequences are there? m The distance between the dimensional subsequence and it is less than or equal to a threshold r;
[0086] Defined as:
[0087] ;
[0088] It is all The average value represents any two m dimensional sequence at threshold r The probability of a match;
[0089] Increase dimensionality to m +1, calculate and Distance less than or equal to r The number of them is denoted as ; Defined as:
[0090] ;
[0091] Indicates from the first w Starting from a subsequence, how many other subsequences are there? m+ The distance between a 1-dimensional subsequence and it is less than or equal to a threshold r;
[0092] definition for:
[0093] ;
[0094] It is all The average value represents any two m +1 dimension sequence at threshold r The probability of a match;
[0095] The sample entropy is then defined as:
[0096] ;
[0097] In the formula: m For sequence dimensions; N This represents the number of samples.
[0098] Based on the sample entropy calculation results, this invention introduces... K Mean clustering reorganizes the modal components. Due to the number of clusters... J The silhouette coefficient has a significant impact on the clustering effect. This invention uses the silhouette coefficient to evaluate the clustering effect of each component, and then selects the optimal number of clusters to ensure that the training time cost is reduced while improving the prediction accuracy. The silhouette coefficient ranges from [-1, 1], and the closer it is to 1, the better the clustering effect.
[0099] Assume that each modal component contains the following number of samples: N p Extracting the first modal component from multiple different modal components i (1≦) i ≦ N p ) sample components samp i ,but N p silhouette coefficients of each sample SC Np The calculation formula is as follows:
[0100] ;
[0101] In the formula: a i Indicates a specific sample samp i The average distance between the sample and other similar samples; b i For the sample samp i The average distance between the sample points and the sample points of different categories that exclude themselves.
[0102] according to Np The silhouette coefficients of each sample are recombined using a weighted average method across all modal components of the same cluster. The energy of each modal component is defined as: .
[0103] For each cluster group Normalized weights are calculated based on energy: ;in, It is the first k The energy of each modal component It is the first i Energy of each modal component; This represents the modal component within its class. Weights within.
[0104] The recombined modal components are then represented as follows: .
[0105] VMD (Virtual Dynamics Decomposition) effectively separates different modal components by adaptively determining the number of modalities, thereby capturing the multi-scale characteristics of energy consumption sequences. Sample entropy is calculated for each modal component to assess its complexity and randomness. Sample entropy is a metric for time series complexity and effectively distinguishes the characteristics of different modal components. Typically, the number of components obtained from load sequence decomposition is large, and these components often exhibit some similarity. Predicting each component separately would significantly increase model training time and amplify prediction errors. Therefore, sample entropy (SE) is introduced to quantify the complexity of different modal components obtained from load sequence decomposition, and this serves as the basis for modal component recombination. Based on the sample entropy calculation results, K-means clustering is introduced to recombine each modal component.
[0106] S4 and GCN-Transformer model construction:
[0107] Graph Convolutional Networks (GCNs) are used to extract load co-energy consumption features. In the real world, a large amount of data exhibits disordered arrangement and lacks a fixed temporal or spatial order, known as non-Euclidean structured data. Furthermore, different nodes may have different numbers of neighboring nodes, and each node may have a unique surrounding structure. Due to the unique structure of this data, traditional convolutional neural networks are no longer suitable for processing it. Graph Convolutional Neurons (GCNs) extract features by interacting with node information along the edges of the graph without disrupting the graph structure of the data, giving them a unique advantage in processing graph-structured data. The reconstructed modal components are input into the GCN model for prediction. GCNs are used to capture the co-energy consumption relationships between different modal components. By constructing a graph structure, the reconstructed modal components are used as nodes, and load relationships are used as edges. Graph convolution operations are then used to extract features between nodes.
[0108] Edge construction based on Dynamic Time Warping (DTW) is based on the core idea of measuring the temporal similarity between different modal components (IMFs). The DTW distance between any two IMFs is calculated; if the DTW distance between the two IMFs is less than a set threshold θ, an edge is constructed. The specific steps are as follows:
[0109] Let X and Y be two modal component sequences of length . T :
[0110] Calculate each time step i , j The Euclidean distance between them We obtain a cost matrix of size T×T.
[0111] Recursively calculate the DTW distance matrix:
[0112] ;
[0113] final DTW The distance is:
[0114] ;
[0115] The computation process of graph convolution operation can be represented as follows:
[0116] ;
[0117] In the formula: Indicates the first l The node feature matrix of the layer, i.e., the network in the th layer. l Layer node representation; Indicates the first l The layer's weight matrix is used to perform linear transformations on the nodes; The adjacency matrix of the graph has self-connections added to represent the connection relationships between nodes; It is a degree matrix, which is a matrix composed of the diagonal elements of the adjacency matrix A; It is an activation function.
[0118] Improving Time Dependency by Incorporating Transformer: The VMD-GCN load forecasting model primarily relies on GCN to learn the cooperative relationships between modal components (IMFs), but it has certain limitations in time series modeling. GCN mainly uses static adjacency matrices for feature propagation, which insufficiently utilizes temporal information, making it difficult to capture long-term load variation trends. Furthermore, it can only handle cooperative relationships between local modal components and cannot dynamically adjust the correlation between modal components, resulting in prediction results that are sensitive to short-term fluctuations and have limited ability to identify sudden abnormal loads. To address these issues, the Transformer is introduced. The Transformer model framework diagram is as follows: Figure 2 As shown, the model enhances its time-dependent modeling capabilities through a self-attention mechanism, enabling it to globally focus on historical load data. This overcomes the limitation of GCN, which can only learn local load relationships, thus more accurately predicting long-term trends and reducing errors caused by short-term fluctuations. Furthermore, the Transformer effectively captures long-range dependencies in the sequence, further improving prediction accuracy and making load forecasting more stable and reliable.
[0119] Calculate the similarity between modal components, and use Dynamic Time Warping (DTW) to calculate the temporal distance between modal components:
[0120] Let X and Y be two modal component sequences of length T: Calculate each time step i , j Euclidean distance between This yields a cost matrix of size T×T; where, Is sequence X in the th order? i The value of each time step; Is sequence Y in the th order? j The value of each time step;
[0121] For each point ( i , j ), calculate its minimum cumulative distance:
[0122] ;
[0123] in, Indicates moving from above to ( i , j The cumulative distance of ) Indicates moving from the left to ( i , j The cumulative distance; Indicates moving from the diagonal to ( i , j The cumulative distance of each point is calculated step by step. i ,j )of , until (T,T).
[0124] Then the sequence X and Y The DTW distance between them is:
[0125] .
[0126] Constructing the GCN spatial graph structure: Defining the graph Node set Representing each modal component, edge set Based on the similarity between modal components Build, if Less than the set threshold Then establish the edges; the adjacency matrix A is formed by... composition, Represented as:
[0127] ;
[0128] Construct the normalized Laplace matrix based on the adjacency matrix:
[0129] ;
[0130] in, For a degree matrix, its diagonal elements D ii Represents a node i The degree is expressed as .
[0131] The formula for calculating the GCN layer is:
[0132] ;
[0133] in, Indicates the first l The node feature matrix of the layer, i.e., the network in the th layer. l Layer node representation; Indicates the first l The layer's weight matrix is used to perform linear transformations on the nodes; It is an adjacency matrix of a graph structure, representing the connection relationships between nodes; It is a degree matrix, and it is an adjacency matrix. A A matrix composed of diagonal elements; It is an activation function; It is the feature matrix of the (l+1)th layer, which is the spatial feature extracted after passing through the GCN layer.
[0134] 4) Transformer extracts temporal features: After GCN processes spatial relationships, it outputs... The sequence is fed into a Transformer to extract time dependencies.
[0135] ;
[0136] in, It is a positional encoding.
[0137] ;
[0138] in, t This is the current time step (time index). d This represents the total dimension of the input features.
[0139] In a multi-head attention layer, the input features The query will be generated through linear transformation. ),key( ),value matrix: .
[0140] Then calculate the self-attention weights:
[0141] ;
[0142] Where: query matrix Key matrix Value matrix , For feature dimension, These are trainable parameters.
[0143] Use multi-head attention ( h (head), then parallel computing h Group attention output:
[0144] ;
[0145] in h It's the number of heads. It is a transformation matrix.
[0146] Residual connection:
[0147] ;
[0148] Feedforward networks:
[0149] ;in, W 1 represents the first-layer weight matrix. b 1 represents the first layer bias. W 2 represents the weight matrix of the second layer. b 2 represents the second layer bias.
[0150] The features obtained after passing through the feedforward network F and Perform residual joins, followed by layer normalization to obtain:
[0151] ;
[0152] Output: The final features extracted by the Transformer The data is fed into the fully connected layer for prediction, yielding future energy consumption forecasts. :
[0153] ;
[0154] in, It is an MLP network.
[0155] S5. Model Training and Prediction: The mean squared error (MSE) loss function is used to measure the error between the model's predicted values and the actual load values, and is defined as follows:
[0156] ;
[0157] in, These are the model's predicted values. This represents the actual load value. This represents the number of samples.
[0158] To prevent model overfitting, at the same time, Regularization constraint model, defining regularization terms:
[0159] ;in, This is the regularization coefficient.
[0160] The final total loss function consists of mean squared error loss and Composition of regularization terms:
[0161] ;in, This represents the weight of the regularization term in the total loss.
[0162] The model is trained using the training set data, and the model parameters are iteratively adjusted to minimize the loss function. In each iteration, the gradient of the loss function with respect to the model parameters is calculated, and the parameters are updated using the optimizer.
[0163] Model performance evaluation: The trained model is applied to the test set to make predictions for each time series sample in the test set. This yields predicted energy consumption values for a future period (e.g., the next 24 hours or the next week). Multiple performance metrics are calculated, including but not limited to:
[0164] Mean Absolute Error (MAE) is used to evaluate the average absolute deviation between predicted and actual values.
[0165] .
[0166] in, For the first i Predicted values at each time point For the first i The actual value at each point in time.
[0167] The root mean square error (RMSE) penalizes large errors more severely and better reflects the overall level of prediction error.
[0168] .
[0169] Mean Absolute Percentage Error (MAPE) expresses prediction error as a percentage, making it easier to intuitively understand the degree of error.
[0170] .
[0171] By comparing the model's performance metrics (such as mean square error MSE, mean absolute error MAE, and coefficient of determination R²) under different building types (such as office buildings, shopping malls, and residences) and different time scales (such as hours, days, and months), we can analyze its performance in different scenarios.
[0172] To visually demonstrate the model's predictive accuracy, a comparison chart of actual and predicted energy consumption can be plotted. A line graph can be used to show the trends of both over time, observing the match between predicted and actual values. Simultaneously, a scatter plot can be used to illustrate the relationship between actual and predicted values, with a y=x reference line added to assess the degree of deviation in the predictions. Furthermore, areas with significant errors should be marked on the graph, and possible causes, such as anomalies or data noise, should be analyzed. Further, statistical analysis of the prediction errors should be performed to evaluate the model's reliability. A 95% confidence interval should be calculated to measure the range of fluctuation in prediction errors, and the distribution of errors (e.g., normal or skewed distribution) should be analyzed to determine if the model has systematic biases (e.g., persistent overestimation or underestimation). Additionally, statistical indicators of the errors (e.g., mean, standard deviation, skewness, kurtosis) should be calculated to more precisely quantify the model's predictive performance, providing a basis for model optimization.
[0173] The effects that this invention can achieve:
[0174] (1) Extracting load coordination relationship features: The coordinated energy consumption relationship between modal components is modeled using a graph convolutional network (GCN). Each modal component is regarded as a node in a graph structure, and the temporal similarity between modal components is calculated through dynamic time warping (DTW) to construct an adjacency matrix, ensuring that the model can automatically identify the implicit correlation between modal components. This enhances the ability to predict future energy consumption trends. Traditional energy consumption prediction methods are usually based on fixed-window time series modeling, which makes it difficult to dynamically adjust the relationship between modal components. However, GCN, through adaptive learning of the graph structure, can adjust the load coordination relationship in different time periods and different building usage scenarios, improve the model's generalization ability, and make the prediction more stable and accurate.
[0175] (2) Integration of Spatial and Temporal Features: The combination of Graph Convolutional Networks (GCN) and the Transformer model enables comprehensive modeling of the spatial collaborative relationships and temporal dependencies of modal components. GCN constructs a graph structure, using different modal components as nodes and temporal similarity as edges, and extracts spatial features between nodes using graph convolution operations, effectively capturing the collaborative energy consumption relationships between modal components. This spatial modeling capability enables the model to identify complex associations between different modal components, such as the mutual influence between air conditioning, lighting, and equipment power consumption. At the same time, the Transformer model enhances its temporal dependency modeling capability through its self-attention mechanism, enabling it to globally focus on long-term trends and periodic changes in historical load data. The self-attention mechanism allows the model to dynamically allocate weights, focusing on the historical time points most important for the current prediction, thereby better capturing the long-range dependencies in the energy consumption sequence. This combination of spatial and temporal features enables the model to capture the multi-scale characteristics of energy consumption sequences more comprehensively. This dual modeling capability significantly improves the stability and reliability of predictions, especially when facing complex and variable energy consumption scenarios. The model can simultaneously take into account spatial coordination and temporal dependence, thereby providing more accurate prediction results.
[0176] (3) Reducing computational complexity: Traditional energy consumption prediction methods typically require modeling each modal component separately. Especially after using techniques such as Variational Mode Decomposition (VMD) to decompose the original energy consumption sequence into multiple components, the model needs to process the features and prediction tasks of each component separately. This component-by-component processing not only leads to a significant increase in computational load but also significantly prolongs model training time, especially when facing large-scale energy consumption data, where the consumption of computational resources and training efficiency issues are particularly prominent. To address this problem, this invention innovatively introduces sample entropy to quantify the complexity of different modal components obtained from load sequence decomposition. Sample entropy can effectively measure the randomness and complexity of time series, thereby distinguishing the characteristics of different modal components. By calculating the sample entropy of each component, the model can identify modal components with similar complexity or characteristics, and then use the K-means clustering algorithm to recombine these components. This sample entropy-based clustering and recombination method reduces the number of modal components that need to be modeled separately, thereby further optimizing the model's efficiency and making the prediction process more efficient.
[0177] (4) Improved Model Generalization Ability: By introducing regularization terms and dynamic time warping (DTW), the model's overfitting problem is effectively prevented, thus improving its generalization ability from different perspectives. First, by adding an L2 regularization term to the loss function, the model can constrain the growth of parameters and avoid overfitting caused by excessively large parameter values. Second, the correlation between modal components is dynamically adjusted using DTW, further enhancing the model's generalization ability. DTW measures the temporal similarity between different modal components, flexibly capturing the dynamic relationship between modal components, rather than relying solely on a fixed time alignment method. This method is particularly suitable for processing energy consumption data with nonlinear time shifts, thereby reducing the impact of outlier data on prediction results.
[0178] (5) Dynamically adjust the correlation of modal components: This invention uses dynamic time warping (DTW) to construct a graph structure to dynamically measure the temporal similarity between different modal components. By setting a threshold θ, the model can automatically adjust the correlation between different modal components according to their similarity, making feature extraction more accurate and effectively avoiding the limitations of fixed correlation settings.
[0179] The advantage of this invention lies in its enhanced ability to identify sudden abnormal loads, especially in scenarios with large load fluctuations, such as office buildings. It can effectively cope with sudden changes in energy consumption caused by factors such as meetings, concentrated startup of office equipment, or temporary increases or decreases in personnel. In addition, this dynamic adjustment mechanism enables the model to respond quickly to sudden load changes, avoiding a decline in predictive performance due to short-term drastic fluctuations, and improving the overall robustness and stability of predictions.
[0180] Based on the same inventive concept, this invention also proposes an energy consumption prediction system for office buildings, comprising:
[0181] The data acquisition module is used to collect the load sequences of different energy-using equipment in the current office building.
[0182] The graph structure construction module is used to decompose the load sequence of different energy-using devices into multiple modal components, calculate the sample entropy of each modal component, reorganize the corresponding modal components based on the sample entropy of each modal component, use each reorganized modal component as a node, use dynamic time warping to calculate the temporal similarity between each modal component, and use the temporal similarity as the edge between nodes to construct the graph structure.
[0183] The prediction module is used to input the graph structure into the GCN-Transformer model, extract the spatial features of the nodes in the graph structure using the graph convolution operation of the Graph Convolutional Network (GCN), input the spatial features of the nodes into the Transformer model, and extract the temporal features of the spatial features by introducing a self-attention mechanism to obtain the spatiotemporal features. By inputting the spatiotemporal features into the fully connected layer, the predicted energy consumption value for a future period of time is obtained.
[0184] The above description is only a preferred embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any equivalent substitutions or modifications made by those skilled in the art within the scope of the technology disclosed in the present invention, based on the technical solution and inventive concept of the present invention, should be covered within the scope of protection of the present invention.
Claims
1. A method for predicting energy consumption in office buildings, characterized in that, Includes the following steps: Collect the load sequences of different energy-using equipment in the current office building; The load sequence of different energy-using equipment is decomposed into multiple modal components, and the sample entropy of each modal component is calculated. Based on the sample entropy of each modal component, the corresponding modal components are recombined. Each recombined modal component is used as a node, and the temporal similarity between each modal component is calculated using dynamic time warping. The temporal similarity is used as the edge between nodes to construct a graph structure. The calculation of the sample entropy for each modal component specifically includes the following steps: grouping each modal component into a set of components with the following dimensions according to their ordinal numbers. m vector subsequences: ,in, Each modal component is composed of N A time series composed of data; define a vector subsequence. With another vector subsequence Distance between It is the absolute value of the maximum difference among the corresponding elements of the two; where, w Representing a subsequence The starting position index, s Represents another subsequence The starting position index; for a given ,statistics and The distance between them is less than or equal to the similarity threshold. r of s The number, and recorded as , , ;for From the first w Starting from a subsequence, others m The distance between the dimensional subsequence and the threshold is less than or equal to the threshold. r The number is defined as ; Calculate all average The average value Represent any two m dimensional sequence at threshold r The probability of a match; increasing the dimension to m +1, calculate and Distance less than or equal to r The number of them is denoted as , ; Calculate from the first w Starting from a subsequence, the others... m+ The distance between a 1-dimensional subsequence and it is less than or equal to a threshold r The number is denoted as ; Calculate all average The average value Represent any two m +1 dimension sequence at threshold r The probability of a match; then the sample entropy. Represented as: In the formula: m For sequence dimensions; N The sample size is defined as follows: Based on the sample entropy of each modal component, the corresponding modal components are recombined, specifically including: defining the sample size contained in each modal component with different frequency features as... N p Extracting the first from multiple different subsequences i Each sample component samp i Then we get N p The silhouette coefficient SC of each sample Np Represented as: ;in, i Represents positive integers, 1 ≦ i ≦ N p ; a i Indicates a specific sample samp i The average distance between the sample and other similar samples; b i For the sample samp i The average distance between the sample points of different categories excluding itself; according to N p The silhouette coefficients of each sample are recombined using a weighted average method across all modal components of the same cluster. The energy of each modal component is defined as: For each cluster group Normalized weights are calculated based on energy: ;in, j It is a positive integer. It is the first k The energy of each modal component It is the first i Energy of each modal component; This represents the modal component in its respective cluster group. The weights within the range are then used to obtain the recombined modal components, which are expressed as follows: ; The graph structure is input into the GCN-Transformer model, and the spatial features of the nodes in the graph structure are extracted using the graph convolution operation of the GCN. The spatial features of the nodes are then input into the Transformer model, and the temporal features of the spatial features are extracted by introducing a self-attention mechanism to obtain the spatiotemporal features. By inputting the spatiotemporal features into the fully connected layer, the predicted energy consumption value for a future period of time is obtained.
2. The method for predicting energy consumption in office buildings according to claim 1, characterized in that, The similarity between modal components is obtained through dynamic time warping (DTW). Specifically, it includes the following steps: Define X and Y as two modal component sequences of length . T : Calculate each time step i , j Euclidean distance between This yields a cost matrix of size T×T; where, x i Is sequence X in the th order? i The value of each time step; y j Is sequence Y in the th order? j The value of each time step; For each point ( i , j ), calculate its minimum cumulative distance: ; in, Indicates moving from above to ( i , j The cumulative distance of ) Indicates moving from the left to ( i , j The cumulative distance; Indicates moving from the diagonal to ( i , j The cumulative distance of each point is calculated step by step. i , j )of ,until ; Then the sequence between X and Y is obtained. DTW The distance is: .
3. The method for predicting energy consumption in office buildings according to claim 2, characterized in that, The method of extracting spatial features of nodes in a graph structure using graph convolution operations of a graph convolutional network (GCN) is expressed as follows: ; in, Indicates the first l The node feature matrix of the layer; Indicates the first l The layer's weight matrix is used to perform linear transformations on the nodes; It is a degree matrix, which is a matrix composed of the diagonal elements of the adjacency matrix A; It is an activation function; the adjacency matrix A is... composition, Represented as: ;in, To set a threshold; For Laplace matrix, .
4. The method for predicting energy consumption in office buildings according to claim 3, characterized in that, The process of inputting the spatial features of nodes into the Transformer model and extracting the temporal features of these spatial features by introducing a self-attention mechanism specifically includes the following steps: Output Extracting temporal dependencies from the input Transformer: Since the Transformer requires location information, the input sequence of the Transformer is represented as follows: ,in , It is a positional encoding, represented as: , t For the current time step, d The total dimension of the input features; In a multi-head attention layer, the input features Generate query, key, and value matrices through linear transformations; Calculate the self-attention weights based on the query, key, and value matrix, and then compute the multi-head attention output in parallel based on these weights. ; The multi-head attention output is residually concatenated with the input sequence to obtain features. ; Will The input is processed in a feedforward network to obtain features. ; The obtained features and After residual connections and layer normalization, the final temporal features extracted by the Transformer are obtained. .
5. The method for predicting energy consumption in office buildings according to claim 1, characterized in that, The load sequence is decomposed into multiple modal components using variational mode decomposition, which includes the following steps: Constructing a mathematical model for variational mode decomposition: ; in For each modal component, It is the first k One modal component; The center frequencies of each modal component are... It is the first k The center frequency corresponding to each mode; It is the Dirac function; K The number of decomposition layers; j 1 represents the imaginary unit; * represents the test paper operator; The original signal; k Represents positive integers; By introducing a penalty factor and Lagrange multiplication operators The mathematical model of variational mode decomposition is transformed into: ; In the formula For Lagrange multipliers, As a penalty factor; The variational mode decomposition model is solved through iterative optimization; in each iteration, the model is updated. And the center frequency, until convergence, to obtain the final result. and the corresponding center frequency.
6. An energy consumption prediction system for office buildings, characterized in that, include: The data acquisition module is used to collect the load sequences of different energy-using equipment in the current office building; The graph structure construction module is used to decompose the load sequence of different energy-using devices into multiple modal components, calculate the sample entropy of each modal component, reorganize the corresponding modal components based on the sample entropy of each modal component, use each reorganized modal component as a node, use dynamic time warping to calculate the temporal similarity between each modal component, use the temporal similarity as the edge between nodes, and construct the graph structure. The calculation of the sample entropy for each modal component specifically includes the following steps: grouping each modal component into a set of components with the following dimensions according to their ordinal numbers. m vector subsequences: ,in, Each modal component is composed of N A time series composed of data; define a vector subsequence. With another vector subsequence Distance between It is the absolute value of the maximum difference among the corresponding elements of the two; where, w Representing a subsequence The starting position index, s Represents another subsequence The starting position index; for a given ,statistics and The distance between them is less than or equal to the similarity threshold. r of s The number, and recorded as , , ;for From the first w Starting from a subsequence, others m The distance between the dimensional subsequence and the threshold is less than or equal to the threshold. r The number is defined as ; Calculate all average The average value Represent any two m dimensional sequence at threshold r The probability of a match; increasing the dimension to m +1, calculate and Distance less than or equal to r The number of them is denoted as , ; Calculate from the first w Starting from a subsequence, the others... m+ The distance between a 1-dimensional subsequence and it is less than or equal to a threshold r The number is denoted as ; Calculate all average The average value Represent any two m +1 dimension sequence at threshold r The probability of a match; then the sample entropy. Represented as: In the formula: m For sequence dimensions; N The sample size is defined as follows: Based on the sample entropy of each modal component, the corresponding modal components are recombined, specifically including: defining the sample size contained in each modal component with different frequency features as... N p Extracting the first from multiple different subsequences i Each sample component samp i Then we get N p The silhouette coefficient SC of each sample Np Represented as: ;in, i Represents positive integers, 1 ≦ i ≦ N p ; a i Indicates a specific sample samp i The average distance between the sample and other similar samples; b i For the sample samp i The average distance between the sample points of different categories excluding itself; according to N p The silhouette coefficients of each sample are recombined using a weighted average method across all modal components of the same cluster. The energy of each modal component is defined as: For each cluster group Normalized weights are calculated based on energy: ;in, j It is a positive integer. It is the first k The energy of each modal component It is the first i Energy of each modal component; This represents the modal component in its respective cluster group. The weights within the range are then used to obtain the recombined modal components, which are expressed as follows: ; The prediction module is used to input the graph structure into the GCN-Transformer model, extract the spatial features of the nodes in the graph structure using the graph convolution operation of the Graph Convolutional Network (GCN), input the spatial features of the nodes into the Transformer model, and extract the temporal features of the spatial features by introducing a self-attention mechanism to obtain the spatiotemporal features. By inputting the spatiotemporal features into the fully connected layer, the predicted energy consumption value for a future period of time is obtained.
Citation Information
Patent Citations
Air pollutant concentration prediction method and related equipment thereof
CN119474762A