1. Introduction
The greenhouse is a construction whose design is mainly focused on protecting crops from external factors, ensuring the development and growth of the plant. It can be considered as a physical and biological system whose dynamics are complex. Among the elements that are part of this type of system, the plant is the most important, and consequently, the environment in which it develops acquires a fundamental role [
1,
2].
The environmental conditions generated in the greenhouse influence the metabolic processes of the plant and, with it, its production and quality. These conditions encompass the climatic parameters of the greenhouse, known as the microclimate [
3]. The relationship between the crop and the microclimate is mainly due to the exchange of matter and energy that exists between them [
4]. The behavior of plants to the microclimatic conditions of the greenhouse varies greatly due to factors such as air temperature, solar radiation, and relative humidity, among others. These internal climatic factors are, in turn, influenced by external climatic conditions, with the temperature and relative humidity of the greenhouse being the variables with the greatest coupling and interaction [
5,
6]. To minimize this external influence, control systems can be implemented to mitigate internal changes and effects on the plant [
7].
The implementation of control systems depends on a good control strategy. For the design of the microclimate control strategy, it is important to know the behavior of the aforementioned factors, where modeling is a necessary tool for this task [
8]. Microclimatic models can be divided into two types [
9].
Physical or mechanistic models: These models provide physical phenomena using differential equations, and the parameters have a physical interpretation. In the case of greenhouses, they allow for the evaluation of heat, the mass transport process, energy balance, transpiration, photosynthesis, CO
2 exchange, and radiation transfer in crops [
10]. For example, models have been developed to determine crop water requirements or evapotranspiration, based on radiation and energy balance [
11,
12,
13,
14].
Black box models: These models attempt to approximate behavior with a priori information, such as fuzzy logic, neural networks, among others. In greenhouses, fuzzy logic has been implemented for remote monitoring and control [
15,
16], genetic algorithms (GA) for optimization processes [
17,
18], and neural networks for microclimate prediction [
19,
20].
The first method, based on the physical laws involved in the process, obtaining the physical model becomes very complex considering the type of system and the physical phenomena involved [
21]. However, they allow us to understand the behavior of the different elements that make up the greenhouse and their relationship between them, where the processes responsible for the transfer of energy and mass are analyzed [
22]. This type of model has been extensively investigated and applied for the simulation and analysis of the microclimate in greenhouses [
23,
24,
25,
26,
27]; additionally, considering greenhouse quality, these models help in the design of greenhouses [
28]. However, as shown in the vast majority of these studies, physical models require a considerable understanding of the system; their development is very difficult [
9], and other sub-models need to be developed [
29].
Black box models are based on an analysis of input and output data from the process [
21]. These models use a system identification approach with linear and nonlinear techniques. It is important to note that by requiring information a priori, the resulting models are built for a specific type of greenhouse in a specific location [
30]. Various methods and algorithms have been applied for the study of the greenhouse microclimate, some of which include the particle swarm optimization algorithm (PSO) [
31,
32,
33], GA [
34,
35], fuzzy logic [
36,
37,
38], and artificial neural networks (ANNs) [
39,
40,
41].
ANNs are models based on mathematical techniques for signal processing, forecasting, and clustering. Its operation is based on biological neurons, which are the processing elements, and by their connections through coefficients (weights), thus forming a neuronal structure [
42]. The application of ANNs in the study of the greenhouse microclimate has been widely explored, with feedforward neural networks (FFNNs) being the most widely used [
43].
In recent years, recurrent neural networks (RNNs) have also shown good results [
5,
44,
45,
46,
47]. RNNs compared to FFNNs generally present better results due to their predictive power [
48], since they can generate and process sequence memories of input models [
49]. The field continues to advance rapidly, with sophisticated hybrid architectures emerging. For instance, a recent study proposed a RIME-CNN-BiLSTM model, which combines convolutional neural networks (CNN) for spatial feature extraction with Bidirectional long short-term memory (BiLSTM) networks for temporal modeling, all optimized using the RIME algorithm for hyperparameter tuning. This model represents the cutting edge in pure data-driven approaches, demonstrating high accuracy for temperature and humidity forecasting in solar greenhouses [
50].
Many greenhouses still choose to use conventional control, but this control strategy may not be adequate to guarantee the desired performance [
51]. In this scenario, various control strategies and techniques have been proposed [
52,
53], where neural networks based on deep learning are just being developed [
5]. For this task, it is necessary to identify the architecture with the best performance, as in the case of FFNNs [
39,
40,
54,
55], and thus, finally, to be able to develop control strategies where deep learning is a tool for greenhouse climate control.
An example of a hybrid control scheme with two inputs and two outputs is presented in
Figure 1. The scheme is made up of a conventional proportional, integral, and derivative multivariable control (PID) and a hybrid recurrent neural network for greenhouse microclimate prediction. In this approach, extractors
and curtains
can be considered as inputs; indoor temperature
and indoor relative humidity
as state variables; outside temperature
, and outside relative humidity
as disturbances.
and
are the reference signal and process output, respectively.
The rise of the Internet of Things has allowed for the development of smart greenhouses, which involve the use of a large amount of data [
56,
57]. RNNs have proven to be an important tool in this field, so it is important to determine the different architectures and elements to obtain better results since there is no systematic method for this process [
58]. Unlike previous studies that focus on either RNNs or FFNNs separately, our work provides a comprehensive evaluation of both architectures under identical conditions. The novel contributions include (1) development of a parallel hybrid architecture combining mechanistic models with Elman RNNs; (2) systematic evaluation of multiple hidden layer configurations for both RNN and FFNN architectures; (3) direct performance comparison between hybrid RNN and FFNN approaches; and (4) practical insights for greenhouse climate control system design.
This research addresses a distinct gap by proposing a hybrid RNN architecture that integrates mechanistic modeling with Elman networks for greenhouse microclimate prediction. While other studies focus on complex, purely data-driven deep learning models, our work explores a different paradigm: enhancing simpler, more computationally efficient recurrent architectures through fusion with physical knowledge. Unlike previous studies that focus on either RNNs or FFNNs separately, our work provides a comprehensive evaluation of both architectures under identical conditions within this hybrid framework. Specifically, we investigate the following research questions: (1) Can hybrid RNNs outperform hybrid FFNNs in predicting greenhouse temperature and humidity? (2) What is the optimal network configuration for each architecture? (3) How does the integration of mechanistic knowledge enhance prediction performance?
3. Results and Discussion
In this research, the performance of the hybrid RNNs and the hybrid FFNNs for the prediction of the temperature and relative humidity of a greenhouse was evaluated and compared.
Figure 5 shows the results in the prediction of the internal temperature in the training phase of the different structures of the RNNs and FFNNs. Both the hybrid RNNs and the hybrid FFNNs show good results, since the values obtained conform to the behavior of the measured data. This result is similar to that reported by Linker and Seginer (2004), who used a hybrid FFNN, which showed a good prediction of greenhouse temperature [
60], and more recent RNN-based models [
5,
48].
During the training phase, both hybrid architectures demonstrated a strong capacity to learn the underlying dynamics of the greenhouse system, achieving near-perfect metrics (R
2 ≈ 0.999) for optimal configurations (
Table 3 and
Table 4). This exceptional performance aligns with and even surpasses the results reported by Linker and Seginer (2004) [
60] for hybrid FFNNs, confirming the effectiveness of integrating mechanistic models with neural networks.
In the case of temperature prediction, the hybrid RNN with three hidden layers emerged as the top performer (MAPE = 8.344 × 10−4; R2 = 0.999), slightly edging out the best hybrid FFNN (two hidden layers; MAPE = 4.343 × 10−3; R2 = 0.999). This suggests that the RNN’s recurrent connections provided a marginal advantage in capturing the complex, time-dependent thermal processes during training. For humidity, a similar pattern was observed, with the three-layer hybrid RNN (MAPE = 1.056 × 10−4) outperforming the best two-layer hybrid FFNN (MAPE = 4.292 × 10−4). The superior performance for humidity prediction (lower errors compared to temperature) across all models may be attributed to the less complex, more direct relationship between ventilation (driven by wind speed) and internal humidity levels as modeled by the mass balance equation.
However, it is critical to note that these near-perfect training scores indicate a high risk of overfitting, a common challenge in neural network modeling that is often not explicitly discussed in similar studies [
39,
40]. The true test of model robustness lies in its performance on unseen data.
Figure 6 shows the results obtained in the training of the hybrid recurrent and hybrid feedforward networks for the prediction of relative humidity.
Table 5 shows the MAPE, MSE, and R
2 values of the hybrid RNNs in the calculation of relative humidity. The configuration with three hidden layers is the best, as was the case with internal temperature prediction. However, the results for the inside relative humidity are better (MPE = 1.056 × 10
−4; MSE = 9.542 × 10
−9; R
2 = 0.999).
In
Table 6, it can be seen that the hybrid FFNN with two hidden layers is the best among all configurations. However, the results (MPE = 4.292 × 10
−4; MSE = 1.061 × 10
−7; R
2 = 0.999) still do not exceed those of the hybrid RNN with three hidden layers.
In the test phase, the results show that hybrid RNNs perform better in most of their configurations compared to hybrid FNNs.
Figure 7 shows the behaviors of the hybrid RNNs and hybrid FFNNs for the prediction of inside temperature. It can be observed that the predictive power is lower in the test phase; however, the hybrid RNNs in configurations of one, two, three, and five hidden layers present good results. However, in the case of hybrid FFNNs, only the one- and two-hidden-layer configurations show favorable results.
For the task of predicting inside temperature on unseen data, hybrid RNNs demonstrated clear superiority and robustness over hybrid FFNNs (
Table 7 and
Table 8). The optimal hybrid RNN (two hidden layers; R
2 = 0.897; MAPE = 0.282) maintained strong performance, while the best hybrid FFNN (two hidden layers; R
2 = 0.898; MAPE = 0.280) was its only configuration that remained competitive. This result significantly advances the findings of Salah and Fourati (2018) [
48], who demonstrated RNN superiority in a pure data-driven context; our work confirms that this advantage persists in a hybrid mechanistic-data-driven framework.
The superior performance of RNNs for temperature prediction can be attributed to their inherent ability to model temporal sequences. Temperature inside a greenhouse exhibits significant inertia, being influenced by accumulated solar energy and past states. The Elman network’s context layers effectively capture these time-lagged dependencies, allowing it to model the thermal dynamics more physically than the memory-less FFNN. The sharp performance drop in FFNNs with more than two hidden layers (e.g., three-layer FFNN R2 = 0.495) indicates their tendency to overfit noise in the training data when complexity increases, a vulnerability less pronounced in the recurrent architectures.
In the test phase for the calculation of inside relative humidity, the results obtained by the hybrid RNNs and the hybrid FFNNs are very similar, as can be seen in
Figure 8.
The difference in MAPE, MSE, and R
2 values between the different configurations of the hybrid RNNs is not very significant, as can be seen in
Table 9.
In contrast to temperature, the prediction of relative humidity during testing showed remarkably similar performance between hybrid RNNs and FFNNs (
Table 9 and
Table 10). The best models for both architectures achieved nearly identical metrics (e.g., RNN R
2 = 0.916 vs. FFNN R
2 = 0.916). This parity suggests that the internal relative humidity in our experimental setup was predominantly driven by instantaneous factors rather than long-term temporal histories. The primary drivers are likely the outside humidity (H
out) and the ventilation rate, which is a direct function of external wind speed (W
s) as defined in the mechanistic mass balance (Equations (10) and (11)). Since these are present in the current input vector, the FFNN lacks no critical information, negating the RNN’s primary advantage. This finding is crucial for practical applications, as it indicates that for humidity control in similar greenhouse types, a simpler and computationally cheaper hybrid FFNN might be sufficient, while for temperature, the investment in a hybrid RNN is justified.
In general, the values obtained by the hybrid RNN in any of its configurations for the calculation of inside relative humidity are good. The hybrid RNN with one hidden layer was the best, but only in terms of presenting smaller values for MAPE and MSE (0.262 and 0.257, respectively). RNNs are superior to FFNNs in greenhouse microclimate forecasting [
48]. However, in the test phase, the prediction of inside humidity between hybrid RNNs and hybrid FFNNs is very similar.
A consistent finding across all models and variables was the degradation of performance in testing for architectures with more than three hidden layers. For instance, the seven-layer hybrid RNN yielded an R
2 of only 0.503 for temperature prediction. This challenges the blanket application of “deeper is better” and aligns with the practical findings of Taki et al. (2018) [
40], who also found intermediate complexity to be optimal for greenhouse models. Overly complex networks appear to overfit the specific conditions of the training data, including the synthetic data generated by the mechanistic model, thus reducing their ability to generalize.
While a direct quantitative comparison against pure data-driven models was not the core focus of this experiment, the high performance achieved with a relatively small 10-day experimental dataset strongly implies the value added by the mechanistic model. Our hybrid RNN’s test performance (R
2 = 0.897 for temperature) is competitive with, and in some cases superior to, pure data-driven models reported in the literature that often use much larger datasets [
19,
20,
39]. For example, Outanoute et al. (2016) [
39] reported R
2 values around 0.85–0.92 for temperature using pure FFNNs. The integration of physical knowledge likely provided a regularizing effect, guiding the learning process and compensating for data scarcity, a key advantage of hybrid modeling as postulated by Linker and Seginer (2004) [
60]. Our results can be better understood when positioned alongside contemporary advances in the field. The recently developed RIME-CNN-BiLSTM model exemplifies the pursuit of high accuracy through sophisticated deep learning architectures, employing convolutional and bidirectional LSTM networks with automated RIME optimization [
50]. In comparison, our study demonstrates an alternative pathway: by integrating mechanistic knowledge with a simpler Elman RNN architecture, we achieved a similarly robust performance (R
2 = 0.897) while potentially gaining advantages in computational efficiency and model interpretability.
In summary, the results demonstrate that hybrid RNNs, particularly with 1–2 hidden layers, are a robust tool for greenhouse microclimate prediction, especially for temperature. The choice between RNNs and FFNNs, however, should be variable-specific, with RNNs being the preferred choice for temperature due to temporal dynamics, and FFNNs being a viable, efficient alternative for relative humidity prediction in scenarios dominated by instantaneous drivers.
4. Conclusions
In this study, we comprehensively evaluated hybrid recurrent neural networks (RNNs) against hybrid feedforward neural networks (FFNNs) for predicting greenhouse microclimate. Our findings provide answers, which are summarized as follows:
- (1)
Can hybrid RNNs outperform hybrid FFNNs in predicting greenhouse temperature and humidity?
Yes, but the superiority is variable-dependent. In predicting internal temperature, hybrid RNNs demonstrably outperform hybrid FFNNs. The recurrent architecture of the Elman network is uniquely suited to capturing the temporal dynamics and thermal inertia of the greenhouse environment, leading to more accurate and robust predictions during the testing phase. In contrast, in predicting relative humidity, the performance of hybrid RNNs and FFNNs was comparable. This suggests that humidity levels are more directly influenced by immediate, static factors (e.g., instantaneous ventilation rate or outside humidity) that do not heavily rely on temporal memory, thereby negating the primary advantage of the recurrent structure.
- (2)
What is the optimal network configuration for each architecture?
Our systematic evaluation reveals that optimal performance is not achieved by simply adding more layers. For the hybrid RNN, the configuration with two hidden layers was optimal for predicting inside temperature (R2 = 0.897), while the hybrid FFNN also performed best with two hidden layers. Critically, configurations with more than three hidden layers consistently led to a decrease in predictive performance for both architectures, indicating a tendency to overfit the training data rather than improving generalization. This finding underscores the importance of architectural parsimony for this specific application.
- (3)
How does the integration of mechanistic knowledge enhance prediction performance?
The integration of the mechanistic model was crucial for two primary reasons. First, it provided a physical foundation for the data-driven approach, guiding the learning process and ensuring that predictions adhere to fundamental principles of energy and mass balance. Second, it enabled the generation of a robust synthetic dataset, which compensated for the limitations of a short experimental data collection period. This synergy enhanced the model’s predictive generalization and robustness, proving particularly valuable in forecasting the more dynamically complex variable of temperature.
4.1. Limitations
Despite the promising results, this study has several limitations that also outline directions for future work:
Dataset Scale and Diversity: The experimental data were collected over a 10-day period from a single greenhouse. This limits the model’s exposure to long-term seasonal variations, different crop cycles, and diverse climatic conditions, which may affect its generalizability.
Model Scope: The study focused exclusively on predicting temperature and humidity. Other critical microclimate factors, such as CO2 concentration and vapor pressure deficit, were not included, nor were crop-dependent variables like leaf area index or transpiration rates.
Architectural Selection: The process for selecting the number of neurons per layer and other hyperparameters was empirical. The lack of a systematic optimization method means that the reported configurations may not be the global optimum.
4.2. Future Research
It would be highly valuable to investigate a serial hybrid configuration, where the mechanistic model’s output serves as a direct input to the neural network, and compare its performance with the parallel approach used here. Future models should also incorporate a broader set of inputs, including CO2 levels, soil moisture, and specific crop parameters, to create a more comprehensive microclimate prediction system.
It would be beneficial to explore more sophisticated RNN architectures like long short-term memory (LSTM) or gated recurrent units (GRUs), coupled with automated hyperparameter tuning (e.g., using Bayesian optimization or genetic algorithms), to further enhance performance and robustness. The ultimate goal is to deploy these models in real-time control systems. Research should focus on computational efficiency for embedded systems and investigate transfer learning techniques to adapt pre-trained models to new greenhouse designs and geographical locations with minimal data.