**6.2. How the MPC controller works**

The control logics implemented in the SEAM4US simulator is based on a simple particle filtering mechanism (Fig. 12). The controller randomly generates a number of different control options that are sent to the predictor. The predictor updates the model with the control parameters and by means of Bayesian inference calculates the environment and energy consumption parameters. Then the controller ranks the predictor outcomes according to a cost function and to constraint satisfaction. The best performer is then selected and used in the next control step. In the PdG case described in section 6.1, control options are all the driving frequencies of the fans installed in the station and described by variables FreSF1 and FreSF2, as explained in section 5.2. The model predictor is made of the two Bayesian Networks AF-BN and TP-BN described in section 5.1. and depicted in Figs. 7 and 8. Once a set of outcomes (e.g. expected energy consumption, comfort parameters etc.) is had per each value of the inputs, the cost function in eq. (23) selects the best control strategy and sends it to the actuation system. This value is kept constant over one hour, after which another MPC step is run by the controller to re-adjust actuators for the next hour.

**Figure 12.** Flowchart showing the procedure adopted by the MPC controller for the PdG case study.

fixed one. The inclusion of the large PdG environmental model was not that easy. The Dymola model did not allow exporting the solver that is uniquely able to simulate the model within an FMU. Therefore, we have opted for a loosely coupled simulating environment, which runs the Dymola and the Simulink in parallel and synchronize them through a DDE channel. A wrapper of the Dymola model, which essentially implements an FMI, provides the necessary

The control logics implemented in the SEAM4US simulator is based on a simple particle filtering mechanism (Fig. 12). The controller randomly generates a number of different control options that are sent to the predictor. The predictor updates the model with the control parameters and by means of Bayesian inference calculates the environment and energy consumption parameters. Then the controller ranks the predictor outcomes according to a cost function and to constraint satisfaction. The best performer is then selected and used in the next control step. In the PdG case described in section 6.1, control options are all the driving frequencies of the fans installed in the station and described by variables FreSF1 and FreSF2, as explained in section 5.2. The model predictor is made of the two Bayesian Networks AF-BN and TP-BN described in section 5.1. and depicted in Figs. 7 and 8. Once a set of outcomes (e.g. expected energy consumption, comfort parameters etc.) is had per each value of the inputs, the cost function in eq. (23) selects the best control strategy and sends it to the actuation system. This value is kept constant over one hour, after which another MPC step is run by the controller

**Figure 12.** Flowchart showing the procedure adopted by the MPC controller for the PdG case study.

sync and message transfer functionalities.

30 Dynamic Programming and Bayesian Inference, Concepts and Applications

**6.2. How the MPC controller works**

to re-adjust actuators for the next hour.

Fig. 13 - Some plots from the simulations in search of optimal control strategies: frequency of the fans in charge of mechanical air supply according to the control policy (top) and related air **Figure 13.** Some plots from the simulations in search of optimal control strategies: frequency of the fans in charge of mechanical air supply according to the control policy (top) and related air temperature plots determined by the most meaningful control strategies (bottom).

temperature plots determined by the most meaningful control strategies (bottom). Fig. 13 shows an example of a simulation result of three days of operation, which is relative to the environmental control. The simulation time is represented along the x axis, while the y axis represents the fan frequencies in Fig. 13-a. Negative frequencies means that the fan direction is inverted (extracting air instead of supplying). Three curves are reported. The dashed curve (Baseline) depicts the current policy used for fan control, as it is actually implemented in the station, which we assumed as the baseline. The fan is driven at maximum speed for all the station opening time and it is turned off during the closure time. The second dash-dot curve represents MPC constrained to only two driving frequencies, while the third (continuous) curve is related to a continuous frequency driving. In addition to the fact that MPC control provides an energy saving rate that can rise up to 35%, it is noteworthy to realize why this happens. Comparing the baseline curve with the MPC controlled, it appears that in many cases the driving frequencies and the baseline have opposite signs. This means that in the standard baseline driving the station fans very often are opposed to the air flow induced by the external sources, and therefore contribute negatively to the air exchange and to the comfort parameters. This is reflected by the temperature curves that are slightly lower – i.e. more comfortable - for the MPC controlled environment despite the huge energy saving (Fig. 13-b). Summarizing, these Fig. 13 shows an example of a simulation result of three days of operation, which is relative to the environmental control. The simulation time is represented along the x axis, while the y axis represents the fan frequencies in Fig. 13-a. Negative frequencies means that the fan direction is inverted (extracting air instead of supplying). Three curves are reported. The dashed curve (Baseline) depicts the current policy used for fan control, as it is actually implemented in the station, which we assumed as the baseline. The fan is driven at maximum speed for all the station opening time and it is turned off during the closure time. The second dash-dot curve represents MPC constrained to only two driving frequencies, while the third (continuous) curve is related to a continuous frequency driving. In addition to the fact that MPC control provides an energy saving rate that can rise up to 35%, it is noteworthy to realize why this happens. Comparing the baseline curve with the MPC controlled, it appears that in many cases the driving frequencies and the baseline have opposite signs. This means that in the standard baseline driving the station fans very often are opposed to the air flow induced by the external sources, and therefore contribute negatively to the air exchange and to the comfort parameters. This is reflected by the temperature curves that are slightly lower – i.e. more comfortable-for the MPC controlled environment despite the huge energy saving (Fig. 13-b). Summarizing,

and on the flexibility of the Bayesian predictor and of the Bayesian Inference paradigm.

8. Conclusions

reasonable computational effort is required.

results show how the effectiveness of the MPC control of complex environment relies on the power

In this Chapter we have shown that the role of Bayesian predictors may be critical in order to implement predictive control of buildings. This kind of control is one of the most effective ones currently being developed by researchers, because it is able to smooth control actions and to trigger them in advance. However, it cannot be applied without a reliable predictor of the expected state of the controlled domain. Such a predictor must be queried in real-time, which is feasible just in case a

In other words, computationally demanding software programs cannot be used to produce predictions at run time, but they can be run to generate datasets and these datasets may be used to transfer knowledge into Bayesian Networks. At this juncture, Bayesian inference may be performed: in fact, these results show how the effectiveness of the MPC control of complex environment relies on the power and on the flexibility of the Bayesian predictor and of the Bayesian Inference paradigm.

*MPC* Model based Predictive Control *PdG-L3* Passeig de Gracia – Line 3 station *BEMS* Building Energy Management System

*Section 2*

*Section 3*

*P( yi | xi*

*Sub-section 4.1*

*X ^*

*HVAC* Heat, Ventilation, Air conditioning and Cooling

*<sup>d</sup>*, *d*^ Disturbances and their predictions respectively

*)* Any entry of the conditional probability matrix

ξ Evidence observed before estimating future values of random variables *BEL (x)* Overall belief accorded to proposition X=x by all evidence so far received by ξ

*Bs* Bayesian Network structure ordering a set of variables in domain U

its joint set of parents are in state *j*

in a Bs will come out with one of its states *k*, given

*m* Measures from building's sensor network

*X, Y, Z* Random events or prepositions *M y| <sup>x</sup>* Conditional probability matrix

*P(x)* Prior probability

λ*(x)* Likelihood vector

*U* Domain to be modelled

*n* Number of variables in Bs

*qi* Number of states of Π<sup>i</sup> *ri* Number of states of x

*Ci* Any record of a random sample

Π*<sup>i</sup>* Any set of variables in Bs which are parents of *Xi*

*ijk* Physical probability that any variable *Xi*

*c* Normalization constant in a gamma function *N* Multinomial parameter in a gamma function

*<sup>i</sup>* Predicted value of any random variable *Xi*

*Xmax* Maximum value of variable *Xi*

*D* Random sample

β 1/*P*(ξ)

*<sup>y</sup>*, *y*^ Outputs of the controlled building and their predictions respectively *<sup>u</sup>*, *u*^ Inputs of the controlled building and their predictions respectively

Bayesian Networks for Supporting Model Based Predictive Control of Smart Buildings

http://dx.doi.org/10.5772/58470

33
