A warehouse entry flow calculation method, system, storage medium and electronic device
By constructing a flow prediction system based on an LSTM model and combining it with artificially smoothed data to optimize the inbound flow model, the problem of flow value distortion in existing technologies has been solved, achieving high accuracy and low cost inbound flow prediction.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-02
- Publication Date
- 2026-04-07
AI Technical Summary
Existing technologies, when calculating inflow, use smoothing methods that weaken extreme values in the data, leading to distorted flow values and difficulty in reflecting important information such as flood peaks. Furthermore, errors in measured water levels and the influence of dynamic reservoir capacity can cause outliers, requiring manual intervention to ensure the rationality of inflow.
We collected reservoir hydrological data, constructed sample data, and trained a flow prediction model. We used an LSTM model to generate simulated smooth flow, combined with artificially smoothed inflow data, and optimized model parameters by constructing a loss function and penalty term to generate accurate simulated smooth flow.
This improved the accuracy and stability of inbound flow forecasting, reduced the cost of manual intervention, and ensured the rationality and continuity of flow forecasting.
Smart Images

Figure CN120068591B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present disclosure belongs to the technical field of reservoir regulation, and particularly relates to a smooth inflow calculation method and system, a storage medium and an electronic device. BACKGROUND
[0002] Inflow calculation is one of the most important basic works in reservoir regulation, and the preparation of reservoir flood forecasting and regulation scheme, the development of reservoir regulation chart, the economic evaluation of reservoir regulation, and the reservoir flood regulation calculation all need to calculate inflow.
[0003] In the prior art, when using the water balance method to obtain the calculation of inflow, a smoothing method is usually used for processing. The smoothing method often weakens extreme values in the data, so this method may cause some flow values to be distorted, ultimately leading to the calculated inflow being difficult to accurately reflect important information such as flood peaks, and extreme hydrological events such as flood peaks often have an important impact on reservoir regulation and safe operation. At the same time, due to large errors in measured water levels and the influence of dynamic reservoir capacity, abnormal values often occur in the calculation of inflow, and artificial smoothing of inflow is often required according to the trend and magnitude of the predicted flow to ensure the reasonableness of the inflow. SUMMARY
[0004] To solve the above problems, the present disclosure provides a smooth inflow calculation method, system, storage medium and electronic device, which collects reservoir hydrological data, constructs sample data, forms a training set, trains a flow prediction model, and obtains an optimal parameter model. An analytical optimization algorithm is constructed to generate analytical inflow for subsequent generation of simulated smooth flow. The optimal parameter model generates simulated smooth flow according to the analytical flow data and future predicted flow data. In the process of determining the optimal parameter model, artificial smooth inflow data is used, which can include artificial experience when the optimal parameter model generates simulated smooth flow, improve the accuracy of prediction, and reduce the cost of artificial labor.
[0005] The present disclosure is implemented by the following technical solutions:
[0006] In a first aspect, the present disclosure provides a smooth inflow calculation method, which comprises:
[0007] Collecting reservoir hydrological data, processing the reservoir hydrological data, and determining the original data;
[0008] Generating sample data from the original data and constructing a sample set, dividing the sample set into a training set and a test set;
[0009] Constructing a flow prediction model, training the flow prediction model using the training set, and determining an optimal parameter model;
[0010] Obtain analytical flow data and future forecast flow data, and use the optimal parameter model to generate simulated smooth flow based on the analytical flow data and future forecast flow data.
[0011] Furthermore,
[0012] Collect inflow data, historical water level data, and the relationship between water level and reservoir capacity; and correlate inflow data with historical water level data and the relationship between water level and reservoir capacity.
[0013] The inbound flow data is integrated to determine the raw data, which includes calculated inbound flow data, predicted inbound flow data, and manually smoothed inbound flow data.
[0014] Furthermore,
[0015] Preprocess the raw data to fill in any missing values.
[0016] Determine the time steps for calculating inbound flow data, forecasting inbound flow data, and manually smoothing inbound flow data;
[0017] Based on the time step, the calculated inflow data is divided into multiple first data segments, the forecasted inflow data is divided into second data segments, and the manually smoothed inflow data is divided into third data segments.
[0018] Using the first data segment and the corresponding second data segment as input, and the third data segment corresponding to the first data segment and the second data segment as output, sample data is constructed, and multiple sample data are used to generate a sample set;
[0019] The sample set is divided into a training set and a test set according to the time sequence.
[0020] Furthermore,
[0021] The first time step is the calculated inbound flow data, the second time step is the predicted inbound flow data, and the third time step is the manually smoothed inbound flow data. The start time of the predicted inbound flow data lags behind the start time of the calculated inbound flow data and the start time of the manually smoothed inbound flow data.
[0022] Furthermore,
[0023] Based on the calculated inbound traffic data at the first time step, the data is divided into first data segments. Each first data segment corresponds to the calculated inbound traffic data at the first time step, and adjacent first data segments are continuous in time.
[0024] Based on the forecast inflow data at the second time step, the data is divided into second data segments. Each second data segment corresponds to the forecast inflow data at the second time step, and adjacent second data segments are continuous in time.
[0025] Based on the manually smoothed inbound traffic data at the third time step, the data is divided into third data segments. Each third data segment corresponds to the manually smoothed inbound traffic data at the third time step, and adjacent third data segments are continuous in time.
[0026] Furthermore,
[0027] The first dataset consists of three temporally consecutive data segments, and the second dataset consists of two temporally consecutive data segments. The first and second datasets are used as input, and the third data segment is used as output.
[0028] The first dataset is continuous in time; for two adjacent second datasets, the calculated inbound traffic data for the later second dataset is delayed by a second time compared to the calculated inbound traffic data for the earlier second dataset.
[0029] Furthermore,
[0030] In the process of generating sample data, one second dataset corresponds to two first datasets, and the two first datasets are temporally consecutive and also temporally consecutive with their corresponding second datasets; one first dataset corresponds to one third data segment; the nth sample data is specifically represented as follows:
[0031] Input: (X) n Y round (n / 2)); Output [q] n ];
[0032] Among them, X n Let n be a non-zero positive integer, and let Y be the first dataset. Each first dataset consists of three temporally consecutive first data segments. round(n / 2) For the second dataset, round(n / 2) represents rounding up. Each second dataset consists of two temporally consecutive second data segments; q n This is the third data segment, where n is a non-zero positive integer.
[0033] Furthermore,
[0034] Build an LSTM model for traffic prediction, set the initial parameters of the LSTM model, train the LSTM model using the training set, and generate simulated traffic.
[0035] A loss function is constructed by combining the penalty terms determined based on the simulated flow rate and the given flow rate; where the given flow rate is either measured data or standard data calculated in practice.
[0036] The output error of the LSTM model is calculated layer by layer. The initial parameters of the LSTM model are updated based on the output error. The optimal parameter model is determined by combining the loss function.
[0037] Furthermore,
[0038] The loss function is constructed by combining the penalty term determined based on the simulated flow rate and the given flow rate, and is specifically expressed as follows:
[0039] L(θ)=λ data loss data +λ smoothing loss smoothing ;
[0040] Where L(θ) is the loss function of the LSTM model; loss data The root mean square error of the simulated flow rate and the given flow rate; loss smoothing λ is a penalty term used to penalize portions of the simulated flow that do not conform to flow continuity constraints. data , λ smoothing These are the weighting coefficients;
[0041] Penalty loss smoothing The formula is specifically expressed as follows:
[0042]
[0043] Where, q t Let q be the simulated flow rate determined by the LSTM model in time period t. t+1 Q represents the simulated flow rate determined by the LSTM model during time period t+1; t Let Q be the manually smoothed inbound flow rate for time period t. t+1 Let Q be the manually smoothed inbound flow rate for the (t+1)th time period. t and Q t+1 Used as a given flow rate; N can be a non-zero positive integer or positive infinity.
[0044] Furthermore,
[0045] Construct the objective function and solve it to obtain the calculation formula for the analytical inflow related to the real-time reservoir data; the real-time reservoir data includes the observed value of the real-time reservoir storage and the reservoir outflow.
[0046] Based on the real-time reservoir water storage and outflow, the inflow is analyzed.
[0047] Secondly, based on the same inventive concept, the present disclosure also provides a smooth inbound flow calculation system, the system including a data collection module, a data processing module, a model generation module, an algorithm generation module and a model calculation module;
[0048] The data collection module is used to collect reservoir hydrological data, process the reservoir hydrological data, and determine the raw data;
[0049] The data processing module is used to generate sample data based on the raw data, construct a sample set, and divide the sample set into a training set and a test set.
[0050] The model generation module is used to build a traffic prediction model, train the traffic prediction model using a training set, and determine the optimal parameter model.
[0051] The algorithm generation module is used to construct analytical optimization algorithms and generate analytical inflow rates by combining real-time reservoir data.
[0052] The model calculation module is used to determine the analytical flow data and the future forecast flow data, and to generate simulated smooth flow based on the analytical flow data and the future forecast flow data using the optimal parameter model.
[0053] Thirdly, based on the same inventive concept, the present disclosure also provides a computer-readable storage medium storing one or more programs, which, when executed, can realize the aforementioned smooth inbound flow calculation method.
[0054] Fourthly, based on the same inventive concept, embodiments of this disclosure also provide an electronic device, including a processor, a communication interface, the aforementioned computer-readable storage medium, and a communication bus. The processor, communication interface, and computer-readable storage medium communicate with each other via the communication bus. The processor is used to execute a program stored in the aforementioned computer-readable storage medium.
[0055] Compared with the prior art, this disclosure has the following advantages:
[0056] In the process of predicting inbound flow, the smoothing of inbound flow by humans was simulated, which improved the accuracy and stability of inbound flow prediction and reduced labor costs.
[0057] Other features and advantages of this disclosure will be set forth in the description which follows, and will be apparent in part from the description, or may be learned by practicing the disclosure. The objects and other advantages of this disclosure may be realized and obtained by means of the structures pointed out in the description, claims and drawings. Attached Figure Description
[0058] To more clearly illustrate the technical solutions in the embodiments of this disclosure or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of this disclosure. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0059] Figure 1 A flowchart of a smooth inbound flow calculation method provided in this embodiment of the disclosure;
[0060] Figure 2 A schematic diagram of an LSTM model provided in an embodiment of this disclosure;
[0061] Figure 3 A block diagram of a smooth inbound flow calculation system provided in this disclosure embodiment;
[0062] Figure 4 This is a schematic diagram of an electronic device structure provided in an embodiment of the present disclosure. Detailed Implementation
[0063] To make the objectives, technical solutions, and advantages of the embodiments of this disclosure clearer, the technical solutions of the embodiments of this disclosure will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this disclosure, and not all embodiments. Based on the embodiments of this disclosure, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this disclosure.
[0064] Firstly, Figure 1 A flowchart of a smooth inbound flow calculation method provided in this disclosure embodiment is shown below. Figure 1 As shown in the embodiments of this disclosure, a method for calculating smooth inbound flow is provided, including:
[0065] S1: Collect reservoir hydrological data, process the reservoir hydrological data, and determine the raw data.
[0066] S2: Generate sample data based on the original data and construct a sample set, dividing the sample set into a training set and a test set.
[0067] S3: Build a traffic prediction model, train the traffic prediction model using the training set, and determine the optimal parameter model.
[0068] S4: Obtain analytical flow data and future forecast flow data, use the optimal parameter model, and generate simulated smooth flow based on the analytical flow data and future forecast flow data.
[0069] In this embodiment, reservoir hydrological data is collected to construct sample data, forming a training set. This training set is then used to train the flow prediction model, resulting in an optimal parameter model. Analytical flow data and future forecast flow data are obtained by analyzing historical data, observational data, and forecast data, as well as through prediction models or software. Alternatively, an analytical optimization algorithm can be constructed to generate analytical inflow flow, which is then used to generate simulated smooth flow. The optimal parameter model generates simulated smooth flow based on the analytical flow data and future forecast flow data. In determining the optimal parameter model, manually smoothed inflow flow data is used. Therefore, the simulated smooth flow generated by the optimal parameter model incorporates human experience, improving prediction accuracy while reducing labor costs.
[0070] In some examples, reservoir hydrological data is collected, processed, and the raw data is determined, including:
[0071] S11: Collect inflow data, historical water level data, and the relationship between water level and reservoir capacity. The inflow data is correlated with the historical water level data and the relationship between water level and reservoir capacity.
[0072] S12: Integrate the inbound flow data to determine the raw data, which includes calculated inbound flow data, forecasted inbound flow data, and manually smoothed inbound flow data.
[0073] In some examples, sample data is generated from the raw data, and a sample set is constructed, which is then divided into a training set and a test set, including:
[0074] S21: Preprocess the original data to fill in any missing values.
[0075] Specifically, it is necessary to check for missing values in the original data. Interpolation and imputation methods can be used to fill in the missing values, including linear interpolation, previous value imputation, and mean imputation. The calculated inbound flow data, forecasted inbound flow data, and manually smoothed inbound flow data are preprocessed into time-continuous data for subsequent segmentation based on time steps.
[0076] S22: Determine the time step for calculating inbound flow data, forecasting inbound flow data, and manually smoothing inbound flow data.
[0077] S23: Based on the time step, the calculated inflow data is divided into multiple first data segments, the forecasted inflow data is divided into second data segments, and the manually smoothed inflow data is divided into third data segments.
[0078] S24: Using the first data segment and the corresponding second data segment as input, and the third data segment corresponding to the first data segment and the second data segment as output, construct sample data, and generate a sample set from multiple sample data.
[0079] S25: Divide the sample set into a training set and a test set according to the time sequence.
[0080] In some examples, the time steps for calculating inbound flow data, forecast inbound flow data, and manually smoothed inbound flow data are determined, including:
[0081] The first time step is the calculated inbound flow data, the second time step is the predicted inbound flow data, and the third time step is the manually smoothed inbound flow data. The start time of the predicted inbound flow data lags behind the start time of the calculated inbound flow data and the start time of the manually smoothed inbound flow data.
[0082] In this embodiment of the disclosure, the first time is 2 hours, the second time is 12 hours, and the third time is 6 hours. The calculated inbound flow data has a step size of 2 hours, the predicted inbound flow data has a step size of 12 hours, and the manually smoothed inbound flow data has a step size of 6 hours. The starting time of the predicted inbound flow data is delayed by 12 hours compared to the starting time of the calculated inbound flow data, and the starting time of the manually smoothed inbound flow data is delayed by 6 hours compared to the starting time of the calculated inbound flow data.
[0083] In some examples, based on the time step, the calculated inflow data is divided into multiple first data segments, the predicted inflow data is divided into second data segments, and the manually smoothed inflow data is divided into third data segments, including:
[0084] Based on the calculated inbound traffic data at the first time step, the data is divided into first data segments. Each first data segment corresponds to the calculated inbound traffic data at the first time step, and adjacent first data segments are continuous in time.
[0085] Based on the forecast inflow data at the second time step, the data is divided into second data segments. Each second data segment corresponds to the forecast inflow data at the second time step, and adjacent second data segments are continuous in time.
[0086] Based on the manually smoothed inbound traffic data at the third time step, a third data segment is defined. Each third data segment corresponds to the manually smoothed inbound traffic data at the third time step, and adjacent third data segments are temporally continuous. The specific representations of the first, second, and third data segments are as follows:
[0087] Each first data segment is represented as: [x1, x2, x3, ..., x8, ...];
[0088] Each second data segment is represented as: [y1, y2, ...];
[0089] Each third data segment is represented as: [q1, q2, ...];
[0090] Among them, the adjacent first data segments in [x1, x2, x3, ..., x8, ...] are continuous in time, the adjacent second data segments in [y1, y2, ...] are continuous in time, and the adjacent third data segments in [q1, q2, ...] are continuous in time.
[0091] In this embodiment, since the starting time of the forecasted inflow data is 12 hours behind the starting time of the calculated inflow data, and the starting time of the manually smoothed inflow data is 6 hours behind the starting time of the calculated inflow data; and since the step size of the first data segment is 2 hours, the step size of the second data segment is 12 hours, and the step size of the third data segment is 6 hours; therefore, it is understandable that the end time of x6 is the starting time of y1, the end time of x3 is the starting time of q1, and so on.
[0092] In some examples, sample data is constructed using a first data segment and its corresponding second data segment as input, and a third data segment corresponding to the first and second data segments as output. Multiple sample data segments generate a sample set, including:
[0093] The first dataset consists of three temporally consecutive data segments, and the second dataset consists of two temporally consecutive data segments. The first and second datasets are used as input, and the third data segment is used as output.
[0094] The first dataset is continuous in time; for two adjacent second datasets, the calculated inbound traffic data for the later second dataset is delayed by a second time compared to the calculated inbound traffic data for the earlier second dataset; therefore, there is a duplicate second data segment in the two adjacent second datasets.
[0095] Furthermore, in the process of generating sample data, one second dataset corresponds to two first datasets, and the two first datasets are temporally continuous, as are their corresponding second datasets; one first dataset corresponds to one third data segment; the nth sample data can be specifically represented as:
[0096] Input: (X) n Y round(n / 2) Output [q] n];
[0097] Among them, X n Let n be a non-zero positive integer, and let Y be the first dataset. Each first dataset consists of three temporally consecutive first data segments. round(n / 2 ) represents the second dataset, round(n / 2) indicates rounding up, and each second dataset consists of two temporally consecutive second data segments; q n This is the third data segment, where n is a non-zero positive integer.
[0098] It should be understood that the time steps of the calculated inbound flow data, the predicted inbound flow data, and the manually smoothed inbound flow data provided in this embodiment of the disclosure, as well as the method of constructing the sample data, are only a specific example. The time steps of the calculated inbound flow data, the predicted inbound flow data, and the manually smoothed inbound flow data, and the method of constructing the sample data can be adjusted accordingly based on the actual flow data.
[0099] In some examples, a traffic prediction model is built, trained using a training set, and the optimal parameter model is determined, including:
[0100] S31: Construct an LSTM model for traffic prediction, set the initial parameters of the LSTM model, train the LSTM model using the training set, and generate simulated traffic.
[0101] S32: Construct a loss function by combining the penalty term determined based on the simulated flow rate and the given flow rate; where the given flow rate is the measured data or the standard data actually calculated.
[0102] S33 calculates the output error of the LSTM model layer by layer, updates the initial parameters of the LSTM model based on the output error, and determines the optimal parameter model by combining the loss function.
[0103] Specifically, based on the output error calculated layer by layer, the initial parameters of the LSTM model are updated using the gradient descent method to obtain an LSTM model with the lowest possible loss function value. The LSTM model at this point is then tested using a test set. If it passes the test set test, the optimal parameter model is finally determined. The optimal parameter model can generate manually smoothed inbound traffic data with human experience.
[0104] In some examples, a loss function is constructed by combining a penalty term determined based on the simulated flow rate and the given flow rate, specifically expressed as:
[0105] L(θ)=λ data loss data +λ smoothing loss smoothing ;
[0106] Where L(θ) is the loss function of the LSTM model; loss data To calculate the root mean square error (RMSE) of the simulated flow rate and the given flow rate, the RMS error can be normalized; loss smoothing λ is a penalty term used to penalize portions of the simulated flow that do not conform to flow continuity constraints. data , λ smoothing These are the weighting coefficients.
[0107] Penalty loss smoothing The formula is specifically expressed as follows:
[0108]
[0109] Where, q t Let q be the simulated flow rate determined by the LSTM model in time period t. t+1 Q represents the simulated flow rate determined by the LSTM model during time period t+1; t Let Q be the manually smoothed inbound flow rate for time period t. t+1 Let Q be the manually smoothed inbound flow rate for the (t+1)th time period. t and Q t+1 Used as a given flow rate; N takes the form of a non-zero positive integer or positive infinity. Understandably, Q... t and Q t+1 The corresponding output value in the sample data, namely the manually smoothed inbound flow with human experience, is therefore regarded as the standard data actually calculated.
[0110] In some examples, before obtaining analytical flow data and future forecast flow data, and using the optimal parameter model to generate simulated smooth flow based on the analytical flow data and future forecast flow data, the process also includes: constructing an analytical optimization algorithm, combining it with real-time reservoir data, to generate analytical inflow flow.
[0111] Furthermore, an analytical optimization algorithm is constructed, which, combined with real-time reservoir data, generates an analytical inflow rate, including:
[0112] S41': Construct the objective function and solve it to obtain the calculation formula for the analytical inflow related to the real-time reservoir data; the real-time reservoir data includes the observed value of the real-time reservoir storage and the reservoir outflow.
[0113] S42': Generate the analytical inflow rate based on the real-time reservoir storage and outflow.
[0114] Understandably, analytical flow data and future forecast flow data can be obtained by analyzing historical data, observation data, forecast data, and through predictive models or software. Alternatively, analytical optimization algorithms can be constructed to generate analytical flow data for subsequent generation of simulated smooth flow data.
[0115] Example 1:
[0116] S101: Collect reservoir hydrological data, process the reservoir hydrological data, and determine the raw data.
[0117] Reservoir hydrological data includes inflow data, historical water level data, and water level-storage capacity relationship. Historical water level data and the water level-storage capacity relationship are collected according to actual research needs. Historical water level data includes high-temporal-resolution measured water level data obtained from reservoir water level monitoring stations, and the water level-storage capacity relationship includes the reservoir water level-storage capacity relationship curve. Inflow data is correlated with historical water level data and the water level-storage capacity relationship; for example, historical water level data and the water level-storage capacity relationship can be used in determining inflow data. Inflow data specifically includes calculated inflow data, predicted inflow data, and artificially smoothed inflow data. Among them, calculated inflow data is determined using the eight-segment method.
[0118] The collected reservoir hydrological data is processed in several ways, including integrating and consolidating historical water level data and the relationship between water level and reservoir capacity; it also includes integrating and calculating inflow data, forecast inflow data, and artificially smoothed inflow data according to time series, which are then used as raw data.
[0119] S102: Generate a sample set based on the original data, and divide the sample set into a training set and a test set.
[0120] First, it's necessary to check for missing values in the original data. Missing values can be filled using interpolation, imputation, or other methods, including linear interpolation, previous value imputation, and mean imputation. The calculated, predicted, and manually smoothed inbound flow data are preprocessed into time-continuous data for subsequent segmentation based on time steps.
[0121] The time steps for calculated inbound flow data, forecasted inbound flow data, and manually smoothed inbound flow data are determined, and these data are then divided into data segments based on the time steps. The calculated inbound flow data uses a 2-hour time step, the forecasted inbound flow data uses a 12-hour time step, and the manually smoothed inbound flow data uses a 6-hour time step. The start time of the forecasted inbound flow data lags behind the start time of the calculated inbound flow data by 12 hours, and the start time of the manually smoothed inbound flow data lags behind the start time of the calculated inbound flow data by 6 hours. Based on the calculated inbound flow data with a 2-hour step size, the data is divided into three segments: a first data segment, where each segment corresponds to 2 hours of calculated inbound flow data, and adjacent segments are temporally continuous; based on the predicted inbound flow data with a 12-hour step size, the data is divided into a second data segment, where each segment corresponds to 12 hours of predicted inbound flow data, and adjacent segments are temporally continuous; and based on the manually smoothed inbound flow data with a 6-hour step size, the data is divided into a third data segment, where each segment corresponds to 6 hours of manually smoothed inbound flow data, and adjacent segments are temporally continuous. The specific representations of the first, second, and third data segments are as follows:
[0122] Each first data segment is represented as: [x1, x2, x3, ..., x8, ...];
[0123] Each second data segment is represented as: [y1, y2, ...];
[0124] Each third data segment is represented as: [q1, q2, ...];
[0125] Among them, the adjacent first data segments in [x1, x2, x3, ..., x8, ...] are continuous in time, the adjacent second data segments in [y1, y2, ...] are continuous in time, and the adjacent third data segments in [q1, q2, ...] are continuous in time.
[0126] Since the start time of the forecasted inflow data lags behind the start time of the calculated inflow data by 12 hours, and the start time of the manually smoothed inflow data lags behind the start time of the calculated inflow data by 6 hours; and since the step size of the first data segment is 2 hours, the step size of the second data segment is 12 hours, and the step size of the third data segment is 6 hours; therefore, it is understandable that the end time of x6 is the start time of y1, the end time of x3 is the start time of q1, and so on.
[0127] In this embodiment, sample data is constructed based on the time steps of the calculated inflow data, the predicted inflow data, and the artificially smoothed inflow data, corresponding to the first data segment, the second data segment, and the third data segment. All sample data are used as a sample set, and the sample data are continuous in time. During the construction of the sample data, three temporally continuous first data segments are used as the first dataset, and two temporally continuous second data segments are used as the second dataset. The first and second datasets are used as inputs, and the third data segment is used as the output. The first datasets are continuous in time, and for any two adjacent first datasets, the calculated inflow data corresponding to the later first dataset is delayed by 6 hours compared to the calculated inflow data corresponding to the earlier first dataset. The second datasets are continuous in time, and for any two adjacent second datasets, the calculated inflow data corresponding to the later second dataset is delayed by 12 hours compared to the calculated inflow data corresponding to the earlier second dataset. Since the second dataset includes two adjacent second data segments, and each second data segment corresponds to 12 hours of predicted inflow data, there is overlap in the second data segments between adjacent second datasets. The sample data is constructed as follows:
[0128] The following are four sets of sample data as examples:
[0129] Input: ([x1, x2, x3], [y1, y2]); Output: [q1];
[0130] Input: ([x4, x5, x6], [y1, y2]); Output: [q2];
[0131] Input: ([x7, x8, x9], [y2, y3]); Output: [q3];
[0132] Input: ([x 10 x 11 x 12 [y1, y2]; Output [q4];
[0133] Furthermore, in the process of generating sample data, one second dataset corresponds to two first datasets, and the two first datasets are temporally continuous, as are their corresponding second datasets; one first dataset corresponds to one third data segment; the nth sample data can be specifically represented as:
[0134] Input: (X) n Y round(n / 2) Output [q] n ];
[0135] Among them, X nLet n be a non-zero positive integer, representing the first dataset. Each first dataset consists of three consecutive data segments in time: the first dataset is [x1, x2, x3], the second dataset is [x4, x5, x6], and so on. round(n / 2) For the second dataset, `round(n / 2)` represents rounding to the nearest integer. Each second dataset consists of two consecutive data segments in time. The first second dataset is [y1, y2], the second is [y2, y3], and so on. n This is the third data segment, where n is a non-zero positive integer.
[0136] In this embodiment of the disclosure, the training set and test set are determined according to the rate-setting period and the test period. For example, the sample data in the sample set are arranged in chronological order, and according to the time sequence, the first 80% of the sample data in the sample set is used as the training set, and the last 20% of the sample data is used as the test set. The values of each flow data in the sample data are usually relatively large. In order to prevent the problem of numerical explosion or gradient vanishing, a normalization method is required for preprocessing.
[0137] S103: Construct a traffic prediction model, train the traffic prediction model using the training set, and determine the optimal parameter model.
[0138] In this embodiment of the disclosure, when constructing the traffic prediction model, the LSTM (Long Short-Term Memory) model is selected as the traffic prediction model.
[0139] Set the initial parameters of the LSTM model, including the forget gate weights, forget gate bias terms, input gate weight matrix, input gate bias terms, candidate memory unit weight matrix, candidate memory unit bias terms, output gate weights, output gate bias terms, learning rate, number of layers, etc.
[0140] like Figure 2 As shown, each layer of the LSTM model is calculated in the order of forget gate, input gate, cell state update, and output gate, and finally the output value is obtained. The output value is used as the input of the next layer for the calculation of the next layer.
[0141] The forgetting gate determines the cell state at the previous moment. t-1 Information that needs to be retained and forgotten needs to be considered in the LSTM model. Cell states are the long-term memory in the LSTM model, capable of retaining information over a long period without being forgotten. This is achieved through adjustments to the forgetting and input gates, allowing cell states to selectively retain or forget information, ensuring that useful information is preserved for extended periods. The formula for calculating the forgetting gate is:
[0142] f t =σ(Wf [x t h t-1 ]+b f (1)
[0143] Among them, f t The output of the forget gate, ranging from (0, 1), represents the proportion of information retained from the previous state; σ is the sigmoid activation function; W f Forget gate weights; h t-1 This is the hidden state from the previous moment, containing memory information from that moment; x t For input data; b f This is the bias term for the forget gate, used to adjust the flexibility of the model.
[0144] The input gate determines the information stored in the cell state; candidate memory units are used to update the cell state. The formula for calculating the input gate is:
[0145] i t =σ(W i [h t-1 x t ]+b i (2)
[0146]
[0147] Among them, i t The input gate output represents the retention ratio of the current input information; W i This is the weight matrix of the input gate; b i It is the bias term of the input gate; It is a candidate memory unit; W c It is the weight matrix of the candidate memory units; b c It is the bias term for candidate memory units; h t-1 This is the hidden state from the previous moment, containing memory information from that moment; x t For input data.
[0148] Update cell status:
[0149]
[0150] In the formula, C t The current cell state; f t The output of the forget gate, ranging from (0, 1), represents the proportion of information from the previous state that is retained; C t-1 Indicates the cell state at the previous moment; i t Input gate output; It is a candidate memory unit.
[0151] The output gate determines the final output value, which is then passed to the next layer or the next time step. The formula for calculating the output gate is:
[0152] o t =σ(W o [h t-1 x t ]+b o (5)
[0153] h t =o t tanh(C t (6)
[0154] Among them, o t The output of the output gate is in the range (0, 1), representing the proportion of information output in the cell state; W o b represents the weights of the output gate. o For the bias term of the output gate; C t The current cell state; h t The hidden state at the current moment is passed as an output value to the next layer or the next time step; h t-1 This is the hidden state from the previous moment, containing memory information from that moment; x t For input data.
[0155] The training set includes multiple sample datasets. These datasets use calculated and predicted inflow rates as input, and manually smoothed inflow rates as output. During training, the LSTM model performs forward propagation. For each set of calculated and predicted inflow rates, the model attempts to calculate and output a prediction of an inflow rate that approximates the manually smoothed inflow rate. The LSTM model iterates through multiple layers to generate the simulated flow rate corresponding to the training set.
[0156] To further optimize the LSTM model and determine the optimal parameter model, a loss function is constructed by combining a penalty term determined based on simulated flow rate and given flow rate. The given flow rate is either measured data or standard data calculated from actual data. The loss function is used to evaluate the LSTM model; the smaller the value of the loss function, the more accurate the output of the LSTM model. The LSTM model is evaluated based on the value of the loss function, and the initial parameters are adjusted to determine the optimal parameter model.
[0157] The loss function is specifically expressed as follows:
[0158] L(θ)=λ data loss data +λ smoothing loss smoothing (7)
[0159] Where L(θ) is the loss function of the LSTM model; loss data To calculate the root mean square error (RMSE) of the simulated flow rate and the given flow rate, the RMS error can be normalized; loss smoothing λ is a penalty term used to penalize portions of the simulated flow that do not conform to flow continuity constraints. data , λ smoothing These are the weighting coefficients.
[0160] Penalty loss smoothing The formula is specifically expressed as follows:
[0161]
[0162] Where, q t Let q be the simulated flow rate determined by the LSTM model in time period t. t+1 Q represents the simulated flow rate determined by the LSTM model during time period t+1; t Let Q be the manually smoothed inbound flow rate for time period t. t+1 Let Q be the manually smoothed inbound flow rate for the (t+1)th time period. t and Q t+1 Used as a given flow rate; N can be a non-zero positive integer or positive infinity.
[0163] Furthermore, the loss function is expanded to:
[0164]
[0165] Where L(θ) is the loss function of the LSTM model; loss data The extended formula, q t The simulated flow rate determined by the LSTM model in time period t. This represents the average value of the manually smoothed inbound flow rate.
[0166] After constructing the loss function, for each layer in the LSTM model, the output error is calculated layer by layer from the output layer to the input layer:
[0167] δ (l) =δ (l+1) ·W (l+1) ·σ′ (l) (z (l) (10)
[0168] Where, δ (l) Let δ be the output error of the layer. (l+1) W represents the output error of the (l+1)th layer. (l+1) Let σ' represent the weight matrix from layer l to layer l+1, where σ is the sigmoid activation function. (l)Let z be the derivative of the activation function. (l) For the linear combination of the l-th layer, for example, the product of the input and weight matrices of the LSTM model, plus the bias term; z (l) The specific formula may be adjusted based on the actual situation, and no further specific limitations are made here.
[0169] Based on the output error calculated layer by layer, the initial parameters of the LSTM model are updated using the gradient descent method to obtain an LSTM model with the lowest possible loss function value. The LSTM model at this point is tested using a test set. If it passes the test set test, the optimal parameter model is finally determined. The optimal parameter model can generate manually smoothed inbound traffic data with human experience.
[0170] S104: Construct an analytical optimization algorithm and combine it with real-time reservoir data to generate analytical inflow.
[0171] In constructing the analytical optimization algorithm, the continuity of the inflow and the water level estimation error are considered simultaneously, making it a dual-objective optimization problem. The objective function is then constructed and solved accordingly.
[0172] First, determine the objective function and the corresponding constraints. The objective function is expressed as:
[0173]
[0174] The constraints are expressed as follows:
[0175]
[0176] Among them, Z i,j and These are the estimated and observed water levels at time i and location j, respectively. i O is the average inbound flow rate at time i. i I is the average outflow rate at time i, Δf is the time interval from time i to time i+1, and I i R is the inflow of water at time i. i The outflow from reservoir i at time i The observed water level at time i is the reservoir's water storage capacity. The relationship between water level and reservoir capacity f(·) is obtained α is a weighting factor ranging from 0 to 1, and n and m are the length of the inflow sequence and the number of measured water levels, respectively.
[0177] Furthermore, formula (11) also makes the flow rate difference between adjacent time points equal. The difference between the observed water level and the estimated water level Minimum. When α is 0, formulas (11) and (12) are equivalent to the traditional water balance method (SWB). Substituting formula (12) into formula (11) yields:
[0178]
[0179] Among them, the reservoir outflow R i Observed values of reservoir water storage Given that V i As a decision variable for inverting inbound flow.
[0180] After constructing the objective function, it is necessary to solve the objective function to obtain the optimal parsed inbound traffic.
[0181] The objective function is analyzed using the Lagrange method, and the specific process is as follows:
[0182]
[0183]
[0184] Where W is a coefficient matrix of dimension (n+1)×(n+1); V={V i , i = 1, 2, ..., n+1} is a state variable vector of dimension (n+1)×1, representing the estimated value of the reservoir's water storage; It is a constant vector of dimension 1×(n+1), whose value is related to the reservoir outflow R. i Observed values of reservoir water storage Related.
[0185] The estimated value of the reservoir's water storage capacity can be determined using formulas (14a)-(14c):
[0186]
[0187] Furthermore, the calculation formula for inbound and outbound flow rates was determined, and the analytical optimization algorithm was constructed. The calculation formula for inbound flow rates is as follows:
[0188]
[0189] Where ΔT is the time interval from time i to time i+1, I i V is the inflow of water at time i. i As a decision variable for inbound flow inversion, Q can represent the storage capacity at time i. i This is used to analyze the inflow rate, thereby obtaining the calculation formula for the analyzed inflow rate related to the real-time data of the reservoir.
[0190] In the analytical optimization algorithm of this embodiment, the weight value α represents the weight of the inflow variation term in the objective function, and its value ranges from 0 to 1. When α is 1, it means that only the inflow variation is considered; when α is 0, it means that only the water level error is considered. In this case, the analytical method is equivalent to the water balance method. The value of α is determined by the competition between the continuity of the inflow and the estimation error of the water storage. Under the condition of determining the water level observation accuracy and the non-negative inflow of the reservoir, a trial-and-error algorithm is used for estimation.
[0191] Real-time reservoir data includes observed values of real-time reservoir storage and outflow. By collecting these data and using an analytical optimization algorithm, the inflow rate is calculated.
[0192] S105: Determine the analytical flow data and the future forecast flow data, use the optimal parameter model, and generate a simulated smooth flow based on the analytical flow data and the future forecast flow data.
[0193] Collect sufficient analytical inflow and future forecast flow data, for example, three analytical inflow flow data with a two-hour step size and two future forecast flow data with a 12-hour step size; after determining the analytical flow data and future forecast flow data, use the optimal parameter model to generate simulated smooth flow based on the analytical flow data and future forecast flow data.
[0194] Understandably, the difference between the method for obtaining future forecast flow data and the aforementioned forecast inflow flow data is that they correspond to different time periods, and the methods of obtaining them can be the same or different.
[0195] Secondly, Figure 3 A block diagram of a smooth inbound flow calculation system provided in this disclosure embodiment is shown below. Figure 3 As shown, based on the same inventive concept, this disclosure also provides a smooth inflow calculation system, comprising: a data collection module, a data processing module, a model generation module, an algorithm generation module, and a model calculation module. The data collection module collects reservoir hydrological data, processes the hydrological data, and determines the raw data. The data processing module generates sample data based on the raw data and constructs a sample set, dividing the sample set into a training set and a test set. The model generation module constructs a flow prediction model, trains the flow prediction model using the training set, and determines the optimal parameter model. The algorithm generation module constructs an analytical optimization algorithm, combines real-time reservoir data, and generates an analytical inflow. The model calculation module determines the analytical flow data and the future forecast flow data, uses the optimal parameter model, and generates a simulated smooth flow based on the analytical flow data and the future forecast flow data.
[0196] Thirdly, based on the same inventive concept, the present disclosure also provides a computer-readable storage medium storing one or more programs, which, when executed, can realize the aforementioned smooth inbound flow calculation method.
[0197] Fourthly, based on the same inventive concept, embodiments of this disclosure also provide an electronic device, including a processor, a communication interface, the aforementioned computer-readable storage medium, and a communication bus. The processor, communication interface, and computer-readable storage medium communicate with each other via the communication bus. The processor is used to execute a program stored in the aforementioned computer-readable storage medium.
[0198] It should be noted that the electrical connection between the above-mentioned units does not necessarily mean the connection between lines. The indirect connection method can be applied to the embodiments of this disclosure as long as it achieves the purpose of this disclosure.
[0199] Although the present disclosure has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features; and such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present disclosure.
Claims
1. A method for calculating smooth inbound flow rate, characterized in that, The method includes: Collect reservoir hydrological data, process the reservoir hydrological data, and determine the raw data; Based on the original data, sample data is generated, and a sample set is constructed, which is then divided into a training set and a test set. Construct a traffic prediction model, train the traffic prediction model using the training set, and determine the optimal parameter model; Obtain analytical flow data and future forecast flow data, and use the optimal parameter model to generate simulated smooth flow based on the analytical flow data and future forecast flow data; The step of constructing a traffic prediction model, training the traffic prediction model using a training set, and determining the optimal parameter model includes: An LSTM model is constructed for use as the traffic prediction model. The initial parameters of the LSTM model are set, and the LSTM model is trained using a training set to generate simulated traffic. A loss function is constructed by combining the penalty term determined based on the simulated flow rate and the given flow rate; wherein the given flow rate is measured data or standard data calculated in practice. The output error of the LSTM model is calculated layer by layer, the initial parameters of the LSTM model are updated according to the output error, and the optimal parameter model is determined by combining the loss function.
2. The method according to claim 1, characterized in that, The process of collecting reservoir hydrological data, processing the reservoir hydrological data, and determining the raw data includes: Collect inflow data, historical water level data, and the relationship between water level and reservoir capacity; The inbound flow data is integrated to determine the raw data, which includes calculated inbound flow data, predicted inbound flow data, and manually smoothed inbound flow data.
3. The method according to claim 1, characterized in that, The process of generating sample data from the original data and constructing a sample set, dividing the sample set into a training set and a test set, includes: The original data is preprocessed to fill in any missing values. Determine the time steps for the calculated inbound flow data, the predicted inbound flow data, and the manually smoothed inbound flow data; Based on the time step, the calculated inflow data is divided into multiple first data segments, the forecasted inflow data is divided into second data segments, and the manually smoothed inflow data is divided into third data segments. Using the first data segment and the corresponding second data segment as input, and the third data segment corresponding to the first data segment and the second data segment as output, sample data is constructed, and multiple sample data are used to generate a sample set; The sample set is divided into a training set and a test set according to the time sequence.
4. The method according to claim 3, characterized in that, The determination of the time step for calculating the inbound flow data, forecasting the inbound flow data, and manually smoothing the inbound flow data includes: The calculated inbound flow data is at a first time step, the predicted inbound flow data is at a second time step, and the manually smoothed inbound flow data is at a third time step; the start time of the predicted inbound flow data lags behind the start time of the calculated inbound flow data and the start time of the manually smoothed inbound flow data; the start time of the manually smoothed inbound flow data lags behind the start time of the calculated inbound flow data.
5. The method according to claim 3, characterized in that, The process of dividing the calculated inbound flow data into multiple first data segments, the predicted inbound flow data into second data segments, and the manually smoothed inbound flow data into third data segments based on the time step includes: Based on the calculated inbound traffic data at the first time step, the data is divided into first data segments. Each first data segment corresponds to the calculated inbound traffic data at the first time step, and adjacent first data segments are continuous in time. Based on the forecast inflow data at the second time step, the data is divided into second data segments. Each second data segment corresponds to the forecast inflow data at the second time step, and adjacent second data segments are continuous in time. Based on the artificially smoothed inbound traffic data at the third time step, the data is divided into third data segments. Each third data segment corresponds to the artificially smoothed inbound traffic data at the third time step, and adjacent third data segments are continuous in time.
6. The method according to claim 3, characterized in that, The process involves using a first data segment and its corresponding second data segment as input, and a third data segment corresponding to the first and second data segments as output, to construct sample data. Multiple sample data sets generate a sample set, including: The first dataset consists of three temporally consecutive data segments, and the second dataset consists of two temporally consecutive data segments. The first and second datasets are used as input, and the third data segment is used as output. The first dataset is continuous in time; for two adjacent second datasets, the calculated inbound traffic data for the later second dataset is delayed by a second time compared to the calculated inbound traffic data for the earlier second dataset.
7. The method according to claim 6, characterized in that, The process of constructing sample data by taking a first data segment and a corresponding second data segment as input, and a third data segment corresponding to the first and second data segments as output, and generating a sample set from multiple sample data segments, further includes: In the process of generating sample data, one second dataset corresponds to two first datasets, and the two first datasets are temporally consecutive and also temporally consecutive with their corresponding second datasets; one first dataset corresponds to one third dataset; the nth sample data is specifically represented as: enter:( , ); Output ; in, Let n be a non-zero positive integer, and each first dataset consists of three consecutive first data segments in time. For the second dataset, This indicates rounding up. Each second dataset consists of two consecutive second data segments in time.
8. The method according to claim 1, characterized in that, The loss function is constructed by combining the penalty term determined based on the simulated flow rate and the given flow rate, and is specifically expressed as follows: ; in, The loss function for the LSTM model; The root mean square error between the simulated flow rate and the given flow rate; This is a penalty term used to penalize portions of simulated flow that do not conform to flow continuity constraints. , These are the weighting coefficients; Penalty items The formula is specifically expressed as follows: ; in, Let t be the simulated flow rate determined by the LSTM model in time period t. The simulated flow rate is determined by the LSTM model in the (t+1)th time period; Let t be the manually smoothed inbound flow rate. For the manually smoothed inbound flow in the (t+1)th time period, and Used as a given flow rate.
9. The method according to claim 1, characterized in that, The smooth inbound flow calculation method further includes: Construct the objective function and solve it to obtain the calculation formula for the analytical inflow related to the real-time reservoir data; the real-time reservoir data includes the observed value of the real-time reservoir storage and the reservoir outflow. Based on the real-time reservoir water storage and outflow, the inflow is analyzed.
10. A smooth inbound flow calculation system, characterized in that, The system includes a data collection module, a data processing module, a model generation module, an algorithm generation module, and a model calculation module; The data collection module is used to collect reservoir hydrological data, process the reservoir hydrological data, and determine the raw data; The data processing module is used to generate sample data based on the raw data, construct a sample set, and divide the sample set into a training set and a test set. The model generation module is used to build traffic prediction models, train the traffic prediction models using training sets, and determine the optimal parameter model, including: An LSTM model is constructed for use as the traffic prediction model. The initial parameters of the LSTM model are set, and the LSTM model is trained using a training set to generate simulated traffic. A loss function is constructed by combining the penalty term determined based on the simulated flow rate and the given flow rate; wherein the given flow rate is measured data or standard data calculated in practice. The output error of the LSTM model is calculated layer by layer, the initial parameters of the LSTM model are updated according to the output error, and the optimal parameter model is determined by combining the loss function. The algorithm generation module is used to construct analytical optimization algorithms and generate analytical inflow rates by combining real-time reservoir data. The model calculation module is used to determine the analytical flow data and the future forecast flow data, and to generate simulated smooth flow based on the analytical flow data and the future forecast flow data using the optimal parameter model.
11. A computer-readable storage medium storing one or more programs, characterized in that, When one or more programs are executed, the smooth inbound flow calculation method described in any one of claims 1-9 is implemented.
12. An electronic device comprising a processor, a communication interface, a computer-readable storage medium as described in claim 11, and a communication bus; wherein, The processor, communication interface, and computer-readable storage medium communicate with each other via a communication bus; Its features are, The processor is used to execute programs stored in a computer-readable storage medium.
Citation Information
Patent Citations
Reservoir water level prediction method based on recurrent neural network and attention mechanism
CN111553394A
Reservoir inflow prediction method based on neural differential equation
CN112541839A