# Energy-Water Management System Based on MPC for a Greenhouse in a Mapuche Indigenous Community
## 6 Case Study  
In this case study, the proposed energy-water management system was applied to a greenhouse in the Mapuche indigenous community Jose Painecura Huenalihuen. This greenhouse had an area of 60 m\({}^{2}\), and its microclimate was regulated by opening and closing windows. These characteristics were established based on those of a previous greenhouse at the same location, with windows open during the day and closed at night. The greenhouse was divided into two sections: the first half was used to test the proposed management systems, and the second half was manually irrigated by a farmer. The farmer agreed that tomato cultivation would be implemented in the greenhouse for the testing experiment. Before implementing the proposed EWMS and performing the on-site experiments, the EWMS was tested and calibrated in a simulation environment. However, only meteorological data measured every 10 minutes at a meteorological station in the time spans 14 June 2019-2 September 2019 and 23 October 2019-11 January 2020 were available. Climate variables were used in the first round of calibration and testing with the EMS and WMS. For the EMS, the data were organized into tuples of 144 inputs (regressors) and 288 outputs (predictions). Then, the dataset was separated into training, validation, and testing sets with proportions of 60% of the data for training, 20% for validation, and 20% for testing. In the case of the WMS, the data were divided into two sets spanning 81 days,denoted as winter data (14 June 2019 to 2 September 2019) and summer data (23 October 2019 to 11 January 2020). Finally, to analyze the performance of the system, the RMSE and MAPE were calculated for the predictions in different parts of the prediction horizon (1, 144, and 288 steps for the short term and 1, 14, and 28 days for the medium term). Two experiments were performed to test the short-term controller. In the first experiment, the performance of the climate control system was compared with that of a standard MPC and a manual control scheme in two scenarios. The first scenario involved winter data, and the second scenario involved summer data. In both scenarios, an initial crop age of 14 days and a total duration of 80 days were used. The references for temperature and relative humidity used for this experiment were  
\[T_{ref}(k)= \begin{cases}24\left[{}^{\circ}\mathrm{C}\right]&,\,\,Ir(k)\geq 1 00\left[\frac{\mathrm{W}}{\mathrm{m}^{2}}\right],\\ 14.5\left[{}^{\circ}\mathrm{C}\right]&,\,\,Ir(k)<100\left[\frac{\mathrm{W}}{ \mathrm{m}^{2}}\right],\end{cases}  \tag{47}\] \[HR_{ref}(k)= \,\,\,\,65\%. \tag{48}\]  
These reference values were determined by choosing the center of the normal zone of each variable (see Table 1). The MPC used for comparison was based on the following objective function:  
\[J= \sum_{j=1}^{2H}\lambda_{1}\Big{(}T_{gr}(k+j)-T_{ref}(k+j)\Big{)}^{ 2}+\lambda_{2}\Big{(}HR_{gr}(k+j)-HR_{ref}(k+j)\Big{)}^{2} \tag{49}\] \[+\sum_{j=1}^{\mathrm{N_{0}}}(\Delta W_{s}(k+j-1))^{2},\]  
where \(\lambda_{1}=\frac{10}{1.5^{2}}\) and \(\lambda_{2}=\frac{1}{10}\). The manual control scheme worked by keeping the windows open during the day (\(Ir(k)\geq 100\)) and closed during the night \(Ir(k)<100\). The results of this experiment were assessed based on the percentage of time for which both the temperature and humidity were in their security zones (\(T_{sec}\) and \(H_{sec}\), respectively) and normal zones (\(T_{norm}\) and \(H_{norm}\), respectively), as defined in Table 1. Another metric used was the number of times the window state changed \(\#\Delta W_{s}\). The second experiment with the short-term controller was carried out to assess its performance based on a fixed reference. The simulated scenario included the winter data and an initial crop age of 14 days.