On the controlling of temperature : A proposal for a real-time controller in

Environmental conditions in broiler houses, specifically temperature, are key factors that should be controlled to ensure appropriate environment for broiler rearing. In countries with tropical/subtropical climate, like Brazil, high temperatures produce heat stress to animals, affecting the production process. This research proposes a real-time model to control temperature inside broiler houses. The controller is a self-correcting model that makes real-time decisions on the ventilation system operation (exhaust fans) together with temperature prediction at the facility. The model involves partial differential equations (PDE) whose parameters are updated according to data registered in real-time. Some experiments were carried out at a pilot farm in the municipality of Jundiaí, São Paulo State, Brazil, for different periods during winter and summer. The results based on simulations in comparison with the current automatic ventilation system show that the model is consistent to keep temperature under control for an efficient production. The model achieved a bias of 0.6 °C on average in comparison with the ideal temperature, whereas the automatic controller measured a bias of 3.3 °C, respectively. Future lines suggest that this approach could be useful in many other situations that involve environmental control for livestock production.


Introduction
Poultry production provides animal protein to many people worldwide.Chickens adapt to most areas, are relatively inexpensive and have a high productivity rate.Most poultry production uses intensive farming techniques that involve sophisticated decisions (Reboiro-Jato et al., 2011).However, in regions with tropical/subtropical climate, like Brazil, broiler rearing is commonly affected by high temperature values, affecting the production by causing heat stress and high mortality rates (Renaudeau et al., 2012).In addition, chickens are housed in facilities where environmental conditions are monitored and controlled by automatic systems to achieve ideal temperature conditions to maximize production.In particular, depending on the broiler age/breed, well-established standards indicate that ideal temperatures that should be kept inside the houses (Cobb-Vantress, 2012;Yahav et al., 2004).Temperatures out of standards affect the thermal comfort of the animals, which could be lead to less weight gain, feed efficiency and high mortality rates (Donkoh, 1989;Razuki et al., 2011).Nowadays, automatic systems are crucial to ensure effective stability to microclimate conditions in the facilities (Bustamante et al., 2013).However, in Brazil, many farmers still produce without sophisticated controllers and perform their activities by controlling the ventilation system with basic controllers or even manually.
Therefore, this research proposes a model to support temperature control by assisting the ventilation system with decision-making in real-time and tempera-ture prediction at the facility.Most automatic controllers are reactive and act according to current data with preestablished rules, without tools for forecasting or selflearning.This study describes a complete framework to deal with the problem that combines applied mathematics, self-correcting and real-time response.The paper starts presenting materials and methods.Then, the pilot farm and experiments are presente d with the results and discussion.Finally, additional considerations and future works are listed.

Introducing the model
Temperature in a broiler house at time t + Δt is a function of external temperature, internal temperature at time t, controls of heating, ventilation or cooling equipment, as well as a number of unknown parameters that should be fitted in the best possible way to replicate the real behavior of the system.
Decisions about the controls at instant t 0 (initial time) should be taken according to a prediction of the system state along a reasonable period [t 0 , t f ], that is, from initial time t 0 to final time t f .This "reasonable" period t f -t 0 minutes (typically, 1 h) with a number of intervals n (typically, n = 10, that is, 6 min each) is set by assuming that this temporal granularity could fit the real-time approach of the model considering feasibility, response to support the ventilation system and the intrinsic dynamics of the thermal conditions inside the broiler houses, as suggested by experts consulted during the research.The prediction of the external temperature in [t 0 , t f ] may be obtained from meteorological forecasting, whereas internal temperature during this period and for different possible controls needs a mathematical model.

Research
Assuming that such a mathematical model is available, the controls should be chosen to optimize the temperature throughout the period [t 0 , t f ].This means that the model that predicts the internal temperature should be run many times to have the closest predicted temperatures in relation to the ideal ones.
The essence of the mathematical prediction model is to foresee the behavior of the environment at t+Δt for all t in [t 0 , t f ] by using the system state at instant t.This problem naturally leads to models that are based on partial differential equations (PDE).Strictly speaking, the natural model should involve PDE of a complex Fluid Mechanics problem in three spatial dimensions.However, this model should be run many times to check different control strategies; therefore, standard Computational Fluid Dynamics (CFD) procedures are not affordable since they could not solve the whole problem in real time, as required by the application (Anderson, 1995;Fletcher and Fletcher, 1988;Rojano et al., 2015).Some radical simplifications of the problem are necessary to obtain a reasonable and practical prediction of the model.This research presented simplifications for a consistent control model for the improvement of environment conditions of temperature control for poultry production.
Fluid mechanics models rely on very complex representation of 3D (or, perhaps, 2D) phenomena to reproduce real behavior as well as possible.However, the necessity to predict temperature in real time inhibits the possibility of using such models due to time response and computational costs.Therefore, our proposal focused on developing a model that could be solved under real-time conditions by allowing self-correction of parameters and reflecting the physical characteristics of the phenomenon.The decision for the model approximation degree to reality is crucial and depends on practical goals of the modeling process.Thus, our objective is not the accurate approximation of the model to the phenomenon, but its capacity to make satisfactory decisions from a practical viewpoint.

Model
For a better understanding of the model, Table 1 summarizes the set of symbols, parameters and acronyms used in this proposal.
Consider a broiler house with a longitudinal wall (called here as "segment") [0, L] ⊂  where L represents the facility length and a is the wall thickness.Two segments, [-a, 0] and [L, L + a] represent the left-wall and right-wall, respectively.The diffusion coefficient in the walls is called σ w and the diffusion coefficient in the broiler house is called σ a .In addition, the control devices increase or decrease internal temperature u degrees per time unit, where u = u(x, t) is a function that depends on control decisions.This leads to the following diffusion problem: Step 5 -Implement the control, save for learning and stop, proceed implementing the control d i1 and save T(x; After d units of real time, also save the real temperature inside the broiler house.Stop.A flowchart of the conceptual algorithm is shown in Figure 1.
Note that the algorithm decides the best sequence of controls along the interval of real time [t 0 , t f ], but it only imposes the implementation of the control computed for the first interval [t 0 ; t 0 + d].On one hand, considering the whole interval [t 0 , t f ] to make decision instead of using merely [t 0 , t 0 + d] prevents of making greedy decisions based only on the initial state at the facility, which could lead to overcooling or overheating.On the other hand, only the control decided for [t 0 ; t 0 + d] deserves to be implemented in practice, as new data are coming permanently to the system that allows repeating the simulations with better knowledge of the real environment.
After stopping the algorithm, the control d i1 is implemented and "we wait" d units of real time before updating t 0 and t f for running the algorithm again.This means that d is the number of time units in which the broiler house is subject to the control d i1 before a new control optimization.

Optimization and learning
Optimization appears twice in the context of the algorithm implementation.The optimal choice of the controls d i1 , . . .d in that maximizes the score comes from an optimization procedure whose characteristics depend on the type of control devices available in the broiler (3) T (-a, t) = T(L + a, t) given for all t ≥ 0 (5) In other words, Equations ( 1) to ( 6) represent a diffusion problem (Welty et al., 2008) in the segment [-a, L + a], where the diffusion coefficients are σ w and σ a in different regions.A boundary condition represents the external temperature and an initial condition that represents the initial temperature of the broiler house.Moreover, the temperature T(x, t) at the facility decreases if control u(x, t) is greater than zero, and increases otherwise.
The control function depends on the control devices.These control devices have a finite number of possible states d 0 , d 1 , ... , d N .For example, d j may indicate that the number of connected exhaust fans is j, by assuming that exhaust fans are the only control devices in the broiler house under analysis.A function u dj (x, t) is associated to each possible control state d j : Therefore, in the absence of connected exhaust fans, internal temperature tends to increase a degrees per time unit, but the activation of each fan decreases the temperature b degrees per time unit.
The following conceptual algorithm describes how decisions are made.The algorithm runs on a continuous basis during the life of the broiler house (whole process of broiler rearing).This algorithm is "conceptual" because, for the sake of simplicity, details concerning discretization and location of sensors are omitted.Inputs associated to the algorithm are: T ideal , temperature that depends on the age of chickens and type of the broiler house.The wellestablished value seeks to achieve thermal comfort of the animals to maximize their biological response and, therefore, weight gain.Moreover, it is assumed that L, a, σ w , σ a and the functions u j are given for all j = 0, 1, ..., N. To fix date, time is measured in minutes and execution of the algorithm starts when real "clock time" is t 0 .A simulation time is established of t f -t 0 minutes (typically, one hour) and a number of intervals for simulation n (typically, n = 10).Thus, d is defined as follows:

Conceptual algorithm
Step 1 -Establish initial and boundary conditions: Using ing Algorithm modifies the model parameters σ w , σ a and the dependence of u with respect to d i , for the predicted temperature at t 0 + d coincides as much as possible with the real one obtained by the sensors.Moreover, it is not admissible abrupt modifications of the previous used parameters, which, especially after some hours of execution in the real environment, have already been the object of adjustments.For this reason, this Learning Algorithm consists of trying local random variations (10 % at most) around the already used parameters.

Calibration
Calibration is an optional procedure that can be executed at any time during the algorithm operation, assuming that data on external and internal temperatures are registered during a comparative large period (24 h) together with the controls that were implemented along that period.In the calibration procedure, one tries to find the algorithmic parameters that produce the best fit of the temperatures computed by the Algorithm to the real temperatures collected so far.

Computer requirements
The installation of the system requires a laptop computer (3.5 GHz Intel Core i7 processor and 16GB 1600 MHz DDR3 RAM memory, running OS X Yosemite -version 10.10.4) to perform calculations.Sensors are required to provide the temperature measurements in the broiler house.The model was programmed in Fortran 90.Codes were compiled by the GFortran, FORTRAN compiler of GCC (version 4.9.2) with O3 optimization directive enabled.Parameters a and b were initialized taking a = 0.02 and b = 0.01 and are updated throughout the learning process to fit better models to new data.The other main algorithmic parameters are σ a , the diffusion coefficient in the broiler house and σ w , the diffusion coefficient in the wall.In this case, they were initialized to σ a = 1 and σ w = 0.5, but they are continuously updated according to the learning process.

The pilot farm
Experiments were carried out in one pilot poultry farm, in the municipality of Jundiaí, São Paulo State, Brazil (Latitude 23º11'11" S, Longitude 46º53'03" W).The broiler house is approximately 750 m above sea level and according to the international system of Köppen, the predominant climate in this region is Cwa (hot climate with a dry winter), with a mean air temperature of 22 °C in the hot season, and 15 °C in the cold season (registered by a local weather station managed by the Brazilian Institute of Meteorology).
The facility is the type Blue House (BH): the ventilation system with negative pressure with an automatic controller FANCONTROL CC3, cooling pad system, and roof made of fiber cement, automatic feeding and drinking lines.Its dimensions are: length, 150.0 m; width, 15.0 m; sidewall height 2.5 m; and flock density average of 12 birds m −2 .

Experiments
Controller simulations were performed on the pilot farm by comparing the evolution of the temperature measured by the model and the temperature registered by the automatic system when a rearing process was present.These experiments refer to different periods for different seasons of the year.Three experiments were designed and implemented.
Experiments were carried out by choosing different values of d and t f − t 0 .This means that the algorithm chooses the present control, which operates the following d minutes aiming to maximize the score in the following 10d min.

Experiment 1
Two typical winter days: maximum external temperature was 32 °C around 14h00 and minimum 13 °C around 06h00.The initial average temperature at the facility was 22.2 °C.The ideal temperature according to the age of the birds (31-32 d old) is 22 °C (Cobb-Vantress, 2012).Results of simulation of the controller versus temperature registered by the sensors of the automatic controller are reported in Figure 2.
During the night, when the external temperature is lower than 22 °C, both algorithms keep similar internal temperatures.In this situation, exhaust fans are typically off, then, the algorithm is virtually inactive.However, during daytime, when temperatures rise, the proposed controller shows a better performance by keeping the internal temperature always below 22.4 °C, while the automatic controller reaches 24.5 °C.Considering these temperature peaks and comparing with the ideal temperature, the maximum discrepancy (bias) of the proposed model was 0.4 °C and for the automatic controller was 2.5 °C, respectively.Experiment 2 Two typical summer days: the maximal external temperature was 37.8 °C at 13h30 and the minimal was 24.0 °C between 00h00 and 06h00.The initial average temperature in the broiler house measured at 15h00 was 22.0 °C.T ideal was established at 22 °C as in experiment 1. Results are represented in Figure 3.
In this experiment, the difference between the two algorithms is clearer and more consistent.Even during the night, due to higher temperature than in the previous experiment, our algorithm shows a much better performance by keeping the internal temperature of the broiler house around 22 °C.During the day, our algorithm always keeps the internal temperature below 22.4 °C, but the standard algorithm (automatic controller) allowed the internal temperature to reach 26.0 °C.Here, the maximum discrepancy of the proposed model was again 0.4 °C and 4 °C for the automatic controller.
The main reason for these different behaviors is that our model predicts the internal temperature in a reasonably accurate way and made decisions according to predictions, whereas the standard control takes decisions only according to current measurements.In addition, these measurements could be affected for sensor problems, such as a bad calibration, noise or signal transmissions inside the automatic controller.

Experiment 3
Long-term experiment -a simulation for 24 d during winter season (final stage of the rearing process from 22 to 46 d old): the maximal external temperature was 35.6 °C and the minimal was 12.2 ° C. The initial average temperature inside the facility was 22.5 °C at 15h00.Here, the average of the T ideal was set at 21 ° C. Results are presented in Figure 4.
Once again, the results show the advantages of this proposal compared to the standard control mechanism.Consistently, our algorithm keeps the temperature closer to ideal during daytime, while the standard con-trol mechanism, especially on hotter days, allows internal temperature to reach 25.0 °C or even more.The discrepancy in comparison with the average of T ideal was approximately 1 °C for the model and 3.5 °C for the automatic controller, respectively.
If an average is calculated from the three experiments, the proposed model obtained a discrepancy in comparison with T ideal of approximately 0.6 °C and the automatic controller registered a mean value of 3.3 °C, respectively.
Finally, in this research, a real-time controller to keep and control adequate temperatures values in broiler houses was proposed.The system uses the PDE model to predict temperature inside the broiler house.The model is "semi-physical" on the sense that preserves some physical characteristics of the system, but it uses strong simplifications.Simplifications are used to allow computational implementation to be executed in real time.The optimization procedures involved in the model are fast enough to be compatible with the system operation and that the control system reacts in an adequate way to typical variations of temperature, keeping the internal temperature at acceptable levels.Its feasibility to support ventilation systems seems reasonable.Some empirical experiments have been designed to compare the model versus other automatic controllers on different farms.The proposed controller aims to provide maximum simplification of the physical phenomenon compatible with good decisions.Other controllers that could be based on linear or even nonlinear regression models may be excessively far from physical reality, whereas controllers based on full fluid mechanics are impractical for real-time predictions, considering the cost of computer devices and response time.This proposal is fully portable and may be coupled to complex engineering of different sensor architectures.Moreover, the system is adaptable to different dimensions of broiler houses due to its learning process for fitting parameters.Therefore, future lines are focused on a complete evaluation of the system.These lines refer to more testing activities in the field.Although the sensitivity and stability analysis of the proposed controller is beyond the scope of this work, a theoretical analysis will be addressed in a mathematical-oriented future work, due to the importance of the topic.From the practical viewpoint, in the range of parameters that corresponds to broiler houses, stability and sensitivity seemed to be quite satisfactory.
The methodological approach used in this work can be applied in many real problems, involving complex physical phenomena, mainly in problems related to environmental control for livestock production that requires judicious simplifications for reliable modeling.Many human decisions require real-time optimization procedures and self-correcting strategies increase accuracy and help as supporting tools in the decision-making process.

Figure 2 −
Figure 2 − Evolution of the temperatures for experiment 1 -Two typical winter days.

Figure 3 −
Figure 3 − Evolution of the temperatures for experiment 2 -Two typical summer days.

Figure 4 −
Figure 4 − Evolution of the temperatures for experiment 3 -A simulation for 24 d during winter season.

Table 1 −
List of symbols, parameters and acronyms of the proposed controller., interpolations and weather forecasting, establish the initial conditions for temperature at the facility and walls, as well as the boundary conditions that concern the external temperature from time t 0 to t f ,Step 2 -Trial controls: Choose "trial controls" d i1 , ..., d in , where d ik ∈ {d 1 , ... , d N } for all k = 1, ..., n.Solve the PDE: Solve the problem (Equations 1 to 6) from t = t 0 to t = t f , considering that the source function u(x, t) is determined by the choice of d i1 ,..., d in in Step 2. Namely, in the solution process of Equations 1-6, assume that for all k = 1,..., n, if t ∈ [t 0 + (k-1)d, t 0 + kd] the function u(x, t) is the one that corresponds to the control state d ik .
b Decrease of internal temperature per activation of each fan °C per unit time n Number of intervals for simulation d Simulation time min PDE Partial Differential Equations CFD Computational Fluid Dynamics Sci.Agric.v.75, n.6, p.445-451, November/December 2018 appropriately located sensorsStep 4 -Determine the score of the sequence of controls {d i1 ,..., d in }: Considering the values of the predicted temperatures T(x, t 0 + kd) for x ∈ [0, L] and k = 1,..., n, computed in Step 3, compute a score a score for the sequence of controls decided in Step 2. If this score is not satisfactory yet, go to Step 2 to simulate the behavior of the system under new controls, or else, proceed to Step 5.