## 1. Introduction

Model predictive control (MPC) is a control method (or group of control methods) which make explicit use of a model of the process to obtain the control signal by minimizing an objective function. Control law is easy to implement and requires little computation, its derivation is more complex than that of the classical PID controllers. The main benefit of MPC is its constraint handling capacity: unlike most other control strategies, constraints on inputs and outputs can be incorporated into the MPC optimization (Camacho, E., 2004). Another benefit of MPC is its ability to anticipate to future events as soon as they enter the prediction horizon. The implementation supposes good knowledge of system for the purpose of model creation using the system identification. Modeling and identification as a methodology dates back to Galileo (1564-1642), who also is important as the founder of dynamics (Johanson, R., 1993). Identification has many aspects and phases. In our work we use the parametric identification of real system using the measured data from control centre. For the purpose of identification it is interesting to describe the sought process using input-output relations. The general procedure for estimation of the process model consists of several steps: determination of the model structure, estimation of parameters and verification of the model. Finally we can convert the created models to any other usable form. This chapter gives an introduction to model predictive control, and recent development in design and implementation. The controlled object is an urban tunnel tube. The task is to design a control system of ventilation based on traffic parameters, i.e. to find relationship between traffic intensity, speed of traffic, atmospheric and concentration of pollutants inside the tunnel. Nowadays the control system is designed as tetra - positional PID controller using programmable logic controllers (PLC). More information about safety requirements for critical processes control is mentioned in the paper (Ždánsky, J., Rástočný, K. and Záhradník, J., 2008). The ventilation system should be optimized for chosen criteria. Using of MPC may lead to optimize the control way for chosen criteria. Even more we can predict the pollution in the tunnel tube according to appropriate model and measured values. This information is used in the MPC controller as measured disturbances. By introducing predictive control it will be made possible to greatly reduce electric power consumption while keeping the degree of pollution within the allowable limit.

## 2. Tunnel ventilation system

Emissions from cars are determined not only by the way they are built but also by the way they are driven in various traffic situations. Various gases are emitted by combustion engine. They consist largely of oxides of nitrogen (NO_{x}), carbon monoxide (CO), steam (H_{2}O) and particles (opacity). Because of these dangerous gases, it is necessary to provide fresh air in longer tunnels. The fresh air which is used to lower the concentration of CO also serves to improve visibility. The purpose of ventilation is to reduce the noxious fumes in a tunnel to a bearable amount by introducing fresh air. Every tunnel has some degree of natural ventilation. But a mechanical ventilation system should have to be installed. In order to create air stream, jet fans are installed on the ceiling or side walls of the tunnel. The fans take in tunnel air and blow it out at higher speed along the axis of the tunnel. In the tunnel is mounted several fans with about hundred kW each.

The design and industrial implementation of automatic control systems requires powerful and economic techniques together with efficient tools. In order to solve a control problem it is necessary to first describe somehow the dynamic behaviors of the system to be controlled. Traditionally this is done in terms of a mathematical model. Mathematical models are mathematical expressions of essential characteristics of an existing system that describe knowledge about the system in a usable form.

Ventilation control system will base on model and sensors information about NO_{x}, opacity, velocity, number of vehicles and CO measurements. According to the amounts of pollutants in exhaust gas, air flow driven by the vehicles and degree of pollution inside the tunnel, optimized operation commands will given to the jet fans. “Optimum” means that pollutant concentration is kept within the allowable limit (for CO, 75 ppm or less), and at the same time electric power consumption is minimized. Another criterion is also possible, for example: number of switching the jet fans.

### 2.1. Tunnel description

The ventilation system in urban tunnel Mrázovka in Prague represents one function unit designed as longitudinal ventilation with a central efferent shaft and protection system avoiding spread of harmful pollutants into the tunnel surround area. Ventilation is longitudinal facing in direction of traffic with air suction at the south opening of the eastern tube (ETT) and at the branch B, with air being transferred at the north opening to the western tunnel tube (WTT) (Pavelka, M. and Přibyl, P., 2006). The task is to design a control system of ventilation based on traffic parameters, i.e. to find relationship between traffic intensity, speed of traffic, atmospheric and concentration of pollutants inside the tunnel. To do that the eastern tunnel tube (ETT) has been chosen as a model example due to principle of mixing polluted air from ETT to WTT (measured concentrations of pollutants in the WTT are also influenced by traffic intensity in the ETT).

To get the required description, the following data has been taken from the tunnel control centre: traffic intensity of trucks and cars, their speed, concentrations of CO (carbon monoxide), NO_{x} (oxides of nitrogen), OP (opacity-visibility) from the ETT, atmospheric pressure etc. These values are measured by sensors installed inside the tunnel (at five different places of the ETT). Traffic parameters are measured at three places, air flow at three places and concentrations of NO_{x} and atmospheric pressure in the north portal.

Traffic intensity is sensed by a camera system and the cars are then counted and sorted by categories in database system. More information about monitoring of the traffic can be found in (Pirník, R., Čapka, M. and Halgaš, J., 2010). About the security by transferring the data is discussed in (Holečko, P., Krbilová, I., 2006).

## 3. Mathematical models for MPC

Mathematical models are mathematical expressions of essential characteristics of an existing or designed system that describe knowledge about the system in a usable form. Turbulence inside the tunnel, variety of traffic and atmospherics make the system behavior stochastic. To make the models we use the parametric identification. The MATLABs tools allowed a conversion between several types of models. The main tasks of system identification were the choice of model type and model order. For Single-input Multiple-output discrete time linear systems we can write the metrics equation for jet fan characteristics:

The “Jet Fan Model” is a model in the MPC format that characterizes effect of ventilator on CO concentration, NO_{x} concentration and visibility (opacity). It is a system with 1 input (*u*) and 3 outputs (dilution of CO-Out1, NO_{x} concentration-Out2 and opacity OP-Out3). One of the main advantages of predictive control is incorporation of limiting conditions directly to the control algorithm. The “Jet Fan Model” characteristics are shown in Fig. 2.

The “Disturbance Model” is a model of the tunnel tube in state space representation:

This model is used to predict the pollutions inside the tunnel tube. These data enter to the measured disturbances input (MD) of MPC controller for the purpose of switching the jet fans before the limit will be exceeded.

Created model was validated by several methods (Hrbček, J., 2009). The purpose of model validation is to verify that identified model fulfills the modeling requirements according to

subjective and objective criteria of good model approximation. In method “Model and parameter accuracy” we compare the model performance and behavior with real data. A deterministic simulation can be used, where real data are compared with the model response to the recorded input signal used in the identification. This test should ascertain whether the model response is comparable to real data in magnitude and response delay.

This method showed graphically accuracy between simulated values and measured values. Although the simulated and measured data not fit precisely, this result is sufficient for most stochastic system like pollution inside the road tunnel.

An Akaike Final Prediction Error (FPE) for estimated model was also determinate. The average prediction error is expected to decrease as the number of estimated parameters increase. One reason for this behavior is that the prediction errors are computed for the data set that was used for parameter estimation. It is now relevant to ask what prediction performance can be expected when the estimated parameters are applied to another data set. This test shows the flexibility of the model structure. We are looking for minimum value of FPE coefficient.

## 4. Model predictive control of ventilation system

Under the term “Model Predictive Control” we understand a class of control methods that have certain characteristic features. MPC refers to a class of computer control algorithms that utilize an explicit process model to predict the future response of a plant. From this model the future behaviour of the system is predicted over a finite time interval, usually called prediction horizon, starting at the current time *t*.

### 4.1. The basic idea of predictive control

The receding horizon strategy is shown in Fig. 4.

The future outputs for a determined horizon *N*, called the prediction horizon, are predicted at each instant t using the process model. These predicted outputs *y*(*t* + *k*|*t*) 1 for *k* = 1…*N* depend on the known values up to instant t (past inputs and outputs) and on the future control signals *u*(*t*+*k*|*t*), k = 0... *N*-1, which are those to be sent to the system and calculated.

The set of future control signals is calculated by optimizing a determined criterion to keep the process as close as possible to the reference trajectory *w*(*t* + *k*) (which can be the setpoint itself or a close approximation of it). This criterion usually takes the form of a quadratic function of the errors between the predicted output signal and the predicted reference trajectory. The control effort is included in the objective function in most cases. An explicit solution can be obtained if the criterion is quadratic, the model is linear, and there are no constraints; otherwise an iterative optimization method has to be used. Some assumptions about the structure of the future control law are also made in some cases, such as that it will be constant from a given instant.

The control signal *u*(*t*|*t*) is sent to the process whilst the next control signals calculated are rejected, because at the next sampling instant *y*(*t*+*1*) is already known and step 1 is repeated with this new value and all the sequences are brought up to date. Thus the *u*(*t*+1|*t*+1) is calculated ( which in principle will be different from the *u*(*t*+1|*t*) because of the new information available) using the receding horizon concept (Camacho, E. F., Bordons, C., 2004).

The notation indicates the value of the variable at the instant *t* + *k* calculated at instant *t*.

### 4.2. Application to real system

Tunnel ventilation is expected to fulfil the following requirements at least (Godan, J. at all. 2001):

Concentration of emissions in the tunnel kept within the acceptable limits for the monitored harmful pollutants, in consideration of time spent by persons inside the tunnel;

Good visibility for through passage of vehicles under polluted air inside the tunnel;

Reduction of effects of smoke and heat on persons in the case of vehicle fire;

Regulation of dispersion of pollutants in the air caused by petrol fumes from vehicles into the surround environment of the tunnel.

Model Predictive Control (MPC) comes from the late seventies when it became significantly developed (Camacho, E. F., Bordons, C., 2004) and several methods were defined. In this work we have applied the Dynamic Matrix Control (DMC) method which is one of the most spread approaches and creates the base of many commercially available MPC products. It is based on the model obtained from the real system:

where *h*_{i} are FIR (Finite Impulse Response) coefficients of the model of the controlled system. Predicted values may be expressed:

We assume that the additive failure is constant during the prediction horizon:

Response can be decomposed to the component depending on future values of control and to the component determined by the system state in time n:

where *f*(*n*+*k*) is that component which does not depend on future values of action quantity:

Predicted values within the prediction horizon *p* (usually *p*>>*N*) can be arranged to the relation (8):

where the prediction horizon is *k*=1...*p*, with respect to *m* control actions. Regulation circuit is stable if the prediction horizon is long enough. The values may be arranged to the dynamic matrix *G*:

and expression used for prediction can be written in the matrix form:

where *ŷ* is a vector of contributions of action quantity and f are free responses.

The MATLAB’s Model Predictive Control Toolbox uses linear dynamic modeling tools. We can use transfer functions, State-space matrices, or its combination. We can also include delays, which are in the real system. The model of the plant is a linear time-invariant system described by the equations:

where *x*(*k*) is the *n*_{x} -dimensional state vector of the plant, *u*(*k*) is the *n*_{u}-dimensional vector of manipulated variables (MV), i.e., the command inputs, *v*(*k*) is the *n*_{v}-dimensional vector of measured disturbances (MD), *d*(*k*) is the *n*_{d}-dimensional vector of unmeasured disturbances (UD) entering the plant, *y*_{m} (*k*) is the vector of measured outputs (MO), and *y*_{u}(*k*) is the vector of unmeasured outputs (UO). The overall *n*_{y}-dimensional output vector *y*(*k*) collects *y*_{m}(*k*) and *y*_{u}(*k*). In the above equations *d*(*k*) collects both state disturbances (*B*_{d}≠0) and output disturbances (*D*_{d}≠0).

The unmeasured disturbance *d*(*k*) is modeled as the output of the linear time invariant system:

The system described by the above equations is driven by the random Gaussian noise *n*_{d}(*k*), having zero mean and unit covariance matrix. For instance, a step-like unmeasured disturbance is modeled as the output of an integrator. In many practical applications, the matrices A, B, C, D of the model representing the process to control are obtained by linearizing a nonlinear dynamical system, such as

at some nominal value *x*=*x*_{0}, *u*=*u*_{0}, *v*=*v*_{0}, *d*=*d*_{0}. In these equations *x´* denotes either the time derivative (continuous time model) or the successor *x*(*k*+1) (discrete time model).

The MPC control action at time k is obtained by solving the optimization problem:

where the subscript "( )*j*" denotes the *j*-th component of a vector, "(*k*+*i*|*k*)" denotes the value predicted for time *k*+*i* based on the information available at time *k*; *r*(*k*) is the current sample of the output reference, subject to

with respect to the sequence of input increments {*ε*, and by setting *u*(*k*)=*u*(*k*-1)+ Δ*u*(*k*|*k*), where Δ*u*(*k*|*k*) is the first element of the optimal sequence. Note that although only the measured output vector *y*_{m}(*k*) is fed back to the MPC controller, *r*(*k*) is a reference for all the outputs. When the reference r is not known in advance, the current reference *r*(*k*) is used over the whole prediction horizon, namely *r*(*k*+*i*+1)=*r*(*k*) in Equation 14.

In Model Predictive Control the exploitation of future references is referred to as anticipative action (or look-ahead or preview). A similar anticipative action can be performed with respect to measured disturbances *v*(*k*), namely *v*(*k*+*i*)=*v*(*k*) if the measured disturbance is not known in advance (e.g. is coming from a Simulink block) or *v*(*k*+*i*) is obtained from the workspace. In the prediction, *d*(*k*+*i*) is instead obtained by setting *n*_{d}(*k*+*i*)=0. The *w*^{Δu}*ij*, *w*^{u}*ij*, *w*^{y}*ij*, are nonnegative weights for the corresponding variable. The smaller w, the less important is the behavior of the corresponding variable to the overall performance index. And *u*_{j,min}, *u*_{j,max}, Δ*u*_{j,min}, Δ*u*_{j,max}, *y*_{j,min}, *y*_{j,max} are lower/upper bounds on the corresponding variables. The constraints on *u*, Δ*u*, and *y* are relaxed by introducing the slack variable *ε*≥ 0. The weight *ρε* on the slack variable ε penalizes the violation of the constraints. The larger *ρε* with respect to input and output weights, the more the constraint violation is penalized. The Equal Concern for the Relaxation vectors *V*^{u}_{min},*V*^{u}_{max}, *V*^{Δu}_{min}, *V*^{Du}_{max}, *V*^{y}_{min}, *V*^{y}_{max} have nonnegative entries which represent the concern for relaxing the corresponding constraint; the larger *V*, the softer the constraint. *V*=0 means that the constraint is a hard one that cannot be violated (Bemporad A., Morari M., N. Lawrence Ricker., 2010).

### 4.3. Constraints

In many control applications the desired performance cannot be expressed solely as a trajectory following problem. Many practical requirements are more naturally expressed as constraints on process variables. There are three types of process constraints: Manipulated Variable Constraints: these are hard limits on inputs *u*(*k*) to take care of, for example, valve saturation constraints; Manipulated Variable Rate Constraints: these are hard limits on the size of the manipulated variable moves Δ*u*(*k*) to directly influence the rate of change of the manipulated variables; Output Variable Constraints: hard or soft limits on the outputs of the system are imposed to, for example, avoid overshoots and undershoots (Maciejovski, J.M., 2002). We use the Output constraints and Manipulated Variable Constraints.

## 5. Simulation in MATLAB

Models of the tunnel and ventilator have been obtained through identification of real equipments. Higher traffic intensity causes increase of pollutant concentrations in the tunnel. This intensity is expressed as a vector containing really measured data. The MATLAB environment is used to simulate behavior of the system according to the Fig. 5.

It is a closed-loop control (regulation) of the system with limitations imposed to control quantity and outputs. It uses the internal model and solves optimization problem with the use of quadratic programming. We can choose the prediction horizon P and the control horizon M. The output constraints were set to 6, because this is the maximum input for three pairs of jet fans corresponding with real system. Weight matrix is selected as a diagonal matrix, with each element weighting the corresponding control signal. For instance, if the influence of particular control is to be reduced, then the corresponding diagonal element will be increased to reflect this intention. Weight tuning is the essential task to set the controller. In Fig. 7 we can see the results in comparison to Fig. 6.

### 5.1. Simulation results

The presented simulation results are obtained for the following concentration limits: 6 ppm for CO concentrations, 0.02 ppm for NOx concentrations and 0.05 ppm for visibility concentrations. These values are below really defined maximum limits. According to the curve of the output quantity (Fig. 6) it is apparent, that no emission value has extended the defined limit. However, the value of under-set maximum limit may be extended since one ventilator need not be able to dilute CO concentration sufficiently.

The abbreviation ppm is a way of expressing very dilute concentrations of substances. Just as per cent means out of a hundred, so parts per million or ppm means out of a million. It describes the concentration of something in air.

For this simulation we have six acting jet fans in this part of road tunnel. In the next simulations we have used a possibility to set weighing matrices (*uwt*) for tuning the controller. The control quantity *u* is adapted to the input of Jet Fan control unit. The black lines represent the concentrations of pollution without using the controller. They are named CO. The grey lines represent the concentrations of pollution with using the controller. They are named COr. Opacity and concentration of NO_{x} is below the dangerous limits. The jet fans were switched on two times per day for chosen limits. We can see how affect the ventilation system to reduce the pollution. In this paper we pointed out only to concentration of CO, because this type of pollution is most dangerous for human organism.

As it was mentioned in the previous section the weight tuning is also important part of controller creation.

Well tuned controller leads to optimal control. After changing the weights, the jet fans were switched on only once per day, furthermore the next day all the fans were not switched on in the same conditions.

Opacity and concentration of NO_{x} is below the dangerous limits. The jet fans were switched on once per day for chosen limits. The concentrations of NO_{x} and opacity (OP) are shown in Fig. 8.

For this simulation the NO_{x} concentrations and opacity was below defined maximum limits. When the jet fans are switched on these pollutions are also decreased.

### 5.2. Implementation

The biggest advantage of Automatic Code Generation affects those developers who already use MATLAB and Simulink for simulation and solutions design and to developers who used to tediously rework implemented structures in a language supported by Automation Studio in the past. In the procedures listed below the Automatic Code Generation tool provided by B&R represents an innovation with endless possibilities that help to productively reform the development of control systems. The basic principle is simple: The module created in Simulink is automatically translated using Real-Time Workshop and Real-Time Workshop Embedded Coder into the optimal language for the B&R target system guaranteeing maximum performance of the generated source code. Seamless integration into an Automation Studio project makes the development process perfect (B&R Automation Studio Target for Simulink. 2011). Since the tunnel ventilation system use programmable logic controllers (PLC) it is suitable for real implementation. In our department we have appropriate equipment for this solution.

The elimination of extensive reengineering in Automation Studio allows simple transfer of complex and sophisticated Simulink models to the PLC (Hardware-in-the-Loop). Closed-loop controllers can also be easily tested and optimized on the target system without requiring the user to adjust large amounts of code and run the risk of creating coding errors (Rapid Prototyping). Rapid prototyping: Automatic Code Generation makes it possible to quickly and easily transform sophisticated Simulink based control systems into source code and integrate them into an Automation Studio project. Many potentially successful ideas have been immediately rejected due to the large amount of time required for conversion into executable machine code and the risk of developing a dead end solution.

The “Rapid Prototyping” concept brings an end to this. Using Simulink and the Automatic Code Generation tool provided by B&R, any system, no matter how complex, can be intuitively built, compiled and tested in a short amount of time. This practically eliminates implementation errors as the Automatic Code Generation tool has been well-proven over several years in critical fields like aviation or automotive industry (B&R Automation Studio Target for Simulink. 2011). Nowadays the control algorithm is implemented and awaiting for connection to the real system. Fig. 11. shows the model in Simulink.

We created the model in Simulink according to model for simulations. We replaced the simulated inputs by “B&R IN” blocks and simulated output by the “B&R OUT” block. The Real-time Workshop provides utilities to convert the SIMULINK embedded models in C code and then, with the compiler, compile the code into a real-time executable file. Although the underlying code is compiled into a real-time executable file via the C compiler, this conversion is performed automatically without much input from the user. The concept in Fig. 10. shows that a simulation model can be used in the simulation testing of the predictive control system, and after completing the test, then with simple modification to the original Simulink programs, the same real-time predictive control system can be connected to the actual plant for controlling the plant.

## 6. Conclusion

The paper presents a methodology that has been used for design parametric models of the road tunnel system. We needs identification of system based on data obtained from the real ventilation system. Model from one week data has been created and verified in MATLAB environment. This part is the ground for best design of ventilation control system. Presented results point out that created model by identification method should be validate by several method. Model of a three-dimensional system has been created and simulated in MATLAB environment using the predictive controller. Presented results confirm higher effectiveness of predictive control approach. The weight tuning is important part of controller creation as the simulation results had proved. The predictive controller was successfully implemented to programmable logic controller.