Hamiltonian Decomposition for Online Implementation of Model Predictive Control
A thesis submitted to the University of Manchester for the degree of Doctor of Philosophy in the Faculty of Science and Engineering
2018
Eduardo N. Poupard
Supervised by Prof. William P. Heath
School of Electrical and Electronic Engineering Contents
1 Introduction 17 1.1 Background and motivation ...... 17 1.2 Statement of originality and thesis outline ...... 18 1.2.1 Part I ...... 19 1.2.2 Part II ...... 19 1.2.3 Part III ...... 21 1.2.4 Additional work ...... 22 1.2.5 Mathematical tools ...... 22
I Unconstrained Optimal Control Problem 23
2 Free-final State Optimal Control Problem 24 2.1 Continuous-time analysis ...... 24 2.1.1 Problem formulation ...... 24 2.1.2 Two-point boundary-value problem ...... 25 2.2 Discrete-time analysis ...... 26 2.2.1 Problem formulation ...... 27 2.2.2 Two-point boundary-value problem ...... 28
3 Linear Quadratic Regulator 29 3.1 Finite-horizon formulation ...... 29 3.1.1 Linear system of equations ...... 31 3.2 Solution via Riccati equation ...... 32 3.2.1 Derivation via linear system of equations ...... 33 3.3 Solution via eigenvalue decomposition ...... 34 3.3.1 Receding horizon control implementation ...... 37 3.3.2 The case of A being singular ...... 38
4 LQ Tracking Problem 41 4.1 Finite-horizon formulation ...... 41 4.1.1 Linear system of equations ...... 42 4.2 Solution via Riccati equation ...... 43 4.2.1 Derivation via linear system of equations ...... 44 4.3 Solution via eigenvalue decomposition ...... 46 4.3.1 Receding horizon control implementation ...... 49
2 II Constrained Optimal Control Problem 52
5 Model Predictive Control Framework 53 5.1 Fundamentals ...... 54 5.1.1 Sparse formulation ...... 55 5.1.2 Necessary conditions ...... 57 5.2 Interior point method ...... 57 5.2.1 Primal-dual interior point algorithm ...... 58 5.2.2 Mehrotra’s predictor-corrector algorithm ...... 59
6 Newton system factorization 62 6.1 General system decomposition ...... 62 6.1.1 Hamiltonian decomposition ...... 64 6.2 Riccati recursion method ...... 66 6.2.1 Algorithm ...... 68 6.2.2 Numerical example ...... 69 6.3 Eigenvalue factorization method ...... 70 6.3.1 Algorithm ...... 70 6.4 Splitting method implementation ...... 72 6.4.1 Algorithms ...... 74 6.4.2 Numerical experiment ...... 75
7 Fast Hamiltonian/GMRES solver 79 7.1 Incomplete LU factorization ...... 80 7.1.1 Tailor-made preconditioners ...... 80 7.2 Companion-like matrix ...... 83 7.2.1 Algorithm ...... 86 7.2.2 Recursion sequence structure on the companion-like matrix . . . . . 87
7.2.3 Nonsingular matrix ZN guarantee ...... 88 7.2.4 Flop count ...... 89 7.2.5 Direct method comparison ...... 90 7.3 GMRES method application ...... 91 7.3.1 Convergence ...... 92 7.3.2 Algorithm ...... 94 7.3.3 Flop count ...... 94 7.4 Numerical experiments ...... 96 7.4.1 Experiment 1: Feasibility ...... 96 7.4.2 Experiment 2: Convergence verification under rounding errors . . . . 97 7.4.3 Experiment 3: Convergence subject to different horizons ...... 99 7.4.4 Experiment 4: Comparison ...... 100 7.4.5 Experiment 5: Numerical issue ...... 102 7.5 The case of A being singular ...... 105 7.5.1 Formulation ...... 105 7.5.2 Numerical example ...... 106 7.5.3 Eigenvalue trajectories ...... 108
3 7.5.4 Convergence experiment ...... 109
8 Conclusions of part I and II 112 8.1 Comments on novel methods (part I) ...... 112 8.2 Further work on novel methods (part II) ...... 113 8.2.1 On the splitting methods ...... 113 8.2.2 On the Hamiltonian recursion solver ...... 113 8.2.3 On the Hamiltonian/GMRES solver ...... 114
III Embedded Model Predictive Control 115
9 Festo AG & Co.KG Collaboration 116 9.1 The Company ...... 116 9.2 Why Model Predictive Control (MPC)? ...... 117 9.2.1 MPC offered by major control-systems vendors ...... 118 9.3 Programmable Logic Controller platform (PLC) ...... 120 9.3.1 Embedded MPC on PLCs ...... 120 9.3.2 Comparison between different PLC platforms ...... 121 9.3.3 Some commercial embedded APC software for PLCs ...... 122
10 Optimization Solver Engine 123 10.1 Tracking and Disturbances Framework on MPC ...... 123 10.1.1 Coordinate transformation and steady-state target problem . . . . . 124 10.1.2 Dynamic regulation problem ...... 125 10.1.3 Constant disturbances and zero offset ...... 125 10.2 Case Study: Flotation-Cell System ...... 127 10.2.1 Single-tank model ...... 128 10.3 Numerical experiment: Flotation-cell system ...... 130 10.3.1 Control design objective and settings ...... 131 10.3.2 Simulation ...... 133 10.4 Optimization Code Generation ...... 136
11 Hardware-in-the-loop Test (HIL) 138 11.1 PLCs Test Rig ...... 138 11.1.1 HIL test diagram ...... 139 11.2 Industrial experiment 1: Flotation-cell system ...... 140 11.2.1 Feasibility of the Hamiltonian recursion method ...... 140 11.2.2 Hamiltonian Recursion vs. Riccati Recursion ...... 143 11.3 Industrial experiment 2: Continuous stirred tank reactor (CSTR) ...... 146 11.3.1 Control design objective and settings ...... 147 11.3.2 Simulation ...... 149 11.3.3 Real-time controller test ...... 151
12 Conclusions of part III 153 12.1 Further work ...... 153
4 A Relevant code for parts II and III 155
A.1 HQ preconditioner function ...... 155
A.2 D˜hqr companion-like matrix recursion function ...... 157
A.3 D˜hqr companion-like vector recursion function ...... 159
A.4 HR preconditioner function ...... 160
A.5 Application of GMRES method for companion-like matrix D˜hqr ...... 161 A.6 S-Function for Flotation-cell system ...... 163 A.7 S-Function for Continuous stirred tank reactor (CSTR) ...... 165
B Double-tank model 167
54, 359 words
5 List of Figures
1.1 Layout of the novel contribution presented in part II, and its place within the Model Predictive Control (MPC) framework...... 21
3.1 Computation of gain matrix P1 for the receding horizon control on the LQR. Comparison between the Riccati equation (red) and the eigendecomposition approach from Algorithm 3.2 (blue)...... 38
4.1 Computation of gain matrix P1 and gain vector π1 for the receding hori- zon control on the LQ tracking problem. Comparison between the Riccati equation (red) and the eigendecomposition approach from Algorithm 4.2 (blue)...... 51
6.1 Simulation with MPC controller using the Riccati recursion method. . . . . 69 6.2 Comparison of the computational time during the simulation of the online part of the MPC controller using the Riccati recursion and eigenvalue method. 76 6.3 Convergence of a naive implementation of the splitting method on system (6.23). The number of iterations on the splitting method was set at i = 30. Each line represents a vector whose length is the number of k−iterations of the Mehrotra’s algorithm (Algorithm 5.1). The elements of the vector correspond to the residual norm after i−iterations...... 78
7.1 Relative error corresponding to the optimal solution vector, p = [x, u, λ, µ, t], during a closed-loop MPC simulation on a second order plant. The x axis corresponds to the sample time t. The y axis represents the interior-point
iterations, k. The relative error (z axis) is computed by ρ = kpcom −
prick∞/kprick∞ at each (t, k)...... 90 7.2 Comparison of the computational time during the simulation of the MPC controller on system (7.1) between the Hamiltonian recursion (blue) and the Riccati recursion (red) methods...... 91
7.3 MPC simulation for the oscillating-masses example with nx = 40 states using the Hamiltonian/GMRES solver within an interior-point algorithm.
First plot shows the evolution of the states xk subject to constraints, with
initial conditions xk = 3.5 for the displacements, and xk = 0 for the veloci- ties. Second plot shows the profile of the control inputs subject to constraints. 97
6 7.4 Convergence of the Hamiltonian/GMRES solver for the oscillating-masses
example with nx = 40 states. The x axis corresponds to the sample time t throughout the MPC simulation. The y axis corresponds to the iterations of the interior-point algorithm at every sample time/(t − sample). The z axis shows the profile of the number of iterations of the GMRES method that solves system (7.1)...... 98 7.5 Relative residual of the Hamiltonian/GMRES solver for the oscillating- masses example. The x axis corresponds to the sample time t through- out the MPC simulation. The y axis corresponds to the iterations of the interior-point algorithm at every sample time/(t − sample). The z axis shows the profile of the relative residual of the GMRES method that solves system (7.1)...... 98 7.6 Convergence of the Hamiltonian/GMRES solver for the oscillating-masses
example with number of masses m = 80 (nx = 160 states). The x axis corresponds to the number of samples time/(t − sample) throughout the MPC simulation. The y axis corresponds to the iterations of the interior- point algorithm. The z axis refers to the number of iterations of the GMRES method that solves system (7.1)...... 99 7.7 Four different MPC simulations for the oscillating-masses example with
nx = 40 states using the Hamiltonian/GMRES solver within an interior- point algorithm. With four different values of the horizon, N = 5, 10, 20, 40. The x axis corresponds to the GMRES iterations and the y axis represents the number of recurrences that happen throughout all the IPM iterations, without distinction of the sample time in which a given GMRES run occurred.100 7.8 Comparison between the Hamiltonian/GMRES solver (Algorithm 7.3) and the GMRES preconditioned method proposed in [1]. All the parameters for the MPC simulation of the oscillating-masses example resembled exactly those in [1]. The x axis corresponds to the IPM iterations and the y axis represents the number of GMRES iterations...... 101 7.9 Closed-loop simulation of the second order system (6.17). Double precision, u = 1 × 10−16, was used (which is standard for MATLAB®). The MPC controller is tested by two optimization solvers, the Hamiltonian/GMRES and the Riccati recursion...... 103 −1 −1 7.10 Infinity norm k·k∞ profile of the vector M T . For clarity, every plot also highlights the maximum and minimum norm. Double precision, u = 1 × 10−16, was used. The x axis corresponds to the number of samples time/(t − sample) throughout the MPC simulation. The y axis represents the iterations of the interior-point algorithm...... 104 7.11 Closed-loop simulation of the second order system (6.17) by an MPC con- troller with the Hamiltonian/GMRES solver. High precision arithmetic was set up at u = 1 × 10−45, using the Multiprecision Computing Toolbox [2]. . . 105 7.12 Condition number κ of matrix D˜ = H−1D H−1 subject to variations hqrα Qα hqr R of the α parameter. Experiment set with horizon N = 2...... 107
7 7.13 Eigenvalue trajectories of matrix D˜ = H−1D H−1. Each trajectory hqrα Qα hqr R (y axis) is the absolute value |µ| of an eigenvalue µ = a + bi. The x axis represents the variation of the α parameter...... 108 7.14 Imaginary plane for the eigenvalues µ = a+bi of matrix D˜ = H−1D H−1. hqrα Qα hqr R Experiment set with horizon N =2...... 109 7.15 GMRES experiment with different values of the horizon N. The x axis represents the α parameter and the y axis is the number of GMRES iterations.110 7.16 GMRES experiment with different values of the horizon N. The x axis represents the α parameter and the y axis is the condition number κ of matrix D˜ = H−1D H−1...... 111 hqrα Qα hqr R
9.1 A Bionic Kangaroo designed by Festo Bionic Learning Network. The flight phase control uses an optimal state feedback controller [3]...... 117 9.2 MPC hierarchy found in industrial applications (diagram from [4])...... 118 9.3 Some of the major control-systems vendors offering MPC software in their corresponding product portfolio. Within the industrial jargon, MPC soft- ware is known as APC which stands for Advanced Process Control. All these brands are registered trademarks...... 119 9.4 CPX platform. Festo proprietary PLC...... 120 9.5 Research overview of the implementation of MPC algorithms on PLCs. Ref- erences: 1. G. Valencia-Palomo & J.A. Rossiter [5], 2. M. Kvasnica et al. [6], 3. G. Frison et al. [7], 4. D.K.M. Kufoalor et al. [8], 5. B. Huyck et al. [9] and 6. M. Pereira et al. [10]...... 121
10.1 Closed-loop system diagram with MPC controller for tracking reference and zero offset...... 127 10.2 Flotation-cell system for three tanks connected in series...... 128 10.3 Closed-loop digital MPC controller for a Flotation-cell system with three tanks. The MPC controller is based on the control diagram in Figure 10.1 using a Matlab® function. For the plant, an S-function is coded for three nonlinear first-order differential equations (10.18)...... 134 10.4 Closed-loop MPC simulation for a Flotation-cell system with three tanks using the optimization solver presented in Algorithm 7.1...... 135 10.5 Code generation process diagram for an MPC algorithm, from MATLAB® code to Structured-text language (IEC 61131-3 environment)...... 136
11.1 Test rig for an MPC controller experiment. It has two PLCs and a touch screen (HMI). Physical connection between equipment is done through Eth- ernet TCP/IP protocol...... 138 11.2 Hardware-in-the-loop (HIL) diagram. The MPC controller is implemented on the PLC and the model is running in MATLAB®. All the equipment is connected through OPC protocol (Open Platform Communications). . . . 139 11.3 Image captured from CODESYS environment. It shows the code size in the PLC after the code generation process (Figure 10.5)...... 140
8 11.4 Image captured from Festo HMI touch screen device showing real-time per- formance of the main tailor-made screen for the Flotation-cell system. . . . 141 11.5 Real-time closed-loop MPC controller for a Flotation-cell system with three tanks using the optimization solver presented in Algorithm 7.1...... 141 11.6 Image captured from CODESYS already logged into the Festo PLC (online). It shows the MPC function block...... 142 11.7 Image captured from CODESYS already logged into the Festo PLC (online). It shows the cycle time for the solution of the optimization problem (5.1). . 142 11.8 Image captured from Festo HMI touch screen device showing real-time per- formance of the main tailor-made screen for the Flotation-cell system with two PLCs. Comparative test between Hamiltonian recursion and Riccati recursion methods...... 143 11.9 Measured outputs y corresponding to the level sensors. Two real-time closed-loop MPC controllers running in parallel for two Flotation-cell sys- tems, with three tanks each. Two optimization solvers used: (i) the Hamil- tonian recursion method, in blue (Algorithm 7.1) and (ii) the Riccati recur- sion approach, in red (Algorithm 6.1)...... 144 11.10 Manipulated variables u corresponding to the process valves. Two real- time closed-loop MPC controllers running in parallel, for two Flotation-cell systems with three tanks each. Two optimization solvers used: (i) the Hamiltonian recursion method, in blue (Algorithm 7.1) and (ii) the Riccati recursion approach, in red (Algorithm 6.1)...... 145 11.11 Diagram of a Continuous stirred tank reactor (CSTR), from [11]...... 146 11.12 Closed-loop digital MPC controller for a CSTR reactor. The MPC con- troller is based on the control diagram in Figure 10.1 using a Matlab® function. For the plant, an S-function is coded for the nonlinear third-order differential equations (11.1)...... 149 11.13 Closed-loop MPC simulation for a Continuous stirred tank reactor (CSTR) using the optimization solver presented in Algorithm 7.1. The measured outputs y correspond to the molar concentration c, the reactor tempera- ture T and the level tank h. The inputs u are the outlet flow F and the
temperature Tc of the jacketed cooling system...... 150 11.14 Image captured from CODESYS showing the size of the code after gener- ating the runtime files for the MPC controller...... 151 11.15 Image captured from the Festo HMI touch screen device showing real-time performance of the main tailor-made screen for the Continuous stirred tank reactor (CSTR)...... 151 11.16 Real-time closed-loop MPC controller experiment for a Continuous stirred tank reactor (CSTR) using the optimization solver presented in Algorithm 7.1. The measured outputs y correspond to the molar concentration c, the reactor temperature T and the level tank h. The inputs u are the outlet
flow F and the temperature Tc of the jacketed cooling system...... 152
B.1 Flotation-cell system for three tanks connected in series (a single-tank array in each side and a double-tank array in the middle)...... 167
9 List of Algorithms
3.1 Solution of LQR with Vaughan’s method ...... 37 3.2 Non-recursive for unconstrained free-final state MPC ...... 37 4.1 Eigenvalue decomposition for LQ tracking ...... 49 4.2 Eigenvalue decomposition for unconstrained MPC tracking problem . . . . 50 5.1 Mehrotra’s Predictor-Corrector ...... 61 6.1 Riccati recursion method for the step direction computation ...... 68 6.2 Eigenvalue factorization method for the step direction computation . . . . . 71
6.3 Eigenvalue factorization for Mc offline part (time-variant systems) . . . . . 74
6.4 Eigenvalue factorization for Mc offline part (time-invariant systems) . . . . 75
6.5 Eigenvalue factorization for Mc online part (time-invariant systems) . . . . 75
7.1 Direct factorization of system (7.1) via companion-like matrix D˜hqr ..... 86 7.2 Remaining step direction computation ∆˜ p ...... 87 7.3 Fast Hamiltonian/GMRES solver for the solution of system (7.1) using the
companion-like matrix D˜hqr ...... 95
10 List of Tables
7.1 Computational cost dependent on N of the Hamiltonian recursion Algo- rithm 7.1 ...... 89 7.2 Computational cost dependent on N of the Riccati recursion Algorithm 6.1 89 7.3 Computational cost of the fast Hamiltonian/GMRES Algorithm 7.3, de- pendent on horizon N ...... 94
9.1 Comparative PLC properties between different manufacturers ...... 121 9.2 APC software embedded on PLCs currently offered by some manufacturers 122
10.1 Physical parameters for the Flotation-cell system, refer to [12]...... 132
11.1 Physical parameters for the Continuous stirred tank reactor (CSTR), refer to [13]...... 147
11 Abstract
Reliable and optimal decision-making tools are essential in industry to achieve high per- formance. One of these tools is Model Predictive Control (MPC), which is an advanced control technique that generates an action that affects the controlled variables of a given process with respect to a performance criteria, while satisfying the process’ physical and operational restrictions. At the core of the MPC algorithm lies an optimization prob- lem that is solved by a numerical method at every sample time. New demand for more self-contained and autonomous modular processes has seen MPC embedded in small- scale platforms, such as Programmable Logic Controllers (PLCs). This has prompted a need for custom-made numerical methods that help to efficiently run the computation- ally demanding optimization algorithms. In this thesis, we design effective optimization solvers for PLCs by proposing several approaches that factorize the Newton system of the interior-point method (IPM). These approaches are based on the two-point boundary- value (TPBV) problem structure, rarely explored in MPC, called the Hamiltonian system. One of the main proposals is that, once the augmented system is in the Hamiltonian form, it can be reduced to an incomplete LU factorization in which two possible options are available to compute the solution of the system: (i) A direct method called the Hamil- tonian recursion method, and (ii) an iterative method called the Hamiltonian/GMRES method. Regarding the former, a forward substitution of a sequence of matrices is carried out, whereas with the latter, a Krylov method is used. We prove that the convergence of the iterative method is bounded and its rate is quantified. Numerical experiments demonstrate that both methods are feasible and efficient compared to the state-of-the-art methods. Declaration
No portion of the work referred to in the thesis has been submitted in support of an application for another degree or qualification of this or any other university or other institute of learning
13 Copyright
i. The author of this thesis (including any appendices and/or schedules to this thesis) owns certain copyright or related rights in it (the Copyright) and s/he has given The University of Manchester certain rights to use such Copyright, including for administrative purposes.
ii. Copies of this thesis, either in full or in extracts and whether in hard or electronic copy, may be made only in accordance with the Copyright, Designs and Patents Act 1988 (as amended) and regulations issued under it or, where appropriate, in accordance with licensing agreements which the University has from time to time. This page must form part of any such copies made.
iii. The ownership of certain Copyright, patents, designs, trademarks and other intellec- tual property (the Intellectual Property) and any reproductions of copyright works in the thesis, for example graphs and tables (Reproductions), which may be described in this thesis, may not be owned by the author and may be owned by third par- ties. Such Intellectual Property and Reproductions cannot and must not be made available for use without the prior written permission of the owner(s) of the relevant Intellectual Property and/or Reproductions.
iv. Further information on the conditions under which disclosure, publication and com- mercialisation of this thesis, the Copyright and any Intellectual Property and/or Re- productions described in it may take place is available in the University IP Policy (see http://documents.manchester.ac.uk/DocuInfo.aspx?DocID=24420), in any relevant Thesis restriction declarations deposited in the University Library, The University Li- brary’s regulations (see http://www.library.manchester.ac.uk/about/regulations/) and in The University’s policy on Presentation of Theses.
14 Acknowledgments
-The number of people who have been kind enough to help me, directly or indirectly, throughout this amazing journey is simply untraceable, and therefore, I apologize in ad- vance to those who I unintentionally left out from the following acknowledgements.
-My main gratitude to my supervisor, Prof. William P. Heath, who first of all believed in my PhD proposal and thereafter, thoroughly guided me through the difficult (but yet fascinating) intricacies of the PhD. I can now say, it was all worthy and specially fun. Also special thanks to all the colleagues from the control group who have given me advice and guidance. Likewise, I am most grateful to Stefan G¨uttel, from the School of Mathematics, whose collaboration turned out to be essential for the content of chapters 6 and 7.
-To David Bell, whose friendship has had the perfect balance, from discussing ideas about optimal control to enduring those off-road runs up on the hills in the Peak District.
-To all my family; my mom, my grandmother, my two sisters and my brother, who have constantly given me love and support. I promise that I will make up for all the time that
I have been away.
-To Isabelle, whose love and unconditional support made this PhD project a success, which would not have been possible otherwise.
-And last but not least, the research presented throughout this dissertation has received funding from two entities, Festo AG & Co.KG and the Mexican Council of Science and
Technology (CONACYT). Festo granted me a contract for a feasibility study and the de- velopment of a built-in MPC function block for their PLCs. Specially, I would like to thank
Chris Stich and Florian Zieker, from the PA Future Concepts, for their constant support and their trust from the beginning of the project. I am also truly grateful to CONACYT for providing me during 5 years with the most valuable asset all over the world: time.
Eduardo Poupard
Manchester UK, 2018
15 To my mom, grandmother and siblings who have always been there Chapter 1
Introduction
1.1 Background and motivation
Model Predictive Control (MPC) is an optimization technique that uses a dynamic model of a process to generate a prediction of the control input actions subject to inequality constraints. It is this last feature, along with its multivariable structure, that sets MPC apart from other more classical control techniques, i.e. the natural incorporation of the system’s physical restrictions and the possibility to integrate several I/Os, all within the same controller [4]. The history of MPC dates back to the 1970s, especially in the petro- chemical industry where MPC was applied to large-scale systems, for instance, distillation columns. Some of the first research published about MPC was by (i) [14], where MPC was called Model Algorithmic Control (MAC) and (ii) [15], where MPC was defined as
Dynamic Matrix Control (DMC). During the last two decades, some of the major control software vendors have picked up on the MPC advantages and it can now be found in a wide variety of industries, especially in the process industry [16]. Nowadays, due to advances in research and computational technologies, it is a matter of time before MPC is widespread and has a direct effect on several public topics, such as cancer treatment [17].
From a mathematical viewpoint, an MPC controller computes the solution of an opti- mization problem at every sample time. This means that some necessary and sufficient conditions have to be satisfied. In the case of the necessary conditions, these boil down to a nonlinear system of equations that has to be solved by a numerical method. Since there has always been a tradeoff between the size of the system and the time needed to obtain the solution of the optimization problem, much of the research over the last years has been
17 about developing state-of-the-art techniques that render these numerical methods more efficient. This is exactly where this thesis’ motivation lies.
This thesis proposes a couple of methods that efficiently compute the two-point boundary- value (TPBV) problem from optimal control. We chose to address this problem because it is the natural structure (in the form of a linear system of equations) that appears within the Sequential Quadratic Programming (SQP) algorithm, which is an optimization method widely used for nonlinear MPC (refer to [18] and [19]). An application using SQP based on the Riccati recursion can be found in [20]. The Riccati approach is used throughout the thesis to compare the performance of our own methods. Riccati-based solvers can be found in [21], [7], [22] and [23]. Furthermore, high performance optimization solvers that can be deployed into embedded platforms are FORCES [24], qpDUNES [23] and OSQP [25].
Analysis of their corresponding applicability and performance can be found in [26], [23] and [25] respectively. Additional optimization solvers for general purposes are ACADO
Toolkit [27] and OOQP [28].
Likewise, the need for more autonomy on self-contained processes has seen the MPC ap- plied to small-scale systems [29], where embedded platforms are commanding the control task. Platforms such as field-programmable gate arrays (FPGAs) have received plenty of attention from the MPC research community. Work on this can be found in [30], [31], [32] and [33]. In this thesis, we analyze the online implementation of MPC on another kind of platform quite widespread in industry, called Programmable Logic Controllers (PLCs).
The collaboration between a company (more details about this below) and our research has looked at the development of tailor-made optimization solvers for such devices.
Finally, the main focus of this thesis is on the numerical feasibility and efficiency of the proposed MPC algorithms, and therefore topics regarding robustness, stability and opti- mality of MPC are beyond the scope of this current work. Excellent references for these topics are [34], [13] and [35].
1.2 Statement of originality and thesis outline
This thesis contains 12 chapters and two appendices, split in three parts,
1. Unconstrained Optimal Control Problem.
2. Constrained Optimal Control Problem.
18 3. Embedded Model Predictive Control.
The chapters corresponding to each part and their specific details are described in the following sections.
1.2.1 Part I
This part contains four chapters related to optimal control problems that have only equal- ity constraints. In chapter 2, we briefly outline the fundamentals of the free-final state optimal control formulation in which its necessary conditions give rise to the two-point boundary-value (TPBV) problem. This is the only mathematical framework required throughout the thesis, since we deal with only quadratic objective functions with linear constraints (equality and inequality), and therefore, the sufficient conditions are satisfied.
In chapter 3, a brief analysis of the finite-horizon Linear Quadratic Regulator (LQR) and its fundamentals are given for discrete-time dynamic systems, with emphasis on the linear system of equations required to solve the problem. The factorization of this system could be carried out by two methods mainly, (i) by the well-known Riccati equation [36], or
(ii) by an eigenvalue decomposition (less known) [37]. We present here the first contribu- tion of the thesis related to the implementation of the eigenvalue decomposition on the receding horizon idea for unconstrained Model Predictive Control (MPC), along with its implications for online applications.
In chapter 4, the fundamentals of the Linear Quadratic tracking problem are given along with an extension of the eigenvalue decomposition to factorize this problem. This is the second contribution of the thesis. As a third contribution, we also apply this extension to the receding horizon idea and its implications on online controllers are discussed. The novel results in this part are published in [38].
1.2.2 Part II
This part contains four chapters, mainly related to efficient numerical methods applied to optimization algorithms for MPC. In chapter 5, a brief outline of the Model Predic- tive Control (MPC) framework is given, especially about the extension of the necessary conditions presented in part I, which are known as the Karush-Kuhn-Tucker (KKT) con- ditions [39], and include the inequality constraints into the formulation. As stated before, the sufficient conditions hold due to a quadratic performance index and linear constraints
19 (convex). When the necessary conditions become nonlinear a numerical method is needed, as opposed to the LQR, whose necessary conditions are linear and there exists a closed- form solution. The primal-dual interior point method [40] is chosen because the size of the problem remains constant throughout the iterations (contrary to active-set methods) and it has a polynomial-time convergence. For practical use, there exist some varieties of interior-point algorithms, such as the Mehrotra’s Predictor-Corrector algorithm [41], which is used here as an outer algorithm for the methods presented in the following chap- ters.
The interior-point method uses the second derivative of the gradient, which boils down to a linear system of equations (Newton system). In chapter 6, we decompose the Newton system, which resembles the structure of the two-point boundary-value (TPBV) problem, into the Hamiltonian form. We then present three algorithms to factorize this system, (i) the well-known Riccati recursion method [21], (ii) the eigenvalue decomposition and (iii) a modification of the eigenvalue decomposition method, which drops some of the compu- tational cost offline and uses the splitting method to compute the remaining part. The contributions presented up to this part are published in [38] and [42] (in abstract form).
Chapter 7 presents the main contributions of this thesis. In this chapter, the Hamiltonian form system is preconditioned by two matrices (left and right), giving rise to an incomplete
LU factorization. An interesting result is that the matrix produced by this factorization can be given explicitly and has the form of a companion-like matrix. We propose two methods to factorize this matrix: (i) A direct method called Hamiltonian recursion solver, which carries out a forward substitution, computing a sequence of matrices that are then used to factorize the system. Some numerical experiments are shown to demonstrate fea- sibility and equivalence against the Riccati recursion method. (ii) An iterative method called Hamiltonian/GMRES solver, which uses a Krylov method to find the solution of the system. Fast convergence is a requirement for iterative methods in order to be efficient against direct methods. We prove that if the GMRES method is used to solve the system of the companion-like matrix, convergence is guaranteed to be bounded and depends on the size of the system (number of states). Several experiments are carried out so as to prove convergence and feasibility. We also address a special case in which this convergence is no longer guaranteed. Figure 1.1 depicts a summary of the novel methods presented in chapter 7, along with the splitting approach from chapter 6, and their place within the
Model Predictive Control framework. The methods, results, theorems and experiments
20 presented throughout this chapter (and the splitting method) will be part of a journal paper which is currently in preparation.
Nonlinear Model Predictive Control (NMPC)
Numerical Optimization Methods: Newton Type Methods
Sequential Quadratic Programming (SQP)
Interior-Point Method (IPM)
Linear-quadratic subproblems factorization Two-point boundary-value Problem (TPBV)
Preconditioned Preconditioned Hamiltonian\Eigenvalue Hamiltonian Hamiltonian Riccati-Recursion Decomposition and Decomposition with Decomposition with Method Splitting methods GMRES method Symplectic recursion
Iterative methods Direct methods
Novel methods
Band-structure exploiting methods
Figure 1.1: Layout of the novel contribution presented in part II, and its place within the Model Predictive Control (MPC) framework.
Chapter 8 gives a brief analysis of the main results from parts I and II, highlighting the opportunities for future research.
1.2.3 Part III
The final part of the thesis contains four chapters, mainly addressing the implementa- tion of MPC algorithms on small-scale devices known as Programmable Logic Controllers
(PLCs). In chapter 9, we give the details of the collaboration between our research project and a company called Festo AG & Co.KG.
Part I and part II, except for chapter 4, deal exclusively with the regulator problem, i.e. the controller drives the states from some initial conditions to the equilibrium point (zero).
In chapter 10, we provide the extension in which all the methods presented previously can be applied to the tracking MPC problem. Likewise, an industrial case study is presented,
21 called the Flotation-cell system, where the Hamiltonian recursion method is tested in sev- eral simulations. After this, the details and steps for the code generation are given. The objective of this part is to translate the code of the Hamiltonian recursion method, written in Matlab®, into the PLC language.
After the PLCs code is generated, a test rig is set up with two PLCs and a HMI touch panel (in chapter 11). The necessary code for the PLCs and the touch screen is developed.
To evaluate performance, a Hardware-in-the-loop (HIL) test is carried out between the real-time MPC controller (based on the Hamiltonian recursion method) embedded in the
PLCs; and a Flotation-cell system emulated in Matlab®. In addition, a comparative test is done between the Hamiltonian recursion method and the Riccati recursion approach.
For the last part of this chapter, an additional industrial case study is tested, the Con- tinuous stirred tank reactor (CSTR), in order to evaluate performance and to determine whether the Hamiltonian recursion method is versatile and numerically feasible in em- bedded platforms. Chapter 12 gives a brief analysis of the main results from part III, highlighting the opportunities for future research. We comment on possible alternatives to make the generated code more efficient.
1.2.4 Additional work
A byproduct of this research is published in [43]. An MPC algorithm designed for this thesis identifies the optimal state trajectory and commands the DC motor controllers installed on a multi-actuator system. This implementation resulted in energy savings for the electromechanical system.
1.2.5 Mathematical tools
The foundations of this thesis are:
Optimal control theory, with references found in [44] and [36].
Numerical methods for optimization problems, with references found in [45] and [46].
For the interior point method, one can refer to [40].
Applied linear algebra, specially references related to the factorization of systems of
linear equations, such as [47] and [48].
22 Part I
Unconstrained Optimal Control Problem
23 Chapter 2
Free-final State Optimal Control Problem
2.1 Continuous-time analysis
This part deals with unconstrained optimal control problems. In order to avoid ambiguity with the title, we refer to problems that are subject solely to equality constraints (such as dynamical systems). In part II, we will work with an extension to these problems by adding inequality constraints into the formulation.
2.1.1 Problem formulation
The calculus of variations gives rise to a suitable framework to solve optimal control problems. It is an extensive topic that is supported by rigorous mathematical proofs. Here, we will present a brief summary oriented to the part that is important for our description ahead. For more information related to calculus of variations within the optimal control theory refer to [49] and [44]. We will consider a continuous system expressed as a vector form which contains nonlinear differential equations
x˙(t) = f(x(t), u(t), t), (2.1) where the vector function f : R(n+m+1) 7→ Rn has continuity condition in order to have a
n m unique solution, where x(t) ⊂ R and u(t) ⊂ R . The initial conditions, x(t0) are given.
24 Moreover, consider the following scalar performance index
Z tf J = ϕ(x(tf ), tf ) + L(x(t), u(t), t)dt, (2.2) to where ϕ(x(tf ), tf ) is the terminal cost and L(x(t), u(t), t) is a scalar function. The problem
∗ is to find an optimal control law u (t) which minimizes (2.2) over the interval to ≤ t ≤ tf subject to system (2.1). Using the Lagrange multiplier λ(t) to adjoin the system, the performance index becomes
Z tf > Jˆ = ϕ(x(tf ), tf ) + L(x(t), u(t), t) + λ (t)[f(x(t), u(t), t) − x˙] dt. (2.3) to
Defining another scalar function which encapsulates L(x(t), u(t), t) and λ(t), whose name is the Hamiltonian Function (based on the Hamiltonian’s principle in mechanics [44, 36]).
H(x(t), u(t), λ(t), t) = L(x(t), u(t), t) + λ>f(x(t), u(t), t). (2.4)
Including the Hamiltonian function (2.4) in the performance index (2.3)
Z tf > Jˆ = ϕ(x(tf ), tf ) + H(x(t), u(t), λ(t), t) − λ (t)x ˙ dt. (2.5) to
We need to find from (2.5) an expression that represents its first variation. Thus, carrying out integration by parts of the last term of Jˆ (see [44])
Z tf > > ˙ > Jˆ = ϕ(x(tf ), tf ) − λ (tf )x(tf ) + λ (to)x(to) + H(x(t), u(t), λ(t), t) + λ x(t) dt. (2.6) to
As previously mentioned, the control input u(t) has to minimize (or maximize) the per- formance index. Then, let (2.6) be evaluated by the first variation for fixed times, to and tf
" # " # ∂ϕ Z tf ∂H ∂H δJˆ = − λ> δx + λ>δx + + λ˙ > δx + δu dt. (2.7) t=to ∂x | {z } to ∂x ∂u | {z } t=tf 2 | {z } |{z} 1 3 4
2.1.2 Two-point boundary-value problem
The first variation δJˆ has to be zero in order to be an extremum. To avoid determining
δx and δu explicitly, we make the coefficients of (2.7) vanish:
1. At the final time tf the coefficient of the variation δx(tf )(x(tf ) is not known) must
25 vanish. Namely, the Lagrange multiplier λ(tf ) must be equal to
> ∂ϕ λ (tf ) = . (2.8) ∂x(tf )
2. As the initial state is given x(to), the variation δx(to) is zero and therefore this term vanishes.
3. It would be complicated to analyze directly the variation of δx and δu along the
trajectory within the integrand, so it is easier to make their coefficients vanish, i.e.
for the states x
∂H λ˙ > = − . (2.9) ∂x
4. And for the control inputs u
∂H = 0. (2.10) ∂u
Equations (2.1), (2.9) and (2.10) are known as the necessary conditions of the optimal control problem (2.2). For more information, one can refer to the Pontryagin’s minimum principle [50]. The solution of this system renders Jˆ an extremum (minimum or maximum).
To ensure Jˆ to be a minimum, it is well known that its second order variation must be
δJ 2 ≥ 0 [36]. This condition holds if a quadratic performance index and linear constraints are considered. This will be the case throughout this thesis. The boundary conditions of the system are the initial condition of the state x(to) and the final condition of the Lagrange multiplier defined in (2.8). Such a problem is known as the two-point boundary- value problem (TPBVP) and there exist several methods to solve it. In the next chapter we will present two of these methods, the Riccati equation and the eigenvalue decomposition.
2.2 Discrete-time analysis
Throughout this dissertation we are mostly interested in computer-based controllers that are applicable to real-time industrial applications. Hence, it is necessary to have a suitable optimal control approach that renders the previous section (the continuous formulation) usable for these applications. Such an approach is the discrete-time formulation, which
26 is an approximation of the continuous one. We will present an analogy of the previous section suited for discrete-time systems.
2.2.1 Problem formulation
The following description is standard, from [44, p.42-45] and [36, p.19-24]. The analogy of system (2.1) to a nonlinear discrete-time dynamical system is
k xk+1 = f (xk, uk) , (2.11)
nx with initial condition x0. The state variables are defined as xk ∈ R and the control
nu inputs uk ∈ R . The discrete performance index is
N−1 X k J = φ (N, xN ) + L (xk, uk) , (2.12) k=0 where function φ is a terminal cost that evaluates the final state xN at the final sample time k = N. The function Lk is a Lagrangian function. The form of these two functions depends on the application itself and one that suits a wide variety of systems in engineering is the quadratic function, which will be utilized throughout this dissertation. Since this optimal control problem is subject to the equality constraints (2.11), its derivative df, with respect to x and u, has to be adjoined to the derivative of the performance index (2.12), dJ. To do so, J can become
N−1 X h k | k i J = φ (N, xN ) + L (xk, uk) + λk+1 f (xk, uk) − xk+1 , (2.13) k=0 where λk+1 is called the Lagrange multiplier of the equality constraints. An additional
k scalar function named the Hamiltonian is used to encapsulate L and λk+1 and thus, facilitating handling in subsequent derivations. This Hamiltonian function is
k k | k H (xk, uk) = L (xk, uk) + λk+1f (xk, uk) . (2.14)
The performance index after some manipulations is now
N−1 | 0 X h k | i J = φ (N, xN ) − λN xN + H (x0, u0) + H (xk, uk) − λkxk . (2.15) k=1
27 A necessary condition to find a minimum of (2.15) is that its increment dJ should be zero
0 0 ∂φ | ∂H ∂H dJ = − λN dxN + dx0 + du0 ∂xN ∂x0 ∂u0 | {z } | {z } | {z } 1 2 3a N−1 k k N k−1 X ∂H | ∂H X ∂H | + − λk dxk + duk + − xk dλk . (2.16) ∂xk ∂uk ∂λk k=1 | {z } | {z } k=1 | {z } 4 3b 5
2.2.2 Two-point boundary-value problem
As shown in section 2.1.2, in order for dJ to be zero, all its coefficients must vanish. These are the necessary conditions for optimality. The interpretation of (2.16) is as follows,
1. The boundary condition of the Lagrange multiplier is
∂φ λN = . (2.17) ∂xN
2. As the initial state is given x0, then dx0 = 0 and this term vanishes.
3. To avoid determining directly duk from k = 0,...,N − 1, we set its coefficients to zero, namely
∂Hk = 0. (2.18) ∂uk
Equation (2.18) is known as the stationary condition.
4. The same as before with dxk from k = 0,...,N − 1, its coefficient must vanish
∂Hk λk = . (2.19) ∂xk
5. And also for dλk from k = 1,...,N, its coefficient must vanish
∂Hk xk+1 = . (2.20) ∂λk+1
Relations (2.19) and (2.20) are known as the costate and state equations respectively. This system, along with the initial x0 and final condition (2.17) is the two-point boundary-value problem (TPBVP) for the discrete-time optimal control problem of system (2.11).
28 Chapter 3
Linear Quadratic Regulator
In 1960, Kalman [51] showed that the linear quadratic regulator (LQR) can be solved by applying the Riccati equation backwards in time. One technique used to solve this equation was proposed by MacFarlane [52], where an eigenvalue decomposition is applied.
This method is limited since it can be only used for infinite-horizon problems. Vaughan generalized this approach (for continuous [53] and discrete-time systems [37]), where the solution can also be obtained for finite-horizon problems. In Vaughan’s work the prediction horizon N is included explicitly within the algorithm. In this part we first present the basic formulation of the free-final state finite-horizon LQR formulation, followed by the well-known solution method, the Riccati equation. We finalize with the implementation of the eigenvalue decomposition as an alternative solution for the problem.
3.1 Finite-horizon formulation
The following description is standard [36, p.32-47]. The mathematical formulation of the free-final state problem for the finite-horizon LQR is described below
N−1 1 | 1 X | | min x PN xN + x Qxk + u Ruk X ,U 2 N 2 k k k=0
s.t. xk+1 = Axk + Buk, x0 = x(0) (3.1)
nx where the affine equality constraints represent the system dynamics, xk ∈ R is the
nu state variable with sequence X = (x0, x1, . . . , xN ), uk ∈ R is the input variable with sequence U = (u0, u1, . . . , uN−1) and N is the prediction horizon. We will assume across
29 √ this dissertation that the pair (A, B) is stable and the pair Q, A is detectable. For simplicity, we will consider a time-invariant system. Weighting matrices (Q, P ) ≥ 0 and
R > 0 are symmetric. The Hamiltonian function for (3.1) is
1 Hk = x|Qx + u|Ru + λ| (Ax + Bu ) , (3.2) 2 k k k k k+1 k k
nx where λk ∈ R is the Lagrange multiplier. By applying the necessary conditions for optimality defined in (2.20) and (2.19) , the coupled state and costate equations can be described as follows
x A −BR−1B| x k+1 k = , (3.3) λk QA| λk+1 where the coefficient matrix in this system is referred as the discrete Hamiltonian matrix.
Assuming matrix A is non-singular, system (3.3) can be expressed as a backward recursion, i.e.
−1 −1 −1 xk A A BR B| xk+1 = , (3.4) −1 −1 −1 λk QA A| + QA BR B| λk+1
2nx×2nx where the coefficient matrix of (3.4) is defined as Hm ∈ R . Now, using the station- ary condition (2.18)
∂Hk | 0 = = Ruk + B λk+1, (3.5) ∂uk we can obtain the optimal control input
−1 | uk = −R B λk+1. (3.6)
We also need to take into account the initial condition x0 and the final condition (2.17) for this two-point boundary-value problem, that for this case becomes
∂φ λN = = PN xN . (3.7) ∂xN
To solve the problem it is necessary to use the sweep method presented in Bryson & Ho [44, p. 47] that computes a sequence of nx × nx matrices, Pk, which makes the final condition
30 (3.7) hold for all the times k ≤ N, i.e.
λk = Pkxk. (3.8)
Bearing in mind (3.8), we can now set the control input (3.6) in terms of the states in order to have a state feedback controller. To achieve this, we substitute the dynamical system of (3.1) and solve for uk in (3.6), i.e.
| −1 | uk = − (B Pk+1B + R) B Pk+1Axk. (3.9)
To obtain the sequence of matrices Pk, two different methods are presented in sections 3.2 and 3.3 respectively.
3.1.1 Linear system of equations
One of the structures seldom explored in the optimal control literature of the finite-horizon problem is its general form as a linear system of equations. Strictly speaking, the solution to this problem boils down to the solution of a system in the form of Dz = b. All methods used to solve the optimal control problem are in fact carrying out a factorization of such a system and in doing so, finding the system’s solution.
To show this general form we will first change slightly the system (3.4) by decomposing matrix Hm into
−1 A−1 A−1BR−1B| A 0 IBR−1B| Hm = = , (3.10) QA−1 A| + QA−1BR−1B| −QI 0 A| then system (3.4) becomes
A 0 x IBR−1B| x k k+1 = . (3.11) −QI λk 0 A| λk+1
The system (3.11) does not explicitly use the inverse of A, which does not exist in systems with delays. It follows that this system forms, along with the initial condition x0 and the final condition (3.7), the following system of equations of the two-point boundary-value
31 problem
−I xk x0 −A 0 IG λk 0 Q −I 0 A| x 0 k+1 −A 0 IG λk+1 0 .. Q −I 0 A| . xk+2 0 = − , (3.12) . . . . . ...... λk+2 0 ...... . . . . . . . . . . . . .. −A 0 IG . . | Q −I 0 A xN 0 PN −I λN 0 | {z } | {z } | {z } Dlqr zlqr blqr
−1 2(N+1)nx×2(N+1)nx where G = BR B|. The dimensions are Dlqr ∈ R and zlqr, blqr ∈
R2(N+1)nx . We will show that (3.12) is the general linear system of equations that applies for either the LQR, the LQ tracking problem or the Model Predictive Control (MPC), and that its factorization entails the solution of such methods.
Remark 3.1.1. From a practical viewpoint, the solution of system (3.12) for the case of the LQR (or LQ tracking problem) lacks value and usually there is no need to obtain it explicitly, since the main objective of this control strategy is to use the state feedback control law already derived in (3.9). On the contrary, for MPC, system (3.12) becomes relevant as it does need to be computed explicitly at every sample time, as we will show in chapter 6.
3.2 Solution via Riccati equation
To solve the finite-horizon problem, we can find a sequence of matrices Pk from k = 0 ...N. It is known that such a sequence represents in fact the solution to the Riccati equation.
To show this, the control input (3.9) is substituted into the state equation of (3.1)
| −1 | xk+1 = A − B (B Pk+1B + R) B Pk+1A xk. (3.13)
32 Since λk = Pkxk, substituting (3.13) into the costate equation of system (3.3) gives
| | −1 | Pkxk = Qxk + A Pk+1 A − B (B Pk+1B + R) B Pk+1A xk.
From this relation, it is easy to see the backward recursion structure of matrix Pk, i.e.
| | | −1 | Pk = Q + A Pk+1A − A Pk+1B (R + B Pk+1B) B Pk+1A. (3.14)
Therefore the sequence of matrices Pk is found by carrying out a backward recursion of
(3.14) with the initial parameter PN , which is the weighting matrix of the terminal con- dition in (3.1). The matrix quadratic sequence Pk is the well-known discrete time-varying
Riccati equation. It is easy to observe that Pk just depends on given parameters, neither the state nor the costate (there is no need to compute them in real-time applications).
Therefore, it can be computed offline and stored in the computer memory ready to be used in the online controller.
3.2.1 Derivation via linear system of equations
Another way to derive the Riccati equation is to factorize the system Dlqrzlqr = blqr (3.12).
For this case, we substitute the final condition in the system, λN = PN xN , into the sub- system of xN−1 and λN−1, namely
A 0 x IG x N−1 N = , −QI λN−1 0 A| λN or
−1 xN = (GPN + I) AxN−1, and
| −1 λN−1 = QN−1xN−1 + A PN (GPN + I) AxN−1.
−1 So, if we define PN−1 = QN−1 + A|PN (GPN + I) A
λN−1 = PN−1xN−1.
33 This relation shows that it is possible to factorize the system (3.12) by computing a sequence of matrices
−1 | −1 | Pk = Q + A Pk+1 I + BR B Pk+1 A, (3.15)
from k = N − 1 ... 0. Hence, once P0 is computed, λ0 = P0x0 can be found triggering a forward substitution to solve the system. Ultimately, if the Sherman-Morrison-Woodbury formula [47] is implemented on (3.15), then evidently
| | | −1 | Pk = Q + A Pk+1A − A Pk+1B (R + B Pk+1B) B Pk+1A, which is nothing but the Riccati equation derived in (3.14).
3.3 Solution via eigenvalue decomposition
This method was proposed by Vaughan [37]. Firstly, we define a matrix
0 I J = , −I 0 then, it can be shown that
| HmJ Hm = J . (3.16)
A matrix Hm (3.10) satisfying (3.16) is called symplectic. This means that if µ ∈ µ(Hm), where µ(Hm) is the set of distinct eigenvalues of Hm, then 1/µ ∈ µ(Hm) [48, p.420-421], i.e.
u u υ 1 υ | Hm = µ ⇒ Hm = . υ υ −u µ −u
Assuming that Hm is diagonalizable (semisimple eigenvalues), it can be expressed in terms of the following transformation
−1 Hm = VDV , (3.17)
34 where
M V11 V12 V¯11 V¯12 D = , V = , V−1 = , −1 M V21 V22 V¯21 V¯22 where M ∈ Cnx is diagonal and has the eigenvalues outside the unit circle (the unstable ones). Thus, M −1 ∈ Cnx has the stable eigenvalues (inside the unit circle) and columns of V ∈ C2nx×2nx are the eigenvectors. For simplicity, it is assumed that the eigenvalues of
Hm are distinct. We carry out the following change of variable
x w i i = V , (3.18) λi yi in system (3.4) by using transformation (3.17)
w w k k+1 = D . (3.19) yk yk+1
The solution of (3.19) is easy to obtain since D is diagonal. In terms of the final conditions the solution is
N−k wk M wN = . (3.20) −(N−k) yk M yN
This solution is ill-conditioned when N − k → ∞, therefore rewriting (3.20)
−(N−k) wN M wk = . (3.21) −(N−k) yk M yN
Recalling final condition (3.7), its relation with (3.19) at the final time N is
V21wN + V22yN = P (V11wN + V12yN ) , (3.22)
solving for yN in terms of wN
yN = T wN , (3.23)
35 where
−1 T = − (V22 − PV12) (V21 − PV11) . (3.24)
Now, using (3.21)
yk = Tkwk, (3.25) where
−(N−k) −(N−k) Tk = M TM . (3.26)
Next step is to use xk from (3.19) and (3.25)
xk = V11wk + V12yk = (V11 + V12Tk) wk, (3.27) or
−1 wk = (V11 + V12Tk) xk. (3.28)
Substituting (3.28) into λk from (3.19)
−1 λk = (V21 + V22Tk)(V11 + V12Tk) xk, (3.29) or
λk = Pkxk, (3.30) where
−1 Pk = (V21 + V22Tk)(V11 + V12Tk) . (3.31)
Equation (3.31) is an equivalent expression of the discrete time-varying Riccati equation shown in (3.14) to solve the finite-horizon LQR problem (3.1). Algorithm 3.1 shows the procedure to solve a time-invariant closed-loop linear system,
36 Algorithm 3.1 Solution of LQR with Vaughan’s method −1 1: Hm = VDV . EV Decomposition −1 2: T = − (V22 − PV12) (V21 − PV11)
*Solution of the system given x0:
3: for k = 0 to N − 1 do
−(N−(k+1)) −(N−(k+1)) 4: Tk+1 = M TM −1 5: Pk+1 = (V21 + V22Tk+1)(V11 + V12Tk+1) −1 6: uk = − (B|Pk+1B + R) B|Pk+1Axk
7: xk+1 = Axk + Buk
8: end for
3.3.1 Receding horizon control implementation
To pave the way for Model Predictive Control (MPC), the receding horizon control (RHC) idea will be implemented on the previous eigendecomposition approach. Roughly speak- ing, the RHC idea ([54] and [55]) is the theoretical framework for MPC (heretofore still unconstrained) which only requires u0 of the sequence U computed for the finite-horizon LQR problem. Therefore, for time-invariant systems, the eigenvalue decomposition is com- puted only for u0 and with a computational load independent of the horizon. Algorithm 3.2 contemplates this, and is proposed by Poupard & Heath [38].
Algorithm 3.2 Non-recursive for unconstrained free-final state MPC −1 1: Hm = VDV . EV Decomposition −1 2: T = − (V22 − PV12) (V21 − PV11)
−(N−1) −(N−1) 3: T1 = M TM −1 4: P1 = (V21 + V22T1)(V11 + V12T1) *Optimal control input for RHC:
−1 5: u0 = − (B|P1B + R) B|P1Ax0 . x0 given
Conversely, for computing u0 using the Riccati equation (3.14) a backward recursion