# Energy-Water Management System Based on MPC for a Greenhouse in a Mapuche Indigenous Community
## 3 Problem Statement  
Achieving proper water and energy rationing is a relevant problem that must be overcome during the implementation of crop control systems in greenhouses. Additionally, the effects of climate change and trends in water scarcity must be considered, as they vary between different regions of the world. Therefore, to improve the operation of greenhouse systems, a control strategy that supports the optimal management of water and energy resources is proposed. Specifically, an integrated EWMS was designed based on MPC, and energy and water use were assessed from two temporal perspectives: a short-term perspective in which energy consumption is optimized for the next two days, and a medium-term perspective in which the water is managed for the next 28 days. As shown in Figure 1, the water available for daily irrigation comes from a water tank installed in the greenhouse. Thus, for the medium-term objective associated with the WMS, the system controls the reference value for daily irrigation \(\bar{V}\), which must be set by the controller based on the expected volume of water stored in the tank \(V_{Tank}\), the amount of water lost via evapotranspiration, and the previous amount of irrigated water \(V_{irr}\) used. Moreover, in the short term, the controller needs to optimize energy use to maintain proper climate conditions (such as temperature \(T_{gr}\) and humidity \(HR_{gr}\)) to grow crops. In the greenhouse system used in this work, the controller requires electrical energy to operate the different actuators available, such as for the water pump used to refill the tank \(Rec_{pump}\) (binary variable--0 for closed and 1 for open); perform valve regulation to control the amount of water used for irrigation \(I\) (continuous variable--0 for no irrigation and 1 for irrigation for a full sample time); and control the openness of windows \(W_{s}\) (binary variable--0 for closed and 1 for open). Here, all the energy necessary to operate this system comes from a photovoltaic system with a battery backup subsystem installed in the greenhouse. Thus, the short-term goal of the controller is to comply with the water use requirements at the medium-term scale while maintaining appropriate climate conditions and safe values of the state of energy \(SoE\) to ensure an optimized battery lifespan. Due to the stochastic behavior of the external climate conditions, the optimal management of future water use requires the proper characterization of the air temperature \(T_{ext}\), solar irradiance \(Ir\), and external humidity \(HR_{gr}\). In this work, neural networks were used to provide information to the controller about future scenarios and climate conditions. Wind speed \(u^{ext}\) was also needed to implement this controller; however, due to the high uncertainty associated with the future values of this signal and the limited amount of data available for running models, a moving average for predictions in the short term was adopted. Then, the optimal management of water and energy use was realized by running two model predictive controls: one for the short-term objectives and another for the medium-term water management objectives. For both MPC blocks, the internal variables of the greenhouse were considered by using approximations of the relevant phenomenological models available in the literature, and the ground temperature \(T_{ss}\) was required in these models. As shown in Figure 1, the prediction of the climate conditions at both the medium and short terms plays an essential role in supporting the management of available resources for the greenhouse. In the next section, the strategies used to predict the internal and external climate conditions are explained in detail.