Method, device and equipment for farm load prediction based on multi-source data
By using variational mode decomposition of multi-source data and the Transformer model, the problems of insufficient accuracy and generalization ability in power load forecasting of livestock farms were solved, and more accurate power load forecasting and energy allocation were achieved.
Patent Information
- Application Number
- CN202610235288.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-02-27
- Publication Date
- 2026-06-23
Smart Images

Figure CN122264187A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of power load forecasting, and in particular to a method, apparatus and equipment for forecasting farm load based on multi-source data. Background Technology
[0002] With the intensive development of large-scale poultry farming, power load forecasting has become a key requirement for optimizing energy allocation and reducing electricity costs in farms. However, the widespread use of various electrification equipment has led to strong fluctuations and multi-factor coupling in farm power load. Traditional forecasting techniques that rely solely on historical loads are no longer adequate for these characteristics, neglecting the load-driving factors in the farming scenario. Consequently, the forecasting accuracy and generalization ability are insufficient to meet the actual needs of farms.
[0003] Therefore, there is an urgent need for a load forecasting method that can combine multi-source data from livestock farms to improve the accuracy and usability of power load forecasting results for livestock farms. Summary of the Invention
[0004] In view of this, embodiments of the present invention provide a method, apparatus and equipment for predicting farm load based on multi-source data, so as to obtain more accurate farm power load prediction results.
[0005] In a first aspect, embodiments of the present invention provide a method for predicting farm load based on multi-source data, including: Acquire historical load data, animal growth data, environmental data, and equipment data from the farm; The historical load data is decomposed using the variational mode decomposition algorithm to obtain multiple load components. The variational mode decomposition algorithm is optimized for parameters using a sparrow search algorithm, which establishes a fitness function for the load components based on the growth data of the farmed animals. The multiple load components, the animal growth data, the environmental data, and the equipment data are concatenated and input into a preset Transformer model to obtain the power load prediction curve of the farm.
[0006] In one possible implementation, the parameters of the variational mode decomposition algorithm are optimized using a sparrow search algorithm, including: Initialize the parameters of the variational mode decomposition algorithm and decompose the load data to obtain the load components corresponding to the current parameters; Substitute the load component corresponding to the current parameter into the fitness function to obtain the fitness function value corresponding to the current parameter; A population is generated based on the sparrow search algorithm. The optimal parameters of the variational mode decomposition algorithm are obtained by iteratively searching the population for the parameters that minimize the fitness function value.
[0007] In one possible implementation, the sparrow search algorithm establishes a fitness function for the load component based on the farmed animal growth data, including: Based on the growth data of the farmed animals, the frequency band range and weight of the low-frequency band, mid-frequency band and high-frequency band are determined respectively; The fitness function is established based on the weights of the low-frequency band, the mid-frequency band, and the high-frequency band, as well as the energy distribution of the load component in the low-frequency band, the mid-frequency band, and the high-frequency band, the complexity of the load component, the concentration of the load component, and the reconstruction error of the load component.
[0008] In one possible implementation, the fitness function is:
[0009] in, The reconstruction error is referred to as "the reconstruction error". , and These are the energy percentages corresponding to the load components with the highest energy percentages in the low-frequency band, the mid-frequency band, and the high-frequency band, respectively. , and The weights of the low-frequency band, the mid-frequency band, and the high-frequency band are respectively. This is a complexity penalty for the load components; A penalty for the concentration of the load component; , and All of these are preset penalty coefficients.
[0010] In one possible implementation, the method for obtaining the preset Transformer model includes: Initialize the Transformer model, train the Transformer model using the Adam optimizer, and perform model validation and testing to obtain a pre-trained Transformer model; Using the root mean square error as the loss function, the loss function value corresponding to the current hyperparameter is determined based on the power load prediction curve output by the pre-trained Transformer model. Generate a hyperparameter population, and iteratively search within the hyperparameter population for the hyperparameter that minimizes the loss function value to determine the preset Transformer model.
[0011] In one possible implementation, the historical load data is decomposed according to the variational mode decomposition algorithm to obtain multiple load components, including: Based on the historical load data, multiple candidate load components and the center frequency corresponding to each component are determined; Substitute the multiple candidate load components and the center frequency corresponding to each component into the objective function of the variational mode decomposition algorithm to determine the objective function value corresponding to the multiple candidate load components. The multiple candidate load components and their corresponding center frequencies are iteratively updated until the objective function value converges, thus obtaining the multiple load components.
[0012] In one possible implementation, after acquiring the historical load data, animal growth data, environmental data, and equipment data of the farm, the method further includes: The historical load data, the farmed animal growth data, the environmental data, and the equipment data are subjected to time alignment, outlier processing, and normalization.
[0013] In one possible implementation, the farmed animal growth data includes the type and age of the farmed animals; the environmental data includes temperature, humidity, and carbon dioxide concentration; and the equipment data includes equipment start-up and shutdown status data.
[0014] Secondly, embodiments of the present invention provide a farm load prediction device, comprising: The data acquisition module is used to acquire historical load data, animal growth data, environmental data, and equipment data from the farm. The load decomposition module is used to decompose the historical load data according to the variational mode decomposition algorithm to obtain multiple load components; wherein, the variational mode decomposition algorithm is optimized for parameters by the sparrow search algorithm, and the sparrow search algorithm establishes a fitness function for the load components based on the growth data of the farmed animals; The Transformer prediction module is used to concatenate the multiple load components, the growth data of the farmed animals, the environmental data, and the equipment data, and then input them into a preset Transformer model to obtain the power load prediction curve of the farm.
[0015] Thirdly, embodiments of the present invention provide an electronic device, including a memory and a processor, wherein the memory stores a computer program and the processor executes the steps of the method as described in the first aspect or any implementation thereof.
[0016] The beneficial effects of the embodiments of the present invention compared with the prior art are as follows: In this embodiment of the invention, historical load data, animal growth data, environmental data, and equipment data of the farm are acquired. A fitness function for the load components is established based on the animal growth data. The variational mode decomposition algorithm is optimized using a sparrow search algorithm, effectively suppressing mode aliasing and ensuring that the multiple load components obtained from the decomposition are adapted to the characteristics of the farm's animal growth and load data. By fusing multiple load components from the load data with multi-source data from the farm, and performing power load prediction based on a preset Transformer model, the prediction model's generalization ability to farm scenarios is improved. This ensures that the prediction results match the farm's load fluctuations and periodic patterns, providing a reliable basis for farm electricity consumption decisions. This embodiment of the invention effectively reduces the impact of multi-factor coupling on the accuracy of prediction results, improves the accuracy of power load prediction, and provides technical support for efficient energy allocation and reasonable control of electricity costs in farms. Attached Figure Description
[0017] Figure 1 This is a schematic diagram illustrating the implementation process of a farm load prediction method based on multi-source data provided in an embodiment of the present invention. Figure 2 This is a schematic diagram of the structure of a farm load prediction device provided in an embodiment of the present invention; Figure 3 This is a schematic diagram of an electronic device provided in an embodiment of the present invention. Detailed Implementation
[0018] The present application will be described more clearly below with reference to specific embodiments. These embodiments will help those skilled in the art to further understand the function of the present application, but do not limit the present application in any way. It should be noted that those skilled in the art can make several modifications and improvements without departing from the concept of the present application. These all fall within the protection scope of the present application.
[0019] It should be understood that, when used in this application specification and the appended claims, the term "comprising" indicates the presence of the described features, integrals, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, integrals, steps, operations, elements, components and / or a collection thereof.
[0020] It should also be understood that the term “and / or” as used in this application specification and the appended claims means any combination of one or more of the associated listed items and all possible combinations, and includes such combinations.
[0021] In the description of this application and the appended claims, the terms "first," "second," "third," etc., are used only to distinguish descriptions and should not be construed as indicating or implying relative importance.
[0022] References to "one embodiment" or "some embodiments" as described in this specification mean that one or more embodiments of this application include a specific feature, structure, or characteristic described in connection with that embodiment. Therefore, the phrases "in one embodiment," "in some embodiments," "in other embodiments," "in still other embodiments," etc., appearing in different parts of this specification do not necessarily refer to the same embodiment, but rather mean "one or more, but not all, embodiments," unless otherwise specifically emphasized. The terms "comprising," "including," "having," and variations thereof mean "including but not limited to," unless otherwise specifically emphasized.
[0023] Furthermore, the term "multiple" mentioned in the embodiments of this application should be interpreted as two or more.
[0024] In the production and operation of large-scale farms, the power load is dynamically affected by multiple factors: the operating requirements of equipment such as temperature control and feeding vary significantly at different growth stages of farmed animals; fluctuations in temperature, humidity and carbon dioxide concentration in the farming environment trigger high-frequency operation of ventilation equipment; and the power loads of feed processing, lighting and other functions are basically fixed, making the load exhibit the characteristics of multi-frequency fluctuation and nonlinear coupling.
[0025] In actual production, traditional load forecasting methods often rely on single historical load data, failing to adequately correlate with other key data from the farm. This makes it difficult to capture the periodic and sudden fluctuations in load, frequently resulting in large forecasting errors. This directly affects the rationality of power allocation in farms, potentially leading to insufficient power supply during peak load periods or significant energy waste during off-peak hours. Furthermore, the lack of accurate load forecasting hinders the optimal allocation and utilization of renewable energy, restricting the achievement of energy-saving goals in farms.
[0026] Therefore, developing a method for predicting farm load that can integrate multi-source aquaculture-related data and accurately extract load characteristics is of great practical significance and application value.
[0027] See Figure 1 This invention provides a method for predicting farm load based on multi-source data, detailed below: Step S101: Obtain historical load data, animal growth data, environmental data, and equipment data of the farm.
[0028] Specifically, animal growth data may include the type and age of the animals; environmental data may include temperature, humidity, and carbon dioxide concentration; and equipment data may include equipment start-up and shutdown status data.
[0029] The type of farmed animals and their age determine their energy requirements and equipment operation modes at different stages, which are the root causes of load changes. Environmental temperature, humidity and carbon dioxide concentration are key parameters for the control of the farming environment. Changes in these parameters will trigger the start and stop of equipment such as ventilation and temperature control, thus significantly affecting the power load. Equipment start and stop status data are a direct representation of equipment operation, and their frequency and time distribution directly determine the fluctuation of the equipment's power load.
[0030] In the aquaculture industry, growth days refer to the total number of days that a farmed animal has gone through from birth (or hatching) to the present moment. It can measure the growth and development stage of an animal and is closely related to the animal's physiological state, nutritional needs, and environmental control requirements.
[0031] Step S102: Decompose historical load data according to variational mode decomposition algorithm to obtain multiple load components; wherein, variational mode decomposition algorithm optimizes parameters through sparrow search algorithm, and sparrow search algorithm establishes fitness function for load components based on the growth data of farmed animals.
[0032] To address the non-stationary characteristics of livestock load, variational mode decomposition is used to decompose historical load data into several load components with specific frequency characteristics. The sparrow search algorithm is introduced to establish a fitness function for the load components for parameter optimization. By utilizing prior knowledge of livestock growth data, the algorithm searches for load components that correspond to low-frequency changes in growth trends, daily cycles, and high-frequency transients of equipment start-up and shutdown. This allows the decomposed load components to directly correspond to the actual physical processes of the farm, thus providing a more comprehensive reflection of the farm's power consumption characteristics.
[0033] In one possible implementation, historical load data is decomposed using a variational mode decomposition algorithm to obtain multiple load components, including: Based on historical load data, multiple candidate load components and their corresponding center frequencies are determined.
[0034] Substitute multiple candidate load components and their corresponding center frequencies into the objective function of the variational mode decomposition algorithm to determine the objective function values corresponding to the multiple candidate load components.
[0035] Iteratively update multiple candidate load components and their corresponding center frequencies until the objective function value converges, thus obtaining multiple load components.
[0036] Each load component represents the fluctuation characteristics within a specific frequency range in the original load data; the center frequency is the core characteristic parameter of each load component, representing the frequency center of the fluctuation pattern described by that component. Different center frequencies correspond to different fluctuation periods and patterns.
[0037] Specifically, the objective function can be defined as the minimum sum of the bandwidths of all load components, or as the reconstruction error between the original load data and the restored load data obtained by superimposing the inverse transformed load components. The smaller the objective function value, the better the mode decomposition effect. After several consecutive iterations, if the objective function value converges, it indicates that the algorithm has found a stable, near-optimal decomposition result, and the current candidate load components and their corresponding center frequencies are the decomposition results.
[0038] In one possible implementation, the parameters of the variational mode decomposition algorithm are optimized using a sparrow search algorithm, including: Initialize the parameters of the variational mode decomposition algorithm and decompose the load data to obtain the load components corresponding to the current parameters.
[0039] Substitute the load component corresponding to the current parameter into the fitness function to obtain the fitness function value corresponding to the current parameter.
[0040] A population is generated based on the sparrow search algorithm. The optimal parameters for the variational mode decomposition algorithm are obtained by iteratively searching the population for parameters that minimize the fitness function value.
[0041] For example, the sparrow search algorithm can optimize the number of modes, bandwidth penalty factor, time-domain data sampling step size, DC component identification, and convergence tolerance of the variational mode decomposition algorithm.
[0042] The number of modes determines the number of load components to be decomposed, affecting the decomposition precision and mode aliasing. The bandwidth penalty factor controls the bandwidth of each component, affecting the load component's ability to capture data from different frequency bands. The time-domain data sampling step size affects the data volume and computational complexity. The DC component identifier determines whether to remove the DC component from the signal, affecting the extraction of DC information from the original data. The convergence tolerance is the threshold for iterative convergence, which relates to the decomposition accuracy and the required computational load. Optimizing these parameters using the sparrow search algorithm can achieve a better balance between decomposition accuracy, computational efficiency, and avoiding signal aliasing.
[0043] Step S103: After splicing multiple load components, farmed animal growth data, environmental data and equipment data, input them into the preset Transformer model to obtain the farm's power load prediction curve.
[0044] In one possible implementation, methods for obtaining a pre-defined Transformer model include: Initialize the Transformer model, train the Transformer model using the Adam optimizer, and perform model validation and testing to obtain a pre-trained Transformer model.
[0045] Using the root mean square error as the loss function, the loss function value corresponding to the current hyperparameter is determined based on the power load prediction curve output by the pre-trained Transformer model.
[0046] Generate a hyperparameter population, iteratively search within the hyperparameter population for the hyperparameter that minimizes the loss function value, and determine the preset Transformer model.
[0047] The decomposed load components are concatenated with data on animal growth, environment, and equipment. A lightweight feature alignment network is used to initially learn the scale relationships between features from different sources. Then, the self-attention mechanism of the Transformer encoder is used to dynamically calculate the correlation weights between features from different sources. This allows for a more efficient comparison of the contributions of temperature changes and the activation of temperature and humidity control equipment to load changes within the same time step. This dynamic, data-driven attention allocation method achieves a deep integration of environmental changes, equipment responses, and load fluctuations, rather than simply providing parallel inputs.
[0048] The output of the Transformer model is the predicted result of the load component. In this embodiment of the invention, the predicted values of all components are inversely transformed and superimposed to obtain the power load prediction curve. The hyperparameters of the pre-trained Transformer model already have basic predictive capabilities, but the hyperparameters still need further optimization. Therefore, this embodiment of the invention uses the root mean square error as the calculation basis to measure the deviation between the model's predicted load and the actual load. The smaller the value, the higher the prediction accuracy.
[0049] A hyperparameter population is a group of individuals that contain a set of hyperparameter combinations. Specifically, the hyperparameter combinations can include the learning rate, number of attention heads, and hidden layer dimension of the Transformer model. Each individual corresponds to a set of hyperparameters to be evaluated.
[0050] For example, when iteratively searching in a hyperparameter population, an optimization algorithm is used. The optimization algorithm may include the sparrow search algorithm, genetic algorithm, particle swarm optimization algorithm, simulated annealing algorithm, etc. By iteratively updating the hyperparameter combinations in the population, the set of hyperparameters that minimizes the loss function value is selected.
[0051] In this embodiment of the invention, historical load data, animal growth data, environmental data, and equipment data of the farm are acquired. A fitness function for the load components is established based on the animal growth data. The variational mode decomposition algorithm is optimized using a sparrow search algorithm, effectively suppressing mode aliasing and ensuring that the multiple load components obtained from the decomposition are adapted to the characteristics of the farm's animal growth and load data. By fusing multiple load components from the load data with multi-source data from the farm, and performing power load prediction based on a preset Transformer model, the prediction model's generalization ability to farm scenarios is improved. This ensures that the prediction results match the farm's load fluctuations and periodic patterns, providing a reliable basis for farm electricity consumption decisions. This embodiment of the invention effectively reduces the impact of multi-factor coupling on the accuracy of prediction results, improves the accuracy of power load prediction, and provides technical support for efficient energy allocation and reasonable control of electricity costs in farms.
[0052] In the decomposition of farm loads, it is necessary to dynamically adjust the fitness evaluation criteria for load components based on the growth data of farmed animals to improve the physical meaning and predictive suitability of the load components. Therefore, the sparrow search algorithm establishes a fitness function for load components based on the growth data of farmed animals, which may include: Based on the growth data of farmed animals, the frequency band range and weight of low-frequency band, mid-frequency band and high-frequency band are determined respectively.
[0053] Based on the weights of the low-frequency, mid-frequency, and high-frequency bands, as well as the energy distribution of the load components in these bands, the complexity of the load components, the concentration of the load components, and the reconstruction error of the load components, a fitness function is established.
[0054] The frequency band range is a load frequency interval divided according to the type of farmed animals. The low-frequency band corresponds to the long-term operating load of the equipment, the medium-frequency band corresponds to the daily cycle load, and the high-frequency band corresponds to the instantaneous fluctuating load; the weight is the importance coefficient of each frequency band in the fitness assessment, which can be adjusted according to the type of farmed animals; the energy distribution is the proportion of energy of the load component within the frequency band; the complexity characterizes the randomness and unpredictability of the load component; the concentration reflects the degree to which the energy of the load component is concentrated in the typical growth cycle of the farmed animals, and is related to the type of farmed animals; the reconstruction error is the deviation between the inversely transformed and superimposed load component data and the original load data.
[0055] This invention determines the frequency band range and weights of the fitness function by combining the growth data of farmed animals, and incorporates energy distribution, complexity, concentration and reconstruction error into the fitness function. This allows the sparrow search algorithm to be optimized to obtain optimal decomposition parameters that better match the actual load patterns of farms, thereby improving the quality of load components and further enhancing the accuracy of load prediction.
[0056] Specifically, the fitness function can be:
[0057] in, This represents the reconstruction error; , and These represent the energy percentages of the load components with the highest energy proportions in the low-frequency, mid-frequency, and high-frequency bands, respectively. , and The weights for low-frequency band, mid-frequency band, and high-frequency band are respectively. This is a complexity penalty for the load components; A penalty for the concentration of the load component; , and All of these are preset penalty coefficients.
[0058] Complexity penalty can be obtained from the sample entropy or variance of the center frequency of the load component; concentration is an evaluation index whose value can be calculated based on the center frequency and energy distribution of the load component. These characteristics reflect the degree of concentration of the load component for a typical growth cycle. When the concentration is less than a preset threshold, a larger concentration penalty is applied.
[0059] In one possible implementation, after acquiring historical load data, animal growth data, environmental data, and equipment data from the farm, the following is also included: Historical load data, farmed animal growth data, environmental data, and equipment data are processed for time alignment, outlier handling, and normalization.
[0060] This invention ensures that the data input to the model is synchronized and available in the time dimension by performing time alignment, outlier processing, and normalization on multi-source data, thereby effectively improving the input quality, training stability, and prediction accuracy of subsequent load decomposition and prediction models.
[0061] Based on the above, the following specific embodiment will provide a detailed description of the farm load prediction method based on multi-source data: (1) Acquire data and preprocess it Acquire historical load data, types of farmed animals, age of animals, environment, temperature, humidity, carbon dioxide concentration, and equipment start-up and shutdown status data of the farm; All data underwent time alignment, outlier handling, and normalization. All data are processed using a 15-minute time stamp and a sliding window method for uniform time granularity. High-frequency data (such as 5-minute environmental parameters) are aggregated through linear interpolation, while low-frequency data (such as 1-hour meteorological data) are padded forward.
[0062] For continuous data (such as temperature), apply the 3σ criterion to remove data points that exceed ±3 standard deviations, and fill the gap with a moving average of the previous and next 5 points.
[0063] For a specific type of continuous data (such as temperature, power, etc.) to be normalized, first iterate through all samples of this data in the historical dataset and find its minimum value (denoted as ). ) and maximum value (denoted as ), and then for each data point Subtract the minimum value from it This yields the difference between the data point and the minimum value. The difference is then divided by the range between the maximum and minimum values (i.e., the range between the maximum and minimum values). The original data is linearly mapped to the [0,1] interval; discrete variables (such as device start-up and shutdown) are converted into one-hot codes (0-1 vectors).
[0064] (2) Parameter optimization and decomposition implementation of variational mode decomposition algorithm Existing empirical mode decomposition algorithms are prone to mode aliasing, leading to cross-interference between high-frequency equipment and low-frequency load signals. This invention introduces a variational mode decomposition algorithm, which can strictly distinguish various load characteristics in the frequency domain. Using preprocessed historical load data as input, a variational constraint model is constructed based on the variational mode decomposition algorithm, setting initial parameters such as the number of modes K, bandwidth penalty factor α, time-domain data sampling step size, DC component identifier, and convergence tolerance tol (penalty factor ∈ [1000, 5000]). The sparrow search algorithm is used to iteratively optimize the parameters of the variational mode decomposition algorithm, with the maximum number of iterations set to [value missing]. =150, with the optimization objective of minimizing the fitness function of the load component, to achieve adaptive partitioning of the load component.
[0065] The method for establishing the fitness function is as follows: First, a prior knowledge base is established based on the type of poultry farm. For broiler farms, the growth cycle is typically 30–50 days (40 days in typical cases), and load changes during the growth process exhibit a distinct three-tiered structure: low-frequency changes in growth trends, diurnal rhythmic fluctuations, and high-frequency transients during equipment start-up and shutdown. For layer hen farms, the growth cycle is approximately 500 days, with relatively gentler low-frequency changes and more pronounced diurnal cycle characteristics. Different target frequency bands and weight parameters are set during the variational mode decomposition algorithm parameter optimization stage to achieve adaptive modeling for different poultry types.
[0066] In this embodiment of the invention, the sparrow search algorithm uses the parameters of the variational mode decomposition algorithm as search variables to construct an initial population containing N individuals, with a population size of N=100. Each individual represents a set of variational mode decomposition algorithm parameter combinations to be evaluated. For each individual, variational mode decomposition is first performed on the original load signal to obtain several load components; then, the energy distribution of each load component in each frequency band is calculated based on power spectral density analysis. According to different poultry types, the following frequency band constraints and weights are set: For broiler farms, the typical growth cycle is 40 days. The low-frequency band ranges from 30 to 50 days, reflecting the growth trend of farmed animals; the mid-frequency band ranges from 20 to 28 hours, reflecting diurnal periodicity; and the high-frequency band ranges from 15 minutes to 2 hours, reflecting equipment start-up and shutdown and environmental fluctuations. The weights of each frequency band are as follows: .
[0067] For egg-laying hen farms, the typical growth cycle is 500 days. The low-frequency band is a reasonable range for approximately 500 days, the mid-frequency band is 20 to 28 hours, and the high-frequency band is 15 minutes to 2 hours. The weight of the low-frequency band is 0.2, the weight of the mid-frequency band is 0.6, and the weight of the high-frequency band is 0.2. The weights of each band are... .
[0068] Based on this, a comprehensive fitness function is constructed. :
[0069] in, This represents the reconstruction error; , and These represent the energy percentages of the load components with the highest energy proportions in the low-frequency, mid-frequency, and high-frequency bands, respectively. , and The weights for low-frequency band, mid-frequency band, and high-frequency band are respectively. This is a complexity penalty for the load components; A penalty for the concentration of the load component; , and All of these are preset penalty coefficients.
[0070] Complexity penalty The concentration can be obtained from the sample entropy or variance of the center frequency of the load component; concentration is an evaluation index whose value can be calculated based on the center frequency and energy distribution of the load component. These characteristics reflect the degree of concentration of the load component over a typical growth cycle. When the concentration is less than a preset threshold, a larger concentration penalty is applied. By minimizing the fitness function The optimal parameter combination that balances reconstruction accuracy and physical interpretability can be obtained by finding the correct value.
[0071] Using the optimized variational mode decomposition algorithm parameters, the load signal is decomposed into K load components and residual terms of different frequencies, which correspond to the characteristic frequencies of different equipment operation. For example, the high-frequency load component corresponds to equipment start-up and shutdown, while the low-frequency load component corresponds to continuous equipment operation and diurnal periodic load changes.
[0072] (3) Transformer model construction and load forecasting Traditional forecasting methods often rely solely on historical load data, neglecting crucial information about the farm. This invention constructs a multidimensional tensor sequence X∈R at the Transformer input layer. T×D D includes all load components and fused features. Multiple load components, farmed animal growth data, environmental data, and equipment data are concatenated and aligned to construct feature tensors. For each type of feature data, time is plotted on the vertical axis and the feature dimension on the horizontal axis, forming the following matrix:
[0073] in, This refers to the number of steps taken over time (e.g., 96 steps per day). For the number of load components, , , These are feature dimensions for environmental data, equipment data, and farmed animal growth data, respectively. Finally, these features are concatenated column-wise to form a unified multidimensional input sequence. Where T=96 (24 hours × 4 time points / hour) is used as the input to the Transformer model to model load change patterns driven by multiple factors.
[0074] Construct a Transformer-based encoder-decoder architecture. The encoder consists of four layers, each employing a multi-head self-attention mechanism to capture the temporal dependencies of long sequence data. The parameters of the multi-head self-attention mechanism can be optimized using an optimization algorithm, with the optimization range being: the number of heads... Feedforward network dimension Furthermore, each layer contains residual connections and layer normalization modules; the decoder layer has 4 layers, aligning the input sequence and the prediction sequence through an attention mechanism, and the output vector has a dimension of [missing information]. The predicted values for each load component.
[0075] First, model pre-training is performed. The model is initialized with optimized parameters, and the Adam optimizer is used for training on historical data. The model is divided into a training set (70%), a validation set (15%), and a test set (15%), with a sampling interval of 15 minutes. The root mean square error is used as the loss function, and the initial learning rate is 0.0001. The model outputs the predicted power load values for the next 1-24 hours.
[0076] Next, we optimize the model's hyperparameters. This involves adjusting the hyperparameters of the Transformer model (learning rate, etc.). η The number of attention heads (H) and the hidden layer dimension (d) are encoded as the position vectors of individual sparrows. The root mean square error of prediction based on historical data is used as the loss function, and the calculation formula is as follows:
[0077] in, This represents the actual load component. To predict load components, The number of samples; By employing the discoverer-follower-guarder mechanism of the sparrow search algorithm, a global search is performed within the parameter space, iteratively updating the parameter combinations until the loss function is reached. Convergence. The learning rate is scheduled using cosine annealing, with a maximum learning rate of 10. -4 -10 -3 The system performs adaptive adjustment within intervals and outputs the final predicted load components. The final predicted load components are then evaluated and validated using four evaluation metrics and different decomposition strategies to assess the model's prediction accuracy.
[0078] The final predicted load components are subjected to inverse normalization and inverse transformation, and the inverse transformation results of all predicted load components are superimposed to obtain the power load prediction curve of the farm.
[0079] In this embodiment of the invention, a fitness function is constructed based on the growth data of farmed animals. Based on this fitness function, the parameters of the variational mode decomposition algorithm are optimized using the sparrow search algorithm, which effectively solves the problem of load component cross-interference caused by mode aliasing in traditional methods and realizes adaptive decomposition of farm load for animals at different growth stages. At the same time, by constructing a Transformer model that integrates multi-source data and using an optimization algorithm to further optimize the model hyperparameters, the accuracy and generalization ability of load prediction are improved.
[0080] It should be understood that the sequence number of each step in the above embodiments does not imply the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present invention.
[0081] See Figure 2This invention provides a farm load prediction device 2, comprising: Data acquisition module 21 is used to acquire historical load data, animal growth data, environmental data and equipment data of the farm; The load decomposition module 22 is used to decompose the historical load data according to the variational mode decomposition algorithm to obtain multiple load components; wherein, the variational mode decomposition algorithm optimizes the parameters through the sparrow search algorithm, and the sparrow search algorithm establishes a fitness function for the load components based on the growth data of the farmed animals; The Transformer prediction module 23 is used to stitch together the multiple load components, the animal growth data, environmental data and equipment data, and input them into a preset Transformer model to obtain the power load prediction curve of the farm.
[0082] In one possible implementation, the load decomposition module 22 is used to initialize the parameters of the variational mode decomposition algorithm and decompose the load data to obtain the load components corresponding to the current parameters. Substitute the load component corresponding to the current parameter into the fitness function to obtain the fitness function value corresponding to the current parameter; A population is generated based on the sparrow search algorithm. The optimal parameters for the variational mode decomposition algorithm are obtained by iteratively searching the population for parameters that minimize the fitness function value.
[0083] In one possible implementation, the load decomposition module 22 is further configured to determine the frequency band range and weight of the low-frequency band, mid-frequency band and high-frequency band respectively based on the growth data of farmed animals; Based on the weights of the low-frequency, mid-frequency, and high-frequency bands, as well as the energy distribution of the load components in these bands, the complexity of the load components, the concentration of the load components, and the reconstruction error of the load components, a fitness function is established.
[0084] In one possible implementation, the load decomposition module 22 is further configured to determine multiple candidate load components and the center frequency corresponding to each component based on historical load data. Substitute multiple candidate load components and their corresponding center frequencies into the objective function of the variational mode decomposition algorithm to determine the objective function values corresponding to the multiple candidate load components. Iteratively update multiple candidate load components and their corresponding center frequencies until the objective function value converges, thus obtaining multiple load components.
[0085] In this embodiment of the invention, the farm load prediction device combines farm animal growth data, optimizes variational mode decomposition parameters using a sparrow search algorithm, and inputs multi-source data into the Transformer model, thereby achieving more accurate load decomposition and prediction, and effectively improving the accuracy and reliability of the power load prediction curve.
[0086] See Figure 3 The diagram shows a schematic of the electronic device 3 provided in an embodiment of the present invention, which is described in detail below: like Figure 3 As shown, the electronic device 3 in this embodiment includes a processor 30 and a memory 31. The memory 31 stores a computer program 32. When the processor 30 executes the computer program 32, it implements the steps in the various method embodiments described above. Alternatively, when the processor 30 executes the computer program 32, it implements the functions of each module in the various device embodiments described above.
[0087] For example, computer program 32 may be divided into one or more modules / units, which are stored in memory 31 and executed by processor 30 to complete the present invention. The one or more modules / units may be a series of computer program instruction segments capable of performing a specific function, which describe the execution process of computer program 32 in electronic device 3.
[0088] Electronic device 3 may include, but is not limited to, processor 30 and memory 31. Those skilled in the art will understand that... Figure 3 This is merely an example of electronic device 3 and does not constitute a limitation on electronic device 3. It may include more or fewer components than shown, or combine certain components, or different components. For example, electronic device 3 may also include input / output devices, network access devices, buses, etc.
[0089] For the sake of simplicity and clarity, only the above-described functional modules / units are used as examples. In practical applications, the functions described above can be assigned to different functional modules / units as needed. These modules / units can be implemented in hardware, software, or a combination of both.
[0090] In the above embodiments, the descriptions of each embodiment have their own emphasis. Parts not detailed or described in a particular embodiment can be referred to in the relevant descriptions of other embodiments. Unless otherwise specified or in conflict with logic, the terminology and / or descriptions between different embodiments are consistent and can be referenced interchangeably. Technical features in different embodiments can be combined to form new embodiments based on their inherent logical relationships.
[0091] The above-described embodiments are only used to illustrate the technical solutions of the present invention, and are not intended to limit it. Although the present invention 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. 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 invention, and should all be included within the protection scope of the present invention.
Claims
1. A method for predicting farm load based on multi-source data, characterized in that, include: Acquire historical load data, animal growth data, environmental data, and equipment data from the farm; The historical load data is decomposed using the variational mode decomposition algorithm to obtain multiple load components. The variational mode decomposition algorithm is optimized for parameters using a sparrow search algorithm, which establishes a fitness function for the load components based on the growth data of the farmed animals. The multiple load components, the animal growth data, the environmental data, and the equipment data are concatenated and input into a preset Transformer model to obtain the power load prediction curve of the farm.
2. The method for predicting farm load based on multi-source data according to claim 1, characterized in that, The parameters of the variational mode decomposition algorithm are optimized using the sparrow search algorithm, including: Initialize the parameters of the variational mode decomposition algorithm and decompose the load data to obtain the load components corresponding to the current parameters; Substitute the load component corresponding to the current parameter into the fitness function to obtain the fitness function value corresponding to the current parameter; A population is generated based on the sparrow search algorithm. The optimal parameters of the variational mode decomposition algorithm are obtained by iteratively searching the population for the parameters that minimize the fitness function value.
3. The method for predicting farm load based on multi-source data according to claim 1, characterized in that, The sparrow search algorithm establishes a fitness function for the load component based on the growth data of the farmed animals, including: Based on the growth data of the farmed animals, the frequency band range and weight of the low-frequency band, mid-frequency band and high-frequency band are determined respectively; The fitness function is established based on the weights of the low-frequency band, the mid-frequency band, and the high-frequency band, as well as the energy distribution of the load component in the low-frequency band, the mid-frequency band, and the high-frequency band, the complexity of the load component, the concentration of the load component, and the reconstruction error of the load component.
4. The method for predicting farm load based on multi-source data according to claim 3, characterized in that, The fitness function is: in, The reconstruction error is referred to as "the reconstruction error". , and These are the energy percentages corresponding to the load components with the highest energy percentages in the low-frequency band, the mid-frequency band, and the high-frequency band, respectively. , and The weights of the low-frequency band, the mid-frequency band, and the high-frequency band are respectively. This is a complexity penalty for the load components; A penalty for the concentration of the load component; , and All of these are preset penalty coefficients.
5. The method for predicting farm load based on multi-source data according to claim 1, characterized in that, The method for obtaining the preset Transformer model includes: Initialize the Transformer model, train the Transformer model using the Adam optimizer, and perform model validation and testing to obtain a pre-trained Transformer model; Using the root mean square error as the loss function, the loss function value corresponding to the current hyperparameter is determined based on the power load prediction curve output by the pre-trained Transformer model. Generate a hyperparameter population, and iteratively search within the hyperparameter population for the hyperparameter that minimizes the loss function value to determine the preset Transformer model.
6. The method for predicting farm load based on multi-source data according to claim 1, characterized in that, The historical load data is decomposed according to the variational mode decomposition algorithm to obtain multiple load components, including: Based on the historical load data, multiple candidate load components and the center frequency corresponding to each component are determined; Substitute the multiple candidate load components and the center frequency corresponding to each component into the objective function of the variational mode decomposition algorithm to determine the objective function value corresponding to the multiple candidate load components. The multiple candidate load components and their corresponding center frequencies are iteratively updated until the objective function value converges, thus obtaining the multiple load components.
7. The method for predicting farm load based on multi-source data according to claim 1, characterized in that, After acquiring historical load data, animal growth data, environmental data, and equipment data from the farm, the process also includes: The historical load data, the farmed animal growth data, the environmental data, and the equipment data are subjected to time alignment, outlier processing, and normalization.
8. The method for predicting farm load based on multi-source data according to any one of claims 1 to 7, characterized in that, The animal growth data includes the type and age of the animals; the environmental data includes temperature, humidity, and carbon dioxide concentration; and the equipment data includes equipment start-up and shutdown status data.
9. A livestock farm load prediction device, characterized in that, include: The data acquisition module is used to acquire historical load data, animal growth data, environmental data, and equipment data from the farm. The load decomposition module is used to decompose the historical load data according to the variational mode decomposition algorithm to obtain multiple load components; wherein, the variational mode decomposition algorithm is optimized for parameters by the sparrow search algorithm, and the sparrow search algorithm establishes a fitness function for the load components based on the growth data of the farmed animals; The Transformer prediction module is used to concatenate the multiple load components, the growth data of the farmed animals, the environmental data, and the equipment data, and then input them into a preset Transformer model to obtain the power load prediction curve of the farm.
10. An electronic device, characterized in that, It includes a memory and a processor, the memory storing a computer program, and the processor executing the computer program to implement the method as described in any one of claims 1 to 8.