Adaptive Linear Grey-Box Models for Model Predictive Controller of Residential Buildings

Model predictive control (MPC) is an advanced optimal control technique to minimize a control objective while satisfying a set of constraints and is well suited to activate the building energy flexibility. The MPC controller performance depends on the accuracy of the model prediction. Inaccurate predictions can directly lead to low control performance. Linear time-invariant (LTI) models are often used in MPC in buildings. However, LTI models do not adapt to the weather conditions varying throughout the whole space-heating season, which makes the MPC based on LTI models not perform well over a long period of time. Therefore, this study introduces an adaptive MPC where the parameters of a linear grey-box model are continuously updated in real-time. Two alternative versions of this adaptive control are investigated. The first one, called partially adaptive MPC, only updates the effective window area of the grey-box model, while the second one, called fully adaptive MPC, updates all the parameters of the grey-box model. Results show that the partially adaptive MPC is not able to deliver satisfactory prediction performance. The fully adaptive MPC shows better performance compared to the other models when implemented in a MPC, especially in avoiding thermal comfort violation.


Introduction
The grid system today is facing new challenges due to the fastly increasing penetration of renewable energy resources (RES).The weather-dependent RES brings intermittent and is prone to uncertainty which makes the balance between the electricity supply and demand a challenging task.Thus, more flexibility is needed for the current energy system.Demand response (DR) is considered as a feasible solution on the demand side, which can adapt to volatile electricity generation (Esther & Kumar, 2016;Oconnell et al., 2014).Buildings account for a significant proportion of final energy consumption in developed countries (Pérez-Lombard et al., 2008) (20-40%).The thermal mass of building envelopes can be used as short-term heat storage to perform DR.This study mainly investigates model predictive control (MPC) to activate the flexibility of the building thermal mass.The MPC controller enables the indoor temperature to fluctuate within acceptable indoor temperature limits for the occupants while it optimizes the time profile of energy use by loading the building thermal mass at certain periods.The MPC controller performance strongly depends on the accuracy of the model prediction.Therefore, identifying an accurate prediction model is a key task for the deployment of MPC.
This study focuses on MPC using grey-box models as the prediction model.Grey-box models have a structure based on physical laws, while the model parameters are calibrated on measurement data (i.e., based on time-series data).The grey-box models are not as mathematically complex as white-box models, so they are less computationally expensive to solve.Grey-box models also have better extrapolation properties than black-box models (Madsen et al., 2016).In grey-box models, lumped resistance and capacitance (RC networks) are commonly used to represent the model structure of the building, which is also used in this study.Some existing studies have shown that linear time-invariant (LTI) models can approximate the thermal dynamics of buildings with sufficient accuracy for MPC purposes (Bacher & Madsen, 2011;M. D. Knudsen & Petersen, 2020;Michael Dahl Knudsen & Petersen, 2017;Prívara et al., 2013;Vogler-Finck et al., 2018).However, the performance of the MPC controller cannot be maintained if it is applied over a long period of time due to the timevarying weather conditions throughout the year.Thus, an MPC controller where the parameters of the grey-box model can be updated in real-time should provide satisfactory control performance over a long period of time.This paper uses virtual experiments (i.e., cosimulation) to compare the performance of a conventional MPC based on an LTI model to an adaptive MPC.IDA ICE is a detailed dynamic building performance simulation (BPS) software, which is used as the emulator for virtual experiments.The MPC controller is implemented in MATLAB with a co-simulation function in IDA-ICE provided by the company EQUA.

Description of virtual experiments setup
This study uses a building model in IDA ICE developed in a previous study (Yu et al., 2021) as the emulator for the co-simulation.It is a detached house in Oslo.The floor area of the house is approximately 160 m 2 and is constructed in wood.The lightweight construction complies with Norwegian passive house standards (NS 3700 [15]) requirements.The appearance of the building is shown in Figure 1, while its floor plan is presented in Figure 2. The envelope of the building is the dominant heat dynamics to be modeled in this study, which has good linear properties.Thus, it is reasonable to use the linear grey-box model as the prediction model for the MPC controller design.The internal doors of the building are set to be open in the virtual experiments.Therefore, the mono-zone grey-box model is considered as the prediction model.The temperature of the indoor air node is represented by the volume-averaged temperature of the nine zones in IDA ICE.Electrical radiators are selected to be the space-heating system in the BPS since they are it is the most common for Norwegian residential buildings (Bøeng et al., 2014).The heat dynamics of electrical radiators are neglectable due to much smaller thermal inertia compared to the envelope.The profile for internal gains and occupancy is taken from the Norwegian technical standard TS3031:2016 (Norge, 2016).The heat dynamics of the building need to be perturbed to obtain the data for training the model parameters.The Pseudo-Random Binary Signal (PRBS) approximates white noise properties, which can excite the dynamic system in a large spectrum of frequencies (Kristensen et al., 2004;Lennart, 1999).The electrical radiator is the only controllable input of the system, so the PRBS signal is applied to the electrical radiator to obtain the training data.It is not always feasible to apply PRBS signal in real operation due to thermal discomfort caused by large variations of the indoor temperature for occupants.Therefore, the time of applying PRBS signal should also be limited.This study takes one week in November as the training week to apply PRBS signal to the heating system.In the co-simulation, the length of each MPC time step is set to 15 min.IDA ICE first sends the current calculated volume-averaged indoor temperature of the building to MATLAB.Then the MPC controller takes the prediction of the weather data and internal heat gains into the optimization to output the optimal control sequence for the heating system.However, only the first step decision of the control sequence is taken and sent back to IDA ICE.The heaters in the building will execute the calculated optimal power after receiving the control signal.When this time step is done in IDA ICE, the new state of the volume-averaged indoor temperature is sent back to MATLAB again; a new round starts.The process will keep iterating in time using this co-simulation setup until the pre-determined simulation period is finished.A similar co-simulation setup with IDA ICE has been applied in the study (Khatibi et al., 2022).A short initialization period is necessary for IDA ICE to come to realistic temperatures in each zone of the model, so PID control is applied at the beginning of co-simulation.The length of the initialization period in this study is set to be half-day.
In the co-simulation framework, there are variable constraints set in the MPC due to system limitations.In the IDA ICE model, the total heating power of all the radiators is 3220W.The radiator in IDA ICE is assumed to be able to modulate its power by adjusting its part load ratio (PLR).Thus, the power constraint of the heating system in the MPC is from 0 to 3220W.The thermal comfort should also be considered and it is here considered using minimum and maximum indoor temperature limits.The minimum indoor temperature limit is set to be 20 °C and the maximum limit is set to be 24 °C.There is a night setback for the minimum temperature limilt decreasing from 20°C to 16 °C from 11PM to 7AM.

Methodology Grey-box model
A grey-box model structure that has too many parameters may lead to overfitting and increase the calculation cost.
Lower order models with few parameters can decrease the calculation cost for the MPC optimization but at the cost of unacceptable prediction performance.A considerable amount of research has already been done to find suitable mono-zone grey-box model structures to be applied to MPC of buildings (Bacher & Madsen, 2011;Berthou et al., 2014;Harb et al., 2016;Reynders et al., 2014;Viot et al., 2018).In the previous study (Yu et al., 2022), a 3R2C grey-box model has proven to be a suitable trade-off between model complexity and accuracy for the test case.Therefore, this model structure is used for the MPC controller in our work.The model structure and its parameters are given in Figure 3 and Table 1.

Ci
Heat capacity including the thermal mass of the air, the furniture [kWh/K].

Ce
Heat capacity of external wall [kWh/K].
UAie Heat conductance between the building envelope and the interior [kW/K].
UAea Heat conductance between the outdoor and the building envelope [kW/K].
UAinf Heat conductance between the outdoor and the interior node (components with negligible thermal mass, like windows and doors) [kW/K].

Qint
Internal heat gain from artificial lighting, people and electric appliances [kW].

Qh
Heat gain delivered to the heat emitter [kW].

Isol
Global solar irradiation on a horizontal plane [W/m 2 ].

Ai
The effective window area of the building corresponding to Ti [m 2 ].

Ae
The effective window area of the building corresponding to Te [m 2 ].
MATLAB system identification toolbox (Ljung, 2014) is used to calibrate the parameters of the grey-box model.This paper uses the global optimization routine of the previous study (Yu et al., 2021) to avoid the local optimum.The routine consists of two stages.The heuristic particle swarm optimization (PSO) is used at the first stage to give a general estimation of parameter values.Then the gradient-based optimization function (greyest) is applied in the second stage to further polish the parameter values.The objective function f(x) of the optimization is defined as Equation 1.

Optimal Control Problem Formulation
The goal to implement MPC in the building varies between applications.The objective function of the MPC in our study is to minimize the total electricity use of the heating system while keeping the building within the thermal comfort temperature limits.
With the control objectives and constraints, the optimal control problem can be formulated.The time step of each control decision is 15 minutes.The prediction horizon of the MPC controller is set to be 24 hours (96 slots, N = 96).This duration of the prediction horizon is a typical value found in the literature.It keeps the computational time reasonable.The equations of the optimization problem are given below.
In the equations, x[k] is the state vector in discrete-time, F, G and C are the discrete state space matrice obtained from the grey-box model identification process, u[k] is the input vector in discrete-time and y[k] is the output.K is the tunned steady Kalman gain.Qh [k] is the calculated optimal heat power at each step for the prediction horizon, while Qh,max [k] is the max power of the heating system.ε1 [k] and ε2 [k] are the slack variables of the soft constraints on the thermal comfort band.The existence of soft constraints can help the solver to avoid infeasible optimization problems by allowing thermal comfort limits to be violated.Tindoor [k] is the predicted indoor temperature from the grey-box model.Tlow [k] and Tup [k] are the corresponding temperature limits during the prediction horizon.The thermal discomfort (ε) is quantified in Kelvin hours outside the predefined thermal comfort limits.L is the penalty factor for discomfort in the objective function.For favor comparison of results, it has been decided that the thermal discomfort should be rare when using MPC so that a very high value of 10 8 is given to the penalty L. MPC resorts to a receding horizon.The above optimization problem is solved at each step to get the optimal control decision.Then, the initial states of the model and the weather forecasts are updated with the receded prediction horizon.Due to the quadratic form of the slack variables ε1 and ε2, a solver that can solve quadratic programming problems is needed.In this study, the toolbox YALMIP (Lofberg, 2004) in MATLAB is used for the formulation of the optimization problem, while Gurobi (Lofberg & Gurobi Optimization, 2004) is used to solve the optimization problem.

Conventional and Adaptive MPC
The baseline MPC is based on LTI models, which keep the value of the model parameters constant during simulation.The LTI model trained using the full winter experiments with intermittent heating is called FullWinter.
The LTI model trained using the PRBS experiments of November is called PRBSNOV.
The partially adaptive MPC takes the FullWinter model to initialize the model, only the effective window area (Ai) parameter is updated during the simulation.The pseudocode for updating the effective window area is presented in Algorithm 1.The fully adaptive MPC also starts with the FullWinter model but updates all the seven parameters of the model during simulation.The pseudo-code for fully adaptive MPC is presented in Algorithm 2.
The sliding accumulated error (ErrorS) is the index to detect when the parameters need to be updated.The sliding accumulated error sums up the absolute value of the prediction error (value difference between the measurement and the model prediction).The length of the sliding accumulated error is set to be 12 steps (i.e., 3 hours).When the ErrorS is larger than a predefined threshold, it actives the parameter updating routine.The threshold is called error_index and is set to be 5 in this study.It is unreasonable to use a short training period to update the model parameters as the parameters can be unphysical or with large uncertainty.On the opposite, taking a long period of historical data for training is also not optimal since the adaptive MPC should be able to adapt the parameters for changing operating conditions.Pushed to extremes, a very long training period will make the adaptive model converge to the LTI model.Thus, the two adaptive MPC take a training period of 7 days of data to update the model parameters.As a result, the adaptive MPC routines are not able to start the first model update during the first seven days of co-simulation.
Algorithm 1: Pseudo-code for the partially adaptive MPC

Results
The results using different MPCs are presented in this section.The virtual experiment starts from November 1 st to December 31 th (i.e., 61 days).The first 12 hours of simulation always start with a PID control to stabilize the co-simulation environment.Then, the control is switched to MPC.PRBSNOV MPC uses the LTI grey-box model trained using the data from one week of building operation with the PRBS excitation in November (PRBSNOV).FullWinter MPC uses the LTI grey-box The indoor temperature computed using co-simulation and the four MPC controllers are shown in Figure 4.
Figure 5 is a close-up section of Figure 4 and the corresponding heating power of the radiator is also given.
The aggregated results are given in .The history of the effective window area update is shown in Figure 6.
It can be seen that the FullWinter MPC can not make a satisfactory prediction, which causes the thermal comfort constraint to be significantly and frequently violated.The partially adaptive MPC shows only slightly better performance compared to the FullWinter MPC.The thermal comfort constraint is still frequently violated.These two models consume less energy compared to the other two models (i.e., the fully adaptive MPC and the PRBSNOV MPC).However, the MPC should first guarantee the thermal comfort of the occupants and then provide DR service to the grid.The FullWinter MPC and Partially Adaptive MPC consume less energy because they are less accurate, which causes the indoor temperature to drop below the minimum indoor temperature threshold.The heating system is switched on too late in the morning and causes large thermal discomfort.This indicates that the LTI grey-box model trained using the full winter data may not be suitable as the prediction model in MPC.Furthermore, quite surprisingly, only updating the effective window area of the model is not sufficient.This is also confirmed by the history of updates of the effective window area.The partially adaptive MPC updates the window area continuously, which means that the sliding accumulated error is always very large during simulation.The PRBSNOV MPC performs much better than the previous two models in terms of thermal discomfort.The resulting energy use of the PRBSNOV MPC is consequently higher.This result proves that it is necessary to use a model that is calibrated using a training period similar to the period when the MPC will be operated.The fully However, the consumed energy is even higher.The fully adaptive model performs better than the partially adaptive model mainly due to the extra degrees of freedom to adapt the model parameters.After the first update of the parameters done by the fully adaptive MPC, the violation of the indoor temperature constraint is significantly reduced.As shown in Figure 6, the effective window area is only updated three times during the simulation, which means that the obtained model is accurate and can deliver a decent prediction.

Conclusion
This study aims to assess different MPC controller performances using virtual experiments by coupling IDA ICE and MATLAB.The control objective of the MPC controller is to minimize the energy use with a high penalty on the thermal discomfort to give priority to thermal comfort over energy use.
Results show that the LTI grey-box model trained using the FullWinter data is not suitable as MPC prediction model.This model is too general and gives large prediction errors during specific periods of the winter.This is confirmed by the LTI grey-box model training using a PRBS excitation sequence for one week in November (PRBSNOV).The model is better calibrated to November than the FullWinter model and the resulting MPC gives better performance.
Although the effective window area is known to vary significantly during the space-heating season, only updating the window area of the model is surprisingly not enough to reach satisfactory MPC performance.The lower amount of indoor temperature violations of the fully adaptive MPC compared to the PRBSNOV MPC demonstrates the need to update all the model parameters during the space-heating season.
In future work, the performance of the four MPC controllers will be compared for different objective functions (e.g, minimization of the energy cost or the energy use during peak hours) and different magnitudes for the penalty coefficient weighting the thermal discomfort in the objective function.
The data collected from IDA ICE simulations are used to train the parameters of the grey-box model.Then, the obtained model is used as the prediction model for the MPC controller.The adaptive MPC controller has two versions in this study.The first version, called partially adaptive MPC, only updates the effective window area of the grey-box model when the prediction error is large during the MPC operation.The reason is that solar radiation is the dominant factor that influences the model accuracy due to the cloud condition, changing altitude and zenith angles of the sun.The second version, called fully E3S Web of Conferences 362, 12001 (2022) https://doi.org/10.1051/e3sconf/202236212001BuildSim Nordic 2022 adaptive MPC, updates all the parameters of the grey-box model when the prediction error is large during the MPC operation.The second version has more freedom to fit the model parameters compared to the first one.However, the second version of adaptive MPC theoretically takes more time to converge to a new set of parameters and may have the risk of obtaining a set of unphysical parameters due to insufficient training data.Both versions of the adaptive model use the full space-heating season data (here called full winter) to train the model parameters as the initial model to start the adaptive MPC.This study compares the performance of a conventional MPC based on an LTI grey-box model to the adaptive MPC.

Figure 1 :
Figure 1: 3D geometry of the building model in IDA ICE (showing the southwest facade) It starts on November 23rd and lasts for one week (close to the middle of the whole experimental period).The outdoor temperature is mild with an average value of 5 ℃.The data generated under typical operations are also used as training data.Intermittent heating with changing temperature setpoints is applied.The setpoint is shifted between daytime and nighttime (i.e. a night setback) and the local controller of the radiator is on-off.The model trained from the PRBS signal is only used for the LTI control model.The model trained from the full winter intermittent heating with changing temperature setpoints is also used as the initial model for the adaptive MPC.

Figure 2 :
Figure 2: Floor plan of the test building (ducts for the supply ventilation air are in blue and in red for extraction)

Figure 3 :
Figure 3: 3R2C grey-box model Table 1: The physical interpretation of the parameters of the 3R2C grey-box model Parameters Physical interpretation and unit Ti Temperature of the internal node (i.e., indoor air, furniture) [°C].Te Temperature of the external walls [°C]. 1

Figure 5 :
Figure 5: Close-up of the indoor temperature profile under the operation of different MPC controllers with energy saving objective

Table 2 :
Results summary of MPC controllers' performancemodel trained with the data from the intermittent heating with changing temperature setpoints during the full spaceheating season (i.e., from November 1 st to March 31 th ).