Building energy consumption prediction method and monitoring prediction system based on WGAN algorithm

Through the building energy consumption prediction method based on the WGAN algorithm, the variational autoencoder and the XGBoost algorithm are used to extract and screen energy consumption features, combined with reinforcement learning to optimize the hyperparameters, and establish a generative adversarial network model to solve the problem of urban public building energy consumption monitoring and prediction. solve the problem and achieve more stable and accurate energy consumption prediction.

CN111178626BActive Publication Date: 2024-10-25SUZHOU UNIV OF SCI & TECH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN201911387967.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2019-12-30
Publication Date
2024-10-25
Estimated Expiration
2039-12-30

AI Technical Summary

Technical Problem

Existing technology makes it difficult to effectively monitor and predict the energy consumption of urban public buildings, making it difficult to take energy-saving measures.

Method used

A building energy consumption prediction method based on the WGAN algorithm is adopted. By obtaining building energy consumption data and feature data, a variational autoencoder is used to extract advanced features, and combined with the XGBoost algorithm for feature screening, a GAN prediction model is established, and reinforcement learning is used to optimize hyperparameters. , and finally perform energy consumption prediction through a generative adversarial network model.

Benefits of technology

It improves the performance and speed of the energy consumption prediction model, enhances the stability and accuracy of the prediction, and makes full use of the close connection and interaction between data.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN111178626B_ABST
    Figure CN111178626B_ABST
Patent Text Reader

Abstract

The present invention relates to a building energy consumption prediction method and monitoring prediction system based on WGAN algorithm. It mainly collects the energy consumption data of the building and the related energy consumption characteristic data, uses the variational autoencoder to extract the high-level features, and detects the feature importance through the extreme gradient enhancement algorithm. Then all the energy consumption characteristics obtained are input into the generative adversarial network model for training, and the hyperparameters in the model are optimized by the reinforcement learning algorithm, and finally a prediction model is obtained for predicting the building energy consumption. The energy consumption prediction method of the present invention not only improves the performance and speed of model training, but also makes full use of the close connection and interaction between various data, so that the prediction model is more stable and accurate.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of building energy consumption monitoring and prediction, and in particular to a building energy consumption prediction method and a monitoring and prediction system based on a WGAN algorithm. Background Art

[0002] At present, with the rapid development of economy and the continuous advancement of urbanization, people's living standards are constantly improving. The utilization rate of urban public buildings is constantly increasing. The scale of electricity, fresh water and gas consumed by urban public buildings in the operation process is also increasing. Therefore, it is urgent to monitor the building energy consumption data and related data, and use these data to predict the future building energy consumption, so as to take necessary measures according to the predicted values ​​to achieve the purpose of energy saving. Summary of the invention

[0003] Based on this, the present invention provides a building energy consumption prediction method based on the WGAN algorithm. The method is conducive to predicting future building energy consumption values, so as to take necessary measures according to the predicted building energy consumption values ​​to achieve the purpose of energy saving.

[0004] A building energy consumption prediction method based on WGAN algorithm, comprising:

[0005] S100, obtain building energy consumption data and building energy consumption characteristic data set R d ,in,

[0006] R d ={(x 11 ,x 12 ,x 13 ......x 1j ),(x 21 ,x 22 ,x 23 ......x 2j )......(x i1 ,x i2 ,x i3 ......x ij )},d represents

[0007] Number of features, x ij Represents a feature, subscript i represents the i-th sample, i∈N*, j represents the j-th feature, j∈N*;

[0008] S200, R d Input variational autoencoder to obtain high-level energy consumption feature dataset R g , the building energy consumption characteristic data set R in step S100 d and advanced energy consumption feature dataset R g Merge to form the input feature dataset Rr ;

[0009] S300, R r Feature screening through XGBoost algorithm;

[0010] S400, establish a GAN prediction model, and convert the R r Input the GAN prediction model and train the GAN prediction model through the WGAN algorithm. After completing one GAN prediction model training, use the reinforcement learning algorithm to optimize the hyperparameters in GAN, LSTM and CNN, find the best combination of hyperparameters and update them, and then enter the next GAN prediction model training until the optimal GAN ​​prediction model is obtained;

[0011] S500, predicting building energy consumption value through the optimal GAN ​​prediction model.

[0012] The above method collects the energy consumption data of the building and the related energy consumption characteristic data, uses the variational autoencoder to extract high-level features, and detects the importance of features through the extreme gradient enhancement algorithm. Then all the energy consumption features obtained are input into the generative adversarial network model for training, and the hyperparameters in the model are optimized by the reinforcement learning algorithm, and finally a prediction model is obtained for predicting the energy consumption of the building. The energy consumption prediction method of the present invention not only improves the performance and speed of model training, but also makes full use of the close connection and interaction between various data, making the prediction model more stable and accurate.

[0013] In one embodiment, in step S200, R d Input variational autoencoder to obtain high-level energy consumption feature dataset R g , specifically including:

[0014] S210, construct an encoder Encoder and a decoder Decoder;

[0015] S220, the real energy consumption characteristic data x∈R d Input the encoder to obtain the mapping output z of x, and the actual output is the distribution function of z

[0016] S230, calculating the encoder's objective function KL according to the output of step S220;

[0017] S240, obtain sampling z~N(μ(x),σ 2 (x));

[0018] S250, input z into the decoder to obtain the mapping output f(z) of z. Since the values ​​of each dimension have different

[0019] The same variance, so the actual mapping output is f(z) = (μ,σ 2 );

[0020] S260, calculating the objective function L of the decoder according to the output of step S250;

[0021] S270, adding KL and L to obtain a total target loss function, and optimizing the total target loss function;

[0022] S280, after training is complete, skip the last layer of the decoder when creating the output, thereby obtaining a higher-level feature sequence R g , that is, the advanced energy consumption feature dataset R g .

[0023] In one embodiment, the encoder and decoder both use convolutional networks, and the encoder and decoder have 4 dense layers, with 300 neurons in each layer.

[0024] The encoder objective function KL is specifically defined as:

[0025]

[0026] where G is the dimension of z,

[0027] The sampling z~N(μ(x),σ 2 (x)) includes: the new input generates samples ε~N(0,1) from the standard Gaussian distribution, and defines z=μ(x)+σ(x)*ε,

[0028] The objective function L of the decoder is the log-likelihood with mean μ and variance σ as parameters, defined as:

[0029]

[0030] In one embodiment, in step S300, R r Feature screening is performed through the XGBoost algorithm, including:

[0031] S310, daily building energy consumption forecast Initialized to 0, the actual value of daily building energy consumption is y i ;

[0032] S320, define the objective function: O bj(t);

[0033] S330, calculate the derivative g of the objective function for each sample prediction value i and h i ;

[0034] S340, using the greedy algorithm to build a new decision tree f based on the derivative information t (x);

[0035] S350, using the new decision tree f t (x) Predict a new building energy consumption value and add the newly predicted building energy consumption value to Up to update

[0036] S360, repeating steps S330 to S350;

[0037] S370, calculating the number of times different features participate in the separation decision tree as their feature importance index, and screening important features.

[0038] In one embodiment,

[0039] The objective function is specifically defined as: in f t (x) is the modeling function of the tree, T is the number of leaf nodes, w is the leaf weight value, γ is the leaf tree penalty regularization term, set to 40, λ is the leaf weight penalty regularization term, set to 3, w j represents the jth feature weight;

[0040] The greedy algorithm builds a new decision tree based on the gain formula:

[0041]

[0042] The new decision tree f t (x) Predict a new building energy consumption value and add the newly predicted building energy consumption value to Specifically:

[0043] Where ε is the shrinkage coefficient, which is set to 0.1.

[0044] In one embodiment,

[0045] In step S400, a GAN prediction model is established, and R r Input the GAN prediction model and train the GAN prediction model through the WGAN algorithm, including:

[0046] S401, construct a generator G and a discriminator D;

[0047] S402, define the loss function G_loss of the generator and the loss function D_loss of the discriminator;

[0048] S403, from the real energy consumption data sample Rr Take a sample x i , sample z from the noise variable distribution i ;

[0049] S404, calculating the discriminator loss D_loss;

[0050] S405, updating the discriminator parameter w according to a momentum-based optimization algorithm (momentum Adam);

[0051] S406, truncating the absolute value of the discriminator parameter to no more than a fixed constant c through a truncation function;

[0052] S407, repeat steps S403 to S406, and set the number of cycles;

[0053] S408. Sample z from the noise variable distribution i , calculate the generator loss G_loss;

[0054] S409, updating the generator parameter θ according to the momentum-based optimization algorithm (momentum Adam);

[0055] S410, repeat steps S402 to S409 until the generator parameters remain unchanged and the model training is completed;

[0056] S411, use the sampling result x0 of the real energy consumption sample as the initial value of the state link, that is, x k ;

[0057] S412, using 10% of the energy consumption training data as a random test set, and adjusting the discriminator D using the rank-preserving regression method;

[0058] S413, generate k random noise input generators G, generate K samples, and select a sample x' from K in turn;

[0059] S414, sampling U from uniform distribution U~N(0,1);

[0060] S415, the previously selected sample is x k , calculate the acceptance probability of the new sample x'

[0061] S416, if U≤α, accept the current sample, that is, update x k is x';

[0062] S417, repeat steps S413 to S416, the number of cycles is K times;

[0063] S418, if x kIf it is a true sample x0, restart sampling from the generated sample, otherwise output the current predicted energy consumption value.

[0064] In one embodiment,

[0065] The generator uses a long short-term memory neural network LSTM and uses Xavier initialization. The input of LSTM is the collected and generated energy consumption features, which then enter 500 hidden units and are converted into a single output as a predicted energy consumption value. The sequence step parameter is set to 14, that is, 14 days of data are used to predict the 15th day; the discriminator uses a convolutional neural network CNN,

[0066] The generator loss function G_loss is specifically defined as The discriminator loss function is specifically defined as Where f needs to satisfy the Lipschitz constant restriction, w is the parameter of the discriminator neural network,

[0067] The K is a hyperparameter, and its adjustment can make a trade-off between speed and confidence. For a perfect discriminator, K approaches infinity, that is, the distribution of D is perfectly close to the real data distribution.

[0068] The D(x) is the discriminator score, which is specifically defined as:

[0069] In one embodiment, after completing one GAN prediction model training in step S400, the hyperparameters in GAN, LSTM and CNN are optimized using a reinforcement learning algorithm, the best combination of hyperparameters is found and updated, and then the next GAN prediction model training is started until the optimal GAN ​​prediction model is obtained, specifically:

[0070] S501. The hyperparameter set θ tracked and optimized includes:

[0071] batch_size: The batch size of LSTM and CNN,

[0072] cnn_lr: learning rate of CNN,

[0073] strides: strides in CNN,

[0074] padding: padding in CNN,

[0075] kernel_size: kernel size in CNN,

[0076] dropout: dropout in LSTM,

[0077] filters: the initial number of filters;

[0078] S502, initialize hyperparameter set θ, target hyperparameter θ - =θ, initialize the replay buffer

[0079] S503, initializing the hyperparameter grid Λ and setting the initial state value S0;

[0080] S504, determine the next action a t ;

[0081] S505: Set reward function R and obtain reward r t ;

[0082] S506, obtain the next state value S t+1 =τ(s t ,λ t ,r t ), where λ t Hyperparameter configuration for the latest evaluation;

[0083] S507, and (s t ,s t+1 ,a t ,r) Add to the replay buffer Φ;

[0084] S508, randomly sample B from the replay buffer Φ = {(s,a,Q(s,s',a,r))|(s,s',a,r)~Unif(Φ)};

[0085] S509, B updates the optimal value function Q*, obtains the next hyperparameter set θ', and updates θ=θ';

[0086] S510, repeat steps S504 to S508, and specify the number of times N per cycle u Update θ - =θ,N u is the update frequency;

[0087] S511, repeat steps S503 to S509, the number of times being the product of the size of each training data set and the number of data sets;

[0088] S512: Obtain a new hyperparameter set θ.

[0089] In one embodiment,

[0090] Set the initial state value S0, which is specifically defined as:

[0091] S0=(metafeatures(D),({0} dim(Λ) ,0)),D~Unif(D*),

[0092] Where D* is the training data set,

[0093] The decision of the next action a t , where a t The specific definition is:

[0094]

[0095] The reward function is specifically set to:

[0096] R=2*G_loss+D_loss+G_accuracy,

[0097] Among them, G_loss is the loss of the generator, G_accuracy is the accuracy of the generator, and D_loss is the loss of the discriminator.

[0098]

[0099] The optimal value function Q* is updated by B, and the next hyperparameter set θ' is obtained, and θ=θ' is updated, specifically according to the formula:

[0100]

[0101] A building energy consumption monitoring and prediction system, comprising: an energy consumption real-time data acquisition module, an environmental data acquisition module, a data communication module, an information processing module, a server, a display, a human-computer interaction module and an information storage module;

[0102] The environmental data acquisition module includes: a temperature and humidity sensor for monitoring indoor temperature and humidity, a carbon dioxide sensor for monitoring indoor carbon dioxide concentration, a gas sensor for monitoring indoor flammable gas concentration, an atmospheric pressure sensor for measuring atmospheric pressure, a light intensity sensor and a microcontroller, wherein the temperature and humidity sensor, the carbon dioxide sensor, the gas sensor, the atmospheric pressure sensor and the light intensity sensor are respectively connected to the microcontroller;

[0103] The energy consumption real-time data acquisition module and the microcontroller are respectively connected to the data communication module;

[0104] The data communication module is connected to the information processing module, the information processing module is connected to the server, and the server is connected to the information storage module, the display and the human-computer interaction module;

[0105] The server stores at least one executable instruction, and the executable instruction enables the server to execute operations corresponding to the building energy consumption prediction method.

[0106] In one embodiment, the energy consumption real-time data collection module is a building energy consumption collector, and the building energy consumption collector is connected to the energy consumption meter via an RS485 bus.

[0107] In one embodiment, the microcontroller is a STC15F2K60S2 single chip microcomputer.

[0108] In one of the embodiments, the temperature and humidity sensor is a DHT11 sensor.

[0109] In one embodiment, the gas sensor is an MQ-9 sensor.

[0110] In one of the embodiments, the light intensity sensor is a TSL2561 sensor.

[0111] In one embodiment, the atmospheric pressure sensor is a BMP180 sensor.

[0112] In one embodiment, the carbon dioxide sensor is a MG811 sensor.

[0113] In one embodiment, the human-computer interaction module is a keyboard and a mouse.

[0114] In one embodiment, the information processing module is a third generation Raspberry Pi. BRIEF DESCRIPTION OF THE DRAWINGS

[0115] Figure 1 The present invention is a flowchart of a method for predicting building energy consumption based on the WGAN algorithm.

[0116] Figure 2 This is a schematic diagram of a building energy consumption prediction method based on a WGAN algorithm according to an embodiment of the present invention.

[0117] Figure 3 Schematic diagram of the WGAN algorithm according to an embodiment of the present invention.

[0118] Figure 4 Schematic diagram of a hyperparameter optimization method according to an embodiment of the present invention.

[0119] Figure 5 Schematic diagram of a building energy consumption monitoring and prediction system according to an embodiment of the present invention.

[0120] Figure 6 This is a schematic diagram of the connection between a building energy consumption collector and an electricity meter, a water meter, and a gas meter according to an embodiment of the present invention. DETAILED DESCRIPTION

[0121] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, the specific embodiments of the present invention are described in detail below in conjunction with the accompanying drawings. In the following description, many specific details are set forth to facilitate a full understanding of the present invention. However, the present invention can be implemented in many other ways different from those described herein, and those skilled in the art can make similar improvements without violating the connotation of the present invention, so the present invention is not limited by the specific embodiments disclosed below.

[0122] It should be noted that when an element is referred to as being "fixed to" another element, it may be directly on the other element or there may be an intermediate element. When an element is considered to be "connected to" another element, it may be directly connected to the other element or there may be an intermediate element at the same time.

[0123] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art of the present invention. The terms used herein in the specification of the present invention are only for the purpose of describing specific embodiments and are not intended to limit the present invention. The term "and / or" used herein includes any and all combinations of one or more related listed items.

[0124] like Figures 1 to 3 As shown, an embodiment of the present invention provides a building energy consumption prediction method based on the WGAN algorithm, the method comprising the following steps:

[0125] S100, obtain building energy consumption data and building energy consumption characteristic data set R d ,in,

[0126] R d ={(x 11 ,x 12 ,x 13 ......x 1j ),(x 21 ,x 22 ,x 23 ......x 2j )......(x i1 ,x i2 ,x i3 ......x ij )}, d represents the number of features, x ij Represents a feature, subscript i represents the i-th sample, i∈N*, j represents the j-th feature, j∈N*. N* represents a positive integer.

[0127] It should be noted that the “average of data from multiple similar time points” method can be used to fill in the missing data at individual time points.

[0128] It should be noted that the above building energy consumption data can be the energy consumption data of electricity consumption, water consumption, gas consumption, or comprehensive energy consumption data. Comprehensive energy consumption data can be calculated according to the general rules for comprehensive energy consumption calculation stipulated by the state, that is, various energy consumption is converted into primary energy, and the unit is standard coal equivalent.

[0129] The above building energy consumption characteristic dataset includes the building energy consumption characteristics x ij It can be: indoor temperature and humidity, indoor carbon dioxide concentration, indoor flammable gas concentration, indoor atmospheric pressure or indoor light intensity, etc. For example, the data collected on the first day is (x 11 ,x 12 ,x 13 ,x 14 ,x 15 ,x 16 ), the data collected on the second day is (x 21 ,x 22 ,x 23 ,x 24 ,x 25 ,x 26 ), the data collected on the third day is (x 31 ,x 32 ,x 33 ,x 34 ,x 35 ,x 36 ), and so on. Among them, x 11 represents the indoor temperature, x 12 represents the indoor humidity, x 13 represents the indoor carbon dioxide concentration, x 14 Represents the indoor flammable gas concentration, x 15 represents the indoor atmospheric pressure, x 16 Represents the indoor light intensity.

[0130] Furthermore, the above-mentioned building energy consumption characteristic data may also include other types of data. For example: building function type, structure type, regional climate factors and equipment type quantity. The building function type and structure type are obtained through field research. The regional climate factors specifically include outdoor temperature, wind speed, precipitation, etc., which are obtained from the historical data of the weather station obtained from the Internet. The equipment type quantity is obtained through the building purchase equipment record.

[0131] S200, R d Input variational autoencoder to obtain high-level energy consumption feature dataset R g , the building energy consumption characteristic data set R in step S100 d and advanced energy consumption feature dataset R g Merge to form the input feature dataset Rr .

[0132] S300, R r Feature screening is performed using the XGBoost algorithm.

[0133] S400, establish a GAN prediction model, and convert the R r The GAN prediction model is input and trained by the WGAN algorithm. After completing one GAN prediction model training, the hyperparameters in GAN, LSTM and CNN are optimized by the reinforcement learning algorithm, the best combination of hyperparameters is found and updated, and then the next GAN prediction model training is started until the optimal GAN ​​prediction model is obtained.

[0134] It should be noted that after obtaining a new set of hyperparameters, the values ​​of the hyperparameters in GAN are updated, and the next GAN training is started, which is repeated n times, for example, 10 times, until the hyperparameters no longer change. At this time, the optimal GAN ​​prediction model can be obtained.

[0135] S500, predicting the building energy consumption value through the optimal GAN ​​prediction model. For example, obtaining the energy consumption characteristic data and the actual energy consumption data of the past 14 days, and inputting them into the GAN prediction model, so as to obtain the predicted energy consumption value of the 15th day.

[0136] The above method collects the energy consumption data of the building and the related energy consumption characteristic data, uses the variational autoencoder to extract high-level features, and detects the importance of features through the extreme gradient enhancement algorithm. Then all the energy consumption features obtained are input into the generative adversarial network model for training, and the hyperparameters in the model are optimized by the reinforcement learning algorithm, and finally a prediction model is obtained for predicting the energy consumption of the building. The energy consumption prediction method of the present invention not only improves the performance and speed of model training, but also makes full use of the close connection and interaction between various data, making the prediction model more stable and accurate.

[0137] In this embodiment, in step S200, R d Input variational autoencoder to obtain high-level energy consumption feature dataset R g , specifically including:

[0138] S210, construct an encoder Encoder and a decoder Decoder;

[0139] S220, the real energy consumption characteristic data x∈R d Input the encoder to obtain the mapping output z of x, and the actual output is the distribution function of z

[0140] S230, calculating the encoder's objective function KL according to the output of step S220;

[0141] S240, obtain sampling z~N(μ(x),σ 2 (x));

[0142] S250, input z into the decoder to obtain the mapping output f(z) of z. Since the values ​​of each dimension have different variances, the actual mapping output is f(z) = (μ, σ 2 );

[0143] S260, calculating the objective function L of the decoder according to the output of step S250;

[0144] S270, adding KL and L to obtain a total target loss function, and optimizing the total target loss function;

[0145] S280, after training is complete, skip the last layer of the decoder when creating the output, thereby obtaining a higher-level feature sequence R g , that is, the advanced energy consumption feature dataset R g .

[0146] Specifically, the encoder and decoder above both use convolutional networks. The encoder and decoder have 4 dense layers, with 300 neurons in each layer.

[0147] The encoder objective function KL is specifically defined as:

[0148]

[0149] where G is the dimension of z,

[0150] The sampling z~N(μ(x),σ 2 (x)) includes: the new input generates samples ε~N(0,1) from the standard Gaussian distribution, and defines z=μ(x)+σ(x)*ε,

[0151] The objective function L of the decoder is the log-likelihood with mean μ and variance σ as parameters, defined as:

[0152]

[0153] In this embodiment, in step S300, R r Feature screening is performed through the XGBoost algorithm, including:

[0154] S310, daily building energy consumption forecast Initialized to 0, the actual value of daily building energy consumption is y i ;

[0155] S320, define the objective function: O bj(t);

[0156] S330, calculate the target function for each sample prediction value The derivative g i and h i

[0157] S340, using the greedy algorithm to build a new decision tree f based on the derivative information t (x);

[0158] S350, using the new decision tree f t (x) Predict a new building energy consumption value and add the newly predicted building energy consumption value to Up to update

[0159] S360, repeating steps S330 to S350, the number of iterations is n times, which can be set according to actual conditions;

[0160] S370, calculating the number of times different features participate in the separation decision tree as their feature importance index, and screening important features.

[0161] In this embodiment,

[0162] The objective function is specifically defined as: in f t (x) is the modeling function of the tree, T is the number of leaf nodes, w is the leaf weight value, γ is the leaf tree penalty regularization term, set to 40, λ is the leaf weight penalty regularization term, set to 3, w j represents the jth feature weight;

[0163] The greedy algorithm builds a new decision tree based on the gain formula:

[0164]

[0165] The new decision tree f t (x) Predict a new building energy consumption value and add the newly predicted building energy consumption value to Specifically:

[0166] Where ε is the shrinkage coefficient, which is set to 0.1.

[0167] In this embodiment, the GAN prediction model is established in step S400. r Input GAN prediction model,

[0168] The GAN prediction model is trained through the WGAN algorithm, including:

[0169] S401, construct a generator G and a discriminator D;

[0170] S402, define the loss function G_loss of the generator and the loss function D_loss of the discriminator;

[0171] S403, from the real energy consumption data sample R r Take a sample x i , sample z from the noise variable distribution i ;

[0172] S404, calculating the discriminator loss D_loss;

[0173] S405, updating the discriminator parameter w according to a momentum-based optimization algorithm (momentum Adam);

[0174] S406, truncating the absolute value of the discriminator parameter to no more than a fixed constant c through a truncation function;

[0175] S407, repeat steps S403 to S406, and set the number of cycles, for example, the number of cycles is 5 times;

[0176] S408. Sample z from the noise variable distribution i , calculate the generator loss G_loss;

[0177] S409, updating the generator parameter θ according to the momentum-based optimization algorithm (momentum Adam);

[0178] S410, repeat steps S402 to S409 until the generator parameters remain unchanged and the model training is completed;

[0179] S411, use real energy consumption samples i The sampling result x0 is used as the initial value of the state chain, that is, x k ;

[0180] S412, use 10% of the energy consumption training data R r As a random test set, the discriminator D is adjusted using the rank-preserving regression method;

[0181] S413, generate k random noise input generators G, generate K samples, and select a sample x' from K in turn;

[0182] S414, sampling U from uniform distribution U~N(0,1);

[0183] S415, the previously selected sample is x k, calculate the acceptance probability of the new sample x'

[0184] S416, if U≤α, accept the current sample, that is, update x k is x';

[0185] S417, repeat steps S413 to S416, the number of cycles is K times;

[0186] S418, if x k If x0 is the real sample, then re-sampling starts from the generated sample, otherwise the current predicted energy consumption value is output. It should be noted that the current predicted energy consumption value output here is used to judge the accuracy of the currently trained model.

[0187] In this embodiment, the generator adopts a long short-term memory neural network LSTM and uses Xavier initialization. The input of LSTM is the collected and generated energy consumption features, which then enter 500 hidden units and are then converted into a single output as a predicted energy consumption value, where the sequence step parameter is set to 14, that is, 14 days of data are used to predict the 15th day; the discriminator adopts a convolutional neural network CNN.

[0188] The generator loss function G_loss is specifically defined as The discriminator loss function is specifically defined as Where f needs to satisfy the Lipschitz constant constraint, and w is the parameter of the discriminator neural network. Refers to sampling from the actual energy consumption value, which is y i , Refers to sampling from the samples generated by the generator, and E is the mathematical expectation.

[0189] The K is a hyperparameter, and adjusting it can make a trade-off between speed and confidence. For a perfect discriminator, K approaches infinity, that is, the distribution of D is perfectly close to the real data distribution.

[0190] The D(x) is the discriminator score, which is specifically defined as:

[0191] In this embodiment, after completing the training of the GAN prediction model described in step S400, the hyperparameters in GAN, LSTM and CNN are optimized using the reinforcement learning algorithm, the best combination of hyperparameters is found and updated, and then the next GAN prediction model training is started until the optimal GAN ​​prediction model is obtained. That is, a new strategy based on Q-Learning is adopted to navigate the high-dimensional hyperparameter space. Specifically:

[0192] S501. The hyperparameter set θ tracked and optimized includes:

[0193] batch_size: The batch size of LSTM and CNN,

[0194] cnn_lr: learning rate of CNN,

[0195] strides: strides in CNN,

[0196] padding: padding in CNN,

[0197] kernel_size: kernel size in CNN,

[0198] dropout: dropout in LSTM,

[0199] filters: the initial number of filters;

[0200] S502, initialize hyperparameter set θ, target hyperparameter θ - =θ, initialize the replay buffer

[0201] S503, initializing the hyperparameter grid Λ and setting the initial state value S0;

[0202] S504, determine the next action a t ;

[0203] S505: Set reward function R and obtain reward r t ;

[0204] S506, obtain the next state value S t+1 =τ(s t ,λ t ,r t ), where λ t Hyperparameter configuration for the latest evaluation;

[0205] S507, and (s t ,s t+1 ,a t ,r) Add to the replay buffer Φ;

[0206] S508, randomly sample B from the replay buffer Φ = {(s,a,Q(s,s',a,r))|(s,s',a,r)~Unif(Φ)};

[0207] S509, B updates the optimal value function Q*, obtains the next hyperparameter set θ', and updates θ=θ';

[0208] S510, repeat steps S504 to S508, and specify the number of times N per cycle u Update θ- =θ,N u is the update frequency, the number of iterations is n times, which can be set according to the actual situation;

[0209] S511, repeat steps S503 to S509, the number of times being the product of the size of each training data set and the number of data sets;

[0210] S512: Obtain a new hyperparameter set θ.

[0211] In one embodiment,

[0212] Set the initial state value S0, which is specifically defined as:

[0213] S0=(metafeatures(D),({0} dim(Λ) ,0)),D~Unif(D*),

[0214] Where D* is the training data set,

[0215] The decision of the next action a t , where a t The specific definition is:

[0216]

[0217] The reward function is specifically set to:

[0218] R=2*G_loss+D_loss+G_accuracy,

[0219] Among them, G_loss is the loss of the generator, G_accuracy is the accuracy of the generator, and D_loss is the loss of the discriminator.

[0220] Said Where γ is the discount factor,

[0221] The optimal value function Q* is updated by B, and the next hyperparameter set θ' is obtained, and θ=θ' is updated, specifically according to the formula:

[0222]

[0223] It should be noted that after each training of GAN, three values ​​(G_loss, G_accuracy and D_loss) are passed to the reinforcement learning algorithm to synthesize the reward function, where G_loss is the loss of the generator, G_accuracy is the accuracy of the generator, and D_loss is the loss of the discriminator, which are used to determine the value of adjusting the hyperparameters.

[0224] like Figure 5 and Figure 6As shown, an embodiment of the present invention also provides a building energy consumption monitoring and prediction system. The system includes: an energy consumption real-time data acquisition module, an environmental data acquisition module, a data communication module, an information processing module, a server, a display, a human-computer interaction module and an information storage module.

[0225] The environmental data acquisition module includes: a temperature and humidity sensor for monitoring indoor temperature and humidity, a carbon dioxide sensor for monitoring indoor carbon dioxide concentration, a gas sensor for monitoring indoor flammable gas concentration, an atmospheric pressure sensor for measuring atmospheric pressure, a light intensity sensor and a microcontroller, and the temperature and humidity sensor, carbon dioxide sensor, gas sensor, atmospheric pressure sensor and light intensity sensor are respectively connected to the microcontroller.

[0226] The energy consumption real-time data acquisition module and the microcontroller are respectively connected to the data communication module;

[0227] The data communication module is connected to the information processing module, the information processing module is connected to the server, and the server is connected to the information storage module, the display and the human-computer interaction module.

[0228] The server stores at least one executable instruction, and the executable instruction enables the server to execute operations corresponding to the above-mentioned building energy consumption prediction method.

[0229] When the above system is used, the building energy consumption data can be collected through the energy consumption real-time data collection module. For example, the energy consumption of electricity consumption, water consumption, gas consumption, etc. of the building can be collected. Energy consumption characteristic data can be collected through the environmental data collection module, for example, indoor temperature and humidity data, indoor carbon dioxide concentration data, indoor flammable gas concentration data, indoor atmospheric pressure data, indoor light intensity data, etc.

[0230] The microcontroller is used to send the sensor data to the information processing module through the data communication module. The information processing module can further send the data to the server, and the server can store the data on the information storage module. At the same time, the data can be displayed on the display. At the same time, the server can call the relevant data on the information storage module and predict the building energy consumption according to the above-mentioned building energy consumption prediction method of the present invention.

[0231] Specifically, an expansion board can be set up, and the expansion board can be designed according to the size of the microcontroller and the sensor pins to realize the sensor all-in-one function. The board is connected to hardware modules such as gas sensor, Bluetooth module, air pressure sensor, light intensity sensor, temperature and humidity sensor, etc. In addition, the TXD and RXD interfaces are brought out. When the jumper cap is plugged in, the module is in normal working state. After the jumper cap is removed, the pins can be connected to DuPont lines for Bluetooth AT configuration.

[0232] Specifically, the energy consumption real-time data collection module is a building energy consumption collector, which is connected to energy consumption meters via RS485 bus. For example, the building energy consumption collector is connected to electric meters, water meters, gas meters, etc. via RS485 bus to collect energy consumption data of related meters.

[0233] Specifically, the microcontroller is a STC15F2K60S2 single chip microcomputer, which pre-processes the received sensor data and then sends them to the information processing module in the form of data packets through the data communication module to achieve data transmission.

[0234] Specifically, the temperature and humidity sensor is a DHT11 sensor, which provides digital calibration internally and can achieve a relatively long transmission distance, can simultaneously measure indoor temperature and humidity, is connected to an expansion board and a microcontroller, and uses a single bus for serial data transmission.

[0235] Specifically, the gas sensor is an MQ-9 sensor, which is small in size, high in precision, and stable in performance, and can measure the concentration of indoor flammable gases such as carbon monoxide, methane, and liquefied gas, and is connected to an expansion board and to a microcontroller via an I2C bus.

[0236] Specifically, the light intensity sensor is a TSL2561 sensor, which can measure indoor light intensity, is connected to an expansion board, and is connected to a microcontroller via an I2C bus.

[0237] Specifically, the atmospheric pressure sensor is a BMP180 sensor, which can measure indoor atmospheric pressure, is connected to an expansion board, and is connected to a microcontroller via an I2C bus.

[0238] Specifically, the carbon dioxide sensor is an MG811 sensor, which can measure the carbon dioxide concentration in the room, is connected to the expansion board, and is connected to the microcontroller via an I2C bus.

[0239] Specifically, the human-computer interaction module is a keyboard and a mouse.

[0240] Specifically, the information processing module is a third-generation Raspberry Pi.

[0241] Specifically, the data communication module can be a wireless transmission module such as a Bluetooth module. The Bluetooth module adopts HC-05 Bluetooth and is connected to the expansion board.

[0242] It should be noted that the Bluetooth module and the information processing module (Raspberry Pi 3B) establish a connection via Bluetooth specifically including:

[0243] Bluetooth configuration on the expansion board:

[0244] Use a USB to TTL tool to connect the HC-05 Bluetooth module, use AT commands to set it, and pull the KEY pin high before powering on the Bluetooth to enter AT configuration mode.

[0245] Get the Bluetooth physical address of each HC-05 module through the AT+ADDR command. This address is used to mark each data acquisition module. That is, the Raspberry Pi distinguishes different data acquisition modules according to the physical address of the Bluetooth module to which the data acquisition module is connected, thereby distinguishing different sources of data. Set the serial communication parameters of each module to a baud rate of 9600 through the command "AT+UART=9600,0,0". Set the password of the module to 0000 to facilitate subsequent Bluetooth pairing. Set AT+ROLE=0 to set each Bluetooth module to slave mode, then repower the Bluetooth module and exit AT configuration mode.

[0246] Raspberry Pi Bluetooth configuration:

[0247] Open the Bluetooth serial port on the Raspberry Pi and pair each Bluetooth module. Power on each Bluetooth module and wait for pairing. Then use the bluetoothctl tool to pair. After entering bluetoothctl, first enter the command agent on to open the agent service. Use the command pair <Bluetooth physical address> to pair the Bluetooth module. Use the command trust <Bluetooth physical address> to trust the Bluetooth module. Then use the rfcomm command to bind the Bluetooth physical address of the data acquisition module to the virtual serial port in the Raspberry Pi system. Modify the serial port number and serial port parameters, set the serial port number to rfcomm1, and the serial port parameters to baud rate 9600.

[0248] The Bluetooth module and the information processing module (Raspberry Pi 3B) on the expansion board establish a connection via Bluetooth to obtain information from each sensor, and the present invention uses Python language and the Python serial package to read data from the set virtual serial port.

[0249] Specifically, the information processing module of the present invention transmits data to the server via HTTP protocol. Specifically, it includes:

[0250] First, import Python's math, time and other modules, and wait for ten seconds to reduce the server burden and device energy consumption. During the ten-second wait, access the server and use the url command to access the server. After the connection is successful, initialize the serial port. Then use Python to call Linux commands to obtain the device MAC address, and finally package all data and send it to the server.

[0251] Furthermore, after receiving the relevant data, the server stores it in the MYSQL database through the python command to realize the storage of building environment information.

[0252] The technical features of the above-described embodiments may be arbitrarily combined. To make the description concise, not all possible combinations of the technical features in the above-described embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0253] The above-mentioned embodiments only express several implementation methods of the present invention, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the invention patent. It should be pointed out that, for ordinary technicians in this field, several variations and improvements can be made without departing from the concept of the present invention, and these all belong to the protection scope of the present invention. Therefore, the protection scope of the patent of the present invention shall be subject to the attached claims.

Claims

1. A building energy consumption prediction method based on WGAN algorithm, characterized in that: include: S100, obtain building energy consumption data and building energy consumption characteristic data set R d ,in, R d ={(x 11 ,x 12 ,x 13 ......x 1j ),(x 21 ,x 22 ,x 23 ......x 2j )......(x i1 ,x i2 ,x i3 ......x ij )}, d represents the number of features, x ij Represents a feature, subscript i represents the i-th sample, i∈N*, j represents the j-th feature, j∈N*; S200, R d Input variational autoencoder to obtain high-level energy consumption feature dataset R g , the building energy consumption characteristic data set R in step S100 d and advanced energy consumption feature dataset R g Merge to form the input feature dataset R r ; S300, R r Feature screening through XGBoost algorithm; S400, establish a GAN prediction model, and convert the R r Input the GAN prediction model and train the GAN prediction model through the WGAN algorithm. After completing one GAN prediction model training, use the reinforcement learning algorithm to optimize the hyperparameters in GAN, LSTM and CNN, find the best combination of hyperparameters and update them, and then enter the next GAN prediction model training until the optimal GAN ​​prediction model is obtained; S500, predicting the building energy consumption value by using the optimal GAN ​​prediction model, in step S200, R d Input variational autoencoder to obtain high-level energy consumption feature dataset R g , including: S210, construct an encoder Encoder and a decoder Decoder; S220, the real energy consumption characteristic data x∈R d Input the encoder to obtain the mapping output z of x, and the actual output is the distribution function of z S230, calculating the encoder's objective function KL according to the output of step S220; S240, obtain sampling z~N(μ(x),σ 2 (x)); S250, input z into the decoder to obtain the mapping output f(z) of z. Since the values ​​of each dimension have different variances, the actual mapping output is f(z) = (μ, σ 2 ); S260, calculating the objective function L of the decoder according to the output of step S250; S270, adding KL and L to obtain a total target loss function, and optimizing the total target loss function; S280, after training is complete, skip the last layer of the decoder when creating the output, thereby obtaining a higher-level feature sequence R g , that is, the advanced energy consumption feature dataset R g The encoder and decoder both use convolutional networks, and the dense layers in the encoder and decoder are 4 layers, with 300 neurons in each layer. The encoder objective function KL is specifically defined as: where G is the dimension of z, The sampling z~N(μ(x),σ 2 (x)) includes: the new input generates samples ε~N(0,1) from the standard Gaussian distribution, and defines z=μ(x)+σ(x)*ε, The objective function L of the decoder is the log-likelihood with mean μ and variance σ as parameters, defined as:

2. The building energy consumption prediction method based on the WGAN algorithm according to claim 1 is characterized in that: In step S300, R r Feature screening is performed through the XGBoost algorithm, including: S310, daily building energy consumption forecast Initialized to 0, the actual value of daily building energy consumption is y i ; S320, define the objective function: O bj(t); S330, calculate the derivative g of the objective function for each sample prediction value i and h i ; S340, using the greedy algorithm to build a new decision tree f based on the derivative information t (x); S350, using the new decision tree f t (x) Predict a new building energy consumption value and add the newly predicted building energy consumption value to Up to update S360, repeating steps S330 to S350; S370, calculating the number of times different features participate in the separation decision tree as their feature importance index, and screening important features.

3. The building energy consumption prediction method based on the WGAN algorithm according to claim 2 is characterized in that: The objective function is specifically defined as: in f t (x) is the modeling function of the tree, T is the number of leaf nodes, w is the leaf weight value, γ is the leaf tree penalty regularization term, set to 40, λ is the leaf weight penalty regularization term, set to 3, w j represents the jth feature weight; The greedy algorithm builds a new decision tree based on the gain formula: The new decision tree f t (x) Predict a new building energy consumption value and add the newly predicted building energy consumption value to Specifically: Where ε is the shrinkage coefficient, which is set to 0.

1.

4. The building energy consumption prediction method based on the WGAN algorithm according to claim 1 is characterized in that: In step S400, a GAN prediction model is established, and R r Input the GAN prediction model and train the GAN prediction model through the WGAN algorithm, including: S401, construct a generator G and a discriminator D; S402, define the loss function G_loss of the generator and the loss function D_loss of the discriminator; S403, from the real energy consumption data sample R r Take a sample x i , sample z from the noise variable distribution i ; S404, calculating the discriminator loss D_loss; S405, updating the discriminator parameter w according to the momentum-based optimization algorithm momentum Adam; S406, truncating the absolute value of the discriminator parameter to no more than a fixed constant c through a truncation function; S407, repeat steps S403 to S406, and set the number of cycles; S408. Sample z from the noise variable distribution i , calculate the generator loss G_loss; S409, updating the generator parameter θ according to the momentum-based optimization algorithm momentum Adam; S410, repeat steps S402 to S409 until the generator parameters remain unchanged and the model training is completed; S411, use the sampling result x0 of the real energy consumption sample as the initial value of the state link, that is, x k ; S412, using 10% of the energy consumption training data as a random test set, and adjusting the discriminator D using the rank-preserving regression method; S413, generate k random noise input generators G, generate K samples, and select a sample x' from K in turn; S414, sampling U from uniform distribution U~N(0,1); S415, the previously selected sample is x k , calculate the acceptance probability of the new sample x' S416. If U≤α, accept the current sample, that is, update x k is x'; S417, repeat steps S413 to S416, the number of cycles is K times; S418, if x k If it is a true sample x0, restart sampling from the generated sample, otherwise output the current predicted energy consumption value.

5. The building energy consumption prediction method based on the WGAN algorithm according to claim 4 is characterized in that: The generator uses a long short-term memory neural network LSTM and uses Xavier initialization. The input of LSTM is the collected and generated energy consumption features, which then enter 500 hidden units and are converted into a single output as a predicted energy consumption value. The sequence step parameter is set to 14, that is, 14 days of data are used to predict the 15th day; the discriminator uses a convolutional neural network CNN, The generator loss function G_loss is specifically defined as The discriminator loss function is specifically defined as Where f needs to satisfy the Lipschitz constant restriction, w is the parameter of the discriminator neural network, K is a hyperparameter. Adjusting it can make a trade-off between speed and confidence. For a perfect discriminator, K approaches infinity, that is, the distribution of D is perfectly close to the real data distribution. D(x) is the discriminator score, which is defined as:

6. The building energy consumption prediction method based on the WGAN algorithm according to claim 1 is characterized in that: After completing one GAN prediction model training in step S400, the hyperparameters in GAN, LSTM and CNN are optimized using a reinforcement learning algorithm, the best combination of hyperparameters is found and updated, and then the next GAN prediction model training is started until the optimal GAN ​​prediction model is obtained, specifically: S501. The hyperparameter set θ tracked and optimized includes: batch_size: The batch size of LSTM and CNN, cnn_lr: learning rate of CNN, strides: strides in CNN, padding: padding in CNN, kernel_size: kernel size in CNN, dropout: dropout in LSTM, filters: the initial number of filters; S502, initialize hyperparameter set θ, target hyperparameter θ - =θ, initialize the replay buffer S503, initializing the hyperparameter grid Λ and setting the initial state value S0; S504, determine the next action a t ; S505: Set reward function R and obtain reward r t ; S506, obtain the next state value S t+1 =τ(s t ,λ t ,r t ), where λ t Hyperparameter configuration for the latest evaluation; S507, and (s t ,s t+1 ,a t ,r) Add to the replay buffer Φ; S508, randomly sample B from the replay buffer Φ = {(s,a,Q(s,s',a,r))|(s,s',a,r)~Unif(Φ)}; S509, B updates the optimal value function Q*, obtains the next hyperparameter set θ', and updates θ=θ'; S510, repeat steps S504 to S508, and specify the number of times N per cycle u Update θ - =θ,N u is the update frequency; S511, repeat steps S503 to S509, the number of times being the product of the size of each training data set and the number of data sets; S512: Obtain a new hyperparameter set θ.

7. The building energy consumption prediction method based on the WGAN algorithm according to claim 6 is characterized in that: Set the initial state value S0, which is specifically defined as: S0=(metafeatures(D),({0} dim(Λ) ,0)),D~Unif(D*), Where D* is the training data set, The decision of the next action a t , where a t The specific definition is: The reward function is specifically set to: R=2*G_loss+D_loss+G_accuracy, Among them, G_loss is the loss of the generator, G_accuracy is the accuracy of the generator, and D_loss is the loss of the discriminator. Said Where γ is the discount factor, The optimal value function Q* is updated by B, and the next hyperparameter set θ' is obtained, and θ=θ' is updated, specifically according to the formula:

8. A building energy consumption monitoring and prediction system, characterized in that: include: Energy consumption real-time data acquisition module, environmental data acquisition module, data communication module, information processing module, server, display, human-computer interaction module and information storage module; The environmental data acquisition module includes: a temperature and humidity sensor for monitoring indoor temperature and humidity, a carbon dioxide sensor for monitoring indoor carbon dioxide concentration, a gas sensor for monitoring indoor flammable gas concentration, an atmospheric pressure sensor for measuring atmospheric pressure, a light intensity sensor and a microcontroller, wherein the temperature and humidity sensor, the carbon dioxide sensor, the gas sensor, the atmospheric pressure sensor and the light intensity sensor are respectively connected to the microcontroller; The energy consumption real-time data acquisition module and the microcontroller are respectively connected to the data communication module; The data communication module is connected to the information processing module, the information processing module is connected to the server, and the server is connected to the information storage module, the display and the human-computer interaction module; The server stores at least one executable instruction, and the executable instruction enables the server to execute operations corresponding to the building energy consumption prediction method as described in any one of claims 1 to 7.