Supervisory Model Predictive Control for Optimal Operation of a Greenhouse Indoor Environment Coping With Food-Energy-Water Nexus

This paper presents a greenhouse indoor environment controller based on model predictive control (MPC), which can be integrated into existing greenhouse regulatory systems to optimally maintain critical climatic variables, including artificial lighting levels, CO2 rate, indoor temperature and humidity level within acceptable limits. The MPC based optimization problem aims to maximize the rate of crop photosynthesis while optimizing the use of the available water and energy sources, taking into account the unpredictability and intermittent nature of renewable energies and external atmospheric conditions. This would facilitate the management of greenhouses by anticipating control actions for a better quality of crops production. For that, the mathematical formulation of the optimal control problem is presented, and the numerical results related to the application of the MPC to case studies are analyzed integrating the effects of greenhouse structural considerations and the influence of climate data on its operation.


T Set of time intervals in scheduling horizon
With the threats of climate change, human population growth and scarcity of available water and arable land, the agriculture sector is facing challenges in ensuring food security [1]. Thus, shifting from traditional farming systems to sustainable intensification of agriculture favoring greenhouse crops as a mean of impressive productivity gains, turns out to be essential. In fact, greenhouses have opened a new perspective in the agricultural sector by offering economical land use, as well as carrying out important energy and water savings. They are used in floriculture and horticulture to extend cultural seasons, to protect plants from adverse environmental conditions such as extreme temperatures, wind, hail and rain. . . etc., and to screen out plant pests and diseases [2]. Their main goal is to control the indoor environment to promote the quality, quantity and growth of the crops. However, their indoor environment intelligent monitoring is particularly a complex procedure because of the number of involved variables depending on each other. The appropriate management of its indoor climatic conditions is highly influenced, in addition to the external environmental conditions, by four major control parameters that are the indoor temperature, the relative humidity, the CO 2 concentration, and the indoor light intensity [3] that must be optimally controlled within acceptable limits. In this perspective, to meet the desired requirements, many control strategies have been discussed in fundamental researches such as fuzzy logic controllers and proportional integrative derivative distributed controllers using genetic algorithms that represent useful tools compared to traditional control techniques [4], [5]. Robust control has also shown a good performance regarding the greenhouse temperature and hygrometry control despite the high interaction between the process variables and the external meteorological conditions [6], [7]. Furthermore, the Bayesian network has demonstrated to provide a good approximation of a control signal based on predefined set points, as well as on the environmental conditions [8].
However, the majority of the above-mentioned works have focused on improving the greenhouse internal climate without considering energy concerns. Nevertheless, to face the greenhouse high energy consumption considered as a major factor hindering its development [9], and to reduce the dependence on constrained production of unsustainable energy, the integration of different renewable energy sources (RES) has led to the concept of microgrids [10]. Microgrids can be considered as a portion of the power distribution network including loads, distributed generations and energy storage devices, grouped together within a limited geographic area [11]- [13]. They are bringing added values due to their ability to integrate renewable energies in grid-connected mode, along with their ability to continue operating in islanded modes without disruption on the main network or on the microgrid itself. In grid-connected configuration, the microgrid is connected to the distribution network operator (DNO) making mutual benefits in selling/purchasing power. In islanded mode, the microgrid has to achieve renewable energy autonomy through an energy storage unit to ensure the stability and the continuity of the service [14].
The implementation of microgrids in the agricultural sector corresponds to the needs of enhancing the quality and security of energy supply and of increasing the RES autonomy in rural areas. These agricultural microgrids can produce local socio-economic and environmental benefits. Besides, they can offer an interesting opportunity in promoting sustainable development, while ensuring the reliability, flexibility, efficiency, and environmentally friendly communication capabilities, stimulating thus the modernization of the agricultural sector. Their main goal is to assist in balancing the power generation and the power consumption using sensors, communications, and monitoring technologies [15]. Particularly, greenhouses can be considered as microgrids because of the availability of distributed energy resources and different load types. Thus, they can work in grid connected configuration injecting/extracting electricity excesses/needs into/from the network, or even in the grid disconnected one maximizing the local resources [16]. In fact, with the integration of advanced data processing and smart metering technologies, farmers can have access to management systems that help in supervising their energy needs while automatically controlling the greenhouse indoor microclimate [17].
From the energy management viewpoint, many techniques have been discussed in the literature for the optimal handling of energy consumption during the operation of greenhouses. Commonly, the existing methods fail to globally optimize the energy utilization due to a lack of general optimization scheme that considers the stochasticity of weather conditions, the intermittent behavior of RES and the storage dynamics, which has proven to be a dynamic way for a more efficient real-time control [18]. Besides, antecedent approaches represent limitations from a decision-making viewpoint, they have focused on a partial control of the greenhouse operation neglecting the global optimal management related to the optimal environment, the parameters correlation, the energy consumption and the efficient control [19]. However, studies have suggested that microgrids can achieve high performance through the deployment of advanced control algorithms based on predicted future conditions, the optimal use of storage devices and the implementation of optimal instead of heuristic based approaches [20]. Moreover, from the control point of view, model predictive control (MPC) has been suggested by the power system community as it offers many advantages such as being based on the system predictions, as well as providing feedback mechanisms that handle uncertainties and constraints, which is attractive for systems dependent on renewable energy forecasts [21].
In view of the above discussions, the novel contributions of the paper are to pool the different active systems that make up the greenhouse in order to deploy the necessary control means for an overall optimization of its operation, and this in the context of microgrids. The greenhouse is connected to both photovoltaic panels and wind turbine generator, and to the distributed network operator, and integrates an energy storage unit as well as a water reservoir. This option of installing a unit for the production and storage of green electricity was motivated by the desire to integrate the project into a sustainable development approach, using clean energy. Also, the system integrates the data acquisition via wireless sensor network (WSN) and the global control via a centralized model predictive controller. The proposed model can be implemented as a supervisory real-time control in the existing greenhouse energy management systems to effectively manage their overall energy and water demand, production and storage, with the main objective to track as close as possible the optimal levels of the greenhouse environment critical parameters.
All in all, the originality of this paper can be summarized in the following: • To develop an innovative greenhouse environment control scheme that manipulates all the critical parameters affecting the crop growth, i.e. indoor temperature and relative humidity, CO 2 rate, lighting levels and natural ventilation, while optimizing the energy and water consumptions, taking into account the uncertainty of the external atmospheric conditions and the intermittent nature of renewable energy sources and water needs. It boils down to the implementation of a centralized model predictive controller that considers all operational requirements and constraints. The centralization of operations will contribute to the balance of electricity production, prevents overproduction and under production, and protects against overloads. This would be considered as a stimulating idea to assist the development of modern agriculture driven by renewable energy systems that reinforces production in a sustainable agriculture approach respectful of natural resources.
• To test the MPC strategy through case studies, where the effects of the greenhouse structural considerations and the influences of environmental data are analyzed via numerical results. The case studies are adopted and discussed to demonstrate the benefits and feasibility of the proposed optimization approach. The remainder of this paper is organized as follows: In section II, the greenhouse energy management system is presented with a brief literature review of the existing control approaches, and the MPC strategy for the power and water management problem is formulated. Then, the mathematical models are presented in section III. The simulation results are discussed in section IV. Finally, the main conclusion is presented in Section V.

II. GREENHOUSE OPTIMAL OPERATION A. CONTROL APPROACHES FOR GREENHOUSES
In the regard of greenhouse energy management systems, several control techniques have been discussed in the literature to minimize the energy required for the microclimate regulation. Within this scope, researchers mostly focused on integrating renewable energy sources to reduce the cost for an economical crop growth by providing a sustainable way for greenhouse energy supply. The technologies used in this context are mainly photovoltaic modules [22]- [24], geothermal systems [25]- [27], hybrid photovoltaic/thermal solar collectors [28], [29], or a combination of them [30]. However, other researchers focused on the control and optimization based on mathematical models for optimal greenhouse cultivation practices [31]- [33], [9]. Nevertheless, the majority of these approaches are deterministic and do not integrate the randomness of the weather conditions, which turns out to be effective to deal with data uncertainty in optimal operations [34]. In fact, weather forecast tools are used by greenhouse growers because of their potential to reduce energy demand [9], [35], [36]. They allow, in combination with the greenhouse energy consumption prediction model, to solve the load modeling problem in smart grid applications [37]. Although, under the microgrid paradigm, the authors in [38] studied the optimization of the greenhouse energy utilization taking into account the weather conditions by considering forecasting results. Their objective was to minimize the total energy costs and demand charges via a hierarchical model, but without integrating RES, that is proved to support the transition to precision and sustainable agriculture [39], [40]. Moreover, the authors in [16] have proposed a greenhouse optimal energy management strategy for both grid-connected and islanded modes based on robust optimization. More, the authors in [41] studied a stochastic multi timescale energy management scheme of greenhouses with renewable energy sources.

B. PROPOSED GREENHOUSE ARCHITECTURE
The greenhouse used in this study can be seen as a structure for growing plants in a better controlled environment than outdoors. It offers, through various control tools, perspectives of innovations for a better management of water requirements and energy needs. It is considered as a microgrid that is connected to DNO through electronic converters to enhance the stability in the face of the intermittent nature of power generation and load demand. It integrates also: 1) Photovoltaic panels and a wind turbine generator representing the renewable energy sources; 2) an Energy Storage Unit (ESU) and a reservoir improving the reliability of the energy and water supply; 3) thermal, electrical and water loads representing actuating devices demand such as the fogging system, the dehumidifier, the CO 2 injector, the artificial lighting system, the pumps and the heating and cooling system; 4) an energy management system (EMS) responsible for optimizing the production performance, and 5) the data acquisition system based on wireless sensor network. Fig. 1 displays the general structure of the proposed greenhouse.

C. PROPOSED ENERGY MANAGEMENT SYSTEM
The energy management system is in charge of the optimal and autonomous greenhouse operation under the microgrid paradigm. The first step is to collect the related data from the different sensors available on-site to predict, with an interval of 10 minutes, information of the outdoor environment including temperature, humidity, CO 2 , wind speed and solar radiance. These forecasts are first used by the EMS to determine the predicted quantity of power generated from photovoltaic panels and wind turbine generators, then sent to the main controller, where the rules are implemented, to generate set points control signals for the existing actuators considering optimal ranges and control parameter constraints. The main controller's goal is to optimally distribute the renewable power to the greenhouse loads while reducing the fluctuations by selling the remaining surplus power to the network or storing it in the batteries as a replacement.

D. MPC SCHEME
The principle of predictive control is based on the use of a dynamic model of the process inside the controller in real time in order to anticipate future behaviors. In fact, at each time step, predictions of the controlled variables are computed up to a time horizon (Np), to determine the future control sequence for each power flow, and this with the intention of reaching the desired setpoints by following the reference trajectory. However, only the first element of the calculated control law is applied at the next clock stroke. All these steps are then repeated under the receding horizon principle, i.e. at the next time step, new powers and loads data are available, allowing to compute the new control sequence. The main advantage of this approach is its ability to anticipate future events while providing a clear constraints management.
The MPC basic structure block diagram is depicted in Fig. 2: In our application, the main idea is to choose the control action for the lighting, heating, dehumidification and CO 2 injecting loads, in addition to the master and local pumps, ESU, and power exchanges with the DNO, by repeatedly solving online an optimal control problem, aiming to minimize the objective function delivered by the main controller over a future horizon (Nc), subject to constraints on the manipulated parameters.

III. GREENHOUSE MATHEMATICAL MODELING
In a typical greenhouse, the efficiency of plant production is mainly determined by the adjustment of the crucial climate growth conditions. In fact, the most important factors for the quality and productivity of plant growth are the air temperature, relative humidity, light intensity and Carbone dioxide rate. To achieve a good quality and high production at low expense, these environmental variables must be optimally controlled through heating, supplementary lighting, CO 2 enrichment by injection, humidifying/dehumidifying and air ventilation. The objective function and the mathematical models of the power generators and each energy consuming component considering the operational constraints are described next.

A. OBJECTIVE FUNCTION
The objective function aims to minimize the purchased energy from the DNO, and the deviations from the reference trajectory signals representing the optimal greenhouse environment data as well as the optimal energy and water storage levels, to ensure safety and a good quality of service.
The optimization problem is formulated as a multiobjective optimization problem subject to quadratic cost function where the objective is to optimally manipulate the greenhouse's microclimate environment and to optimize its performance and operation. The first five terms of the objective function aim to minimize the maximum deviation from the reference signals defining respectively the desired indoor temperature, humidity, CO2 rate, artificial lighting, and water load for irrigation purpose. In addition, the objective function considers the operation of the storage system and water reservoir around reference values to ensure the quality of service as well as it minimizes the exchanges with the main grid aiming to increase the use of local renewable energy production. The objective function to be minimized in defined as follow:

B. DYNAMICS MODELS CONSTRAINTS 1) PV POWER GENERATION
Photovoltaic production depends mainly on the solar radiation of the site on which the panels are installed, in addition to the technical characteristics of the panel itself. The optimum voltage V pv and current I pv generated are [40]: where, The PV power generation is: The power output of the PV module is limited between the upper and lower bounds u pv,min < u pv (t) < u pv,max 2) WIND TURBINE POWER OUTPUT Several studies on wind turbine power generators and their exploitation have been addressed. In fact, the wind turbine derives its energy from the kinetic energy of the wind which mainly depends on its speed. In the current work, its power output is provided from a simplified linear model available in literature [42]. With The wind turbine power output is limited between the upper and lower bounds

3) ENERGY STORAGE UNIT
The greenhouse is equipped with an energy storage unit (batteries) whose function is to participate in the balance of the electric loads and renewable energy power generation. In this paper, the ESU is modeled as an energy reservoir with a certain degree of performance and upper and lower storage bounds. Its dynamics can be expressed as [14]: The energy stored should satisfy the ESU capacity limits: u Char,min < u Char (t) < u Char,max (15) u Dis,min < u Dis (t) < u Dis,max Besides, charging and discharging should not operate simultaneously:

4) PUMPING STATIONS AND WATER STORAGE SYSTEM
The greenhouse is equipped with a water storage system (reservoir) used to provide water supply. Its evolution is described as [43]: where the water flows are related to the electrical energy consumed by the pumping stations as follows: The water flows and the water stored in the reservoir should satisfy upper and lower limits:

5) TEMPERATURE CONTROL SYSTEM
Temperature is a major factor controlling the rate of photosynthesis. At low to moderate temperatures, the interactions activity increases with increasing temperature in accordance with the Arrhenius relationship. Thus, to avoid the decrease of crop growth, the greenhouse includes a micro-CHP that aims to maintain the indoor temperature at its optimal desired level. It is given as [44]: where the electric power is defined as: It's worthwhile to mention that the thermal resistance of the greenhouse covering material is defined from the greenhouse geometry and the material conductivity and thickness by The inside temperature of the greenhouse is limited by lower and upper bounds: The micro-CHP power outputs are also limited by lower and upper bounds: Besides, the micro-CHP power output slope is described as:

6) HUMIDITY CONTROL SYSTEM
Relative humidity inside the greenhouse is also considered as one of the most significant variables affecting the crop growth. It is well documented that the water flow taken in by the roots and evaporated through the leaves into the air for the transpiration process can be affected by the humidity level. The higher the relative humidity, the more slowly transpiration occurs, causing consequently tissue damages, growth delays and diseases propagation. Also, low humidity causes hydria stress and affects the process of photosynthesis. Therefore, relative humidity inside the greenhouse needs to be supervised to offer an optimal environment for crop growth. It is defined as [38]: where both saturated and partial pressures can be described approximatively by: The water content of the indoor air w(t) is modeled based on the mass balance theory, taken into consideration the moisture ventilated by natural air ventilation and the water quantity added or removed by the fogger or dehumidifier, as follows where the outdoor water content W out (t) can be estimated by and u fog (t) = u st fog (t) * P fog (40) u deh (t) = u st deh (t) * P deh (41) The relative humidity inside the greenhouse is constrained between upper and lower bounds, which is equivalent to satisfy the following constraints Besides, fogging and dehumidification systems should not operate simultaneously

7) CO2 INJECTOR SYSTEM
Carbon dioxide CO 2 is the most consumed nutrient by plants after water, it is absorbed from the air in gaseous form and its primary effect on plant production is on photosynthesis. CO 2 is found normally in the atmosphere at concentration of 380ppm, but it has been shown in high technology greenhouses that photosynthesis increases rapidly with increasing CO 2 [45]. In fact, many plant species have shown very positive effects and high-quality features from CO 2 enrichment by increased dry weight, plant height, number of leaves and flowers, and lateral branching [46]. Thus, to increase the rate of photosynthesis, it is essential to enrich the greenhouse with additional CO 2 . The CO 2 concentration in the greenhouse is mainly influenced by the injected CO 2 , the CO 2 consumption by the plants via the photosynthesis process and the exchange with the environment via natural ventilation. The change in indoor CO 2 concentration is modeled as [38]: The concentration of CO2 inside the greenhouse at every time slot is constrained between upper and lower bounds CO in,min

8) AIR CIRCULATION CONTROL
Natural ventilation plays an important role in affecting the greenhouse climate. It is required to maintain a uniform environment throughout the greenhouse. The ventilation air flow rate u vent of a greenhouse equipped by only roof or side vents can be simulated with good accuracy combining wind and chimney effects by [47]: H v 4 +C w v wind (t) 2 0.5 (48) Which can be simplified by neglecting the chimney effect generally insignificant for wind speeds greater than 1.5m/s.
where, the discharge coefficient of the vent opening (C d ) and the overall wind effect coefficient (C w ) are both dimensionless coefficients that have been demonstrated to vary significantly according to the windows opening angle [48]. Therefore, the ventilation air flow rate becomes where Then, from the ventilation air flow we obtain N, the greenhouse air exchange rate (h-1), which is defined as: The operation of the ventilation is controlled in the proposed model via the window opening angle, which is constrained between upper and lower bounds α min < α < α max (53)

9) ARTIFICIAL LIGHTING SYSTEM
Light is considered as the most significant parameter for the plant growth because all the active life process in it is not possible without the presence and the active influence of light [49]. It is a source of energy for photosynthesis as well as a source of activating signals for many physiological processes. In fact, in addition to ambient light, plant development is affected also by the light intensity, the photoperiod (light/dark period), and the wavelength or spectral distribution.
In greenhouse production, artificial lighting is used extensively during periods with poor natural light conditions to increase crop growth and quality [46]. In recent years, Light Emitting Diodes (LED) have gained a significant amount of attention in the research community since it represents technical advantages compared to traditional lighting sources [50]. However, some special requirements exist for its design. The most important is to consider the required flux which is The regulation of the greenhouse artificial lighting loads is done according to the incident solar irradiation detected by the WSN, and therefore the total power consumed by the supplementary lighting is: The power generated by the photovoltaic system is: The power generated by the wind turbine generator is: The state of charge of the ESU available is: where u Char (+k) = u pv,esu (t + k) + u w,esu (t + k) +u edn,esu (t + k) + u CHP,esu (t + k) (59) u Dis (t + k) = u esu,al (t + k) + u esu,CO2 (t + k) +u esu,deh (t + k) + u ess,fog (t + k) +u esu,p1 (t + k) + u esu,p2 (t + k) (60) Artificial lighting, CO2 injection, dehumidification and fogging can be provided either by PV panels, wind turbine generators, the ESU or the DNO. The total power consumed by these loads can be written as: The total powers consumed by the pumping stations are: +u esu,p2 (t + k) + u edn,p2 (t + k) (66) The total power purchased from the DNO is: The total power sold to DNO is:

IV. APPLICATION TO CASE STUDIES A. SIMULATION SETUP
To demonstrate the performance of the presented optimization algorithm and to attest its concrete practices, the MPC-based scheduling problem has been simulated and tested through several case studies, of which the most relevant ones are presented here: when operating in good amount of renewable generation over a 24-hour interval (case study 1), and when operating in a worst case over 4-day interval (case study 2). The length of the prediction horizon and control horizon are set equal respectively to 24 h and 96 h with a control interval of 15 min. The greenhouse mathematical models were implemented and solved using Matlab software. The proposed control strategy is run for a typical greenhouse, where the expected outdoor temperature, humidity, CO 2 , solar radiance and wind speed, for both case studies, are shown in Fig. 3. It is connected to the DNO, the renewable generators (PV modules of 1 kW and a wind turbine of 3 kW) and to an energy storage unit with a maximal capacity of 24 kWh to fulfill the electric demand. It contains two pumping stations: one master pump that feeds the reservoir from the water source, and the second local pump dedicated to irrigation. In addition, it is equipped with a micro-CHP with a power to heat ratio of 0.2 for heating and cooling, a supplementary artificial light source consisting of 80 LED lamps of 28W, a CO 2 injector, a dehumidifier and an advanced metering infrastructure based on wireless sensor network. The said devices ratings and parameters are suitably chosen (see Nomenclature). The greenhouse is specialized in the cultivation of tomatoes, where a day temperature of 22 • C and a night temperature of 17 • C is optimum for its root growth and plant development [51], and where a diurnal increase of the indoor CO2 from its ambient level to 800-1000ppm is essential for enhancing its grow rate [52]. The adequate relative humidity requirement ranges from 60% to 70% [51], and the minimum light intensity required by the photosynthesis is 5500 lux at plant surface with a 20-hour photoperiod [53]. Therefore, the expected artificial lighting load should reach 2.2 kW from 12:00 A.M. to 3:00 A.M. and from 6:00 P.M. to 12:00 A.M. where the crop needs supplementary artificial lighting to complete its photoperiod. Besides, considering that greenhouse tomatoes need at least 0.37 m2 per plant with a total planted area of 80 m 2 , and taking into account that every plant needs 2.7l of water per day [51], the expected irrigation water load ensured by the local pump is supposed to be equal to 0.025[m3] in the first interval (15min) of each hour. The dry running protection of the local water pump is also planned. Therefore, a protection system should ensure a minimum level of 20% of the reservoir capacity.

B. RESULTS AND DISCUSSION
The case studies mentioned above are considered to study two specific cases where the environmental conditions are favorable/unfavorable to the wind and photovoltaic production. The solution proposed in the first case study corresponds to a good case of the greenhouse operation over a 24-hour interval, while the second one corresponds to a 4-day simulation, representing different aspects of the operation including a worst-case scenario for continuity and comparison purposes. The power produced by photovoltaic panels and wind turbine for both case studies is shown in Fig. 4. It shows that the peak of the generated photovoltaic power is around noon and follows the typical form of daily solar radiation, while the power produced by the wind turbines is governed by sudden variations of wind speed and affected by its stochastic character. Before analyzing the optimal resulting trajectories, it must be noted that the greenhouse structural considerations, specifically the glazing material type, have an important influence on the greenhouse micro-climate management by offering more or less insulation to cold or heat. In this direction, to demonstrate the best material the greenhouse structure should be constructed of in terms of thermal efficiency, various glazing materials with different conductivities and thicknesses have been chosen for analysis, to determinate the thermal power levels needed to set the greenhouse temperature at its optimal level. In fact, the most common materials used to cover the greenhouses are generally the polycarbonate 4mm-25mm, the glass 3mm, the acrylic 2mm-10mm or the polyethylene 6mm, which the conductivity is equal respectively to 0.19, 1, 0.2 and 0.33W/m.K. Fig. 5 shows the simulation of the MPC based thermal power output needed to rise the greenhouse temperature to the favorable one for these different covering materials. As it can be seen, the polycarbonate 25 mm demonstrates to have the minimum required power with an hourly average gain of 31.54 kW compared to the glass. Besides, the further benefit of using the polycarbonate as a greenhouse covering material, in addition to the cost reduction of the electrical/thermal energy, is to heat a larger area with the same micro-CHP capacity, and higher benefits could be obtained in the case of greater thicknesses. As a result, polycarbonate 25mm is selected to have the highest thermal resistance for the rest of the simulations.

1) CASE STUDY 1
Battery charging/discharging policy is considered as one of the crucial tasks, because it is in charge to fulfill the power load demand specially in peak hours. Fig. 6 first graph depicts the results of the MPC-based optimal behavior of the greenhouse's ESU. It can be easily seen that the ESU presents different trends of charge and discharge according to the availability of energy, the needed electric loads, and the power exchange with the DNO. For instance, in the first interval FIGURE 6. Energy storage unit optimal state and energy sold to the grid. VOLUME 8, 2020 from 00:00 A.M. to 03:00 A.M., the stored energy drops gradually from its initial value set to be equal to 15kWh, until reaching the minimum authorized, and this is mainly due to the absence of the renewable energy production and the starting time of artificial lighting. Then, in the second interval from 03:00 A.M. to 09:00 A.M., the battery charges until reaching its maximal capacity of 24kWh, due to the low energy needed for CO 2 injection and for dehumidifying. Also, it can be observed in the second graph during the same interval of time, that the energy is even sold to the DNO, because wind and solar energy sources and batteries are abundant to fulfil the loads need. And finally, from 09:00 A.M. the battery starts discharging according to the power balance between supply and demand, mainly explained by the high CO 2 injection load needed by the greenhouse in this period.
Optimal control decisions generated by the optimization problem following the receding horizon strategy for heating, dehumidifying, CO 2 injection and supplementary lighting are depicted in Fig. 7. It can be observed that all devices operate within predefined power ranges to regulate the greenhouse microclimate. The algorithm is developed to match the thermal and electrical power outputs of the micro CHP system and the greenhouse temperature reference signal. As it can be seen, the micro CHP is initially exploited to rise the temperature from its initial state of 15.5 • C to the optimal range (see Fig. 8). The micro CHP continue operating until it reaches its maximum capacity to fulfill the heat demand of the greenhouse, and then decreases due to the change of the nighttime and daytime optimal temperatures. As well for the dehumidifier, it operates specially during the day because of the strong relation between the temperature and humidity. In fact, relative humidity levels fluctuate according to greenhouse temperatures, and since the daytime temperature is higher, the system provides more energy to dehumidify during this interval of time. Also, CO 2 injection constitute the most important electric load during the daytime where   the crop start breathing in CO 2 to promote vegetative growth. In the other hand, the third graph of Fig. 7 shows a comparison between the resulted artificial lighting power and its optimal reference signal. It can be observed that the artificial lighting power drops from the desired range. This is mainly due to the charging/discharging ESU capacity limits, the low energy produced by the micro-CHP and the unavailability of the PV production. However, the crop will not be strongly affected since the supplementary lighting system consists of variable intensity LED illumination system configured to provide a change in light intensity versus the input power.
In Fig. 8, the evolution of the MPC-based optimal state of the environmental variables is plot including the inside temperature, relative humidity and CO 2 concentration, in addition to the window opening angle. It can be seen that all controlled parameters vary within the predetermined ranges defined in the nomenclature. In the other hand, regarding the greenhouse natural ventilation, the resulted opening angle is almost always 0, which means that the ventilation is deactivated to avoid the strong loss of heat and CO 2 , and consequently the wasted energy used to compensate this air exchange loss.  The reservoir is used to balance the water flow pumped from the water source and intended for crop irrigation. It is designed to keep a constant water level defined by the water reference signal, by first irrigating when needed and then by storing the water when the energy is available. The evolution of the MPC-based optimal state of the water reservoir is depicted in Fig. 9. It can be viewed that the reservoir shows different behaviors regarding charging/ discharging water depending on the availability of energy. For example, from 00:00 A.M. to 09:00 A.M. and from 06:00 P.M. to 00:00 A.M., the reservoir is in charging mode even if the local pump is activated in the first 15 min of each hour to ensure the water loads. This is explained by the presence of the ESU energy in the first interval and the wind power in the second. However, from 09:00 A.M. to 06:00 P.M., the reservoir is in discharging mode because of the CO2 enrichment high power load. In all cases, the master  pump installed at the reservoir level demonstrates its ability to handle the water-level fluctuations by maximizing the storage potential.

2) CASE STUDY 2
This second case study concerns the same simulations with different control and prediction horizons to show the continuity of the results over 4 days. It can be observed that the ESU replies to the high electrical appliances' consumption by discharging the stored energy while making sure to handle lower and upper ESU bounds' constraints (see Fig. 10). We note that the third day can be considered as the worst case due to the low energy production (see Fig. 4) which has engendered a low energy storage, a zero sale to the DNO and a violation of humidity reference tracking. In fact, as shown in Fig. 12, the relative humidity was not satisfied during this interval of time, even if the dehumidifier did not reach its maximum capacity, because of the conditions of high outdoor relative humidity and limited available energy. Also, the artificial lighting power values have seen the largest declines during that time for the same reasons. However, all the other controlled parameters as well as the control actions have been kept within acceptable ranges.

V. CONCLUSION
This paper proposed a novel control strategy for the optimal operation of a microgrid powered greenhouse. The strategy is formulated using model predictive control to optimally maintain the desired greenhouse microclimate while managing properly energy and water flows dedicated to irrigation, artificial lighting, CO 2 enrichment, dehumidifying, ventilation and heating. The optimization models incorporate uncertainties of renewable energies and loads in addition to weather forecasts. The devices resulted control strategies justifies the effectiveness of the optimization method and its applicability to greenhouse energy management units, by following the microclimate setpoint signals while considering mandatory required operational constraints even with uncertainties.
YASMINE ACHOUR received the degree in electrical engineering from The National School of Applied Sciences of Kenitra, Kenitra, Morocco, in 2016. She held the position of Hardware Development Engineer at the Research and Development Department of several multinationals operating in the automotive sector, such as LEAR Corporation and FAAR Industry. Her current research interests include agricultural greenhouse optimization, renewable energy, efficiency and energy management, and optimization and control of intelligent systems in agriculture.
AHMED OUAMMI received the Ph.D. degree from the Polytechnic School, University of Genoa, Italy, in 2010. He was a Research Fellow with the University of Genoa and worked as an Assistant Professor with the National Center for Scientific and Technical Research (CNRST). He is currently a Research Associate Professor with Qatar University. His research interests include decision support models, control and optimization of smart grids, and microgrids, with special focus on the implementation of original methods, models, and optimal control algorithms with applications to cooperative and interconnected smart systems integrated renewable energy systems. He has published more than 344 publications in international journals cited (Scopus H index = 55; 10254 cites). His research interests include food, water and algal technologies, bioremediation and biofuels, and renewable energy. VOLUME 8, 2020