The invention content is as follows:
the invention aims to determine the energy storage output force under different loads and generated energy under the condition of unstable generated energy of new energy, thereby enhancing the peak clipping and valley filling effects, reducing the waste conditions such as air abandon and the like and improving the economy.
The invention specifically adopts the following technical scheme:
a VAE-CGAN-based energy storage output prediction method is characterized by comprising the following steps:
step 1: collecting historical operation data of the energy storage device, wherein the historical operation data comprises battery voltage, battery ampere hours, discharge multiplying power, battery operation voltage, traditional energy power generation ratio and new energy power generation ratio;
step 2: directly inputting the historical operating data acquired in the step 1 into a VAE model for training to generate data characteristic information, namely generating new data containing information of the historical operating data;
and step 3: constructing a generator and a discriminator based on the CGAN, wherein the generator is used for generating simulation sample data, and the discriminator is used for discriminating the sources of the simulation sample data and real sample data;
and 4, step 4: inputting the characteristic information obtained in the step 2 as condition information into the generator and the discriminator, and performing countermeasure training on the generator and the discriminator, namely, the discriminator receives the simulation sample data and the real sample data acquired in the step 1 and judges the sources of the two data;
and 5: updating the parameters of the generator and the discriminator, namely optimizing the generator and the discriminator;
step 6: adding 1 to the iteration times, returning to the step 5 until the discriminator cannot distinguish the sample data source, and outputting a generator;
and 7: and (4) acquiring real-time operation data of the energy storage device, inputting the real-time operation data into the generator output in the step (6), and predicting the energy storage output condition of the energy storage device.
The invention further adopts the following preferred technical scheme:
the step 2 comprises the following steps:
step 201: constructing an encoder by adopting a layer of LSTM neural network; a decoder is constructed by adopting a layer of LSTM neural network and a layer of full connection layer;
step 202: the encoder receives a first high-dimensional data sequence X ═ X of historical operating data1,x2,…xn]Then, mapping a high-dimensional data sequence X of the historical operating data into a mean vector mu with the length of m and a standard deviation vector sigma with the length of m;
step 203: the encoder calculates a mean vector mu, a standard deviation vector sigma and a parameter sequence delta [ delta 1, delta 2, … delta m ═ according to the mean vector mu and the standard deviation vector sigma]And calculating a hidden variable sequence Z ═ Z by the following formula1,z2,…zm];
zi=μi+δi·exp(σi)
Wherein z isiFor the ith value in the hidden variable sequence Z,μiIs the ith value, σ, in the mean vector μiIs the ith value in the standard deviation vector σ, δ i is a parameter obtained by random sampling in a sample set subject to bernoulli distribution, and subject to a standard normal distribution, i.e., δ i to N (0,1), i ═ 1,2, …, m; step 204: inputting the hidden variable sequence Z obtained by calculation in the step 203 into a decoder, and restoring the hidden variable sequence Z into a second high-dimensional data sequence X ', wherein the second high-dimensional data sequence X' is a characteristic information sequence.
In step 2, the following objective function is adopted for training:
wherein L is1Is a self-encoding reconstruction error, L2Is KL divergence, P (x | Z) is a prior distribution of hidden variables Z representing a decoder in the VAE, q (Z | x) is a posterior distribution of values Z in a sequence of hidden variables derived from any value x in the real data sequence representing an encoder in the VAE;
and when the self-coding reconstruction error value is maximum and the KL divergence value is minimum, finishing training to obtain the characteristic information.
In the step 2, the battery voltage, the battery ampere hour and the discharge multiplying power are trained by adopting the same VAE model;
and the traditional energy power generation ratio and the new energy power generation ratio are trained by adopting independent VAE models respectively.
In step 4, random noise information Z is setnoiseAnd input into a generator together with the condition information, the generator utilizes the nonlinear mapping capability of the neural network to give the noise information znoiseAnd condition information Y into simulation sample data G (z)noise|y)。
In step 4, the generator generating the simulation sample comprises the following steps:
step 401: input random noise sequence ZnoiseWhen the length is n and the length of the conditional information sequence Y is m, the generator establishes a full connection layer to enable the generator to be connected with the random noise sequence ZnoiseThe number of the neurons of the full connection layer corresponding to the condition information sequence Y and the random noise sequence Z are respectivelynoiseThe length of the conditional information sequence Y is consistent with that of the conditional information sequence Y;
step 402: the data of the fully connected layer is corrected such that its mean value is approximately 0 and its variance is approximately 1, i.e., towards a standard normal distribution N (0, 1).
Step 403: random noise Z to be correctednoiseSplicing the correction sequence with the condition information Y correction sequence to form a spliced sequence with the length of (n + m)/10;
step 404: multiplying the same appearance probability p by (n + m)/10 neurons in the spliced sequence with the length of (n + m)/10 obtained in the previous layer to be 0.5;
step 405: in step 404, half of the neurons are temporarily deleted in the current generation, and the undeleted neurons are output from the generator as the simulation sample data.
In step 4, the discriminator discriminating the source of the input data comprises the following steps:
step 406: the discriminator receives the condition information Y, the real sample data sequence X and the simulation sample data sequence generated by the generator;
step 407: the discriminator respectively generates a first hidden layer for the condition information sequence Y, the real sample data sequence X and the simulation sample data sequence, wherein the number of the neurons of the hidden layer is i, and a first weight matrix W is establishedmaxout1Calculating the numerical value of the neuron in the first hidden layer by the following formula;
t’i=wi1×t1+wi2×t2+....+win×tn
wherein, wilIs a weight matrix Wmaxout1The 1 st element of the ith row, t'iIs the value of the ith neuron in the first hidden layer, tiIs the ith data of the input sequence.
Step 408: dividing neurons in a first hidden layer of a condition information sequence Y, a first hidden layer of a real sample data sequence X and a first hidden layer of a simulation sample data sequence into s groups, selecting the neuron with the largest value from each group of the groups as the output of the first hidden layer, and generating a condition information neural network layer, a real sample data neural network layer and a simulation sample data neural network layer, wherein the neural network layer contains s neurons;
step 409: splicing the generation condition information neural network layer, the real sample data neural network layer and the simulation sample data neural network layer to obtain a first neural network layer, wherein the first neural network layer is provided with 3s neurons;
step 410: setting the neuron deletion probability to be 0.5, and processing the first neural network layer in the step 409 to obtain a second neural network layer with random length;
step 411: establishing a second weight matrix Wmaxout2Mapping the second neural network layer by the following formula to obtain a second hidden layer, selecting the neuron with the maximum value in the second hidden layer 2 to map the neuron into a (0,1) interval, and taking the mapped data as the output result of the discriminator;
q’i=w’i1×q1+w’i2×q2+....+w’in×qn
W’j1is a weight matrix Wmaxout2Line j 1 st element, q'1For the 1 st data of the input sequence, qjIs the jth data in the second hidden layer.
In step 411, when the output result of the discriminator is 0.5, the discriminator cannot determine the source of the received data sample; otherwise, the discrimination results in that the received data sample originates from the generator.
In step 5, the constraints of the CGAN model are:
wherein, G (z)
noiseY) is sample data generated by the generator according to the condition information Y and the noise information znoise; d (G (z)
noiseY)) is the output of the discriminator;
replacing with the mean of the generated sample data and the real sample data for log D (x | y) mathematical expectation;
for z is a random number, P
z(z) is a probability distribution function of the random number z,
obey a probability distribution P when z
z(z) mathematical expectation; p
data(x)Probability distribution of input real sample data; p is a probability distribution; v (D, G) represents the game function between the generator and the arbiter.
In said step 5, the generator is optimized by the following formula:
wherein G is the constraint condition of the encoder,
for mathematical expectation, P
data(x | y) is the probability that x is from the true sample data, P, under the conditional constraint of y
G(x | y) is the probability that x comes from the sample data generated by the generator under the conditional constraint of y;
when the value of the formula is minimum, the generator is considered to be optimized.
In said step 5, the discriminator is optimized by the following formula:
wherein D is a discriminator constraint condition;
the discriminator optimization is considered to be completed when the formula takes the maximum value.
When the output result of the discriminator is 0.5, the game between the discriminator and the generator is considered to be balanced, the training is finished, and the trained generator is output;
the invention has the following beneficial effects:
the energy storage output is predicted by using the VAE-CGAN model, so that not only can condition information under a historical scene be modeled, but also unknown condition information can be dealt with, the condition information hidden in an input sequence is trained through the VAE model, the CGAN model of a continuous condition input space is constructed, an optimal generator is obtained through confrontation, and the accuracy of energy storage output prediction is guaranteed. Therefore, the optimal output of the stored energy under the condition of large working condition change can be determined more comprehensively and accurately.
Detailed Description
The following detailed description of the embodiments of the invention is provided in connection with the accompanying drawings.
As shown in fig. 1, the energy storage output prediction method based on VAE-CGAN of the present invention specifically includes the following steps:
step 1: the method comprises the steps of collecting battery voltage, battery ampere hours, discharge rate C and other data such as the power generation ratio of traditional energy and new energy to serve as input sequences of a VAE model, collecting different input sequences to serve as input of the VAE for extracting features according to different systems used by an energy storage battery in actual conditions, wherein the feature sequences with strong correlation such as the battery voltage, the battery ampere hours and the discharge rate C form a multi-element time sequence, analyzing the multi-element time sequence by using the same VAE, and training the data without correlation such as the power generation ratio of the traditional energy and the new energy by using a single VAE. Here, the VAE model input sequence is represented by X ═ X1, X2, … xn ].
Step 2: and (3) training various types of data acquired in the step (1) by using a VAE model to obtain a characteristic information sequence.
Specifically, as shown in fig. 2, step 2 includes the following steps:
step 201: adopting a layer of LSTM (Long short-term memory) neural network to construct an encoder; a decoder is constructed using a layer of LSTM neural network and a layer of fully-connected layers.
Step 202: the encoder receives a first high-dimensional data sequence X ═ X of historical operating data1,x2,…xn]Then, mapping the high-dimensional data sequence X of the historical operating data into a mean vector mu with the length of m and a standard deviation vector sigma with the length of m.
Step 203: the encoder calculates the mean vector mu, the standard deviation vector sigma and the parameter sequence delta [ delta 1, delta 2, … delta m ═ m]And calculating a hidden variable sequence Z ═ Z by the following formula1,z2,…zm]。
zi=μi+δi·exp(σi) (1)
Wherein z isiIs the ith value, mu, in the hidden variable sequence ZiIs the ith value, σ, in the mean vector μiFor the ith value in the standard deviation vector σ, δ i is a parameter obtained by random sampling in a sample set that obeys a bernoulli distribution, and obeys a standard normal distribution, i.e., δ i to N (0,1), i ═ 1,2, …, m.
Step 204: inputting the hidden variable sequence Z obtained by calculation in step 203 into a decoder, restoring the hidden variable sequence Z into a second high-dimensional data sequence X ', wherein X' is [ X1 ', X2', … xn '], that is, the hidden variable sequence Z is identical in dimension to the VAE model input sequence, and finally reconstructing the high-dimensional data feature X' by the full connection layer to obtain a generated m-dimensional feature information sequence Y.
Specifically, the total constraint L in the VAE model training process is calculated and expressed by the following formula;
L=max loss=∫q(z|x)log P(x|z)dz-KL(q(z|x)||P(z)) (2)
the former part of the objective function is the self-coding reconstruction error, which is also called variation lower limit, and the maximum value is taken to represent that when X is used as the input of the encoder, m hidden variables zi are extracted from the encoder in a coding mode, and finally the decoder can recover X from Z with the maximum probability.
The self-encoded reconstruction error L1 is calculated by the following equation:
in the continuous optimization of the encoder, the self-encoding reconstruction error is continuously increased by changing parameters in the LSTM neural network.
The second part is KL divergence, and when the second part takes the minimum value, σi=0,μiWhen z is 0, z can be obtained from the formula (1)iFollowing a standard normal distribution, q (z | x) ═ p (z), KL divergence is zero. The KL divergence is calculated by the following formula:
p (x | Z) is an a priori distribution of hidden variable Z representing the decoder in the VAE, q (Z | x) is a Z a posteriori distribution derived from x representing the encoder in the VAE, it is desirable to fit these two distributions as closely as possible in the VAE model, so P (Z) in the VAE model is a Gaussian distribution with mean 0 and variance 1 when the two fit, KL divergence is 0, when we adjust that q (Z | x) and P (Z | x) are completely consistent, KL divergence vanishes to 0, and Lb and logP (x) are completely consistent. Therefore, no matter what the value of logP (x), we can always make Lb equal to logP (x) by adjusting, and because Lb is the lower bound of logP (x), solving Maximum logP (x) is equivalent to solving Maximum Lb, even if self-coding reconstruction error is Maximum, an optimal encoder model is obtained, and at this time, the trained VAE model can generalize the data characteristics of input data and generate a characteristic sequence as a condition information sequence used in the CGAN model.
And step 3: the method comprises the steps of constructing a generator and a discriminator based on the CGAN, wherein the generator is used for generating simulation sample data, and the discriminator is used for discriminating the sources of the simulation sample data and real sample data.
And 4, step 4: and (3) inputting the characteristic information obtained in the step (2) as condition information into the generator and the discriminator, and performing countermeasure training on the generator and the discriminator, namely, the discriminator receives the simulation sample data and the real sample data acquired in the step (1) and judges the sources of the two data.
And, a random noise information z is set at randomnoiseInput into a generator together with the condition information, the generator utilizes the nonlinear mapping capability of the neural network to give the noise information znoiseAnd condition information Y into simulation sample data G (z)noiseY) is also input to the generator.
In particular, as shown in fig. 3-4, the generation of the immersive sample by the generator comprises in particular the following steps:
step 401: input random noise sequence Z
noiseWhen the length is n and the length of the conditional information sequence Y is m, the generator establishes a full connection layer to enable the generator to be connected with the random noise sequence
The number of neurons of the full-connection layer corresponding to the condition information sequence Y is respectively equal to the random noise sequence
The length of the condition information sequence Y is consistent, wherein the full connection layer aggregates and classifies the characteristics of the input sequence under the condition of not changing the length of the input sequence.
Step 402: the data of the fully connected layer is corrected such that its mean value is approximately 0 and its variance is approximately 1, i.e., towards a standard normal distribution N (0, 1). Preferably, in the present invention, the data of the full-link layer is corrected using the Batch-Normalization algorithm.
Step 403: random noise Z to be correctednoiseAnd splicing the correction sequence with the condition information Y correction sequence to form a spliced sequence with the length of (n + m)/10. In one embodiment of the invention, the input random noise sequence ZnoiseIs 200 and the length of the conditional information sequence Y is 1000, a splicing sequence of length 120 is thus obtained in this step.
Step 404: the neurons in the stitched sequence obtained in step 403 are multiplied by the same probability of occurrence p, which is 0.5. Preferably, the concatenation sequence is processed using the dropout algorithm at this step 404.
Step 405: in step 404, about half of the neurons are temporarily deleted in this generation. Therefore, only part of input sequences participate in the generation in the process of generating the sample data by the generator, and the return value only adjusts the neurons participating in the generation, so that the over-fitting phenomenon of the generator can be avoided. The remaining undeleted neurons are output from the generator and input to the discriminator as generation sample data.
Specifically, as shown in fig. 3-4, the step of identifying the source of the data sample by the discriminator specifically comprises the following steps:
step 406: the discriminator receives the condition information Y, the real sample data sequence X and the simulation sample data sequence generated by the generator;
step 407: and the discriminator respectively generates a first hidden layer for the condition information sequence Y, the real sample data sequence X and the simulation sample data sequence, wherein the number of the neurons of the hidden layer is i. Preferably, in this step, the maxout algorithm is adopted to map each data sequence, and specifically, the weight matrix W is setmaxout1And calculating the hidden layer neuron value by the following formula:
t’i=wi1×t1+wi2×t2+....+win×tn (5)
wherein, wilIs a weight matrix Wmaxout1The 1 st element of the ith row, t'iIs the value of the ith neuron in the first hidden layer, tiIs the ith data of the input sequence.
Step 408: dividing neurons in a first hidden layer of a condition information sequence Y, a first hidden layer of a real sample data sequence X and a first hidden layer of a simulation sample data sequence into s groups, selecting the neuron with the largest value from each group of the groups as the output of the first hidden layer, and generating a condition information neural network layer, a real sample data neural network layer and a simulation sample data neural network layer, wherein the neural network layer contains s neurons. Preferably, in the present invention, the neurons in the first hidden layer are divided into 5 groups, thereby obtaining a neural network layer containing 5 neurons.
Step 409: and splicing the generation condition information neural network layer, the real sample data neural network layer and the simulation sample data neural network layer to obtain a first neural network layer, wherein the first neural network layer is provided with 3s neurons. Preferably, a neural network layer containing 15 neurons is obtained in one embodiment of the present invention.
Step 410: setting the neuron deletion probability to be 0.5, and processing the first neural network layer in the step 409 to obtain a second neural network layer with a random length. Specifically, in one embodiment of the present invention, the first neural network layer is processed using the dropout algorithm, and by setting the neuron deletion probability p to 0.5, that is, in one optimization process of the generator model, each of the 15 neurons has a 50% probability of being temporarily deleted until a part of the neurons is restored and deleted again with the probability p in the next optimization process. A generated neural network layer of random length is obtained.
Step 411: and mapping the second neural network layer by the following formula to obtain a second hidden layer, selecting the neuron with the maximum value in the second hidden layer 2 to map into a (0,1) interval, and taking the mapped data as the output result of the discriminator. That is, when the output result of the discriminator is 0.5, the discriminator cannot judge the source of the received data sample; otherwise, the discrimination results in that the received data sample originates from the generator.
q’i=w’i1×q1+w’i2×q2+....+w’in×qn (6)
W’j1Is a weight matrix Wmaxout2Line j 1 st element, q'1For the 1 st data of the input sequence, qjIs the jth data in the second hidden layer.
Preferably, in step 411, the maxout algorithm is used to map the second neural network layer; and mapping the neurons of the second hidden layer by adopting a sigmoid function.
And 5: the parameters of the generator and discriminator are updated, i.e. the generator and discriminator are optimized. Specifically, after the generator completes one generation, the neural network calculates a loss function of the generated data and propagates the loss function back to modify the parameters of the generator. When the generator completes the adjustment of the parameters, the discriminator judges the generated sample sequence, and when the output data of the discriminator is 0.5, the discriminator cannot judge that the data comes from the generator. When the discriminator output is not equal to 0.5, the generator continues the above-described generation and parameter adjustment process until the discriminator cannot distinguish the source of the sequence of samples generated by the generator. The probability that the generator generates the sample sequence at the moment is considered to be derived from real data by the discriminator, the discriminator also has the probability of 50% to judge that the sample sequence generated by the generator comes from the generator, namely the game between the generator and the generator reaches an equilibrium state, and the obtained generator model parameters can be considered as an optimal generator, namely a generator model for energy storage output prediction is established.
The constraint conditions of the CGAN model are as follows:
wherein, G (z)
noiseY) is sample data generated by the generator according to the condition information Y and the noise information znoise; d (G (z)
noiseY)) is the output of the discriminator;
as a mathematical expectation of log D (x | y), the generated sample data and the mean of the real sample data are used instead;
for z is a random number, P
z(z) is a probability distribution function of the random number z,
obey a probability distribution P when z
z(z) mathematical expectation; p
data(x)Probability distribution of input real sample data; p
z(z) is a probability distribution function for the random number z; p is a probability distribution; v (D, G) represents the game function between the generator and the arbiter.
In said step 5, the generator and the discriminator are optimized by the following two equations, respectively:
wherein the generator constraint is as follows (7):
wherein the discriminator constraint is the following equation (8):
according to respective constraint conditions, a generator and a discriminator in the CGAN model continuously adjust model parameters to enable a constraint function of the generator to be minimum and model parameters of the discriminator to be maximum, and with the aim of optimizing the generator parameters through back propagation of a neural network, the generator parameters comprise a mapping function of a full connection layer in the generator, values on neurons, the number of the neurons and the like.
Step 6: the number of iterations is increased by 1 and the process returns to step 5 until the discriminator cannot distinguish the source of the sample data. Namely, when the output result of the discriminator is 0.5, the game between the discriminator and the generator is considered to be balanced, the training is finished, so that a stronger generator is obtained, and the generator is output as an output prediction model of the energy storage device.
And 7: and (4) acquiring real-time operation data of the energy storage device, inputting the real-time operation data into the generator output in the step (6), and predicting the energy storage output condition of the energy storage device.
The VAE-CGAN model is used for predicting the energy storage output, not only can condition information under a historical scene be modeled, but also unknown condition information can be responded, the condition information hidden in an input sequence is trained through the VAE model, the continuous condition input space input CGAN model is constructed, an optimal generator is obtained through confrontation, and the accuracy of the energy storage output prediction is guaranteed. Therefore, the optimal output of the stored energy under the working environment with strong uncertainty can be determined more comprehensively and accurately.
While the best mode for carrying out the invention has been described in detail and illustrated in the accompanying drawings, it is to be understood that the same is by way of illustration and example only and is not to be taken by way of limitation, the scope of the invention should be determined by the appended claims and any changes or modifications which fall within the true spirit and scope of the invention should be construed as broadly described herein.