Abstract
Grain security is a fundamental guarantee for social stability and sustainable development. Accurate monitoring and prediction of overall granary temperature are essential for reducing storage losses and improving warehouse management efficiency. As an integrated system, the temperature evolution of the grain pile is deeply affected by its inherent physical structure and heat transfer pathways. Therefore, a multi-level warehouse–surface–line–point (WSLP) structural modeling approach driven by the physical properties of the grain pile is proposed to extract the joint environmental and spatial characteristics. Building upon the WSLP framework, a dual-channel time-series prediction architecture integrating both long short-term memory (LSTM) and iTransformer through a mutual verification fusion mechanism is developed to enable synchronized temperature forecasting across different regions of the grain piles. Experiments are conducted using real granary data from Shandong, China. The results demonstrate that the proposed model achieves more than 30% improvement over baseline methods in terms of MAE and RMSE. Moreover, the WSLP-LSTM–iTransformer framework significantly improves prediction accuracy in complex warehouse environments and enhances the interpretability and applicability of deep learning models for grain condition forecasting by incorporating real environmental characteristics.
1. Introduction
Maintaining a stable in-bin temperature is essential for safe grain storage. In practice, the temperature field inside a granary is shaped by ventilation, heat transfer through the grain bulk, and external weather, which jointly produce strong spatial heterogeneity across depths and regions (Figure 1). Therefore, this paper focuses on multi-region temperature forecasting inside grain piles, rather than single-point prediction. Temperature and humidity are both important for storage safety, but in this study humidity is treated as an auxiliary exogenous driver (input feature) to support temperature forecasting, not as the primary prediction target. To support practical deployment, our experiments cover both cylindrical and rectangular granaries and use routinely collected IoT monitoring data [1,2,3,4,5].
Figure 1.
Abnormal temperature of the grain piles and potential hazards.
Nevertheless, monitoring alone may miss early-stage anomalies because local heat and moisture changes can develop before they are obvious at a few monitored points. Predictive modeling can provide earlier warnings by forecasting the future evolution of the temperature field [6]. In our setting, the prediction target is the future temperature at multiple internal sensor locations (and their region-level aggregates such as layer-wise max/min/mean), using historical temperatures together with environmental variables.
Consequently, numerous researchers have studied grain pile temperature prediction. However, several technical challenges remain:
- (1)
- Cross-granary generalization across different geometries: Cylindrical and rectangular granaries exhibit different sensor layouts and heat transfer patterns, which makes it difficult to train a unified predictor.
- (2)
- Irregular sampling and missing data: Sensor intervals can be adjusted by the control system and sensors may fail, leading to gaps and noisy measurements that degrade model stability.
- (3)
- Spatiotemporal coupling for multi-region forecasting: Accurate forecasting requires modeling both temporal dynamics and spatial dependencies across regions (layers, paths, and neighborhoods), rather than treating each point independently.
- (4)
- Integration of exogenous drivers with physical interpretability: Weather and indoor/outdoor temperature–humidity conditions strongly affect the pile, but they are often weakly integrated, and purely data-driven spatial modules can be hard to interpret.
To address these challenges (Figure 2), we propose a hierarchical warehouse–surface–line–point (WSLP) model based on the physical structure of grain piles and their dominant heat transfer pathways. WSLP embeds the physical structure by decomposing the temperature at a location into the following: (i) a warehouse-level environmental trend, (ii) a surface-level planar distribution within a layer, (iii) a line-level vertical diffusion pathway, and (iv) a point-level local neighborhood response. Building on WSLP, we design a hybrid LSTM–iTransformer time-series framework with an adaptive selection/fusion strategy to better handle both local fluctuations and long-range dependencies [7,8]. We compare the proposed approach with SVR, GRU, standalone LSTM, and standalone iTransformer and also conduct ablation experiments with/without WSLP.
Figure 2.
Problems in previous research and solutions proposed in this paper.
The main contributions of this paper are as follows:
- A physically aligned WSLP spatial structure that maps granary geometry into a four-level hierarchy (warehouse/surface/line/point) to model environmental driving and spatial heat transfer.
- A hierarchical feature construction method consistent with WSLP, enabling multi-region forecasting beyond single-point prediction while improving interpretability.
- An LSTM–iTransformer hybrid forecasting framework with an adaptive model selection/fusion mechanism for robust multi-step, multi-point temperature prediction.
- Comprehensive experiments on real-world data from both cylindrical and rectangular granaries, demonstrating improved accuracy and cross-structure generalization.
In the remainder of this paper, Section 2 reviews the relevant literature and summarizes and analyzes the existing grain pile temperature prediction methods. Section 3 describes the data acquisition process and preprocessing method. Section 4 conducts experiments and discusses the performance of the proposed model. Section 5 summarizes the entire paper and outlines future work.
2. Literature Review
2.1. Temperature Prediction
Temperature prediction is a typical nonlinear time-series task and has been widely studied in many domains. For complex systems such as oceans and data centers, adaptive modeling [9], noise suppression [10], and 3-D spatiotemporal modeling [11] have been introduced to improve accuracy under noise and multi-scale dynamics.
Air temperature forecasting—a typical nonlinear time-series task—offers insights for grain pile temperature prediction. Early research relied on Numerical Weather Prediction (NWP) models to simulate atmospheric processes. With advances in computer science and data-driven techniques, machine learning and deep learning have been gradually introduced [12,13]. Recently, physics-informed neural networks that integrate NWP models and deep learning architectures have opened new pathways for temperature forecasting [14].
Due to the influence of grain physical properties [15], airflow [16], and local heat conduction [17], grain pile temperature exhibits stronger spatial heterogeneity and irregular sampling than many standard forecasting benchmarks. This motivates methods that jointly consider exogenous environmental drivers and structured spatial dependencies, rather than treating each point as an independent series.
2.2. Grain Pile Temperature Prediction
2.2.1. Traditional Physical and Chemical Models
Traditional temperature prediction models for grain piles can mainly be classified into two categories. One category is the computational models constructed based on thermodynamics, heat transfer, and energy balance theories. The other is the numerical simulation models of temperature fields built relying on the finite element method. For example, modeling approaches based on Computational Fluid Dynamics have been employed to mathematically simulate heat transfer processes within grain piles, supporting accurate prediction of temperature variations. Sun and Woods [18,19], for instance, developed mathematical models to simulate the cooling processes in wheat and explored the dynamics of moisture and temperature changes. Similarly, Quemada-Villagómez [20] constructed models to predict diurnal and seasonal temperature variations in stored sorghum. Rusinek and Kobyłka [21] applied the discrete element method to model and predict temperature dynamics in rapeseed during storage.
Limitations: These physical and numerical models can be accurate but typically require detailed material parameters, boundary conditions, and intensive computation, which limits scalability to multi-granary deployments and real-time multi-region forecasting.
2.2.2. Traditional Machine Learning Models
Traditional machine learning predicts grain pile temperatures by learning from a large amount of data and uncovering the underlying laws of temperature changes. For instance, Wang [22] proposed a hysteresis cycle model based on difference methods to establish the relationship between ambient air temperature and grain pile temperature for predictive purposes. Similarly, Duan [23] utilized weather data combined with support vector regression to model and predict the surface temperature of stored grain. These machine learning-based models have, to some extent, improved prediction accuracy and reduced reliance on physical and chemical parameters.
Limitations: Traditional ML methods often rely on handcrafted features and are commonly designed for a limited set of locations (e.g., surface temperature), which makes it difficult to capture multi-region coupling and to generalize across different granary geometries.
With the advancement of deep learning technologies and the continuous accumulation of sensor data, deep learning has become a key direction in grain temperature prediction [24].
2.2.3. Deep Learning Models
The nonlinear characteristics caused by fluctuations in environmental factors [25] and grain metabolic activities [26] pose significant challenges to the accurate prediction of grain pile temperatures. Recurrent neural networks (RNNs) and Transformers possess unique advantages in addressing such issues and have demonstrated favorable performance in stock price prediction [27,28,29,30]. Given the similarity between grain temperature sequences and financial time series in terms of complexity and variability, these methods are likewise well suited for grain temperature prediction tasks. For instance, Qu [31], based on multi-point sensors inside the grain piles, proposed the CGTN model, combining a graph convolutional neural network and Transformer to directly predict the temperatures in areas not covered by sensors in the grain piles. Duan [32] used the LSTM model and combined various weather factors to predict the surface temperature of the grain piles. Wu [33] designed a bidirectional LSTM model to better capture the impact of historical information on the current temperature, thus improving the prediction effect. Mao [34] optimized data and noise through the GRU model, combined with multiple linear regression and filtering to improve the prediction accuracy. Liu [35] constructed a fusion model, used a CNN to extract nonlinear features in the temperature sequence, and combined it with the GRU model for sequence prediction, also achieving good prediction results.
Limitations: Although deep learning models can capture nonlinear dynamics, many existing studies focus on single-point forecasting or use black-box spatial modules whose physical meaning is unclear; they also may underutilize explicit granary structure and can be sensitive to irregular sampling and missing data.
Gap and our approach: In contrast, this work introduces a physically aligned WSLP hierarchy to explicitly encode granary structure (warehouse/surface/line/point) and couples it with an adaptive LSTM–iTransformer forecasting framework, aiming to improve multi-region accuracy, interpretability, and cross-geometry generalization.
3. Database and Preprocessing
3.1. Data Source
The experimental data used in this study are systematically collected from multiple sources to ensure a comprehensive characterization of the grain storage environment. Meteorological data, including wind speed, air pressure, and ambient temperature and humidity, are obtained from local meteorological stations or dedicated weather monitoring stations installed at the granary sites. The internal and external temperature and humidity data of the granaries are collected through a distributed sensor network deployed within the storage facilities. These sensors are connected to an industrial control computer for real-time data acquisition and storage. A detailed description of the data storage formats and representative samples is provided in Section 3.2.2.
3.2. Data Processing
In order to achieve accurate temperature prediction in grain storage environment, this study constructed a systematic preprocessing framework, including spatial coordinate system and data preprocessing, to improve data consistency and model robustness.
3.2.1. Coordinate Unification
Modern grain storage facilities are primarily classified into cylindrical and rectangular types based on their structural forms, which accommodate different storage periods and grain types, respectively. Structural differences lead to different sensor deployments in the granary. Therefore, to improve the generalization capability of temperature prediction models, it is essential to unify the coordinate system representations across different types of grain storage facilities.
The process of coordinate system unification is illustrated in Figure 3, which consists of coordinate transformation and quantitative mapping. The normalized quantitative mapping further contributes to improved generalization performance in cross-granary application scenarios.
Figure 3.
Coordinate system unification process.
3.2.2. Data Collection
As shown in Figure 4, external weather factors and the temperature–humidity conditions both inside and outside the granary are key external drivers of thermal variation within the grain piles. Meanwhile, temperature distributions across different regions of the piles serve as the direct foundation for temperature prediction modeling. Accordingly, three core categories of data were collected in this study: (1) Weather data, including key atmospheric variables such as wind speed and pressure (see Table 1); (2) Internal and external granary temperature and humidity data, collected via distributed sensors (see Table 2); (3) Temperature of grain piles, recorded along with the spatial coordinates of internal temperature sensors (see Table 3).
Figure 4.
External drivers of thermal variation within the grain piles.
Table 1.
Data storage: weather data.
Table 2.
Data storage: temperature and humidity data around the granary.
Table 3.
Data storage: temperature of grain piles.
Sensor layout and sampling: The internal sensor network records 3-D coordinates (in meters) for each temperature point. For cylindrical granaries, sensor indices are organized along multiple circumferential/radial positions (indexed by m) and vertical layers (indexed by n), which supports the WSLP surface/line/point construction (e.g., and in our unified indexing). The monitoring system uses a nominal fixed sampling interval (used as the target interval in our experiments), while the practical interval can be adjusted and occasional sensor faults may occur, leading to irregular timestamps and missing values.
To illustrate the storage format and parameter units, Table 1, Table 2 and Table 3 present representative snapshots from 19 June 2023, while the full dataset used for modeling spans 1235 days. All data were stored in JSON format to ensure efficient data transmission and consistent structural organization. Categorical meteorological attributes (e.g., weather condition) were encoded using label encoding, and the numerical range and precision of temperature and humidity values were uniformly standardized to meet the requirements of subsequent modeling.
3.2.3. Data Preprocessing
In practical grain storage scenarios, the acquisition frequency of temperature and humidity sensors is dynamically adjusted in response to changing grain storage conditions. As a result, time-series data may contain missing values or anomalies, which can adversely affect model training and prediction accuracy. To address this, the following preprocessing steps were applied to the raw JSON data: (1) Time-series denoising: Temperature and humidity sequences were organized by timestamp and smoothed using techniques such as moving average filtering or Fourier transform-based denoising. (2) Missing value imputation: Discontinuities in time-series data were repaired using linear or Lagrange interpolation, depending on the context. (3) Outlier detection and correction: Abnormal values were identified and processed using statistical approaches, including Z-score analysis and interquartile range (IQR)-based filtering.
To train time-series models with a consistent input grid, the sequences were aligned to a fixed sampling interval; timestamps without observations after alignment were treated as missing and were imputed using the above interpolation strategies.
3.3. Database
After data collection and preprocessing, this study obtained three core categories of data: weather data , temperature and humidity data around the granary , and sensor data within the grain piles . The data span a period of 1235 days, from 22 December 2021 to 9 May 2025. To support subsequent modeling and analysis, heterogeneous data from multiple granaries were further integrated and consolidated into a unified temperature dataset D.
where i is the time index, is the type of meteorological element, represents the temperature and humidity characteristics inside and outside the granary, and and represent the horizontal position index and vertical layer index of the temperature sensor, respectively.
4. Experimental Results
This chapter systematically presents the methodological framework for grain pile temperature prediction. Based on experimental analysis, this study proposes a spatial relationship model (WSLP) for granary temperature distribution and integrates LSTM and iTransformer to establish a spatiotemporal coupled prediction model. Furthermore, multi-scenario experiments validate the proposed approach in terms of predictive accuracy and computational efficiency, providing a reliable solution for grain storage temperature monitoring.
4.1. Spatial and Temporal Modeling Analysis
This section proposes the WSLP model, developed based on the physical properties of the grain piles to characterize spatial correlations, along with the LSTM and iTransformer models designed to capture temporal dynamics in temperature sequences. Together, these models establish the basis for the proposed spatiotemporal coupling framework.
4.1.1. Spatial Model
- (1)
- Analysis of temperature field in granary
Within the granary environment, the combined effects of ventilation conditions, heat conduction between grain kernels and air gaps, and the resulting temperature gradients lead to pronounced spatial non-uniformity in temperature distribution. Therefore, this study refers to NWP and establishes a spatial relationship model of the temperature field in the granary to accurately describe the temperature variation law in different areas of the piles.
- (1.1)
- Analysis 1: Spatial heterogeneity analysis
To explore the spatial heterogeneity of the temperature distribution and heat transfer pathways within grain storage, this study conducts a preliminary analysis of key influencing factors based on a comprehensive temperature dataset collected from the grain storage system. Specifically, temperature data from multiple layers of Granary No.Q03 on 22 September 2024 were analyzed, and the corresponding temperature distribution map is presented in Figure 5. The results indicate significant temperature differences between the outer and inner layers of the grain piles (e.g., regions near the granary walls and the central area). This discrepancy is primarily attributed to the thermal lag effect in heat conduction through the pore structure of the grain piles, ultimately leading to a non-uniform stratified temperature distribution.
Figure 5.
The 22 September 2024 temperature distribution diagram of different temperature measurement layers in Granary Q03.
- (1.2)
- Analysis 2: Environmental correlation analysis
To investigate the influence of environmental factors on grain storage temperature, this study quantifies their impact by computing the Pearson correlation coefficients between grain pile temperature and various environmental variables, including external air temperature, temperature differentials between the interior and exterior of the granary, humidity, etc. The Pearson correlation coefficient provides a quantitative measure of the degree to which each factor affects grain pile temperature. A positive Pearson correlation coefficient (r > 0) indicates a direct relationship, where higher values correspond to stronger correlations. Conversely, a negative coefficient (r < 0) signifies an inverse relationship, with more negative values representing stronger negative correlations. The Pearson correlation coefficient is calculated as follows:
where r denotes the Pearson correlation coefficient, and represent the feature and target values of the i-th sample, respectively, and are the mean values of x and y, and n is the total number of samples.
This experiment is conducted using a one-year dataset of grain pile temperature measurements and corresponding environmental parameters, and the results are shown in Figure 6. The results reveal a significant positive correlation between external air temperature and grain pile temperature, suggesting that external environmental conditions are the primary driving force behind temperature variations within the grain piles. In contrast, internal humidity exhibits a strong negative correlation with grain pile temperature, indicating that humidity significantly influences the rate of heat transfer. These findings highlight that weather factors not only influence the overall temperature distribution but also impact localized heat transfer processes within the grain piles.
Figure 6.
Pearson correlation analysis between internal temperature and environmental factors. The labels represent internal humidity, external temperature, external humidity, temperature difference, humidity difference, and internal temperature.
- (1.3)
- Analysis 3: Wide–local area correlation analysis
To reveal the spatial correlation between local temperatures inside the grain piles, this study analyzes the temperature relationships across different sensor locations based on the actual deployment of temperature sensors. The Pearson correlation coefficient is employed to quantify the influence of temperature variations within the same measurement layer and along the same vertical axis at different heights. As shown in Figure 7a, a strong correlation is observed among temperature points within the same horizontal layer, with particularly high correlation coefficients within the inner, middle, and outer temperature zones, as indicated by markers (1), (2), and (3). From Figure 7b, we find that although significant temperature differences exist along the same vertical axis within the grain piles, adjacent temperature layers still exhibit a certain degree of correlation. These findings indicate that local temperature variations are not only influenced by their historical states but are also significantly affected by the temperatures of surrounding regions.
Figure 7.
Temperature correlation analysis and sensor layout illustration: (a) in-plane correlation among all sensor locations within the same measurement layer; (b) correlation at the same horizontal location across different heights; (c) schematic of the neighboring sensor directions around a target location; (d) schematic cross-sectional sensor layouts for cylindrical and rectangular granaries.
- (2)
- WSLP model
To accurately characterize the spatial distribution of temperature within grain storage and enhance prediction accuracy, this study proposes the warehouse–surface–line–point (WSLP) spatial relationship model based on the above experimental analysis results, as illustrated in Figure 8. In simple terms, WSLP treats the granary as a structured heat transfer system and models the temperature at each location as the sum of four components: An overall environmental trend (warehouse), a layer-wise planar distribution (surface), a vertical diffusion pathway (line), and a local neighborhood adjustment (point). This decomposition provides an intuitive bridge between the physical structure and the forecasting model, before introducing the detailed equations below.
Figure 8.
WSLP spatial relationship model for cylindrical granary and rectangular granary.
This model systematically describes global heat conduction, planar equilibrium, diffusion pathways, and local thermal responses within the grain piles through a multi-level spatial feature extraction and fusion mechanism. The specific method is as follows:
(i) “Warehouse–Surface” Hierarchical Modeling: Environmental Driving and Planar Heat Conduction
Analysis 1 and Analysis 2 demonstrate that external weather factors exert a long-term driving effect on the grain pile temperature and that the temperature distribution exhibits distinct hierarchical characteristics. In response to this dual nature—environmental driving coupled with stratified heat transfer—the proposed WSLP model introduces a two-layer “warehouse–surface” architecture.
- (2.1)
- “Warehouse level”:
To model the overall temperature distribution and capture the driving trend of the weather environment on the temperature, the following equation is used:
where is the environmental feature vector, which includes meteorological variables and the indoor/outdoor temperature–humidity conditions (humidity-related terms are used as exogenous drivers), and represents the mapping relationship of environmental impacts.
- (2.2)
- “Surface level”:
To characterize the temperature gradient of the same horizontal layer and describe the thermal equilibrium within the plane, the following equation is used:
where represents the 2D plane to which point p belongs, is the average temperature of plane , is the original sensor measurement value, is the temperature gradient vector within the plane, and is the offset vector of point p relative to the center of the plane.
(ii) “Line–Point” Hierarchical Refinement: Local Heat Transfer Path and Gradient Prediction
The correlation analysis of Analysis 3 reveals that the temperature within the same horizontal layer is highly uniform, while a significant lag is observed in the vertical direction, and neighboring measurement points display clear spatial dependencies. In view of these findings, the WSLP model further develops a two-layer “line–point” refinement structure to capture vertical heat transfer paths and local thermal responses.
- (2.3)
- “Line level”:
To describe unidirectional heat conduction path and gradual temperature diffusion, the following equation is used:
where is the heat conduction coefficient (related to the porosity and thermal conductivity of the grain piles), is the path where point p is located, is the temperature of the reference point above the path, and is the temperature of the reference point below the path. In implementation, is initialized with a physically plausible range and then tuned on the validation set to minimize MAE/RMSE for multi-step forecasting.
- (2.4)
- “Point level”:
To refine local temperature dynamics by incorporating neighboring temperature gradients to enhance fine-grained prediction, the following equation is used:
where is the local influence coefficient (obtained through data calibration), is the set of neighborhood temperature measurement points of point p, is the weight of neighborhood q, and is the average temperature of the neighborhood. We calibrate by fitting the point-level residual term on the training set (e.g., least-squares on neighborhood residuals) and keep it fixed during forecasting.
Through this hierarchical modeling framework, the WSLP model systematically integrates environmental driving, planar distribution, vertical heat transfer, and local response mechanisms. Finally, at time t, the temperature value at position p of the granary can be calculated as follows:
- (3)
- Hierarchical Feature Extraction for the WSLP Model
To support the hierarchical predictive capability of the WSLP model, this study optimizes the feature extraction method and constructs a multidimensional feature system based on the hierarchical structure of the above-mentioned WSLP model.
(i) Environmental-Driven Features (Warehouse-Level Features)
Environmental-driven features capture the long-term influence of external weather factors on the overall grain pile temperature. These features are categorized into two subgroups:
- (a)
- Meteorological Element Features :
The existence of gaps in the grain pile causes a lag in the impact of meteorological factors on heat transfer within the grain piles; this study focuses on nine key weather variables (e.g., weather conditions, wind speed, etc.) and calculates their weather lags from 1 to 15 days. Consequently, the weather factor features are constructed, comprising a total of feature variables, defined as follows:
where i is the time index, is the type of meteorological element, is the number of lag days, and is the feature group number.
- (b)
- Temperature and Humidity Difference Features :
Considering that the differences in temperature and humidity between the interior and exterior of the granary directly exert an influence on the heat conduction within the grain piles, two differential feature sets are constructed:
where is the sensor index inside and outside the granary and is the difference type (temperature difference or humidity difference).
(ii) Spatial Correlation Features (Surface/Line/Point-level Features)
Spatial correlation features characterize the internal temperature distribution patterns of the grain piles and are categorized into three subgroups:
- (a)
- Planar Gradient Features :
These features capture the thermal equilibrium state within the same horizontal plane using statistical temperature metrics:
where and are the coordinate axis directions of the two-dimensional plane.
- b
- Wide-area Spatial Features :
By computing the mean and extreme temperature values along a specific direction, these features capture local spatial temperature trends:
where t is the spatial coordinate axis direction (the r, , and z axes for the unified coordinate system).
- (c)
- Neighborhood Local Features :
Based on adjacent temperature measurement points, these features compute local statistics to reflect the thermal conduction effect within a localized region:
where , , are the nearest-neighborhood coordinate offsets (constrained by the actual deployment of sensors).
In summary, we can obtain the feature system , which contains the features corresponding to the warehouse level, surface level, line level, and point level of the WSLP spatial relationship model, respectively. These features can be extracted by convolutional neural networks (CNNs) and transformed into a usable form for subsequent time-series models. This hierarchical feature construction enables the WSLP model to achieve multi-scale temperature prediction, spanning from macro-scale environmental drivers to micro-scale localized responses. Different from models like GNNs, the proposed approach enhances both the interpretability and predictive accuracy of the model, facilitating a more comprehensive understanding of heat distribution within grain storage.
4.1.2. Temporal Model
Time-series data exhibit significant temporal dependence, with future states being influenced by past states. Upon discerning the intrinsic causal relationships within n historical data points and establishing a functional relationship, it becomes feasible to predict data for m future time points, as illustrated in Figure 9. Specifically, using the temperature data of the previous n days to predict the next m days can provide data support for the guarantee of food security.
Figure 9.
Principles of time-series forecasting.
- (1)
- LSTM model
LSTM, a specialized variant of RNNs, introduces gated mechanisms to effectively mitigate the vanishing and exploding gradient problems commonly encountered in long sequence modeling [36,37]. The architecture of the LSTM cell is illustrated in Figure 10. Comprising a forget gate, an input gate, and an output gate, this architecture enables LSTM to selectively retain memory and discard information. Therefore, LSTM is particularly suitable for forecasting the temperature of grain piles, which exhibit complex temporal dynamics.
Figure 10.
The architecture of the LSTM cell.
- (2)
- iTransformer model
The iTransformer is a novel deep learning architecture based on the attention mechanism. By improving the input structure of the vanilla Transformer model [38] and optimizing its architecture, the iTransformer demonstrates enhanced performance in time-series forecasting. As shown in Figure 11, the iTransformer treats the entire time series as variable subcomponents and utilizes the attention mechanism to capture inter-variable correlations, thereby achieving high-accuracy time-series prediction.
Figure 11.
Overview of iTransformer architecture: (a) the architecture of the Transformer encoder; (b) the overall iTransformer architecture.
4.2. Spatiotemporal Prediction Model Based on LSTM–iTransformer
In this study, we propose the WSLP model to capture the spatial temperature dependencies across different regions of the grain piles, while temporal dynamics are modeled using time-series forecasting techniques, as illustrated in Figure 12. LSTM and iTransformer have different advantages in modeling long- and short-term dependencies and multivariate relationships. So, in order to dynamically leverage their respective advantages, a model selection strategy based on Mean Absolute Error (MAE) is introduced. Within the validation set, the MAE of both models is compared: when a significant difference is observed, the model with lower error is selected for prediction; otherwise, a weighted fusion of both outputs is applied based on inverse error ratios. This adaptive framework enables model coordination across varying temporal scales, enhancing both predictive accuracy and system robustness.
Figure 12.
LSTM–iTransformer network architecture and input parameters.
MAE measures the average absolute difference between the predicted and observed values, with a smaller MAE indicating better predictive performance of model f. By computing the MAE of each sub-model on the validation set, the predictive accuracy can be quantitatively compared, providing a basis for model selection and fusion strategies. The calculation formula of MAE is as follows:
where n is the amount of validation set data, is the true value of the i-th observation, and is the corresponding predicted value.
- (1)
- Strategy one:
The LSTM model and the iTransformer model are trained independently. Using a validation set of fixed length w, the MAE is computed for both models. If the absolute difference between their MAEs exceeds a predefined threshold , the model with the lower MAE is selected as the dominant forecasting model . The selection rule is defined as follows:
where w denotes the length of the validation window; and are the predicted values from LSTM and iTransformer at time step i; is the corresponding ground truth value; and is the dominant model selected at time t.
- (2)
- Strategy two:
When the MAE difference between the two models over the same validation window of length w does not exceed the threshold , it indicates that their forecasting performances are comparable. In this case, a weighted ensemble of their outputs is adopted to mitigate potential instability in single-model prediction and enhance forecasting robustness. The ensemble forecast is defined as follows:
where is the weight dynamically assigned based on the inverse error proportion to favor more accurate prediction at time t.
4.3. Experiment and Discussion
To comprehensively evaluate the effectiveness and superiority of the proposed WSLP model in grain warehouse temperature forecasting, we designed the following experiments: (1) hyperparameter optimization during model training; (2) verification of the predictive capability of the WSLP combined with the LSTM–iTransformer framework; and (3) comparison with mainstream time-series prediction models. The experimental data were collected from various types of warehouses, among which Q01-Q12 are cylindrical warehouses and F01-F11 are rectangular warehouses.
4.3.1. Hyperparameter Setting
To ensure optimal model performance, we first conducted a systematic tuning of key hyperparameters, including time window size, number of epochs, and batch size.
Time Window Size: Based on practical forecasting requirements in grain storage environments, we evaluated multiple combinations of historical and future prediction horizons. Multiple forecasting window strategies were evaluated, including configurations such as “15 days of historical data to predict the next 7 days” and “15 to 15”, among others. The results on the test set demonstrated that the 15-to-7 configuration yielded superior performance in terms of MAE, RMSE, and other metrics, as illustrated in Figure 13.
Figure 13.
, , and under different parameters (time window size and 15 days of historical data predict the next 7 days of data).
Batch Size and Epoch: After determining the time window size, we further explored the impact of different batch sizes and epochs. An early stopping strategy was adopted to prevent overfitting. The final parameter selection—epoch = 100 and batch size = 64—was based on a combination of loss curve analysis and test set evaluation. This setting achieved stable training and a low prediction error, as shown in Figure 14. And Figure 15 presents the training loss trajectories under different settings, where loss1 corresponds to the best parameter.
Figure 14.
, , and under different parameters (epochs and batch size, batch size = 64 and epochs = 100).
Figure 15.
Comparison curve of Train loss and Val loss during hyperparameter optimization.
4.3.2. WSLP Model Comparison
To systematically evaluate the applicability and performance advantages of the proposed WSLP model across different warehouse geometries, two sets of experiments were designed:
Single granary-type experiments: The model was independently trained and evaluated on cylindrical and rectangular granaries to compare prediction performance with and without the integration of the WSLP structure.
Mixed granary-type experiments: Data from both cylindrical and rectangular granaries were combined for training to assess the ability of the proposed WSLP framework to provide a unified prediction model for temperature evolution in granaries of different geometries. The results are shown in Table 4.
Table 4.
The impact of WSLP on temperature prediction.
In the single granary-type experiments, the integration of WSLP significantly improved prediction accuracy. For cylindrical warehouses, the MAE decreased from 0.5510 to 0.2109, and for rectangular warehouses, from 0.4744 to 0.1829, indicating that WSLP effectively enhances intra-structure spatial feature extraction.
In percentage terms, WSLP reduced MAE by 61.7% for cylindrical granaries and 61.5% for rectangular granaries in our experiments, indicating that explicitly modeling structure helps capture spatial coupling beyond point-wise learning.
In the mixed granary-type experiment, the WSLP model maintained strong performance, achieving an MAE of 0.3449. Although slightly lower than in the single-structure case, its performance still clearly outperformed models without structural feature modeling (MAE = 0.8388). This result demonstrates the WSLP model’s capability to provide unified and accurate predictions without requiring explicit differentiation between warehouse types.
Overall, the WSLP model achieves a balance between structural adaptability and cross-structure generalization, laying a solid foundation for large-scale, multi-warehouse grain condition monitoring and forecasting.
4.3.3. Inter-Model Comparison
To evaluate the performance of the proposed model, we selected several models introduced in previous studies for comparative experiments. However, as most existing models are limited to predicting the temperature of a single region within the grain bulk, this study focuses on comparing the predictive performance of the proposed model at specific temperature measurement points with the performance of other models applied to the same measurement points. Specifically, the proposed model is compared with the following models commonly used in recent studies:
Support Vector Regression (SVR): A regression model using kernel functions to map data into a high-dimensional space, optimizing a hyperplane for nonlinear regression.
Gated Recurrent Unit (GRU): A recurrent neural network with update and reset gates, effectively capturing temporal dependencies while mitigating gradient vanishing.
To further validate the model’s spatial prediction ability, we selected representative sensor points located at different heights and regions within cylindrical warehouse Q11 (e.g., 16-1, 11-6, 24-11, and 3-16, as shown in Figure 7d); the test dataset spanned 100 consecutive days from 30 January to 9 May 2025.
The aggregated performance metrics are summarized in Table 5. The prediction results of different models at each selected sensor location are presented in Figure 16, Figure 17, Figure 18 and Figure 19, where each plot corresponds to one specific sensor. The inset subplot in each figure provides a zoomed-in view of a representative segment within the prediction interval, allowing for a more detailed comparison between the predicted values and the actual observations across different models.
Table 5.
, , and for different models.
Figure 16.
Granary prediction result at location (NO.Q11-161).
Figure 17.
Granary prediction result at location (NO.Q11-116).
Figure 18.
Granary prediction result at location (NO.Q11-2411).
Figure 19.
Granary prediction result at location (NO.Q11-316).
The results show that the proposed WSLP-LSTM–iTransformer model consistently achieves superior prediction accuracy at the test sensor positions. In terms of overall performance, our method achieved MAE = 0.2601, improving upon SVR (0.4310) by 39.6% and GRU (0.4704) by 44.7% in this setting; it also outperformed standalone LSTM and iTransformer. It achieved the best results in RMSE and metrics, indicating robust performance under complex spatial conditions.
4.3.4. Discussion
Through tuning and comparative experiments, this study has validated the superior ability of the proposed model in capturing the nonlinear dynamic changes in granary temperature time series. The experimental results show that the proposed model significantly outperforms traditional models such as SVR and GRU, especially in regions with significant temperature fluctuations within the grain piles.
We attribute the improvement to two factors: (i) WSLP converts raw multi-point measurements into physically meaningful hierarchical features (environmental trend, planar distribution, vertical diffusion, and neighborhood response), reducing the burden on the temporal model to rediscover spatial structure from scratch; (ii) the LSTM–iTransformer hybrid with adaptive selection/fusion leverages complementary strengths for local fluctuations and longer-range multivariate dependencies, which is beneficial under regime changes driven by weather and operational conditions.
5. Conclusions
To address the critical challenge of grain pile temperature prediction, this study regards the granary as an integrated system governed by its inherent physical structure and heat transfer pathways. From this perspective, we abandon black-box spatial feature relationship capture models (e.g., GNNs) and propose a multi-level “warehouse–surface–line–point” (WSLP) modeling framework to explicitly characterize heat transfer patterns and temperature influence relationships within the spatial structure of the grain pile. This method combines the temperature evolution process of the grain pile with the environment of grain storage and the heat transfer process inside the grain pile, which can effectively describe the temperature variation characteristics of different spaces of the grain pile. By coupling WSLP with a time-series prediction model (LSTM–iTransformer), the framework enables accurate multi-region forecasting while enhancing the physical consistency and interpretability of the results.
Experimental results show that the proposed model improves prediction accuracy and spatial coverage across both cylindrical and rectangular granaries. In our experiments, MAE was reduced by 39.6% compared with SVR and by 44.7% compared with GRU on representative multi-point forecasting tasks.
Moreover, in regions such as the edge of the granary and the top of grain piles, which are more significantly affected by environmental factors, the model’s prediction accuracy is slightly lower than that in the main area of the grain pile. Coupled modeling that considers both external environmental factors and internal heat exchange mechanisms represents an important direction for further improving the overall prediction accuracy of grain pile temperatures.
This research not only provides an efficient and robust technical approach for granary temperature prediction but also establishes a scientific foundation for optimizing environmental control strategies in grain storage. In the future, as grain storage technologies and intelligent management systems continue to advance, the proposed model and methodology are expected to find broader applications in practical grain storage management, contributing significantly to improving grain safety and storage efficiency.
Author Contributions
Conceptualization, B.L. and Y.X.; methodology, B.L., L.S. and P.L.; software, B.L., H.Z. and P.L.; formal analysis, J.Q.; investigation, Y.X. and L.S.; writing—original draft preparation, Y.X. and P.L.; visualization, Y.X. All authors have read and agreed to the published version of the manuscript.
Funding
This research received no external funding.
Institutional Review Board Statement
Not applicable.
Informed Consent Statement
Not applicable.
Data Availability Statement
The author does not have the authority to publicly disclose all the data.
Acknowledgments
During the preparation of this study, the authors used GPT-4/DeepSeek-v3 in order to improve the readability and language of the manuscript. After using this tool/service, the authors have reviewed and edited the output and take full responsibility for the content of this publication.
Conflicts of Interest
The authors declare no conflicts of interest.
References
- Kaushik, R.; Singhai, J. An approach for the development of a sensing system to monitor contamination in stored grain. In Proceedings of the 2019 6th International Conference on Signal Processing and Integrated Networks (SPIN), Noida, India, 7–8 March 2019; IEEE: Piscataway, NJ, USA, 2019; pp. 880–884. [Google Scholar]
- Estaquio, R.P.; Danao, L.A.; Lustro, J.R. A numerical study on performance enhancement of locally produced axial-flow fans for grain drying. In Proceedings of the ASME International Mechanical Engineering Congress and Exposition, Portland, OR, USA, 16–19 November 2020; American Society of Mechanical Engineers: New York, NY, USA, 2020; p. V009T10A057. [Google Scholar]
- Ji, Y.-L.; Ma, X.-M.; Xi, L.; Yu, H.; Zhang, H.; Che, Y.-C. Research on a safe wheat storage monitoring and prediction system. N. Z. J. Agric. Res. 2007, 50, 673–678. [Google Scholar] [CrossRef] [Scilit]
- Zhao, L.; Wang, J.; Li, Z.; Hou, M.; Dong, G.; Liu, T.; Sun, T.; Grattan, K.T.V. Quasi-distributed fiber optic temperature and humidity sensor system for monitoring of grain storage in granaries. IEEE Sens. J. 2020, 20, 9226–9233. [Google Scholar] [CrossRef] [Scilit]
- Kodali, R.K.; John, J.; Boppana, L. IoT monitoring system for grain storage. In Proceedings of the 2020 IEEE International Conference on Electronics, Computing and Communication Technologies (CONECCT), Bangalore, India, 2–4 July 2020; IEEE: Piscataway, NJ, USA, 2020; pp. 1–6. [Google Scholar]
- Wu, W.; Cui, H.; Han, F.; Liu, Z.; Wu, X.; Wu, Z.; Zhang, Q. Digital monitoring of grain conditions in large-scale bulk storage facilities based on spatiotemporal distributions of grain temperature. Biosyst. Eng. 2021, 210, 247–260. [Google Scholar] [CrossRef] [Scilit]
- Hochreiter, S.; Schmidhuber, J. Long short-term memory. Neural Comput. 1997, 9, 1735–1780. [Google Scholar] [CrossRef] [Scilit]
- Liu, Y.; Hu, T.; Zhang, H.; Wu, H.; Wang, S.; Ma, L.; Long, M. iTransformer: Inverted transformers are effective for time series forecasting. arXiv 2023, arXiv:2310.06625. [Google Scholar]
- Simin, W.; Yifei, K.; Yixuan, X.; Chunmiao, M.; Haitao, W.; Weiguo, W. Data center temperature prediction and management based on a Two-stage self-healing model. Simul. Model. Pract. Theory 2024, 132, 102883. [Google Scholar] [CrossRef] [Scilit]
- Han, Y.; Sun, K.; Yan, J.; Dong, C. The CNN-GRU model with frequency analysis module for sea surface temperature prediction. Soft Comput. 2023, 27, 8711–8720. [Google Scholar] [CrossRef] [Scilit]
- Zuo, X.; Zhou, X.; Guo, D.; Li, S.; Liu, S.; Xu, C. Ocean temperature prediction based on stereo spatial and temporal 4-D convolution model. IEEE Geosci. Remote Sens. Lett. 2022, 19, 1003405. [Google Scholar] [CrossRef] [Scilit]
- Christian, R.A.; Patel, D.A. Potential of k-means clustering-based fuzzy logic for prediction of temperature in ambient atmosphere. Arab. J. Sci. Eng. 2015, 40, 227–234. [Google Scholar] [CrossRef] [Scilit]
- Yang, Y.; Gao, P.; Sun, Z.; Wang, H.; Lu, M.; Liu, Y.; Hu, J. Multistep ahead prediction of temperature and humidity in solar greenhouse based on FAM-LSTM model. Comput. Electron. Agric. 2023, 213, 108261. [Google Scholar] [CrossRef] [Scilit]
- Chen, Z.; Gao, J.; Wang, W.; Yan, Z. Physics-informed generative neural network: An application to troposphere temperature prediction. Environ. Res. Lett. 2021, 16, 065003. [Google Scholar] [CrossRef] [Scilit]
- Yu, Y.; Si, X.; Hu, C.; Zhang, J. A review of recurrent neural networks: LSTM cells and network architectures. Neural Comput. 2019, 31, 1235–1270. [Google Scholar] [CrossRef] [Scilit]
- Jia, C.; Sun, D.-W.; Cao, C. Computer simulation of temperature changes in a wheat storage bin. J. Stored Prod. Res. 2001, 37, 165–177. [Google Scholar] [CrossRef] [Scilit] [PubMed]
- Wang, Y.C.; Yang, K.M.; Zhang, Z.T.; Qi, W.; Yang, J. Natural convection heat and moisture transfer with thermal radiation in a cavity partially filled with hygroscopic porous medium. Dry. Technol. 2016, 34, 275–286. [Google Scholar] [CrossRef] [Scilit]
- Sun, D.-W.; Woods, J.L. Deep-bed simulation of the cooling of stored grain with ambient air: A test bed for ventilation control strategies. J. Stored Prod. Res. 1997, 33, 299–312. [Google Scholar] [CrossRef] [Scilit]
- Sun, D.-W.; Woods, J.L. Simulation of the heat and moisture transfer process during drying in deep grain beds. Dry. Technol. 1997, 15, 2479–2492. [Google Scholar] [CrossRef] [Scilit]
- Quemada-Villagómez, L.I.; Molina-Herrera, F.I.; Carrera-Rodríguez, M.; Calderón-Ramírez, M.; Martínez-González, G.M.; Navarrete-Bolaños, J.L.; Jiménez-Islas, H. Numerical study to predict temperature and moisture profiles in unventilated grain silos at prolonged time periods. Int. J. Thermophys. 2020, 41, 52. [Google Scholar] [CrossRef] [Scilit]
- Rusinek, R.; Kobyłka, R. Experimental study and discrete element method modeling of temperature distributions in rapeseed stored in a model bin. J. Stored Prod. Res. 2014, 59, 254–259. [Google Scholar] [CrossRef] [Scilit]
- Wang, Q.; Feng, J.; Han, F.; Wu, W.; Gao, S. Analysis and prediction of grain temperature from air temperature to ensure the safety of grain storage. Int. J. Food Prop. 2020, 23, 1200–1213. [Google Scholar] [CrossRef] [Scilit]
- Duan, S.; Yang, W.; Wang, X.; Mao, S.; Zhang, Y. Grain pile temperature forecasting from weather factors: A support vector regression approach. In Proceedings of the 2019 IEEE/CIC International Conference on Communications in China (ICCC), Changchun, China, 11–13 August 2019; IEEE: Piscataway, NJ, USA, 2019; pp. 255–260. [Google Scholar]
- Sun, F.; Gong, C.; Lyu, Z. Grain storage temperature prediction based on chaos and enhanced RBF neural network. Sci. Rep. 2024, 14, 24015. [Google Scholar] [CrossRef] [Scilit]
- Carrera-Rodríguez, M.; Martínez-González, G.M.; Navarrete-Bolaños, J.L.; Botello-Álvarez, J.E.; Rico-Martínez, R.; Jiménez-Islas, H. Transient numerical study of the effect of ambient temperature on 2-D cereal grain storage in cylindrical silos. J. Stored Prod. Res. 2011, 47, 106–122. [Google Scholar] [CrossRef] [Scilit]
- Zhang, X.; Zhang, H.; Wang, Z.; Chen, X.; Chen, Y. Research on the temperature field of grain piles in underground grain silos lined with plastic. J. Food Process Eng. 2022, 45, e13971. [Google Scholar] [CrossRef] [Scilit]
- Yue, R.; Zhang, Q. A pore-scale model for predicting resistance to airflow in bulk grain. Biosyst. Eng. 2017, 155, 142–151. [Google Scholar] [CrossRef] [Scilit]
- Zhou, H.; Zhang, S.; Peng, J.; Zhang, S.; Li, J.; Xiong, H.; Zhang, W. Informer: Beyond efficient transformer for long sequence time-series forecasting. In Proceedings of the AAAI Conference on Artificial Intelligence, Online, 2–9 February 2021; AAAI Press: Palo Alto, CA, USA, 2021; Volume 35, pp. 11106–11115. [Google Scholar]
- Wang, C.; Chen, Y.; Zhang, S.; Zhang, Q. Stock market index prediction using deep Transformer model. Expert Syst. Appl. 2022, 208, 118128. [Google Scholar] [CrossRef] [Scilit]
- Sang, S.; Li, L. A novel variant of LSTM stock prediction method incorporating attention mechanism. Mathematics 2024, 12, 945. [Google Scholar] [CrossRef] [Scilit]
- Qu, Z.; Zhang, Y.; Hong, C.; Zhang, C.; Dai, Z.; Zhao, Y.; Wu, X.; Jiang, X.; Qian, J.; Gu, Z. Temperature forecasting of grain in storage: A multi-output and spatiotemporal approach based on deep learning. Comput. Electron. Agric. 2023, 208, 107785. [Google Scholar] [CrossRef] [Scilit]
- Duan, S.; Yang, W.; Wang, X.; Mao, S.; Zhang, Y. Temperature forecasting for stored grain: A deep spatiotemporal attention approach. IEEE Internet Things J. 2021, 8, 17147–17160. [Google Scholar] [CrossRef] [Scilit]
- Wu, Y.; Yang, H.; Zhou, K.; Wang, Y.; Zhu, Y. Application of bidirectional LSTM neural network in grain stack temperature prediction. In Proceedings of the International Conference on Bio-Inspired Computing: Theories and Applications, Huangshan, China, 12–14 November 2021; Springer: Berlin/Heidelberg, Germany, 2021; pp. 385–395. [Google Scholar]
- Mao, B.; Tao, S.; Li, B. Grain temperature prediction based on GRU deep fusion model. Int. J. Inf. Technol. Decis. Mak. 2025, 24, 797–815. [Google Scholar] [CrossRef] [Scilit]
- Liu, W.; Liu, S.; Wang, Y.; Li, G.; Yu, L. Research on grain pile temperature prediction based on CNN-GRU neural network. In Proceedings of the International Symposium on Computer Science, Digital Economy and Intelligent Systems; Springer: Cham, Switzerland, 2021; pp. 214–226. [Google Scholar]
- Sherstinsky, A. Fundamentals of recurrent neural network (RNN) and long short-term memory (LSTM) network. Phys. Nonlinear Phenom. 2020, 404, 132306. [Google Scholar] [CrossRef] [Scilit]
- Greff, K.; Srivastava, R.K.; Koutník, J.; Steunebrink, B.R.; Schmidhuber, J. LSTM: A search space odyssey. IEEE Trans. Neural Netw. Learn. Syst. 2016, 28, 2222–2232. [Google Scholar] [CrossRef] [Scilit]
- Vaswani, A.; Shazeer, N.; Parmar, N.; Uszkoreit, J.; Jones, L.; Gomez, A.N.; Kaiser, Ł.; Polosukhin, I. Attention is all you need. arXiv 2017, arXiv:1706.03762. [Google Scholar] [CrossRef] [Scilit]
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content. |
© 2026 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license.


















