Mathematics and Computers in Simulation 60 (2002) 315–324
A neural predictive controller for non-linear systems Mircea Lazar∗ , Octavian Pastravanu Department of Automatic Control and Industrial Informatics, Technical University “Gh. Asachi” of Ia¸s i, Blvd. Mangeron 53A, 6600 Ia¸s i, Romania
Abstract Design and implementation are studied for a neural network-based predictive controller meant to govern the dynamics of non-linear processes. The advantages of using neural networks for modeling non-linear processes are shown together with the construction of neural predictors. The resulting implementation of the neural predictive controller is able to eliminate the most significant obstacles encountered in non-linear predictive control applications by facilitating the development of non-linear models and providing a rapid, reliable solution to the control algorithm. Controller design and implementation are illustrated for a plant frequently referred to in the literature. Results are given for simulation experiments, which demonstrate the effectiveness of the proposed approach. © 2002 IMACS. Published by Elsevier Science B.V. All rights reserved. Keywords: Control architectures; Predictive control; Neural control; Non-linear system identification; Neural network models; Neural predictors
1. Introduction Predictive control is now widely used in industry and a large number of implementation algorithms has been presented in literature such as extended prediction self-adaptive control (EPSAC) [1], generalized predictive control (GPC) [2] and unified predictive control (UPC) [3]. Most of these control algorithms use an explicit process model to predict the future behavior of a plant and because of this, the term model predictive control (MPC) is often utilized. The most important advantage of the MPC technology comes from the process model itself which allows the controller to deal with an exact replica of the real process dynamics, implying a much better control quality [4,5]. Also, the constraints with respect to input and output signals are directly considered in the control calculation, resulting in very rare or even no constraint violation. The inclusion of the constraints is the feature that most clearly distinguishes MPC from other process control techniques, leading to a tighter control and a more reliable controller. Another important characteristic, which contributes to the success of the MPC technology, is that the MPC algorithms consider plant behavior over a future horizon in time. Thus, the effects of both feedforward ∗
Corresponding author. E-mail addresses:
[email protected] (M. Lazar),
[email protected] (O. Pastravanu). 0378-4754/02/$ – see front matter © 2002 IMACS. Published by Elsevier Science B.V. All rights reserved. PII: S 0 3 7 8 - 4 7 5 4 ( 0 2 ) 0 0 0 2 3 - X
316
M. Lazar, O. Pastravanu / Mathematics and Computers in Simulation 60 (2002) 315–324
and feedback disturbances can be anticipated and eliminated, fact, which permits the controller to drive the process output more closely to the reference trajectory. Although industrial processes usually contain complex non-linearities, most of the MPC algorithms are based on a linear model of the process. Linear models such as step response and impulse response models derived from the convolution integral are preferred, because they can be identified in a straightforward manner from process test data. In addition, the goal for most of the applications (e.g. refinery processing) is to maintain the system at a desired steady state, rather than moving rapidly between different operating points, so a precisely identified linear model is sufficiently accurate in the neighborhood of a single operating point. Often, the output of the controller is obtained using software optimization techniques and the control algorithm cannot always be used in manufacturing applications. As linear models are reliable from this point of view, they will provide most of the benefits with MPC technology. Even so, if the process is highly non-linear and subject to large frequent disturbances (e.g. pH control) a non-linear model will be necessary to describe the behavior of the process. Also in servo control problems where the operating point is frequently changing, a non-linear model of the plant is indispensable (e.g. polymer manufacturing, ammonia synthesis) [4]. In situations like the ones mentioned above, the task of obtaining a high-fidelity model is more difficult to build for non-linear processes. Recently, neural networks have become an attractive tool in the construction of models for complex non-linear systems, because of their inherent ability to learn and approximate non-linear functions. A large number of control and identifications structures based on neural networks has been presented in literature (e.g. [6–10]). Most of the non-linear predictive control algorithms imply the minimization of a cost function, by using computational methods for obtaining the optimal command to be applied to the process. The implementation of the non-linear predictive control algorithms becomes very difficult for real-time control because the minimization algorithm must converge at least to a sub-optimal solution and the operations involved must be completed in a very short time (corresponding to the sampling period). This paper analyzes a neural based non-linear predictive controller, which eliminates the most significant obstacles for non-linear MPC implementation by developing a non-linear model, designing a neural predictor and providing a rapid, reliable solution for the control algorithm. The material is organized as follows. Section 2 presents the procedure of obtaining the neural predictors starting from the design of a non-linear neural network-based model of the process. The functionality of the non-linear neural predictive controller is addressed in Section 3, which also includes detailed comments on the implementation of the cost function minimization. Finally, Section 4 gives a simulated example using a non-linear system taken from literature to show how the predictive controller works.
2. Neural predictors This section presents the role and architecture of the neural predictors resulting from the following non-linear modeling techniques based on neural network principles. 2.1. Non-linear systems modeling using neural networks The use of neural networks for non-linear process modeling and identification is justified by their capacity to approximate the dynamics of non-linear systems including those with high non-linearities or
M. Lazar, O. Pastravanu / Mathematics and Computers in Simulation 60 (2002) 315–324
317
Fig. 1. The neural NARMAX model.
dead time. In order to estimate the non-linear process, the neural network must be trained until the optimal values of the weight vectors (i.e. weights and biases in a vector form organization) are found. In most applications, feedforward neural networks are used, because the training algorithms are less complicated. When it comes to non-linear models, the most general one, which includes the largest class of non-linear processes, is doubtless the NARMAX model [11] given by y(k) = F [u(k − d − 1), u(k − d − 2), . . . , u(k − d − m), y(k − 1), y(k − 2), . . . , y(k − n)] (1) where F[·] is some non-linear function, d the dead time, n and m are the orders of the non-linear system model. A neural network-based model corresponding to the NARMAX model may be obtained by adjusting the weights of a multi-layer perceptron architecture with adequately delayed inputs. The neural NARMAX model is briefly represented in Fig. 1. In this case, the neural network output will be given by y(k) = F N u(k − d − 1), y(k − 1) (2) where FN denotes the input–output transfer function of the neural network which replaces the non-linear function F in (1), and u(k − d − 1), y(k − 1) are vectors which contain m, respectively, n delayed elements of u and y starting from the time instant k − 1, i.e. u(k − d − 1) = [u(k − d − 1), u(k − d − 2), u(k − d − m)]T , y(k − 1) = [y(k − 1), y(k − 2), . . . , y(k − n)]T
(3)
The neural NARMAX corresponds to a recurrent neural network, because some of the network inputs are past values of the network output. If Eq. (2) is explicitly written for a two-layer network, the following expression is obtained for the network output at an arbitrary discrete time instant N y y(k) = wj σj (wju u(k − d − 1) + wj y(k − 1) + bj ) + b
(4)
j =1
where N is the number of neurons in the hidden layer, σ j the activation function for the jth neuron from the hidden layer, wju the weight vector (row vector) for the jth neuron with respect to the inputs stored y in u(k − d − 1), wj the weight vector (row vector) for the jth neuron with respect to the inputs stored in y(k − 1), bj the bias for the jth neuron from the hidden layer, wj the weight for the output layer corresponding to the jth neuron from the hidden layer, and b the bias for the output layer. Such structures with a single hidden layer are considered satisfactory for most of the cases. In order to obtain the model of a non-linear process, the vector u(k − d − 1) defined by (3) is applied as input to
318
M. Lazar, O. Pastravanu / Mathematics and Computers in Simulation 60 (2002) 315–324
the process. The plant output is stored in a vector, which will be used as the target vector for the neural network. The target vector together with an input vector, which contains the input values applied to the plant, are used to train the neural network. The training procedure consists in sequentially adjusting the network weight vectors, so that the mean squared error between the desired response (the values from the target vector) and the network output is minimized. Thus when a certain stop criteria is satisfied, the training algorithm gives a set of optimal values of the weight vectors. The neural network with the constant values for the weight vectors, obtained after the training, represents the non-linear model of the system. Before this model is used to obtain the neural predictors, validation of the neural based model is necessary. Two validation methods are recommended: • a what–if test, which is a time validation test consisting in a comparison between the output of the neural network and the output of the non-linear system when an input signal, different from the input signal used to train the network is used. This test uses the following error index to appreciate the quality of the model (with N the number of samples) N (yn (k) − yp (k))2 error index = k=1N (5) 2 y (k) p k=1 where yp is the process output and yn the neural model output. • a correlation test based on five correlation criteria. If the neural network succeeds in all these tests, it is accepted as a good model of the non-linear system. 2.2. Neural network-based predictors The predictors are necessary for the prediction of future values of the plant output that are considered in the predictive control strategy. The implementation approach proposed in this paper uses neural predictors obtained by appropriately shifting the inputs of the neural based model. The predictive control algorithm utilizes them in order to calculate the future control signal. Neural predictors rely on the neural-based model of the process [10,12]. In order to obtain the model of the non-linear system, the same structure of the neural network given by (4) is considered. A sequential algorithm based on the knowledge of current values of u and y together with the neural network system model gives the i-step ahead neural predictor. From Eq. (4), one can properly derive the network output at the k + 1 time instant: y(k + 1) =
N
y
wj σj (wju u(k − d) + wj y(k) + bj ) + b
(6)
j =1
where u(k − d) = [u(k − d), u(k − d − 1), . . . , u(k − d + 1 − m)]T , y(k) = [y(k), y(k − 1), . . . , y(k + 1 − n)]T
(7)
This is the expression of the one-step ahead predictor, with respect to the notations introduced in Eq. (4). In Fig. 2, the construction of the neural predictors is presented in a suggestive manner. Extending Eq. (6) one step further ahead, y(k + 2) can be obtained and generally, the i-step ahead predictor can
M. Lazar, O. Pastravanu / Mathematics and Computers in Simulation 60 (2002) 315–324
319
Fig. 2. The structure of the neural predictors.
be derived: y(k + i) =
N
y
wj σj (wju u(k − d + i − 1) + wj y(k + i − 1) + bj ) + b
(8)
j =1
where u(k − d + i − 1) = [u(k − d + i − 1), u(k − d + i − 2), . . . , u(k − d + i − m)]T , y(k + i − 1) = [y(k + i − 1), y(k + i − 2), . . . , y(k + i − n)]T
(9)
The neural predictors will be used by the predictive control algorithm for calculating the future control signal to be applied to the non-linear system.
3. Predictive control using neural networks The objective of the predictive control strategy using neural predictors is twofold: (i) to estimate the future output of the plant and (ii) to minimize a cost function based on the error between the predicted output of the processes and the reference trajectory. The cost function, which may be different from case to case, is minimized in order to obtain the optimum control input that is applied to the non-linear plant. In most of the predictive control algorithms a quadratic form is utilized for the cost function: J =
N2
N2 [y(k + i) − r(k + i)] + λ u2 (k + i − 1) 2
i=N1
(10)
i=1
with additional requirements: u(k + i − 1) = 0,
1 ≤ Nu < i ≤ N2
(11)
where Nu is the control horizon, N1 the minimum prediction horizon, N2 the prediction horizon, i the order of the predictor, r the reference trajectory, λ the weight factor, and the differentiation operator. The command u may be subject to amplitude constraints: umin ≤ u(k + i) ≤ umax ,
i = 1, . . . , N2
(12)
The cost function is often used with the weight factor λ = 0. A very important parameter in the predictive control strategy is the control horizon Nu , which specifies the instant time, since when the output of the controller should be kept at a constant value.
320
M. Lazar, O. Pastravanu / Mathematics and Computers in Simulation 60 (2002) 315–324
The output sequence of the optimal controller is obtained over the prediction horizon by minimizing the cost function J with respect to the vector u. This can be achieved by setting ∂J = 0, u = [u(k − d), u(k − d + 1), . . . , u(k − d + Nu − 1)]T (13) ∂u However, when proceeding further with the calculation of ∂J/∂u, a major inconvenience occurs. The analytical approach to the optimization problem needs for the differentiation of the cost function and, finally, leads to a non-linear algebraic equation; unfortunately this equation cannot be solved by any analytic procedure. This is why a computational method is preferred for the minimization of the cost function, also complying with the typical requirements of the real-time implementations (guaranteed convergence, at least to a sub-optimal solution, within a given time interval). The computation of the optimal control signal at the discrete time instant k can be achieved with the following algorithm: • The minimization procedure performed at the previous time instant gives the command vector: u = [u(k − d − 1), u(k − d), . . . , u(k − d + Nu − 2)]T
(14)
At the first time instant, the control input vector will contain some initial values provided by the user. The number of values introduced must be equal to the control horizon. • The step ahead predictors of orders between N1 and N2 are calculated by using the vectors u(k − d + N1 − 1), y(k + N1 − 1) and u(k − d + N2 − 1), y(k + N2 − 1), respectively, described in Section 2, as well as the neural network-based process model. • The output control signal is obtained by minimizing the cost function J with respect to the command vector: u = [u(k − d), u(k − d + 1), . . . , u(k − d + Nu − 1)]T
(15)
Thus, two routines were developed to implement the control algorithm in the Matlab environment. The main routine (main unc—version without constraints, main con—version with constraints) minimizes the cost function and applies the command to the non-linear system. It also creates two vectors in which the output command and the process response are stored. The other routine (neur prd) performs the computations necessary for the neural predictors and constructs the cost function to be minimized by the main routine. For the minimization of the cost function, the Matlab’s Optimal Toolbox functions fminunc and fmincon were used, which allow dealing with either unconstrained or constrained optimization problems. Unlike the fminunc function, fmincon allows imposing constraints with respect to the value of the control input such as upper or lower bounds, which are often required in practice. The cost function J is given as an input parameter for the functions mentioned above together with the initial values for the control input vector and some options regarding the minimization method (the maximum number of iterations, the minimum error value, the use of analytical gradients, etc.). In the case of fmincon the constraints must also be specified as input parameters in a matrix form. The advantage of this non-linear neural predictive controller consists in the implementation method that solves the key problems of the non-linear MPC. The implementation is robust, easy to use and fulfills the requirements imposed for the minimization algorithm. Changes in the parameters of the neural predictive controller (such as the prediction horizons, the control horizon, as well as the necessary constraints) are straightforward operations.
M. Lazar, O. Pastravanu / Mathematics and Computers in Simulation 60 (2002) 315–324
321
Fig. 3. Signals used for training the neural network: (a) the input signal applied to the plant; (b) the plant response.
4. Simulation experiments In order to test the efficiency of the proposed control technique, simulation studies were carried out in Matlab. The following non-linear plant taken from literature was considered [13]: y(k) =
2.5y(k − 1)y(k − 2) + 0.3 cos(0.5(y(k − 1) + y(k − 2))) + 1.2u(k − 1) 1 + y 2 (k − 1) + y 2 (k − 2)
(16)
where y is the output of the plant and u the plant input. The entire design procedure, presented in the previous sections was followed step by step by particularizing the general neural network structure presented in Fig. 1 for m = 1, n = 2 and d = 0 in Eq. (3). A neural network structure with ten neurons in the hidden layer was used. In Fig. 3 the input signal applied to plant (16) and the corresponding response are plotted, which will be used to train the neural network, according to a standard series–parallel scheme [7]. The input signal is a finite sequence of white noise. For neural network training the fast back propagation algorithm (routine trainbpx [14]) was used along the theoretical lines presented in Section 2. In Fig. 4 the model is validated using a time validation test
Fig. 4. Model validation: (a) the input signal (identical for both plant and model); (b) the model response (solid line) versus the plant response (dotted line).
322
M. Lazar, O. Pastravanu / Mathematics and Computers in Simulation 60 (2002) 315–324
Fig. 5. The closed-loop system behavior for a sinusoidal reference signal: (a) the process output (solid line) tracking the reference signal (dotted line); (b) the control signal.
Fig. 6. The tracking error: (a) our approach; (b) Liu’s approach [10].
M. Lazar, O. Pastravanu / Mathematics and Computers in Simulation 60 (2002) 315–324
323
for a sinusoidal input signal. The error index calculated with (5) has the value of 0.0108, which means that the model is a very good approximation of the non-linear system. The optimization problem was addressed in accordance with the computational scenario built in Section 3. With respect to the notations introduced in Section 3, the following concrete values were chosen for the tuning parameters of the predictive control algorithm: N1 = 1, N2 = 3 and Nu = 2. Next, the cost function J is constructed: J =
N2
[y(k + i) − r(k + i)]2
(17)
i=N1
By setting ∂J = 0, ∂u
u = [u(k), u(k + 1)]T
(18)
the minimization algorithm gives the control input vector u = [u(k), u(k + 1)]T to be applied to the plant described by (15). In order to check how the implementation algorithm works there were used several reference input signals, such as sinusoidal signals and different step signals. The initial condition of the plant is (y(k − 1), y(k − 2)) = (0, 0)
(19)
and the goal is to control plant (16) so as to track the reference input tight. Fig. 5 presents the performance of the non-linear neural predictive controller for a sinusoidal reference signal. The results obtained, plotted in Fig. 6, were better than the ones reported in literature for the same non-linear plant, but using a different controller (e.g. [10]). 5. Conclusions This paper has developed a methodology to design and implement neural predictive controllers for non-linear systems. The neural network principles were used to construct a neural-based model of the non-linear plant. Once having such a model, the i-step ahead predictors can be obtained and a quadratic form cost function can be utilized to compute the prediction error. A numerical algorithm has been designed to minimize this error and its Matlab implementation has required the development of two new routines. Simulation experiments on an example selected from literature provide good results, fact that encourages our future plan for approaching the whole complexity of a real-time implementation. Acknowledgements The authors would like to acknowledge ANSTI for financing the work under the grant No. 6177/2000. References [1] R.M.C. De Keyser, A.R. Van Cauwenberghe, Extended prediction self-adaptive control, in: Proceedings of the IFAC Symposium on Identification and System Parameter Estimation, York, UK, 1985, pp. 1317–1322.
324
M. Lazar, O. Pastravanu / Mathematics and Computers in Simulation 60 (2002) 315–324
[2] D.W. Clarke, C. Mothadi, P.S. Tuffs, Generalized predictive control. Part I—The basic algorithm and Part II—Extensions and interpretations, Automatica 23 (1987) 137–160. [3] R. Soeterboek, Predictive Control: A Unified Approach, Prentice-Hall, Englewood Cliffs, NJ, 1992. [4] S. Joe Qin, T.A. Badgwell, An overview of industrial model predictive control technology, in: J.C. Kantor, C.E. Garcia, B. Carnahan (Eds.), Proceedings of the Fifth International Conference on Chemical Process Control, AICHE and CACHE, 1997, pp. 232–256. [5] E.F. Camacho, C. Bordons, Model Predictive Control, Springer, London, 1999. [6] S. Chen, S.A. Billings, P.M. Grant, Non-linear system identification using neural networks, Int. J. Contr. 51 (1990) 1191– 1214. [7] K.S. Narenda, K. Parthasathy, Identification and control of dynamical systems using neural networks, IEEE Trans. Neural Networks 1 (1990) 4–27. [8] K.J. Hunt, D. Sbarado, R. Zbikowski, P.J. Gawthrop, Neural networks for control systems—a survey, Automatica 28 (1992) 1083–1112. [9] S. Fabri, V. Kadirkamanathan, Dynamic structure neural networks for stable adaptive control of nonlinear systems, IEEE Trans. Neural Networks 7 (1996) 1151–1167. [10] G.P. Liu, V. Kadirkamanathan, S.A. Billings, Predictive control for non-linear systems using neural networks, Int. J. Contr. 71 (1998) 1119–1132. [11] S. Chen, S.A. Billings, Representations of non-linear systems: the NARMAX model, Int. J. Contr. 49 (1989) 1013–1032. [12] Y. Tan, R. De Keyser, Neural network based adaptive predictive control, in: D. Clarke (Ed.), Advances in Model-based Predictive Control, Oxford University Press, Oxford, 1994, pp. 358–369. [13] F.C. Chen, H.K. Khalil, Adaptive control of a class of non-linear discrete-time systems using neural networks, IEEE Trans. Automatic Contr. 40 (1995) 791–801. [14] H. Demuth, M. Beale, Neural Network Toolbox Users’s Guide, MathWorks, Inc., 1998, pp. 5-2–5-56.