Informatica 41 (2017) 317–331 317 Optimization, Modeling and Simulation of Microclimate and Energy Management of the Greenhouse by Modeling the Associated Heating and Cooling Systems and Implemented by a Fuzzy Logic Controller using Artificial Intelligence Didi Faouzi Materials and Renewable Energy Research Unit M.R.E.R.U University of Abou-bakr Belkaïd B.P. 119, Tlemcen, Algeria E-mail: didifouzi19@yahoo.com / didifouzi19@gmail.com Nacereddine Bibi-Triki Materials and Renewable Energy Research Unit M.R.E.R.U University of Abou-bakr Belkaïd B.P. 119, Tlemcen, Algeria E-mail: n_bibitriki@hotmail.fr Bentchikou Mohamed University of Yahia Fares, Médéa, Laboratory Director (LBMPT), Médéa Algeria E-mail: bentchikou.mohamed@univ-medea.dz Abderrahmane Abène Euro-Mediterranean Institute of Environment and Renewable Energies, University of Valenciennes, France E-mail: a.abene@yahoo.fr Keywords: optimization, modelling, simulation, heater systems, intelligent control, fuzzy logic, greenhouse, cooling pads Received: May 1, 2017 Agricultural greenhouse aims to create a favorable microclimate to the requirements of growth and development of culture, from the surrounding weather conditions, produce according to the cropping calendars fruits, vegetables and flower species out of season and widely available along the year. It is defined by its structural and functional architecture, the quality thermal, mechanical and optical of its wall, with its sealing level and the technical and technological accompanying. The greenhouse is a very confined environment, where multiple components are exchanged between key stakeholders and them factors are light, temperature and relative humidity. This state of thermal evolution is the level sealing of the cover of its physical characteristics to be transparent to solar, absorbent and reflective of infrared radiation emitted by the enclosure where the solar radiation trapping effect otherwise called "greenhouse effect" and its technical and technological means of air that accompany. New climate driving techniques have emerged, including the use of control devices from the classic to the use of artificial intelligence such as neural networks and / or fuzzy logic, etc... As a result, the greenhouse growers prefer these new technologies while optimizing the investment in the field to effectively meet the supply and demand of these fresh products cheaply and widely available throughout the year. In north Africa, greenhouse cultivation is undergoing significant development. To meet an increasingly competitive market and conditioned by increasingly stringent quality standards, "Greenhouse" production systems (heating and air-conditioning systems) Become considerably sophisticated and then disproportionately expensive. That is why locks who want to remain competitive must optimize their investment by controlling production conditions. The aim of our work is to model heating and air conditioning systems whose goal of heating and cooling the air inside our model and implemented in our application of climate control are due to the fuzzy logic that Has the role of optimizing the cost of the energy supplied using MATLAB software. Povzetek: V Matlabu je razvit inteligentni sistem/dom za steklenjake v Alžiriji. 1 Introduction Increased demand and requirement of fresh products consumers throughout the year, led parallelly to a rapid development of agricultural greenhouse, which is today modern and quite sophisticated. Agricultural greenhouse aims to create a favorable microclimate to the requirements of the plant, necessary for its growth and development, from the surrounding weather conditions. it produces based cropping calendars, off-season products, cheap and widely available along the year. [8] 318 Informatica 41 (2017) 317–331 D. Faouzi et al. It is defined by its structural and functional architecture, the optical quality, thermal and mechanical coverage and the accompanying technical means. it is considered as a very confined environment where many components are exchanged between them, and in which the main factor involved in this medium is light, temperature and relative humidity [7-9]. to manage the greenhouse microclimate, greenhouse growers often use methods such as passive static ventilation (opening), shade screens, evaporative cooling etc ... and occasionally the active type. these methods are less expensive but more difficult to manage and optimize [11-14]. The first objective is to improve the thermal capacity of the greenhouse (greenhouse). This is, to characterize the behavior of the complex system that is the greenhouse with its various compartments (ground, culture, cover, indoor and outdoor environment). To develop non-stationary mathematical models usable for simulation, optimization and the establishment of laws and control of simple and effective regulation. These models must reproduce the essential properties of the mechanisms and interactions between different compartments. they must be both specific enough to obey the dynamic and real behavior of the greenhouse system, and fairly small to be easily adaptable to the phases of the simulation. Good modulation instructions depending on the requirements of the plants to grow under shelter and outdoor climatic conditions, result in a more rational and efficient use of inputs and equip the best production performance. The greenhouse climate is modified by artificial actuators, thus providing the best conditions in the immediate environment of energy costs and it requires a controller, which minimizes the power consumption while keeping the state variables as close as possible optimal harvest. In this paper, or using fuzzy logic which is a powerful way to optimize and facilitate the global management of modern greenhouse, while providing through simulation interesting and encouraging which results in an optimization of favorable state variable values for the growth and development of protected cultivation [10-12-13]. The greenhouse originally conceived as an enclosure bounded by a wall transparent to solar radiation, as is the case with the conventional greenhouse, which is widely used in our country, amplifies certain parameters of the surrounding climate and shows conditions that are not favorable to Growth and the development of protected crops. This type of traditional greenhouses answered fairly well in the countries of the Mediterranean basin, is confronted to the intense nocturnal cooling, which sometimes results in the reversal of the internal temperatures and complications of overheating and hygrometric variations According to the seasons. Extreme variations in these parameters, often observed within shelters, constitute a nuisance that can hinder growth and crop development and, at best, penalize yield and product quality. To meet this equation of supply and demand, greenhouse systems have developed over time, thus imposing a great mastery of management and knowledge to achieve a better production [4]. This type of greenhouse, equipped and materialized by climate support; Are a means of transforming local conditions into an operational microclimate favorable to the growth and development of sheltered crops [1]. Technological progress has made considerable progress in the development of agricultural greenhouses. They become very sophisticated (heating systems, air conditioning, accessories and accompanying technical equipment, control computer etc.). New climate control techniques have emerged, including the use of control devices, ranging from the classical to the application of artificial intelligence, now known as neural networks and / or fuzzy logic [2]. The air conditioning of modern greenhouses, allows to keep the crops under shelters under conditions compatible with the agronomic and economic objectives. Serrists opt for competitiveness. They must optimize their investments, the cost of which is becoming more and more expensive [3]. The agricultural greenhouse can be profitable insofar as its structure is improved, the materials of the well chosen walls, depending on the nature and type of production, the technical installations and accompanying equipment must be judiciously defined. Many equipment and accessories have appeared to regulate and control the state variables [6] such as temperature relative humidity, CO2 concentration etc ... At present the climatic computers of the greenhouses, solve the problems of regulation and ensure the observance of the climatic constraints Required by plants. From now on, the climate computer is a tool for dynamic production management, able to choose the most appropriate climate route, to meet the targets set, while minimizing inputs. • Physiological aspect: This relatively complex and insufficiently developed field requires total management and extensive scientific and experimental treatment. This allows us to characterize the behavior of the plant during its evolution, from growth to final development; This allows us to establish an operational model • Technical aspects: The greenhouse system is subject to a large number of data, decisions and actions to be taken on the immediate climatic environment of the plant (temperature, hygrometry, CO2 enrichment, misting, etc.). The complexity of managing this environment requires an analytical, operational, numerical and computer-based approach to the system • Socio-economic aspect: The social evolution, will be legitimated by a demanding and pressing demand of fresh products throughout the year; This state of affairs, involves all socio-economic operators [5], to be part of a scientific, technological and kitchen Optimization, Modeling and Simulation of… Informatica 41 (2017) 317–331 319 dynamics. This dynamic demands high professionalism. New techniques have emerged, including the use of climate control devices in a greenhouse (temperature, humidity, CO2 concentration, etc.). Up to the exploitation of artificial intelligence That the neural networks and / or fuzzy logic. The application of artificial intelligence in the industry has grown considerably, which is not the case in the field of agricultural greenhouses, where its application remains timid. It is from this state of affairs that we initiate research in this field and carry out a modeling based on meteorological data through MATLAB Simulink (Didi Faouzi, et al., 2016), to finally analyze the thermo - energy behavior of the greenhouse microclimate. In our work we have modeled greenhouse systems (heating and cooling system and optimized the use of energy in a greenhouse by a defined intelligent controller such as fuzzy logic (FLC) using the method of Mamdani (Didi Faouzi , Et al, 2016). 2 Modeling of the greenhouse Our model is parameterized (state variables), meaning that spatial heterogeneity is ignored and that the internal content of flows at the boundary of the system boundary is uniformly distributed [1]. The model consists of a set of differential equations formulated as follows [4]: 𝑐𝑎𝑝 ∗ ∂T ∂t = ∑(𝑝𝑢𝑖𝑠𝑠𝑎𝑛𝑐𝑒𝑖𝑛 − 𝑝𝑢𝑖𝑠𝑠𝑎𝑛𝑐𝑒𝑜𝑢𝑡) [W] (1) Where: T: Is the temperature of the element under consideration (C °). 𝑐𝑎𝑝 (J K-1): Is its thermal capacity and the incoming and outgoing thermal power are expressed in watts. 3 Modeling of heating and cooling systems 3.1 Modeling of heating systems The modeled heating system consists of two independent heating pipes: one under the canopy (lower pipes) and the other in the canopy (upper pipes). The heating system located under the canopy; Whose pipes are installed beneath the benches and on the sides of the walking paths must be dimensioned correctly, in order to contribute effectively to the internal climate of the greenhouse. Due to the importance of this heating system, it was modeled with a proportional controller described by [8]: Q𝑓𝑜𝑢𝑟𝑛𝑖𝑒_𝑡𝑢𝑦𝑎𝑢𝑥 = 𝐴sol ∗ ‖𝐾𝑝_𝑡𝑢𝑦𝑎𝑢𝑥 ∗ (𝑇𝑟𝑒𝑓 − 𝑇𝑎𝑖𝑟)‖0 250 (2) Q𝑓𝑜𝑢𝑟𝑛𝑖𝑒_𝑡𝑢𝑦𝑎𝑢𝑥: : Is the thermal power entering the pipes [W]. 𝐾𝑝_𝑡𝑢𝑦𝑎𝑢𝑥 = 125 [W K -1 m-2] : Is the constant of proportionality. 𝐴sol: Is the ground surface of the greenhouse [m2]. 𝑇𝑎𝑖𝑟 [° C] : Is the parameter controlled and 𝑇𝑟𝑒𝑓 [° C] is the desired value of the controlled variable. The term in parentheses ‖ ‖0 250 is limited to a value between zero and 250 [W m-2]. This limitation is made using the "Saturation Simulink®" block, which indicates the maximum and minimum power, That the generator can supply per square meter. The desired temperature 𝑇𝑟𝑒𝑓 is 20 ° C during the day period and 18 ° C during the night period. 3.2 Modeling of cooling systems There are three common methods for cooling greenhouses: (1) natural ventilation (2) mechanical ventilation (3) mist cooling (misting). In our work mechanical ventilation is used [8]: The control system selected is described by: Q𝑜𝑢𝑣𝑒𝑟𝑡𝑢𝑟𝑒 = 𝐴sol ∗ 1 ∗ 10 −3 + 𝐴sol‖𝐾𝑝_𝑜𝑢𝑣𝑒𝑟𝑡𝑢𝑟𝑒(C_H2O𝑎𝑖𝑟 − C_H2O𝑟𝑒𝑓)‖0 1∗10−3 (3) Where : Q𝐻2𝑂_𝑏𝑟𝑜𝑢𝑖𝑙𝑙𝑎𝑟𝑑 : Is the airflow through the opening [W]. 𝐴sol [m 2] : Is the ground surface of the greenhouse [m2]. 𝐾𝑝_𝑏𝑟𝑜𝑢𝑖𝑙𝑙𝑎𝑟𝑑 = 1 [m s -1] : Is the minimum air flow. 𝐾𝑝_𝑜𝑢𝑣𝑒𝑟𝑡𝑢𝑟𝑒 = 0,5 [m 4 s-1 kg-1] : Is the constant of proportionality. C_H2O𝑎𝑖𝑟 [Kg m-3] : Is the concentration of water vapor in air. And C_H2O𝑟𝑒𝑓 , is the desired moisture. 4 Organization of the model Our model was developed using a form of organization according to the model proposed by (Jamisson M. Hill, 2006) [7]. The model of the plant used was set for Douglas fir planting. [7] The plants were started at 0.57 g dry weight and harvested at 1.67 g dry weight; A new growing season was recorded at each harvest. So after we got a complete list of equations that can show the relationships between quantities, it does not tell me how these equations need to be solved numerically on the computer. And even less, how they should be expressed and organized as part of the global model software. Mathematical equations must be translated into computer code, which, when compiled and executed, translates the raw input data into meaningful data. In our model, each block is defined by three sets of variable sets: inputs, state variables that describe the state of behavior and output that are directly dependent on that state. At each time step, the block may be called to execute the following commands [7]: 1. Initialization / reset of outputs and states. 2. Calculation of state derivatives. 320 Informatica 41 (2017) 317–331 D. Faouzi et al. 3. Integrate the state derivatives to calculate the next state. 4. Calculates outputs according to the current state. This methodology is robust and simple and can be applied to a wide range of processes, particularly those involving weighted parameters (mass / energy balance) or transfer functions, so it is very sensitive to crop models . The main impetus for using Simulink is that this methodology is built into the program structure, allowing the user to focus on the side of the model diagram. % GUESS.m % Core routine GUESS model % GUESS (Greenhouse Use of Energy Seedling Simulation) % GUESS is a dynamic lumped parameter process based model of a Douglas Fir % seedling production greenhouse. GUESS models the dynamics of % photosynthesis, and carbon allocation, climate control, and energy use. t1 = cputime; orgpath=path; try path(orgpath,genpath('Subfunctions')); guessinit; % User Defined Parameters guessread; % Load, and process weather data guessmodel; % Execute Simulink model guessoutput; % Display results t2 = cputime; t3 = t2-t1; catch err path(orgpath); rethrow(err); end path(orgpath); fprintf('Model took %4.2f seconds to execute\n', t3); 5 Modeling of the fuzzy controller The fuzzy logic control (FLC) is very robust, it is a flexible method that can be easily modified, and can use several inputs and outputs. It is much simpler than its predecessors (linear algebraic equations), and still very fast And less costly to implement. Then the controllers by fuzzy logic are very simple and easy to use. This method basically consists of three parts: an input, a processing part and an output part [2]: 1) The first part is an input: Indeed, it is represented in the membership functions. 2) The second part is a part of treatment, so-called rules of decisions. 3) The third and final part, is the exit step. The controller converts the results into specific values, which can be managed by another system. One of the first questions to ask when designing a Fuzzy Logic Controller (FLC) is: What are my inputs and outputs? Once this issue is resolved, the next item to deal with is the range of inputs and outputs. When we speak of fuzzy sets, this range is called universal space [4]. An output value controlled by the fuzzy logic theoretical (FLC) is developed using the MATLAB Simulink software. FLC is widely used when modeling the system implies that information is scarce and inaccurate, or when the system is described by a complex mathematical model. An example of this type of structure is the agricultural greenhouse and its variables such as the internal temperature. This state variable influences and activates the dynamic behavior of the greenhouse, it is non-linear. The internal temperature is one of the important and even main variables in the control and modeling of greenhouses. In addition, a FLC is efficient to deal with continuous functions using the membership function (MF) and the IF-THEN rules. In general, a FLC contains four parts: fuzzifier, rules of decisions. , Fuzzy inference engine and defuzzify. First, a set of input data is gathered and converted to a fuzzy set using fuzzy linguistic variables, fuzzy linguistic terms, and membership functions. This step is known as Fuzzification. Then, an inference is made on the basis of a set of rules. Finally, the resulting fuzzy output is matched to a net output using the MF (membership functions) in the defuzzification step. Mamdani is method of fuzzy inference. Is the method we used and applied in our work to optimize the management of the microclimate of our agricultural greenhouse model. This method has fuzzy rules of form (IF-THEN) that have been used to implement the modeling of the fuzzy controller (FLC). In many fuzzy applications, membership functions (MF) have been arbitrarily chosen as trapezoidal, triangular or Gaussian curves depending on the selected ranges. In our model, the sigmoid membership function is considered to define the input and triangular variables for the output variables (Figure 2). All membership functions are defined on the normalized domain [-1, 1] in the discourse universe. With eight linguistic values, as shown in Figure 1. This figure illustrates the fuzzy sets of membership functions that contain seven fuzzy sets. The linguistic values of the fuzzy sets used are: Very cold (TVCOLD), COLD (TCOLD), Uncooked (TCOOL), OK (TGOOD), Low warm (TSH), Warm (TH), Very hot (HST) Designed on the basis of expert knowledge and in specialized literature. We added to our model of the greenhouse an intelligent regulator using the fuzzy logic and we chose the Mamdani method with a single input, we started by first defining the input data and the outputs, and by the following has been attempted to link the membership functions in a logical manner in order to respond to the following steps. The characteristic variables of the system to be controlled and the instructions define the input variables of the fuzzy controller. The characteristic variables are in general the output Optimization, Modeling and Simulation of… Informatica 41 (2017) 317–331 321 variables and, where appropriate, other measures the dynamic evolution of the process. The output variables of the fuzzy controller are the commands to apply to the process. The knowledge base consists of a database and a rule base. The database includes: • Fuzzy sets associated with the input and output variables of the fuzzy controller, • Scaling factors (input) (normalization) and output (demoralization). Then the range of variations (the fuzzy sets) and the membership functions for the input and the output were defined, and each part of the membership function was called by a significant name (Figure 3). After defining the membership functions, the inference rules have been implemented in such a way as to achieve optimum control as desired, for example if the climate inside the greenhouse becomes lime the regulator will automatically Lowering the temperature by closing a heating system or opening a cooling system or by any other means and in order to keep the required instruction which will be translated by the following command [5]: 1. If (Ti is TVCOLD) then (FOG1FAN1 is OFF)(FOG2FAN2 is OFF)(FOG3FAN3 is OFF)(NV is OFF)(Heater1 is ON)(Heater2 is ON)(Heater3 is ON) (1) 2. If (Ti is TCOLD) then (FOG1FAN1 is OFF)(FOG2FAN2 is OFF)(FOG3FAN3 is OFF)(NV is OFF)(Heater1 is ON)(Heater2 is ON)(Heater3 is OFF) (1) 3. If (Ti is TCOOL) then (FOG1FAN1 is OFF)(FOG2FAN2 is OFF)(FOG3FAN3 is OFF)(NV is OFF)(Heater1 is ON)(Heater2 is OFF)(Heater3 is OFF) (1) Figure 1: Creating Input and Output. 322 Informatica 41 (2017) 317–331 D. Faouzi et al. 4. If (Ti is TGood) then (FOG1FAN1 is OFF)(FOG2FAN2 is OFF)(FOG3FAN3 is OFF)(NV is OFF)(Heater1 is OFF)(Heater2 is OFF)(Heater3 is OFF) (1) 5. If (Ti is TSH) then (FOG1FAN1 is OFF)(FOG2FAN2 is OFF)(FOG3FAN3 is OFF)(NV is ON)(Heater1 is OFF)(Heater2 is OFF)(Heater3 is OFF) (1) 6. If (Ti is TH) then (FOG1FAN1 is ON)(FOG2FAN2 is OFF)(FOG3FAN3 is OFF)(NV is OFF)(Heater1 is OFF)(Heater2 is OFF)(Heater3 is OFF) (1) 7. If (Ti is TVH) then (FOG1FAN1 is ON)(FOG2FAN2 is ON)(FOG3FAN3 is OFF)(NV is OFF)(Heater1 is OFF)(Heater2 is OFF)(Heater3 is OFF) (1) 8. If (Ti is TEH) then (FOG1FAN1 is ON)(FOG2FAN2 is ON)(FOG3FAN3 is ON)(NV is OFF)(Heater1 is OFF)(Heater2 is OFF)(Heater3 is OFF) (1) Figure 2: Membership function of the command. Figure 3. Membership functions for input and output variables. Optimization, Modeling and Simulation of… Informatica 41 (2017) 317–331 323 Ti : Indoor temperature. TVCOLD : Temperature very cold. TCOLD : Temperature cold. TCOOL : Temperature is cool. TSH : Temperature increases slowly. TH : Temperature is hot. TVH : Temperature is very hot. HE : super hot temperature. The explanation of the previous decision rules is as follows: 1) If the temperature (TVCOL) inside the greenhouse is very cold, then it is lower than the set temperature, the fuzzy controller sends a signal to automatically trigger all mechanical ventilation and ventilation systems and gives the order of " Open all heating systems". 2) If the temperature (TCOLD) inside the greenhouse is cold , then it is therefore somewhat below the set temperature then the fuzzy controller sends a signal to automatically trigger all mechanical cooling and ventilation systems and gives an order for " Open a single heating system". 3) If the temperature inside the greenhouse is cool therefore the controller gives the same previous order. 4) If the temperature (TSH) inside the greenhouse increases slowly, then the controller gives the order to stop all heating, cooling and mechanical ventilation systems and leave the operation of the ventilation natural. 5) If the temperature (TH) inside the greenhouse is hot, then it is slightly higher than the temperature of the set point, then the fuzzy controller sends a signal to automatically trigger all the cooling, heating and ventilation systems and gives Order to "open mechanical ventilation system" (forced). 6) If the temperature (HVT) inside the greenhouse is very hot, it is higher than the set point temperature, the fuzzy controller sends a signal to automatically trigger all heating systems and allow the operation of two mechanical ventilation systems. 7) If the temperature (TEH) inside the greenhouse is super hot, it is therefore superior to the set point temperature. Then the blurred controller sends a signal to automatically open all mechanical cooling and ventilation systems and stop " Operation of heating systems" and natural ventilation mechanical ventilation. We save the file (.fis) to load it into the workspace and retrieve it in the Simulink Fuzzy block under the same name of the saved file. The simulation of our system was done by MATLAB SIMULINK. The results of the MATLAB / SIMULINK software indicate the high capacity of the proposed technique to control the internal temperature of the greenhouse even in the event of a rapid change of atmospheric conditions. The modeling of the system Is defined in the form of this block diagram introduced in our Simulink shown in Figure (4 and 5). Its goal is to achieve the set temperature of 20 ° C required by the internal environment of our greenhouse. Indeed, by varying the ranges of inferences, the efficiency of the regulator has been increased around this set point. It would also be possible to modify the inference rules or the forms of the membership functions used. For the validation of our model we used the full windows version of MATLAB Simulink R2012b (8.0.0.783), 64bit (win64). The simulation was performed on a TOSHIBA laptop. The latter is equipped with a 700 GB hard drive, and 5 GB of RAM. Simulink parts of the model were performed in "Accelerator" mode which first generated a compact representation of C code in the diagram. Then compiled and executed. Simulink diagrams are obtained in the form of a sub-model integrated into blocks, thus decomposing the global model. Our model is validated independently. Simulink diagrams resulting from the implementation and validation of our greenhouse model and its systems (heating, ventilation, cooling and misting, etc.) are shown in the figures below. The informatics code (program) that gives the order to start the simulation for the figures below is as follows: % guessread % Didi Faouzi % 1-1-2015 -- 5-24-2016 % Opens, reads, processes, and interpolates (per minute basis) hourly % weather data from a text file and converts it into weather vectors for % use by the Simulink model. Also calculates vapor pressures, and % Weather data must be in tab, space, or comma delimited text format % And MUST include in the following columns in this order % date column % time column % Running time in days from first data point % Outdoor temperature F or C % Outdoor Relative Humidity % of VP Saturation % Dew point temperature % Wind Direction in degrees/radians E of N(azimuth) % Wind Speed in mph or m/s % Solar radiation in Langley s/hr or W/m2 % % start cool = column with running time in hrs, min or seconds % start row = column at end of header % NOTE:--------- % This M-File cannot be executed standalone, and must be called % from within the main GUESS module. To run GUESS, type GUESS in the % command window prompt, and press . 324 Informatica 41 (2017) 317–331 D. Faouzi et al. % ------------------------------------------------------------- Figure 4: Schema Simulink represents our Fuzzy Logic Controller. Optimization, Modeling and Simulation of… Informatica 41 (2017) 317–331 325 -- % last modified 4-30-06 %----------- % Read data %----------- %try % Look for errors tic % Start timer warning off fprintf('\n Weather Data File Processing\n') fprintf('Reading File......'); W = dim read(Settings. file. file path, Settings. file. delimiter, ... Settings. file. start row, Settings. file. start cool); switch Settings. sim. frequency case 'hourly' Hours = W(:,1); % Convert to hourly data set case '15min' Quarters = W(:,1); %case '5min' %case '2min' case '1min' Minutes = W(:,1); otherwise error('\n Invalid time step \n'); return end Date Raw = W(:,2); % Days elapsed since start of growing season Temp Raw = W(:,3); % in deg C or F Reel H Raw = W(:,4); % rel. Humidity % %Dew P Raw = W(:,5); % Dew point Temp C or F; eliminate dew point WindDirRaw1 = W(:,6); % Wind Direction in degrees from South, azimuth Wind Raw = W(:,7); % Wind Speed Figure 5. Simulink representation of the heating system model. Figure 6: Simulink Representation of the Ventilation and Cooling Systems Model. 326 Informatica 41 (2017) 317–331 D. Faouzi et al. Solar Raw = W(:,8); % Solar insulation in Langley's or watts/m^2 fprintf('DONE\n') % ---------------- % Unit Conversion % ---------------- % --------------- % Convert date into metric for ease of calculations % --------------- if units. temp == 'F' Temp_C = conv Fto C(Temp Raw); % Dew P_C = convFtoC(Dew P Raw); else if units. temp == 'C' Temp_C = Temp Raw; % Dew P_C = convFtoC(Dew P Raw); else error ('Invalid temperature units'); end switch units. wind case 'mph' Wind Raw = convmph2mps (Wind Raw); case 'mps' % do nothing otherwise error ('Invalid wind speed units'); end %Wind Raw = Power Law Wind Conversion switch units. solar case 'Wm2' % do nothing case 'ly' Solar Old = Solar Raw; Solar Raw = convLyhr2Wm2 (Solar Raw); case 'Btuf2h' Solar Raw = convBtuhrft2toWm2(Solar Raw); otherwise error('Invalid solar units'); end switch units.rel H case '%' Reel H Raw = Reel H Raw / 100; case '1'% do nothing otherwise error('Invalid humidity unit'); end switch units. wind dir case 'deg' Wind Dir Raw = WindDirRaw1 / 180*pi(); case 'read' %do nothing otherwise error('Invalid wind direction unit'); end %------------------------- % Check sampling rate %------------------------- switch Settings. sim. frequency case 'hourly' % 1hr. sampling rate Time Raw = Hours .*(60/Settings.sim.timestep); case '15min' % 15 min. sampling rate Time Raw = Quarters .*(15/Settings.sim.timestep); case '1min' % 1 min. sampling rate Time Raw = Min; end EO Time = Time Raw(length(Time Raw)); % PAR Conversion Light Raw = conv2PAR('sunlight', Solar Raw, 'W/m2'); fprintf('Vapor Pressure, Wet bulb Calculations ......'); % Calculate humidity measurements: vapor pressure or humidity ratios % Calculate Saturation Vapor Pressures Sat VP Raw = p sat(Temp_C); % Saturation Vapor Pressures % modify Sat VP to use Teten's formula (will run faster) % modify all to run with arrays; add *. and ./ VP Raw = Reel H Raw .* Sat VP Raw; % Vapor Pressures Hum Raw = hum ratio (location. pressure, VP Raw); % humidity ratio (mass H2O/mass air) Wet Bulb Raw = (wet bulb (Temp_C, Reel H Raw, location. pressure))'; Wet Bulb VP = p sat (Wet Bulb Raw); Wet Bulb Hum Raw = hum ratio (location. pressure, Wet Bulb VP); fprintf('DONE\n'); fprintf('Wind Pressure Calculations ......'); % Calculate Wind Incidence Angle and Natural Ventilation Pressure Coeff. IncidenceAngleRaw1 = Wind Dir Raw - Greenhouse. Azimuth; % Inlet 1 IncidenceAngleRaw2 = Wind Dir Raw + Greenhouse. Azimuth; % Inlet 2 % Coefficient of Pressures CpRaw2 = ones(length(IncidenceAngleRaw1),1); CpRaw1 = ones(length(IncidenceAngleRaw1),1); for X = 1:length(IncidenceAngleRaw1) CpRaw1(X) = calc Wind Press Coeff(IncidenceAngleRaw1(X)); CpRaw2(X) = calc Wind Press Coeff(IncidenceAngleRaw2(X)); end % Ventilation Rate Wind Factor Raw = abs(CpRaw1 - CpRaw2)./(sort(abs(CpRaw1 - CpRaw2))); U Nat V Raw = Ventilation. Natural. CD is charge .* Wind Factor Raw .* Wind Raw; % Ventilation Rate % ----------------------------------- % Calculate Wind Pressures in Pascals % Find Wind speed at eave height Wind Raw = WS Convert(Wind Raw, Settings. Climate. Wind. measured height, ... Ventilation. Natural. Height, Settings. Climate. Wind. exponent); % Wind Pressure Inlet 1 WindPressure1 = 0.5*Air D(Temp_C, location. pressure)*WindRaw.^2* CpRaw1; % Wind Pressure Inlet 2 WindPressure2 = 0.5*Air D(Temp_C, location. pressure)*WindRaw.^2* CpRaw2; Wind Pressure Raw = WindPressure1 - Optimization, Modeling and Simulation of… Informatica 41 (2017) 317–331 327 WindPressure2; %Flow driven by pressure diff. fprintf('DONE\n'); % fprintf('Solar Radiation Calculations ......'); % --- Solar Altitude & Clearness Index --- % Solar Time Hrs = Time Raw/(60/Settings.sim.timestep) + Settings. sim. time lag; Clock time = mod(Hrs, 24); Day Raw = 1+ Hrs ./ 24; DayRaw2 = floor (Clock time ./ 24); Hr Angle = Hour Angle Correct(Clock time, Day Raw,... location. long - location. std long); Declination = declination (Day Raw); % Solar Altitude Altitude = solar altitude (Declination, location.lat, Hr Angle); Altitude(Altitude < 0) = 0; % can use -6 deg for civil twilight Altitude = (pi/180)* Altitude; % convert to radians % Clearness Index ET Solar = sin(Altitude) * Properties. Solar Constant; % Calculate ET Radiation K Index(1:length(Solar Raw),1)= 0.8; %K Index = Solar Raw./ET Solar; % clearness index for i = 1:length(Time Raw) % Correct for div by/zero if Solar Raw(i) > ET Solar(i) % Can't have clearness index > 1 K Index(i,1) = 1; else if ET Solar(i) == 0 && i > 2 % Maintain previous value K Index(i,1) = K Index(i-1,1); % throughout the night else K Index(i,1) = Solar Raw(i)./ET Solar(i); %clearness index end end % Diffuse vs. Direct [Diffuse Raw Direct Raw] = Split Beam(Solar Raw, K Index); %Rad. splitting fract Diff Raw = f Diffuse(K Index); % f Direct = 1 - f Diffuse; fprintf('DONE\n'); %--------------------- % Long wave Sky Balance %--------------------- fprintf('Long wave Calculations ......'); e_sky = e Sky B(Temp Raw, VP Raw, K Index); T Sky Raw = e_sky.^(1/4) .* Temp Raw; fprintf('DONE\n'); fprintf('Interpolating ......'); %------------------ % Interpolate to 1 minute time step for simulation %------------------ Settings. sim. Max time = EO Time; Time = ((1:EOTime).'); Date = interp1(Time Raw, Date Raw, Time, 'linear'); Temp = interp1(Time Raw, Temp_C, Time, method); Reel H = interp1(Time Raw, Reel H Raw, Time, method); % Dew P = interp1(Time Raw, Dew P_C, Time, method); Wind = interp1(Time Raw, Wind Raw, Time, method); Solar = interp1(Time Raw, Solar Raw, Time, method); U Nat V = interp1(Time Raw, U Nat V Raw, Time, method); Wind Fact = interp1(Time Raw, Wind Factor Raw, Time, method); Diffuse = interp1(Time Raw, Diffuse Raw, Time, methods); fract Diffuse = Diffuse ./Solar; fract Diffuse(~is finit(fract Diffuse))= 0; %Direct = interp1(Time Raw, Direct Raw, Time, method); Sat VP = interp1(Time Raw, Sat V Raw, Time, method); Humidity = interp1(Time Raw, Hum Raw, Time, method); Wet bulbs = interp1(Time Raw, Wet Bulb Raw, Time, method); WB Humidity = interp1(Time Raw, Wet Bulb Hum Raw, Time, method); VP = interp1(Time Raw, VP Raw, Time, method); Light = interp1(Time Raw, Light Raw, Time, method); % Light in PAR Angle = interp1(Time Raw, Altitude, Time, method); T Sky = interp1(Time Raw, T Sky Raw, Time, method); %--- Wind and Natural Ventilation --- Wind Dir = interp1(Time Raw, Wind Dir Raw, Time, method); Wind Pressure = interp1(Time Raw, Wind Pressure Raw, Time, method); fprintf('DONE\n'); fprintf('Generating Lookup Tables ......\n'); fprintf('Saturation Humidity ......'); %--- Saturation Vapor Look up Table --- P Sat Look Up Table. T = 0:0.5:55; P Sat Look Up Table. P = p sat(P Sat Look Up Table. T); %--- dP Sat Look Up Table --- dP Sat Look Up Table. T = 0:0.5:55; dP Sat Look Up Table. P = dp sat(dP Sat Look Up Table. T); %--- Humidity at Wet Bulb Table --- equiv WB Look Up Table. T = linspace(0,50,100); equiv WB Look Up Table .H = linspace(0,1,100); [T2 H] = mesh grid(equiv WB Look Up Table. T, equiv WB Look Up Table .H); equiv WB Look Up Table. Values = equiv WB humidity(T2, H/100, location. pressure); %--- Plant Stuff --- Init Plant; 328 Informatica 41 (2017) 317–331 D. Faouzi et al. fprintf('DONE\n'); fprintf('Packing and Cleanup ......'); %--------------- % Create Weather structure in format wanted by Simulink % and organize into structure for ease of packaging % Simulink Format % Signal = [time step data]; use column vectors for both. % ---------------- Weather. Temp = [Time Temp]; Weather. Reel H = [Time Reel H]; Weather. Solar = [Time Solar]; Weather. Wind = [Time Wind]; Weather. Wind Fact = [Time Wind Fact]; Weather. U Nat V = [Time U Nat V]; Weather. Sat VP = [Time Sat VP]; Weather. Humidity = [Time Humidity]; Weather. Wet Bulb = [Time Wet bulbs]; Weather. VP = [Time VP]; Weather. Wind Dir = [Time Wind Dir]; Weather. WB Humidity = [Time WB Humidity]; Weather. Wind P = [Time Wind Pressure]; Weather. Angle = [Time Angle]; Weather. fract Diffuse = [Time fract Diffuse]; Weather. T Sky = [Time T Sky]; %Weather. Direct = [Time Direct]; %---------------- % Create timer object to override Simulink built-in clock for output % graphing and scoping % ------------------ %-------------- % Cleanup % Clear unneeded data %-------------- clear W Date Raw Reel H Raw Dew P Raw T_C Cp Raw VP Light Solar Old Temp Raw clear Hours Quarters Minutes Light Reel H Sat VP Humidity Wet bulbs Wind clear Wind Humidity Dew P Dew P_C Incidence Angle Hum Raw Cp Wet bulb clear Wind Dir WindDirRaw1 VP Raw Sat VP Raw VP Solar Old Wind Pressure Solar Raw clear Incidence Angle Raw Wet Bulb Raw Temp Wet Bulb Hum Raw WB Humidity Angle clear Diffuse Raw Direct Raw Direct CpRaw1 CpRaw2 Day Raw Altitude clear DayRaw2 WB Humidity Time Raw Temp_C Time Fill K Index pack; fprintf('DONE\n\n'); disp('Ready for simulation!'); to warning on %catch % disp('Corrupt/Invalid Weather data file OR'); % disp('guessread is not a standalone m-file, run guessinit first'); %end. % Plant Growth Diagram figure(5) % Height Graph, subplot 1 subplot(2,2,1) plot(Guess Output. date, Guess Output. Plant. Height); x label('Day'); y label('Height (cm)'); subplot(2,2,2) plot(Guess Output. date, Guess Output .Plant. Diam); x label('Day'); y label('Stem Diameter (mm)'); subplot(2,2,3) plot(Guess Output. date, Guess Output. Plant. Biomass); x label('Day'); y label('Total Dry Biomass (g)'); subplot(2,2,4) plot(Guess Output. date, Guess Output. Plant. Crops); x label('Day'); y label('Crops Harvested(#)'); h = top title('Plant Growth Characteristics'); set(h, 'Font Size', 14); % Indoor Temperature Distribution figure plot(Guess Output. date, Guess Output. temp) title('Temperatures'); x label('Day'); y label(axis); legend('outdoor',' indoor'); figure hold on hits (Guess Output. temp(:,2)); title('Indoor Temperature Distribution'); x label(axis); y label('freq.'); mean temp = mean(Guess Output. temp(:,2)); disp(sprint('Mean Indoor Temperature: %3.2f', mean temp)); s tdev = std(Guess Output. temp(:,2)); disp(sprint('Standard Deviation Indoor Temperature: %3.2f', stdev)); % Costs Diagram figure(2) plot(GuessOutput.date,[GuessOutput.Costs.total, Guess Output.Costs.gas,... GuessOutput.Costs.electricity, GuessOutput.Costs.water]) legend('Total', 'Natural Gas', 'Electricity', 'Water', 'Orientation', ... 'Horizontal', 'Location', 'Best') h = title('Energy Costs'); x label('Day') y label('Cost ($)') set(h, 'Font Size', 14) % Quantities Diagram figure(4) plot(GuessOutput.date,[GuessOutput.Quants.gas*Fue l Converter,... GuessOutput.Quants.electricity, GuessOutput.Quants.water]) legend('Natural Gas(ft^3)', 'Electricity(kWh)', 'Water(gal)', 'Orientation', ... 'Horizontal', 'Location', 'Best') x label('Day') y label('Energy Quantity') Optimization, Modeling and Simulation of… Informatica 41 (2017) 317–331 329 h = title('Energy Quantities'); set(h, 'Font Size', 14). 6 Simulation results 6.1 Discussions on figures The simulation results demonstrate the capabilities and performance of the intelligent controller, as well as the robustness of the fuzzy control. They illustrate in FIG (7) the stability of the variation of internal temperatures during the day and at night ranging from 15 ° C. to 25 ° C. and a relative humidity ranging from 50 % To 80% in the greenhouses of the two regions of Dar El Beida (wetland) and Biskra (arid zone). The temperature gradient due to the greenhouse effect recorded between the interior and the external environment was positive and varied from + 2 ° C to + 14 ° C. It should be noted that the external moisture content of the Dar El Beida zone, varying from 50% to 95%, was higher than that of Biskra, which varies from 35% to 80%. Temperature disturbances were recorded during the fifth season from Figure 7. The evolution of the indoor and outdoor temperature in the form of scoop. Figure 8. Evolution of indoor and outdoor moisture in the form of scoop. 330 Informatica 41 (2017) 317–331 D. Faouzi et al. mid-autumn to early winter, between 20 November and 20 January of the year. This was reflected in peaks in water temperatures and saturations due mainly to heat losses and signal noise caused by repeated cyclic activation and deactivation of heating and ventilation systems and equipment. On the whole, the application of the fuzzy method presents rather satisfactory results. The need to improve the thermal insulation of the greenhouse is essential to reduce the heat losses that generally occur during this cold season in the greenhouse. Improving the greenhouse effect means stabilizing the microclimate and reducing the number of activations and deactivations of the accompanying systems that partly pose the problem of climate management. In the figure (8), the moisture content within the greenhouse in the two wetlands and arid areas generally remains close to the optimum except in summer, where the rate of Humidity sometimes falls below the minimum threshold due to the ventilation necessary to ventilate, compensate and regulate the internal temperature. 7 Conclusion The research work was initiated by a rich and interesting bibliographical study, which allowed us to discover this area of current affairs. A description of the types and models of agricultural greenhouses has been developed. Thermo hydric interactions, which occur within the greenhouse have been approached. The biophysical and physiological state of the plants through photosynthesis, respiration and evapotranspiration were exposed while taking into account their influences on the immediate environment and the mode of air conditioning. The models of regulation and climatic control have been approached from the use of conventional equipment to the use of artificial intelligence and / or fuzzy logic. Knowledge models and computer techniques have been established with a well-defined approach and hierarchy for optimal climate management of greenhouse systems, while naturally adopting the Mamdani method. The aim is to develop a robust and robust air- conditioning control technology to deal with disturbances that may occur in the external and internal environments of the greenhouse system Our assignments are: 1) To define the functioning of the complex system of the greenhouse with its various components (culture-immediate environment) using control models that optimally regulate the climate inside the greenhouse and reproduce the essential Of the properties, mechanisms and interactions between culture and its environment 2) To solve the problem of follow-up by the modeling, design and development of an intelligent controller able to regulate the system by following a desired reference trajectory and a hierarchy of control and regulation of the couplings between The different inputs and / or outputs In this work we develop a climatic control by the Mamdani method based on multi-variable models in line for an adaptive neural model structure. The influence of random perturbations on system performance and optimization must be supported. We have conceptualized, modeled, configured and developed an intelligent controller by fuzzy logic based on the Mamdani method. The simulation of the optimal climate management of the indoor environment of the agricultural greenhouse was carried out for two different regions, one wet, and this is Dar El Beida in ALGER; The other arid and concerns the region of BISKRA. The simulation results highlight the capabilities and performance of the intelligent controller, as well as the robustness of the fuzzy control. They also illustrate the intelligibility of this control for optimal management during the four production seasons. We have also noted deficiencies that have arisen during the operation of the system during the fifth season, from mid-autumn to early winter (from 20 November to 20 January) .This is mainly due to heat losses and Signaling caused by repeated cyclic activation and deactivation of air conditioning equipment (heating and ventilation). This is because these state variables are highly correlated and influenced by the external environment, Solar radiation in the visible and infrared and the physiological response of the culture, a reaction quite natural and implicit. The use of conventional controllers, the configuration of which no longer meets our expectations, nor the optimum climate regulation, but rather to some extent to the artificial intelligence technique, easily handled, to the serrists Characterized by its reliability and robustness in optimal climate management The advantages of fuzzy control must be listed and treated without ignoring the conventional approaches of the classical automatic. All this involves the search for a compromise between complexity, human experience, systems mastery, model realism, configuration mode, and the robustness of the control method for predictive performance. It should be noted that building robust models and practical, robust control methods are not limited by computer and / or digital tools, but rather by our knowledge and control of the dynamics of the ecosystem and its impact on the environment. Optimal climatic management of the greenhouse system. This implies that it is rather limited by the nature and quality of information on the ecosystem and its environment and by the faithful reproduction of this information for decision-making. We remain optimistic in the near future, as regards the use of artificial intelligence technique and its fuzzy logic branch, which is indicated by: 1) Optimum climate control and regulation. 2) The operating efficiency of the energy reserve due to the greenhouse effect. Optimization, Modeling and Simulation of… Informatica 41 (2017) 317–331 331 3) Optimal management of the energy input necessary for the operation of the accompanying systems and equipment. 4) Better productivity of sheltered crops. 5) A significant decrease in human intervention. In the same way, it is necessary to point out the insufficiencies which may arise in the application of the fuzzy logic method and which are due at the moment to a misunderstanding or insufficient information of the ecosystems and their environments, Signal noise problems, the robustness of the fuzzy control, the peaks of the dominant variables; But for the moment all these interference problems and deficiencies can be solved by a realistic approach of the system. As for the prospects, they are numerous. The application of Artificial Intelligence was reserved mainly in the fields of industry, robotics and especially in the Agri-food industry, whereas it can intervene in the management of several systems and processes not or can be tackled up to this day. We propose in our field to promote these techniques to multiply the harvest seasons and to make the exploitation of our agricultural land profitable. 8 References [1] Didi Faouzi, N. Bibi Triki and A. Chermitti, 2016. Optimizing the greenhouse micro-climate management by the introduction of artificial intelligence using fuzzy logic. Int. J. Computer Eng. Technology, 7: 78-92 , Volume 7, Issue 3, May-June 2016, pp. 78–92, Article ID: IJCET_07_03_007. [2] Didi Faouzi, N. Bibi-Triki, B. Draoui, A. Abène, 2016 , Modeling, Simulation and Optimization of- agricultural greenhouse microclimate by the application of-artificial intelligence and/or fuzzy logic, International journal of scientific & engineering research, volume 7, issue 8, august- 2016 issn 2229-5518. [3] Didi Faouzi, N. Bibi-Triki, B. Draoui, A. Abène, 2016 Comparison of modeling and simulation results management micro climate of the greenhouse by fuzzy logic between a wetland and arid region, International Journal of Multidisciplinary Research and Modern Education (IJMRME) ISSN (Online): 2454 - 6119, Volume II, Issue II, 2016 . [4] Didi Faouzi, N. Bibi-Triki, B. Draoui, A. Abène, 2016, Modeling and Simulation of Fuzzy Logic Controller for the purpose of Optimizing the Management Micro Climate of the Agricultural Greenhouse, MAYFEB Journal of Agricultural Science Vol 2 (2016). [5] Didi Faouzi , N. Bibi-Triki , B. Draoui , A. Abène, 2017, Greenhouse Environmental Control Using Optimized, Modeled and Simulated Fuzzy Logic Controller Technique in MATLAB SIMULINK, Computer Technology and Application 7 (2016) 273-286, doi: 10.17265/1934-7332/2016.06.002. [6] Didi Faouzi, N. Bibi-Triki, B. Draoui, A. Abène. Dated 10th March 2017, The Optimal Management of the Micro Climate of the Agricultural Greenhouse through the Modeling of a Fuzzy Logic Controller, International Knowledge Press, Journal of Global Agriculture and Ecology (JOGAE), 7(1): 1-15, 2017, ISSN: 2454-4205, Ref. No. IKP/JOGAE/17/0102. [7] Jamisson M.Hill, dynamic modeling of tree growth and energy use in a nursery greenhouse using MTLAB and Simulink, Cornell University, 7/31/2006. [8] Marco Binotto (May 2014), "Greenhouse climate model an aid to estimate the influence of supplemental lighting on greenhouse climate", School of Science and Engineering at Reykjavík University. [9] Babuska, R., & Mamdani, E. H. (2008). Fuzzy Control. http://www.scholarpedia.org/article/Fuzzy_contr ol. [10] [10] Breemen, A. v., & Vries, T. d. (2000). An Agent-Based Framework for Designing Multi- Controller Systems. Paper presented at the Proceedings of the Fifth International Conference on The Practical Applications of Intelligent Agents and Multi-Agent Technology, Manchester, U.K. [11] [11] Tan, V., Yoo, D.-S., & Yi, M.-J. (2008a). A Multiagent-System Framework for Hierarchical Control and Monitoring of Complex Process Control Systems. Paper presented at the Proceedings of the 11th Pacific Rim International Conference on Multi-Agents: Intelligent Agents and Multi-Agent Systems, Hanoi, Vietnam. [12] [12] Choi, J., Oh, S., & Horowitz, R. (2009). Distributed learning and cooperative control for multi-agent systems. Automatica, 45(12), 2802- 2814. doi: 10.1016/j.automatica.2009.09.025. [13] [13] McArthur, S. D. J., Davidson, E. M., Catterson, V. M., Dimeas, A. L., Hatziargyriou, N. D., Ponci, F., & Funabashi, T. (2007). Multi- Agent Systems for Power Engineering Applications-Part I: Concepts, Approaches, and Technical Challenges. 22, 1743- 1752.doi: 10.1109/tpwrs.2007.908471. [14] [14] Kelly, I. D., & Keating, D. A. (1998). Faster learning of control parameters through sharing experiences of autonomous mobile robots. International Journal of Systems Science 29(7), 783-793.