# On Structure Exploiting Numerical Algorithms for Model Predictive Control Isak Nielsen

Linköping studies in science and technology. Thesis. No. 1727 Licentiate’s Thesis On Structure Exploiting Numerical Algorithms for Model Predictive Control Isak Nielsen LERTEKNIK REG AU T O MA RO TI C C O N T L LINKÖPING Division of Automatic Control Department of Electrical Engineering Linköping University, SE-581 83 Linköping, Sweden http://www.control.isy.liu.se [email protected] Linköping 2015 This is a Swedish Licentiate’s Thesis. Swedish postgraduate education leads to a Doctor’s degree and/or a Licentiate’s degree. A Doctor’s Degree comprises 240 ECTS credits (4 years of full-time studies). A Licentiate’s degree comprises 120 ECTS credits, of which at least 60 ECTS credits constitute a Licentiate’s thesis. Linköping studies in science and technology. Thesis. No. 1727 On Structure Exploiting Numerical Algorithms for Model Predictive Control Isak Nielsen [email protected] www.control.isy.liu.se Department of Electrical Engineering Linköping University SE-581 83 Linköping Sweden ISBN 978-91-7685-965-0 ISSN 0280-7971 Copyright © 2015 Isak Nielsen Printed by LiU-Tryck, Linköping, Sweden 2015 Tillägnas min underbara familj Abstract One of the most common advanced control strategies used in industry today is Model Predictive Control (mpc), and some reasons for its success are that it can handle multivariable systems and constraints on states and control inputs in a structured way. At each time-step in the mpc control loop the control input is computed by solving a constrained finite-time optimal control (cftoc) problem on-line. There exist several optimization methods to solve the cftoc problem, where two common types are interior-point (ip) methods and active-set (as) methods. In both these types of methods, the main computational effort is known to be the computation of the search directions, which boils down to solving a sequence of Newton-system-like equations. These systems of equations correspond to unconstrained finite-time optimal control (uftoc) problems. Hence, high-performance ip and as methods for cftoc problems rely on efficient algorithms for solving the uftoc problems. The solution to a uftoc problem is computed by solving the corresponding Karush-Kuhn-Tucker (kkt) system, which is often done using generic sparsity exploiting algorithms or Riccati recursions. When an as method is used to compute the solution to the cftoc problem, the system of equations that is solved to obtain the solution to a uftoc problem is only changed by a low-rank modification of the system of equations in the previous iteration. This structured change is often exploited in as methods to improve performance in terms of computation time. Traditionally, this has not been possible to exploit when Riccati recursions are used to solve the uftoc problems, but in this thesis, an algorithm for performing low-rank modifications of the Riccati recursion is presented. In recent years, parallel hardware has become more commonly available, and the use of parallel algorithms for solving the cftoc problem and the underlying uftoc problem has increased. Some existing parallel algorithms for computing the solution to this type of problems obtain the solution iteratively, and these methods may require many iterations to converge. Some other parallel algorithms compute the solution directly (non-iteratively) by solving parts of the system of equations in parallel, followed by a serial solution of a dense system of equations without the sparse structure of the mpc problem. In this thesis, two parallel algorithms that compute the solution directly (non-iteratively) in parallel are presented. These algorithms can be used in both ip and as methods, and they exploit the sparse structure of the mpc problem such that no dense system of equations needs to be solved serially. Furthermore, one of the proposed parallel algorithms exploits the special structure of the mpc problem even in the parallel computations, which improves performance in terms of computation time even more. By using these algorithms, it is possible to obtain logarithmic complexity growth in the prediction horizon length. v Populärvetenskaplig sammanfattning Modellprediktiv reglering (eng. Model Predictive Control (mpc) ) är en reglerstrategi som kan användas för att styra system med flera styrsignaler och/eller utsignaler samt ta hänsyn till exempelvis begränsningar i styrdon. Ett exempel på ett sådant system är antisladdsystemet i en modern bil, där bromsarna kan styras automatiskt av exempelvis en mpc-regulator för att motverka att bilen sladdar. Den grundläggande principen med mpc-regulatorn är att styrsignalen beräknas på ett optimalt sätt genom att lösa ett optimeringsproblem. Detta optimeringsproblem består av en kostnadsfunktion som ska minimeras, en modell av hur systemet beter sig samt de begränsningar som finns på styrsignaler och/eller utsignaler. Detta optimeringsproblem måste lösas varje gång en styrsignal ska beräknas, och således är det viktigt att det finns effektiva metoder för att lösa denna typ av problem. Exempel på sådana metoder som är vanligt förekommande är så kallade inrepunkt-metoder (eng. interior-point (ip)) och aktivmängd-metoder (eng. active-set(as)). I dessa två metoder så löser man optimeringsproblemet genom att lösa ett antal förenklade delproblem. Då mpc-regulatorer ska användas för att styra processer som kräver att styrsignalen beräknas snabbt behövs effektiva algoritmer för att lösa dessa förenklade delproblem tidseffektivt, och det är sådana algoritmer denna avhandling fokuserar på. De förenklade delproblemen löses genom att beräkna lösningen till ett linjärt ekvationssystem som kallas Karush-Kuhn-Tucker (kkt)-systemet. Detta ekvationssystem kan man lösa med exempelvis generella metoder eller med så kallade Riccatirekursioner som utnyttjar strukturen i problemet. När man använder en as-metod för att lösa mpc-problemet så görs endast små strukturerade ändringar av kkt-systemet mellan varje förenklat delproblem, men detta har tidigare inte utnyttjats i Riccatirekursionen. I denna avhandling presenteras ett sätt att utnyttja detta genom att bara göra små ändringar av Riccatirekursionen för att på så vis minska beräkningstiden för att lösa delproblemet. Nuförtiden är det vanligt att lösningen till optimeringsproblemet beräknas med hårdvara som klarar av parallella beräkningar, och därför har behovet av parallella algoritmer för att lösa mpc-problem ökat. Att man kan göra beräkningar parellellt innebär att flera delar av problemet kan beräknas samtidigt, och på så sätt minskar den totala beräkningstiden för att lösa optimeringsproblemet. I denna avhandling presenteras två olika parallella algoritmer som kan användas i både ip- och as-metoder. Båda beräknar lösningen till de mindre delproblemen parallellt med ett förutbestämt antal steg, till skillnad från många andra parallella algoritmer där ett okänt (ofta stort) antal steg krävs för att beräkna lösningen. Båda algoritmerna utnyttjar och bevarar strukturen i mpc-problemet, men den senaste algoritmen kan utnyttja strukturen mer effektivt och kan i många fall lösa problemet snabbare. vii Acknowledgments I would like to take the opportunity to express my deepest gratitude to my cosupervisor Dr. Daniel Axehill. Your guidance and support over the past three years have been invaluable to me. Thank you for giving me feedback and inspiration that enables me to improve my research. Since I started here we have had many interesting discussions, and I really appreciate your enthusiasm that always motivates me. I am also very grateful for the valuable feedback and support I have gotten from my supervisor Prof. Anders Hansson. Also, thank you Prof. Svante Gunnarsson and Prof. Fredrik Gustafsson for inviting me to start as a PhD student at the Automatic Control group. I would also like to thank Prof. Svante Gunnarsson for being an excellent head of the Division of Automatic Control, and Ninna Stensgård for helping me with administrative things and for making everything run smoothly in the group. This thesis has been greatly improved by excellent comments from Dr. Sina Khoshfetrat Pakazad, Lic. Daniel Simon, Lic. Johan Dahlin, Lic. Jonas Linder, M. Sc. Hanna Nyqvist and fil. kand. Linnea Ernebro. I am sincerely grateful that you spent some of your valuable time on proof-reading this thesis! Also, thank you Dr. Gustaf Hendeby and Dr. Henrik Tidefelt for providing the LATEX-class that has been used to write this thesis. During my time as a PhD student at the Division of Automatic Control I have had the pleasure of making a lot of new friends. Unfortunately, I can only mention some of you here. Thank you Jonas Linder for being a really good roommate and friend. Also, thank you Johan Dahlin, Hanna Nyqvist, Niclas Evestedt, Clas Veibäck, Sina Khoshfetrat Pakazad, André Carvalho Bittencourt, Karl Granström, Daniel Simon, Emre Özkan, Tohid Ardeshiri, Manon Kok, Ylva Jung, Patrik Axelsson and Niklas Wahlström for being good friends and for sharing fun skiing and canoeing trips, parties and after parties, wine tasting and safari trips and much more. And thanks everyone else at the Automatic Control group for making this a stimulating and friendly working environment! I would also like to thank all my friends outside the university for all fun stuff we have done together, and for all your support. Even though we don’t see each other as often as before it still means a lot to me to have you as friends! Financial support from the Swedish Research Council (vr) and ceniit (Center for Industrial Information Technology) are hereby gratefully acknowledged. Finally, my wonderful parents Kaj and Anneli, my siblings Hugo, Julia and Axel and my lovely girlfriend Linnea: Your love and support mean everything to me, and I wouldn’t be where I am today if it weren’t for all of you! Thank you for always being there for me when I need it the most, and thank you for being the amazing persons you are. I love you all! Linköping, September Anno Domini 2015 Isak Nielsen ix Contents Notation xiii 1 Introduction 1.1 Background and Motivation . . . . . . . . . . . . . . . . . . . . . . 1.2 Contributions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.3 Thesis Outline . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 Optimization 2.1 Basic Concepts . . . . . . . . . . . . . . . . 2.2 Convex Optimization . . . . . . . . . . . . 2.3 Lagrange Duality . . . . . . . . . . . . . . 2.3.1 Weak and strong duality . . . . . . 2.4 Optimality Conditions . . . . . . . . . . . 2.5 Quadratic Programming . . . . . . . . . . 2.6 Active-set Methods . . . . . . . . . . . . . 2.6.1 Adding constraints . . . . . . . . . 2.6.2 Removing constraints . . . . . . . . 2.6.3 Basic primal active-set method . . 2.7 Interior-point Methods . . . . . . . . . . . 2.7.1 Basic primal interior-point method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 Model Predictive Control 3.1 Defining the Model Predictive Control Problem . . . . . . . . . . . 3.2 Solving the Model Predictive Control Problem . . . . . . . . . . . . 3.2.1 Interior-point methods . . . . . . . . . . . . . . . . . . . . . 3.2.2 Active-set methods . . . . . . . . . . . . . . . . . . . . . . . 3.3 Newton Step Computation . . . . . . . . . . . . . . . . . . . . . . . 3.4 Solving the Karush-Kuhn-Tucker System using the Riccati Recursion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.4.1 Derivation of the Riccati recursion . . . . . . . . . . . . . . 3.4.2 Handling singular Karush-Kuhn-Tucker systems . . . . . . 3.5 Computing Eliminated Dual Variables . . . . . . . . . . . . . . . . 3.A Model Predictive Control Formulations . . . . . . . . . . . . . . . . xi 1 1 2 3 5 6 7 7 8 9 10 10 12 13 13 14 15 19 21 22 22 25 27 29 29 32 33 36 xii Contents 4 Low-rank Modifications of Riccati Factorizations 4.1 Problem Formulation . . . . . . . . . . . . . . . . . . . . . . . . . 4.2 Low-rank Modification of the Riccati Factorization . . . . . . . . 4.2.1 Removing control input constraints from the working set 4.2.2 Adding control input constraints to the working set . . . 4.2.3 The impact on subsequent time-steps . . . . . . . . . . . . 4.2.4 Algorithms for modifying the Riccati factorization . . . . 4.3 Extension to General Constraints . . . . . . . . . . . . . . . . . . 4.3.1 Primal and dual problem . . . . . . . . . . . . . . . . . . . 4.3.2 Methods to handle general constraints . . . . . . . . . . . 4.4 Numerical Results . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.4.1 Modification of Riccati factorization . . . . . . . . . . . . 4.A Proof of Lemma 4.1 . . . . . . . . . . . . . . . . . . . . . . . . . . 4.B Derivation of the Dual Problem . . . . . . . . . . . . . . . . . . . 4.B.1 Construct the dual problem . . . . . . . . . . . . . . . . . 4.B.2 Relation between primal and dual variables . . . . . . . . . . . . . . . . . . . . . . . 37 38 38 39 41 43 45 46 46 48 52 52 56 57 57 61 5 Parallel Newton Step Computation 5.1 Problem Decomposition . . . . . . . . . . . . . . . . . . . 5.1.1 Solution of the subproblems . . . . . . . . . . . . . 5.1.2 Solution of a primal degenerate subproblem . . . . 5.2 Parallel Computation of Newton Step . . . . . . . . . . . . 5.2.1 Algorithms for parallel Newton step computation 5.3 Numerical Results . . . . . . . . . . . . . . . . . . . . . . . 5.A Proof of Theorem 5.4 . . . . . . . . . . . . . . . . . . . . . 5.B Proof of Lemma 5.8 . . . . . . . . . . . . . . . . . . . . . . 5.C Proof of Theorem 5.10 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65 67 70 72 75 77 79 82 85 86 6 Parallel Riccati Recursion 6.1 Problem Decomposition and Reduction . . . . . . . . 6.1.1 Splitting into independent parts . . . . . . . 6.1.2 Eliminate local variables in a subproblem . . 6.1.3 Constructing the master problem . . . . . . . 6.2 Computing the Riccati Recursion in Parallel . . . . . 6.2.1 Parallel computation of the Riccati recursion 6.2.2 Parallel Riccati recursion algorithms . . . . . 6.3 Numerical Results . . . . . . . . . . . . . . . . . . . . 6.4 Comparison with Chapter 5 . . . . . . . . . . . . . . 6.A Proof of Lemma 6.2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87 . 88 . 89 . 89 . 95 . 98 . 98 . 99 . 101 . 105 . 107 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 Conclusions and Further Work 109 7.1 Conclusions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109 7.2 Further Work . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110 A Linear Algebra 113 Bibliography 117 xiii xiv Notation Notation Notation Notation R Z Zi,j Sn S+n n S++ R (A) N (A) C⊥ Cc A0 A0 xy xy [a, b] (a, b) relint C dom f rank A ∇f ∇2 f ∇x f ∇2x f x I (In ) x,y ∀x O (g(x)) Meaning Set of real numbers Set of integers Set of integers {i, i + 1, . . . , j − 1, j} Set of symmetric real matrices with n columns Set of positive semi-definite matrices with n columns Set of positive definite matrices with n columns Range of a matrix A Nullspace of a matrix A The orthogonal complement of the set C Complement of the set C The matrix A is positive semidefinite The matrix A is positive definite Each component in x is larger than or equal to the corresponding component in y Each component in x is strictly larger than the corresponding component in y Interval of real numbers z ∈ R such that a ≤ z ≤ b Interval of real numbers z ∈ R such that a < z < b Relative interior of the set C Domain of the function f : Rn → R The rank of a matrix A Gradient of the function f : Rn → R Hessian of the function f : Rn → R Gradient of the function f : Rn → R with respect to the variable x Hessian of the function f : Rn → R with respect to the variable x Column vector of stacked vector components, i.e., T T x = [x0T , . . . , xN ] Identity matrix (of order n) Definition of the variable x as y For all x Complexity growth dominated by g(x) when x → ∞ xv Notation Abbreviations Abbreviation admm as cftoc cpu fpga gpu ip licq kkt lq mhe mpc qp uftoc Meaning Alternating Direction Method of Multipliers Active-Set Constrained Finite-Time Optimal Control Central Processing Unit Field Programmable Gate Array Graphics Processing Unit Interior-Point Linear Independence Constraint Qualification Karush-Kuhn-Tucker Linear-Quadratic Moving Horizon Estimation Model Predictive Control Quadratic Program Unconstrained Finite-Time Optimal Control 1 Introduction Controlling systems and processes to behave in a desired way is one of the main goals in automatic control. It has become an important part of today’s modern society and is found in a wide range of different technologies. Some examples of applications where automatic control is used today are, e.g., process industries, such as pulp factories, control systems in fighter aircrafts, automotive applications, such as autonomous vehicles, cruise controllers and anti-break systems in cars, and many more. In all these examples, some kind of controller is used to achieve the desired behaviour of the system, and this controller can be of different types and complexities depending on for example the control objectives and the system dynamics. 1.1 Background and Motivation Model Predictive Control (mpc) is a control scheme that combines optimization and automatic control. Essentially, an mpc controller consists of a dynamic model of the system, constraints on states and control inputs and an objective function. The control input is computed by predicting the behaviour of the system using the dynamic model, and minimizing (or maximizing) the objective function while satisfying the constraints. The possibility to easily handle multivariable dynamic models and constraints on states and control inputs has made mpc one of the most widely spread and commonly used advanced control strategies in industry (Maciejowski, 2002). Traditionally mpc has been used mainly in petrochemical process plants where the sample time of the controller was long enough to compute a solution to the optimization problem. However, as computational hardware and algorithms for 1 2 1 Introduction solving the optimization problem in the mpc controller have developed, it has been possible to apply mpc to other processes that require much shorter sampling times and/or to more complex systems. Since the optimization problem is usually solved on-line, the usefulness of mpc heavily relies on efficient optimization routines for solving the mpc optimization problem. The optimization problem can be of different types depending on, for example, the dynamical model and the constraints, and different methods can be used to compute the solution. Common types of methods are for instance interior-point (ip) and active-set (as) methods, and in both these types of methods the main computational effort is spent while solving a sequence of subproblems. These subproblems can be solved using, for example, generic solvers or Riccati recursions, and the performance in terms of computation time of these types of methods is dependent on efficient algorithms for solving the subproblems. The focus in this thesis is to present newly developed algorithms which can be used as subroutines in for example ip and as solvers to compute the solution to the subproblems when applied to the optimization problem in mpc. 1.2 Contributions The contributions in this thesis are presented in chapters 4, 5 and 6, and are based on published as well as unpublished material. In Chapter 4, theory and algorithms for utilizing low-rank modifications of the Riccati recursion are presented. This chapter contains unpublished material, and it includes and extends the results presented in the publication I. Nielsen, D. Ankelhed, and D. Axehill. Low-rank modification of Riccati factorizations with applications to model predictive control. In Proceedings of the 52nd IEEE Conference on Decision and Control, pages 3684–3690, Firenze, Italy, December 2013 The second contribution is on theory and algorithms for computing the Newton step for mpc problems in parallel and is presented in Chapter 5. This material is an edited version of the publication I. Nielsen and D. Axehill. An O(log N) parallel algorithm for Newton step computation in model predictive control. In Proceedings of the 19th IFAC World Congress, pages 10505–10511, Cape Town, South Africa, August 2014 The editing has been made to improve the presentation of the results, and no additional technical results have been added. The third contribution is presented in Chapter 6. This contribution is on theory and algorithms for computing the Riccati recursion in parallel in time, and will be presented in the publication I. Nielsen and D. Axehill. A parallel structure-exploiting factorization algorithm with applications to model predictive control. Accepted for publication at the 54th IEEE Conference on Decision and Control, December 2015 1.3 1.3 Thesis Outline 3 Thesis Outline The thesis is organized as follows. In Chapter 2, basic concepts and notation in optimization are introduced, and some common methods to solve convex optimization problems are outlined. In Chapter 3, the mpc problem is discussed and different methods to solve the underlying optimization problem are presented. The main purpose with this chapter is to provide a foundation for the contributions that are presented in chapters 4, 5 and 6. In Chapter 4, it is shown how to utilize low-rank modifications of the Riccati recursion when it is used to compute Newton steps in an as solver for mpc problems. The chapter is concluded with numerical results for the proposed algorithm. Chapter 5 contains theory, algorithms and numerical results for computing the Newton step directly in parallel. The algorithms in this chapter can be applied when solving mpc problems using, for example, ip or as methods. In Chapter 6, theory and algorithms for computing the Riccati recursion directly in parallel are presented, and numerical results for a Matlab implementation and an ansi-c implementation of the proposed algorithm are shown. The thesis is concluded in Chapter 7 and this chapter also contains ideas for further research on the presented topics. In addition, Appendix A contains basic results from linear algebra that is used in the thesis. 2 Optimization Mathematical optimization, or simply optimization, is a framework where the best possible solution to a problem is sought for. Which solution that is regarded to be the best is dependent on the corresponding optimization problem. The optimization problem consists of an objective function and constraints that define the feasible set of the problem, i.e., which solutions that are allowed. The best solution is the element that is in the feasible set, i.e., satisfies all constraints, of the problem and minimizes, or maximizes depending on the problem definition, the objective function. Depending on the optimization problem being solved there can exist a unique solution, several solutions or no solution. Three examples of optimization problems are driving a car between two cities as fast (i), as cheap (ii) or by driving as short distance as possible (iii), while keeping the speed limit and driving on the road. The objective function in the first problem is the total time consumed when travelling between the two cities, and in the second problem, it is the total cost for fuel, wear, etc. In the third problem, the objective function is the total distance travelled, and in all three problems the constraints are, e.g., to keep the speed limits, to stay on the road and physical constraints such as the maximum power given by the car engine. By using these three objective functions three different optimization problems are obtained, all having (possibly) different optimal (or best) solutions. As mentioned earlier, each of the problems might have several solutions, a unique solution or no solution. For example, the problem of driving as short distance as possible has a unique solution if there is only one road that gives the shortest distance. If there are several roads between the cities of equal minimal distance, then there exist several solutions where each is equally good. If there are no roads at all between the two cities the problem does not have any solution. 5 6 2 Optimization The purpose of this chapter is to introduce the basic concepts of optimization and also to give a brief survey of some common families of optimization methods that are used to compute the optimal solution to certain types of optimization problems. The chapter and the introduced notation are inspired by Boyd and Vandenberghe (2004), which is an extensive reference on optimization. 2.1 Basic Concepts Consider an optimization problem given in the form minimize f0 (x) subject to fi (x) ≤ 0, i ∈ Z1,m hi (x) = 0, i ∈ Z1,p , x (2.1) where f0 (x) is the objective function, fi (x) are the inequality constraint functions, hi (x) are the equality constraint functions and x ∈ Rn is the optimization variable. Here, Zi,j is used to denote the set of integers {i, i + 1, . . . , j}. The domain D ⊆ Rn of the optimization problem (2.1) is the set of all points where the objective and constraint functions are defined, i.e., D, m \ dom fi ∩ i=0 p \ dom hi , (2.2) i=1 and a point x ∈ D is said to be feasible if it satisfies the inequality and equality constraints in (2.1). If there exists at least one feasible x ∈ D the optimization problem (2.1) is said to be feasible, and infeasible otherwise. The set of all feasible points is denoted the feasible set. The optimal value p∗ is the infimal value of the objective function evaluated at all feasible points and is defined as n o p∗ , inf f0 (x) | fi (x) ≤ 0, i ∈ Z1,m , hi (x) = 0, i ∈ Z1,p , (2.3) where p∗ = ∞ if the optimization problem is infeasible, and p∗ = −∞ if the optimization problem is unbounded from below. A feasible point x∗ ∈ D with f0 (x∗ ) = p∗ is called an optimal point or an optimal solution to (2.1). An optimization problem minimize f˜0 (x̃) subject to f˜i (x̃) ≤ 0, i ∈ Z1,m̃ x̃ (2.4) h̃i (x̃) = 0, i ∈ Z1,p̃ , is said to be equivalent to (2.1) if x∗ can be trivially computed from the solution x̃∗ and vice versa. Equivalent problems can be used to compute the solution to the original problem by solving an equivalent problem in a simpler form. 2.2 2.2 7 Convex Optimization Convex Optimization Convex optimization problems is a class of optimization problems that attain some special properties which have made it useful in many different areas including, e.g., economics, mechanics, control engineering and circuit design. Before the definition of a convex optimization problem can be presented, some auxiliary definitions are needed. These are given in definitions 2.1, 2.2 and 2.3, and their properties are thoroughly discussed in standard literature such as Boyd and Vandenberghe (2004) and are only repeated here for the sake of completeness. Definition 2.1 (Convex set). A set C is convex if for any two points x, y ∈ C and any θ ∈ [0, 1] it holds that θx + (1 − θ)y ∈ C. (2.5) Definition 2.2 (Convex function). A function f : Rn → R is convex if dom f is a convex set and if for all points x, y ∈ dom f and any θ ∈ [0, 1] it holds that f (θx + (1 − θ)y) ≤ θf (x) + (1 − θ)f (y), (2.6) and strictly convex if strict inequality holds for x , y and θ ∈ (0, 1). Definition 2.3 (Concave function). A function f : Rn → R is concave if −f is convex and strictly concave if −f is strictly convex. Now consider the optimization problem minimize f0 (x) subject to fi (x) ≤ 0, i ∈ Z1,m x (2.7) aTi x = bi , i ∈ Z1,p , where the functions fi for i ∈ Z0,m are all convex. Then (2.7) is a convex optimization problem. Note that this definition of convex optimization problems requires that the equality constraints are affine functions of x. 2.3 Lagrange Duality In Lagrange duality the constraints in the standard problem (2.1), with nonempty domain D, are taken into account by augmenting the objective function using weighted sums of the constraint functions (Boyd and Vandenberghe, 2004). The weights are called Lagrange multipliers and are here denoted λi for the inequality constraints and νi for the equality constraints, giving the Lagrangian L(x, λ, ν) , f0 (x) + m X i=1 λi fi (x) + p X i=1 νi hi (x). (2.8) 8 2 Optimization By minimizing the Lagrangian with respect to the variable x over the domain D the Lagrange dual function g(λ, ν) is obtained, i.e., p m X X λi fi (x) + g(λ, ν) , inf f0 (x) + νi hi (x) . (2.9) x∈D i=1 i=1 This is a concave function that satisfies the relation g(λ, ν) ≤ p∗ if λ 0, (2.10) and takes on the value −∞ if the Lagrangian is unbounded in x (Boyd and Vandenberghe, 2004). Remark 2.4. The Lagrange dual function g(λ, ν) in (2.9) is concave even when the problem (2.1) is not convex. The Lagrange dual function gives a lower bound on the optimal value p∗ of (2.1) if λ 0, and maximizing (2.9) gives the best possible lower bound on p∗ that can be obtained from the Lagrange dual function. Finding this lower bound is equivalent to solving the optimization problem maximize g(λ, ν) subject to λ 0, λ,ν (2.11) which is called the Lagrange dual problem, or simply the dual problem, of (2.1) and λ and ν are called the dual variables. Since the objective function g(λ, ν) to be maximized is concave and the constraints in (2.11) are convex, the dual problem (2.11) is a convex optimization problem (Boyd and Vandenberghe, 2004). Note that it is a convex problem even when the primal problem (2.1) is not. 2.3.1 Weak and strong duality Let the optimal value of the dual problem (2.11) be denoted d ∗ . Then, from (2.10), it is clear that d ∗ ≤ p∗ . (2.12) The property (2.12) is referred to as weak duality and holds even if the primal problem (2.1) is not convex and/or d ∗ or p∗ are infinite. The duality gap is defined as the difference p∗ − d ∗ and is always non-negative. Under certain conditions, the inequality (2.12) holds with equality, i.e., d ∗ = p∗ , and the duality gap is zero. This property is referred to as strong duality and does not hold in general for an optimization problem. Conditions that certify that strong duality holds are called constraint qualifications. One such constraint qualification is given by Slater’s theorem which states that strong duality holds for a convex optimization problem (2.7) given that Slater’s condition holds. This condition states that there must exist a strictly feasible point for strong duality to hold. A weaker, refined, version of Slater’s condition can be used to certify strong duality when some (or all) of the inequality constraint functions are affine. These conditions are given in definitions 2.5 and 2.6. 2.4 9 Optimality Conditions Definition 2.5 (Slater’s condition). There exists an x ∈ relint D such that fi (x) < 0, i ∈ Z1,m , aTi x = bi , i ∈ Z1,p . (2.13) Definition 2.6 (Slater’s refined condition). There exists an x ∈ relint D such that fi (x) ≤ 0, i ∈ Z1,k , fi (x) < 0, i ∈ Zk+1,m , aTi x = bi , i ∈ Z1,p , (2.14) where fi for i ∈ Z1,k are all affine functions. Strong duality implies that if there exists a solution x∗ to (2.7) with optimal value p∗ , then there exists optimal dual variables λ∗ and ν ∗ such that g(λ∗ , ν ∗ ) = d ∗ = p∗ . 2.4 Optimality Conditions Consider an optimization problem given by (2.1) where the functions fi for i ∈ Z0,m and hi for i ∈ Z1,p are all differentiable and strong duality holds. Then the optimal primal and dual solutions to this optimization problem satisfy the so called Karush-Kuhn-Tucker (kkt) conditions (Boyd and Vandenberghe, 2004; Nocedal and Wright, 2006). Definition 2.7 (Karush-Kuhn-Tucker conditions). The conditions ∇f0 (x) + m X i=1 λi ∇fi (x) + p X νi ∇hi (x) = 0, (2.15a) i=1 fi (x) ≤ 0, i ∈ Z1,m , hi (x) = 0, i ∈ Z1,p , (2.15b) (2.15c) λi ≥ 0, i ∈ Z1,m , λi fi (x) = 0, i ∈ Z1,m , (2.15d) (2.15e) are called the Karush-Kuhn-Tucker conditions. The kkt conditions are necessary for optimality of the solution to (2.1). If the problem is convex the conditions are also sufficient for optimality, which is summarized in Theorem 2.8. Theorem 2.8. Consider a convex optimization problem in the form in (2.7) that satisfies Slater’s condition and has differentiable fi for i ∈ Z0,m and hi for i ∈ Z1,p . Then the kkt conditions in Definition 2.7 are necessary and sufficient conditions for optimality, and any primal and dual pair x̃ and (λ̃, ν̃) that satisfies the kkt conditions (2.15) are primal and dual optimal. Proof: See Section 5.5 in Boyd and Vandenberghe (2004). 10 2.5 2 Optimization Quadratic Programming One important class of convex optimization problems are quadratic programs (qps). Many problems can be directly formulated as qps, but qp problems also arise as subproblems in methods for solving general constrained optimization problems (Nocedal and Wright, 2006). A qp is a convex optimization problem in the form (2.7) with affine constraint functions and a quadratic cost function, i.e., minimize x subject to 1 T x Qx + l T x + c 2 AI x bI AE x = bE , (2.16) where x ∈ Rn , Q ∈ S+n , l ∈ Rn , c ∈ R, AI ∈ Rm×n , bI ∈ Rm , AE ∈ Rp×n and bE ∈ Rp . Since the inequality constraints in (2.16) are affine in the optimization variable x, Slater’s refined condition is satisfied and, hence, Theorem 2.8 states that the kkt conditions in Definition 2.7 are necessary and sufficient for optimality. The kkt conditions for a qp problem reduce to Qx + l + AIT λ + ATE ν = 0, AI x bI , AE x = bE , λ 0, λi (aTi x − bi ) = 0, i ∈ Z1,m , (2.17a) (2.17b) (2.17c) (2.17d) (2.17e) and, hence, any x̃ and (λ̃, ν̃) that satisfy (2.17) are primal and dual global optimal solutions to (2.16). Here the notation aTi and bi are used to denote the i:th row of AI and bI , respectively, i.e., T a1 b1 . . , A , .. , b . (2.18) . I I . T bm am The qp problem (2.16) can be solved using any method for convex optimization. In this thesis the focus is on numerical algorithms that can be used as subroutines in optimization methods where the step direction is computed as a Newton step. Examples of such optimization methods can be as methods and ip methods. 2.6 Active-set Methods Active-set methods is a class of methods that has been widely used since the 1970s (Nocedal and Wright, 2006). The basic idea in this type of method is to find the set of equality constraints and inequality constraints in (2.16) that hold with equality at the optimal solution. To simplify notation, the set of all equality constraints and the set of all inequality constaints for a qp problem in the form (2.16) are introduced in Definition 2.9. 2.6 11 Active-set Methods Definition 2.9. Let the sets E and I be defined as the indices of all the equality constraints and inequality constraints, respectively, in the problem (2.16). The set of all indices of equality constraints and inequality constraints that hold with equality, or are active, is called the active set and is defined in Definition 2.10. Definition 2.10 (Active set). The active set at any feasible x in (2.16) is denoted A (x) and consists of all indices of constraints in (2.16) that hold with equality at x, i.e., n o A (x) , E ∪ i ∈ I | aTi x = bi . (2.19) Remark 2.11. When a constraint is said to be in the active set, it should be interpreted as its corresponding index is in the active set. Next, the linear independence constraint qualification is defined and it plays an important role in optimization methods and will be used later on. Definition 2.12 (Linear independence constraint qualifications). For the constraints with indices in the active set A(x) the linear independence constraint qualification (licq) holds if the constraint gradients are linearly independent. When licq is violated it is referred to as primal degeneracy. If the optimal active set A (x∗ ) is known a priori, the optimal solution can be computed by solving the equality constrained qp problem minimize x subject to 1 T x Qx + l T x + c 2 aTi x = bi , i ∈ A (x∗ ) . (2.20) However, the optimal active set is seldom known prior to the solution has been computed, and the fundamental idea with an as solver is to iteratively search for this optimal active set by adding and removing constraint indices from the so called working set. The working set at as iteration j is denoted Wj and consists of the indices of all equality constraints and the subset of the indices of the inequality constraints that are forced to hold with equality. Similarly let Wjc be the complement of the working set Wj containing all the inequality constraints that are temporarily disregarded. A requirement on Wj is that licq holds for the constraints in this set (Nocedal and Wright, 2006). Let xj denote the j:th iterate in the as solver. The step to the next iteration xj+1 is computed by solving an equality constrained qp where the constraints in Wj are forced to hold with equality and the remaining constraints are temporarily disregarded, i.e., minimize 1 T x̂ Q x̂ + l T x̂j+1 + c 2 j+1 j+1 subject to aTi x̂j+1 x̂j+1 = bi , i ∈ Wj . (2.21) 12 2 Optimization When x̂j+1 is computed, there are two different outcomes which requires different actions to be taken. If x̂j+1 = xj , then this point minimizes the objective function in the current working set Wj . Depending on the dual variables λ∗i for i ∈ Wj , the iterate x̂j+1 is either an optimal point of the original problem, or at least one constraint has to be removed from the working set. The other outcome is when x̂j+1 , xj , and in that case a step from xj towards x̂j+1 along pj , x̂j+1 − xj is taken. These different outcomes will be described below. 2.6.1 Adding constraints For an iterate where x̂j+1 , xj , the new iterate is computed by taking a step along pj such that xj+1 = xj + αj pj , αj ∈ [0, 1] , (2.22) pj , x̂j+1 − xj . If the point xj + pj is feasible with respect to all constraints in (2.16), then αj = 1 is used to update the new iterate in (2.22) as xj+1 = xj + pj = x̂j+1 . If xj + pj is not feasible, then one or more constraints are violated when moving from xj to xj + pj . These violated constraints are called blocking constraints and the steplength parameter αj is chosen such that all blocking constraints (and hence all constraints) remain satisfied. All constraints i ∈ Wj are satisfied since they are included as equality constraints in (2.21). Hence, the blocking constraints must be among the constraints i ∈ Wjc (i.e. i < Wj ) and αj can be computed by determining which constraint i ∈ Wjc that is closest to xj along the direction given by pj . Inserting the point (2.22) into each separate constraint i ∈ Wjc gives that the relation aTi (xj + αj pj ) = aTi xj + αj aTi pj ≤ bi , (2.23) must hold for all i ∈ Wjc . Since xj is a feasible point it follows that aTi xj ≤ bi and, hence, (2.23) is satisfied for all αj ≥ 0 whenever aTi pj ≤ 0. This can be seen by writing (2.23) as aTi xj ≤ bi ≤ bi − αj aTi pj , where aTi pj ≤ 0, (2.24) and, hence, constraint i cannot be a blocking constraint. If however aTi pj > 0, then (2.23) is satisfied only for certain choices of the step-length parameter αj , giving the upper limit as aTi (xj + αj pj ) = aTi xj + αj aTi pj ≤ bi ⇐⇒ αj ≤ bi − aTi xj aTi pj . (2.25) To maximize the decrease of the objective function, αj is chosen as large as possible in the set [0, 1] while retaining primal feasibility. Hence, the step-length parameter is chosen as bi − aTi xj . αj , min 1, min (2.26) T i∈Wjc , aTi pj >0 ai pj 2.6 13 Active-set Methods When there exist one or more blocking constraints a new working set Wj+1 is constructed by adding the blocking constraint that corresponds to the minimal step-length parameter in (2.26) to Wj . Let the index of this constraint be i, then the new working set Wj+1 is obtained as Wj+1 = Wj ∪ {i}. (2.27) To find the new step direction after modifying the working set a new equality constrained qp in the form (2.21) is solved, and the procedure described above is repeated until a point x̂j+1 = xj that minimizes the current working set Wj for some as iteration j is found. By defining λi , 0 if i ∈ Wjc and noting that the point xj+1 is a feasible point that minimizes the objective function in (2.21) it can be concluded that (2.17a), (2.17b), (2.17c) and (2.17e) in the kkt conditions are satisfied. 2.6.2 Removing constraints According to the discussion above, (2.17a), (2.17b), (2.17c) and (2.17e) in the kkt conditions are satisfied for the case when x̂j+1 = xj . If also λi ≥ 0, i ∈ Wj ∩ I , (2.28) then (2.17d) is satisfied and the point x̂j+1 satisfies the kkt optimality conditions (2.17) for the qp problem (2.16), and is hence an optimal solution to (2.16). If however λr < 0 for some r ∈ Wj ∩ I , then the kkt condition (2.17d) is violated and the point x̂j+1 cannot be optimal. When λr < 0 for some r ∈ Wj ∩ I it may be possible to decrease the value of the objective function by dropping one of these constraints, i.e., removing it from the working set. Any of the constraints corresponding to a negative dual variable can be removed, but a common choice is to remove the most negative one. However, this does not guarantee that the decrease in the objective function is larger than if another constraint is removed (Nocedal and Wright, 2006). Since constraint r has been removed from the working set, Wj is modified as Wj+1 = Wj \{r}, (2.29) and a new equality constrained qp in the form given by (2.21) with equality constraints given by the indices in Wj+1 has to be solved. 2.6.3 Basic primal active-set method The procedure which is presented in this section describes the basic components of a traditional as method, and is summarized in Algorithm 1. Inspiration for this algorithm is taken from Algorithm 16.3 in Nocedal and Wright (2006). In this algorithm, only one constraint is added or removed at each as iteration. However, there exist methods that changes the working set by adding or removing several constraints at each iteration, see for instance Axehill (2008). At Line 1 in Algorithm 1, a feasible starting point x0 for the solver need to be found. Computing this feasible starting point for a general qp can be done using 14 2 Optimization Algorithm 1 Basic active-set solver for convex qps (Nocedal and Wright, 2006) 1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: Compute a feasible starting point x0 Set W0 to be a subset of the active constraints at x0 for j = 0,1,2,. . . do Compute x̂j+1 by solving (2.21) if x̂j+1 = xj then Compute the Lagrange multipliers λ̂i that satisfy (2.17) if λ̂i ≥ 0 for all i ∈ Wj ∩ I then x∗ := xj STOP else r := argmin λ̂i i∈Wj ∩I 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: Update iterate and working set: xj+1 := xj , Wj+1 := Wj \{r} end if else Compute pj := x̂j+1 − xj and step-length parameter αj from (2.26) Update iterate: xj+1 := xj + αj pj if αj < 1 (blocking constraints) then Set i to the blocking constraint giving αj Update working set: Wj+1 := Wj ∪ {i} else Wj+1 := Wj end if end if end for a so called phase I algorithm and can take up to one-third to one-half of the total solution time (Goldfarb and Idnani, 1983). At Line 2 in Algorithm 1, the initial working set is a subset of the active constraints at x0 , and the iteration sequence to the solution is different for different W0 (Nocedal and Wright, 2006). 2.7 Interior-point Methods In this section a brief introduction of ip methods for convex optimization is given. Consider a convex optimization problem in the form (2.7), i.e., minimize f0 (x) subject to fi (x) ≤ 0, i ∈ Z1,m Ax = b, x (2.30) with twice continuously differentiable functions fi for i ∈ Z0,m and A ∈ Rp×n with rank A = p < n. Assume that the problem is solvable and strictly feasible. The problem (2.30) can be solved using an ip method, where a sequence of equality 2.7 15 Interior-point Methods constrained convex optimization problems minimize tf0 (x) + φ(x) subject to Ax = b, x (2.31) are solved for increasing t > 0 (Boyd and Vandenberghe, 2004). Here, φ(x) is the logarithmic barrier function given by φ(x) , − m X log (−fi (x)) , (2.32) i=1 which is used to approximate the indicator function for each of the inequality constraints. Let x∗ (t) be the optimal solution to (2.31) for a t > 0. Then x∗ (t) is called a central point and the set of points x∗ (t) for t > 0 is called the central path associated with problem (2.30). Every central point is strictly feasible and for each t, the corresponding central point x∗ (t) and the associated dual feasible pair (λ∗ (t), ν ∗ (t)) satisfy the perturbed kkt conditions ∇f0 (x) + m X λi ∇fi (x) + AT ν = 0, (2.33a) i=1 fi (x) ≤ 0, i ∈ Z1,m , Ax = b, i ∈ Z1,p , (2.33b) (2.33c) λi ≥ 0, i ∈ Z1,m , (2.33d) 1 −λi fi (x) = , i ∈ Z1,m . (2.33e) t Furthermore, the duality gap associated with x∗ (t) and (λ∗ (t), ν ∗ (t)) is given by f0 (x∗ (t)) − g(λ∗ (t), ν ∗ (t)) = m/t, (2.34) f0 (x∗ (t)) − p∗ ≤ m/t, (2.35) which gives the relation x∗ (t) and hence is no more than m/t-suboptimal (Boyd and Vandenberghe, 2004). Note that the perturbed kkt conditions (2.33) approach the kkt conditions (2.15) in Definition 2.7 as t → ∞. Remark 2.13. The problem (2.31) can be solved by any method for linearly constrained convex optimization (Boyd and Vandenberghe, 2004). However, in this thesis Newton methods are used. 2.7.1 Basic primal interior-point method In Algorithm 2, a simple basic primal ip method called the barrier method is introduced. This algorithm is based on Algorithm 11.1 in Boyd and Vandenberghe (2004), and it computes a sequence of central points for increasing t until an suboptimal solution, i.e., a solution for t > m/, is found. Computation of these central points is where most of the computational effort in ip methods is spent. 16 2 Optimization Algorithm 2 The Barrier Method (Boyd and Vandenberghe, 2004) 1: 2: 3: 4: 5: 6: 7: 8: 9: 10: Initialize x, t := t (0) > 0, µ > 1, tolerance > 0 loop Centering step: Compute x∗ (t) by solving (2.31), starting at x Update: x := x∗ (t) if Stopping criterion: m/t < then STOP else Increase t: t := µt end if end loop The centering step at Line 3 in Algorithm 2 consists of solving a problem in the form (2.31), which can be done by computing the solution to the perturbed kkt system (2.33) (Boyd and Vandenberghe, 2004). For a primal ip method, this is done by eliminating the dual variable λi in the perturbed kkt system (2.33). The elimination is done using (2.33e) to compute λi as λi = 1 , −tfi (x) (2.36) which inserted in (2.33a) gives the modified kkt system ∇f0 (x) + m X i=1 1 ∇f (x) + AT ν = 0, −tfi (x) i (2.37a) Ax = b, (2.37b) which are also the kkt conditions for (2.31). These can be solved using Newton’s method starting at a feasible x. See for example Boyd and Vandenberghe (2004); Nocedal and Wright (2006) for a description of Newton’s method. In Boyd and Vandenberghe (2004), it is shown that the Newton steps when solving the centering problem (2.31) can be interpreted as Newton steps for solving the modified kkt system in a particular way. Furthermore, it is shown that the Newton step ∆xnt and the corresponding dual variable νnt are given by the unique solution to the linear equations #" " # " # t∇f0 (x) + ∇φ(x) t∇2 f0 (x) + ∇2 φ(x) AT ∆xnt =− , (2.38) νnt 0 A 0 where ν = (1/t)νnt . Hence, solving the centering step (2.31) requires the solution to a sequence of linear systems of equations in the form (2.38). Solving these systems of equations fast is crucial to the performance of an ip method. Remark 2.14. The kkt matrix in (2.38) must be non-singular for ∆xnt to be a proper Newton step (Boyd and Vandenberghe, 2004). In this reference, some conditions that certify non-singularity of the kkt matrix are presented. 2.7 17 Interior-point Methods The system of equations (2.38) that defines a Newton step to the centering problem (2.31) can be interpreted as the optimality conditions for the equality constrained qp problem that is obtained by inserting the second-order Taylor expansions of f0 (x) and φ(x) around x into (2.31). The Taylor expansions are given by 1 T 2 ∆x ∇ f0 (x)∆x, 2 1 φ(x + ∆x) ≈ φ(x) + ∇φ(x)T ∆x + ∆x T ∇2 φ(x)∆x, 2 and inserting these into the centering problem (2.31) gives 1 T 2 minimize ∆x t∇ f0 (x) + ∇2 φ(x) ∆x + t∇f0 (x)T + ∇φ(x)T ∆x+ 2 ∆x tf0 (x) + φ(x) f0 (x + ∆x) ≈ f0 (x) + ∇f0 (x)T ∆x + subject to (2.39) (2.40) (2.41) A∆x = 0. The equality constraints in (2.41) are obtained by inserting x + ∆x into the equality constraints in the centering problem (2.31), i.e., Ax=b A (x + ∆x) = Ax + A∆x = b ⇐⇒ A∆x = 0. (2.42) It is clear that the kkt optimality conditions for (2.41) is given by the system of equations in (2.38). Hence, the equality constrained qp problem (2.41) can be solved directly by solving the systems of equations (2.38), and the centering problem (2.31) can be solved by computing the solution to a sequence of equality constrained qp problems in the form (2.41). 3 Model Predictive Control In this chapter basic notations and concepts for mpc are introduced and some common methods for solving mpc problems are presented. These notations and concepts form a foundation for the theory presented in chapters 4, 5 and 6. mpc is a control strategy where the control input that is applied to the controlled plant is computed by solving an optimization problem. It has become one of the most widely used advanced control strategies in industry today, and some important reasons for its success are that it can handle multivariable systems and constraints on control inputs and state variables in a structured way (Maciejowski, 2002). The solution to the optimization problem can be computed on-line or offline. One technique for solving the optimization problem off-line is explicit mpc, where the state-space is divided into polyhedral regions and an affine state feedback is computed off-line for each region, see for example Bemporad et al. (2002). Given the current state during run-time, the correct feedback can be applied by determining which region the current state belongs to. However, the complexity and memory requirements of computing and storing the regions and control laws might be intractable already for small-sized problems (Grancharova et al., 2003). Hence, explicit mpc is used mostly for problems of small dimensions. In this thesis, methods for computing the solution to the optimization problem on-line are considered. The optimization problem that is the core of the mpc problem is a constrained finite-time optimal control (cftoc) problem. The mpc problem and the corresponding cftoc problem can be of various types depending on, e.g., which application, controlled system and problem formulation that is used. Some common types are linear mpc, nonlinear mpc and hybrid mpc, and in most cases the effort spent when solving the corresponding cftoc problem boils down to solving Newton-system-like equations that correspond to un19 20 3 Model Predictive Control constrained finite-time optimal control (uftoc) problems. Hence, much focus has been spent on solving this type of problems efficiently when it has the special form from mpc, see, e.g., Jonson (1983); Rao et al. (1998); Hansson (2000); Vandenberghe et al. (2002); Axehill and Hansson (2006); Axehill et al. (2010); Axehill (2008); Axehill and Hansson (2008); Diehl et al. (2009); Nielsen et al. (2013); Nielsen and Axehill (2014). The basic idea in mpc is to use a dynamic model of the controlled system to predict the behaviour over a prediction horizon, and optimizing the control signal over this prediction horizon to minimize a performance criterion. In this thesis discrete-time dynamic models are considered. The prediction is performed over a prediction horizon N steps into the future, and longer prediction horizons generally generates more computationally demanding optimization problems but better control performance. The mpc controller operates using a receding horizon strategy, meaning that the control signal at time t0 is computed using the predictions up to t0 + N , and the control input at time t1 is computed using the predictions up to time t1 + N , etc. This can be seen in Figure 3.1, where the control signal at time t = 20 is about to be computed. Here a prediction horizon of N = 20 is used, and the predicted control input and output variable are marked in red. The blue dashed line symbolizes that the predicted output and the real output might be different. At each step in the mpc control loop the measured (or estimated) current state is used as initial value and hence the mpc controller operates in closed loop. The basic steps in an mpc control loop are summarized in Algorithm 3. Control input Output variable MPC - receding horizon 0 5 10 15 20 Time 25 30 35 40 Figure 3.1: Here, the control signal at time t = 20 is computed for an mpc problem with N = 20. The predicted output and control inputs are marked in red. The blue dashed line indicates that the predicted output and the real output might be different. 3.1 21 Defining the Model Predictive Control Problem Algorithm 3 Basic mpc operation 1: 2: 3: 4: 5: repeat Measure (or estimate) current state at time t Solve the optimization problem over the prediction horizon t to t + N to compute the control inputs Apply the first computed control input at time t until Break by user 3.1 Defining the Model Predictive Control Problem Linear mpc problems are the most common type of mpc problems and will be used to present the algorithms in this thesis. Note, however, that similar linear algebra that is used to solve linear mpc problems can also be used in subroutines for solving, e.g., nonlinear and hybrid mpc problems (Axehill, 2008). In the linear mpc problem used in this thesis a quadratic cost function is minimized over a prediction horizon N subject to equality and inequality constraints on states and control inputs. The corresponding cftoc problem for the linear mpc problem is " p #T ! p p " # " p #T " p # N −1 X Qxu,t xtp 1 xt Qx,t lx,t xt p minimize p T p p + p p + ct + p xp ,up lu,t ut 2 ut Qxu,t Qu,t ut t=0 subject to 1 pT p p p T p p x Qx,N xN + lx,N xN + cN 2 N p x0 = x̄ p p p p p (3.1) p xt+1 = At xt + Bt ut + at , t ∈ Z0,N −1 p p p p p Hx,t xt + Hu,t ut + ht 0, t ∈ Z0,N −1 p p p Hx,N xN + hN 0, p p p where xt ∈ Rnx are the states, ut ∈ Rnu,t are the control inputs, and Hx,t ∈ Rnc,t ×nx , p p Hu,t ∈ Rnc,t ×nu,t and ht ∈ Rnc,t describe the inequality constraints. The superscript ”p” denotes a primal problem, and the choice of this notation will later become clear. In this thesis, variables in sans-serif such as p x0 p (3.2) x , ... , p xN denotes a vector consisting of stacked vector components. The equality constraints in the cftoc problem (3.1) are the discrete-time dynamics constraints of the controlled system. Assumption 3.1. p Qx,t p Qt , p T Q xu,t p Qxu,t ∈ S+nx +nu,t , t ∈ Z0,N −1 , p Q u,t p n Qx,N ∈ S+x . (3.3) 22 3 Model Predictive Control Assumption 3.2. n p Qu,t ∈ S++u,t , t ∈ Z0,N −1 . (3.4) If the objective function in the cftoc problem (3.1) satisfies assumptions 3.1 and 3.2, it is a convex qp problem in the form (2.16) with a unique solution. In the following, assumptions 3.1 and 3.2 hold unless stated otherwise. The cftoc problem (3.1) can be cast in a more compact form using similar notation as in (2.16), giving " #T p p " # " p #T " # Qxu xp 1 xp Qx xp p + lpx minimize + cp T p p p Q up lu xp ,up 2 u Qu u xu (3.5) subject to Ap xp + Bp up + ap = 0 p p Hx xp + Hu up + hp 0, p p p p p p p where Qx , Qxu , Qu , lx , lu , cp , Ap , Bp , ap , Hx , Hu and hp are defined in Appendix 3.A, p p and xp and up are the stacked xt and ut as before. 3.2 Solving the Model Predictive Control Problem When Assumption 3.1 holds the cftoc problem (3.1) is a convex qp. Hence, any method for solving this type of problem can be applied to (3.1) to find the optimal solution. In this section ip and as methods that compute the search directions using the Newton method are presented. The section should not be considered a survey on qp methods for mpc, but rather a motivation for the results presented in chapters 4, 5 and 6. 3.2.1 Interior-point methods The cftoc problem in mpc can be solved using ip methods that exploit the structure in the cftoc problem, see, e.g., Wright (1993); Rao et al. (1998); Hansson (2000); Axehill et al. (2007). In Section 2.7 a basic ip method to solve a convex optimization problem was introduced, and here it will be shown that the main computational effort when using this method to solve the cftoc problem (3.1) is spent when solving a sequence of uftoc problems. In Section 2.7 it was argued that a convex optimization problem is solved by solving a sequence of centering problems in the form (2.31), where each centering problem is solved by computing a sequence of Newton steps corresponding to equality constrained qps in the form (2.41). For the cftoc problem (3.1) each of these equality constrained qps can be interpreted as a second-order Taylor expansion of the centering problem (2.31) around a feasible point (x̄p , ūp ). By using the compact form of the cftoc problem as in (3.5), the Hessian and gradient of the 3.2 23 Solving the Model Predictive Control Problem objective function f0 are p Qx 2 p p s∇ f0 (x , u ) = s p T Qxu p Qxu p , Q u p Qx s∇f0 (x , u ) = s p T Q p p xu " p# p " # Qxu xp l + s px , p lu Q up u (3.6) where s is used here instead of t in (2.31) and (2.38) to avoid confusion with the time index t in (3.1). To compute the gradient and Hessian of the logarithmic barrier function in (2.32), i.e., ∇φ(x̄p , ūp ) and ∇2 φ(x̄p , ūp ), it is noted from (2.32) that φ(x, u) = − nc,t N −1 X X t=0 i=1 nc,N X p p p p p log −Hx,i,t xt − Hu,i,t ut − hi,t − log −Hx,i,N xN − hi,N , i=1 (3.7) and hence ∇φ(x, u) and ∇2 φ(x, u) will have the structure ∇x0 φ(x0 , u0 ) .. . " 2 # 2 φ(x, u) ∇ φ(x ) x N N , ∇2 φ(x, u) = ∇2x φ(x, u) ∇xu ∇φ(x, u) = . (3.8) ∇u0 φ(x0 , u0 ) ∇ux φ(x, u) ∇2u φ(x, u) .. . ∇uN −1 φ(xN −1 , uN −1 ) The blocks in the Hessian ∇2 φ(x, u) are block diagonal and are defined as 2 ∇x0 φ(x0 , u0 ) 2 . , .. ∇x φ(x, u) , (3.9) 2 ∇xN φ(xN ) 2 ∇u0 φ(x0 , u0 ) 2 . , .. ∇u φ(x, u) , (3.10) 2 ∇uN −1 φ(xN −1 , uN −1 ) 2 ∇x0 u0 φ(x0 , u0 ) . .. , (3.11) ∇2xu φ(x, u) , 2 ∇ φ(x , u ) N −1 N −1 x u N −1 N −1 0 ... 0 T ∇2ux φ(x, u) , ∇2xu φ(x, u) . (3.12) Here the notation ∇2x φ(x, u), ∇2u φ(x, u) and ∇2xu φ(x, u) denotes the parts in the block partitioning of the Hessian ∇2 φ(x, u), i.e., " 2 # ∇ φ(x, u) ∇2xu φ(x, u) ∇2 φ(x, u) = 2x . (3.13) ∇ux φ(x, u) ∇2u φ(x, u) Hence, ∇φ(x̄p , ūp ) and ∇2 φ(x̄p , ūp ) are computed by inserting x̄p and ūp into (3.8). 24 3 Model Predictive Control The equality constraints in the problem (2.41) can be formed by inserting the point x̄p + ∆x and ūp + ∆u into the dynamics equations in (3.5), i.e., Ap (x̄p + ∆x) + Bp (ūp + ∆u) + ap = 0 ⇐⇒ Ap x̄p + Bp ūp + ap + Ap ∆x + Bp ∆u = 0 ⇐⇒ Ap ∆x + Bp ∆u = 0. (3.14) The last step holds since x̄p and ūp are primal feasible and hence satisfy Ap x̄p + Bp ūp + ap = 0. (3.15) By using the expressions for the gradients and Hessians in (3.6) and (3.8), the objective function of the approximated optimization problem (2.41) can be written " #T # " # p p " Qxu 1 ∆x Qx ∇2x φ(x̄p , ūp ) ∇2xu φ(x̄p , ūp ) ∆x + T s p+ 2 ∆u Qpxu Qu ∇2ux φ(x̄p , ūp ) ∇2u φ(x̄p , ūp ) ∆u " p# " #T " # p p " # Qxu x̄p Qx lx ∇x φ(x̄p , ūp ) ∆x s p T + sf0 (x̄p , ūp ) + φ(x̄p , ūp ). +s p + p Q ∇u φ(x̄p , ūp ) ∆u lu Qu ūp xu (3.16) If the structure in the matrices in (3.16) is considered, it is clear that the quadratic part of the objective function is sparse with the same sparsity pattern as for the quadratic part in the cftoc problem (3.5). Also the linear term has similar structure as in (3.5). Hence, by defining the following variables p p p Qx,t , sQx,t + ∇2xt φ(x̄t , ūt ), t ∈ Z0,N −1 , Qx,N , Qu,t , Qxu,t , lx,t , lx,N , lu,t , ct , (3.17) p p sQx,N + ∇2xN φ(x̄N ), p p p sQu,t + ∇2ut φ(x̄t , ūt ), t ∈ Z0,N −1 , p p p sQxu,t + ∇2xt ut φ(x̄t , ūt ), t ∈ Z0,N −1 , p p p p p p p sQx,t x̄t + sQxu,t ūt + slx,t + ∇xt φ(x̄t , ūt ), t ∈ Z0,N −1 , p p p p sQx,N x̄N + slx,N + ∇xN φ(x̄N ), p T p p p p p p sQu,t ūt + s Qxu,t x̄t + slu,t + ∇ut φ(x̄t , ūt ), t ∈ Z0,N −1 , " p #T " p # " p #T p p " # Qxu,t x̄tp lx,t x̄t Qx,t x̄t p p p s p p T p + sct + φ(x̄t , ūt ), t p +s p p ū l ūt ū Qxu,t Qu,t u,t t t (3.18) (3.19) (3.20) (3.21) (3.22) (3.23) ∈ Z0,N −1 , (3.24) p p p cN , s x̄N T Qx,N x̄N + p T p slx,N x̄N p p + scN + φ(x̄N ), (3.25) and by using the fact that the dynamics equations (3.14) are equivalent to ∆x0 = 0, ∆xt+1 = p At ∆xt (3.26) + p Bt ∆ut , t ∈ Z0,N −1 , (3.27) it is seen that the centering step (2.31) when solving the cftoc problem (3.1) can be solved by computing a sequence of Newton step search directions correspond- 3.2 Solving the Model Predictive Control Problem 25 ing to problems in the form of uftoc problems, given by # " #" # " #T " # N −1 " X 1 ∆xt T Qx,t Qxu,t ∆xt lx,t ∆xt minimize + + ct + T ∆u ∆u l ∆u x,u Q Q 2 t t u,t t u,t xu,t t=0 subject to 1 T T ∆x Q ∆x + lx,N ∆xN + cN 2 N x,N N ∆x0 = 0 p (3.28) p ∆xt+1 = At ∆xt + Bt ∆ut , t ∈ Z0,N −1 . Remark 3.3. In this section the centering step and the corresponding Newton steps for a basic barrier method was presented. However, similar systems of equations also arise when using primal-dual ip methods (Axehill et al., 2007). Hence, the main computational effort in most ip solvers is spent on solving sequences of Newton steps in the form of uftoc problems as in (3.28). 3.2.2 Active-set methods In this section it will be shown how the search directions that are required by an as solver, like for example the one in Algorithm 1, can be computed when solving a cftoc problem in the form in (3.1). Here, cftoc problems with upper and lower bounds on the control inputs will be considered. Hence, the cftoc problem is in the form " p #T ! p p " # " p #T " p # N −1 X Qxu,t xtp 1 xt Qx,t lx,t xt p minimize + + c p T p p p p p t + xp ,up lu,t ut 2 ut Qxu,t Qu,t ut t=0 subject to 1 pT p p p T p p xN Qx,N xN + lx,N xN + cN 2 p x0 = x̄ p p p p p (3.29) p xt+1 = At xt + Bt ut + at , t ∈ Z0,N −1 p umin,t p ut p umax,t , t ∈ Z0,N −1 . Assumptions 3.1 and 3.2 still hold for (3.29). Let the working set Wj and its complement Wjc at as iteration j be introduced as in Section 2.6. In the problem (3.29) only control input constraints are used, and hence the working set describes the set of control inputs that are temporarily fixed to a constant value (either the maximum or minimum limit). Adding a constraint to the working set, i.e., forcing a constraint to hold with equality, thus corresponds to removing that control input as an optimization variable from the optimization problem (3.29). Similarly, by disregarding an inequality constraint the corresponding control input becomes unconstrained and is introduced as an optimization variable in the optimization problem. This can be formalized by p p introducing wt as the free part of the control inputs and vt as the fixed part, i.e., " p# w p p p p p wt , ut (Wjc ), vt , ut (Wj ), ut = Π pt , (3.30) vt 26 3 Model Predictive Control p where Π is a permutation matrix satisfying ΠT Π = I. Here the notation ut (Wj ) p is used to denote the elements in ut that are affected by constraints with indices p p p p in Wj . Using this notation, Bt , Qu,t , Qxu,t and lu,t can be partitioned into parts p p corresponding to wt and vt , respectively, giving h p i h p i p p p p Bt = Bw,t Bv,t ΠT , Qxu,t = Qxw,t Qxv,t ΠT , (3.31) "p # p p Qwv,t T p Qw,t p Π , lu,t = lw,t Qu,t = Π p T ΠT . (3.32) p p lv,t Qwv,t Qv,t p The variables vt can be eliminated from the optimization problem by inserting the fixed values given by the corresponding inequality constraints in the working p p set Wj . Inserting this partitioning of ut and Bt into the dynamics constraints in (3.29) gives p p p p p p p p p p p p p p p p p p xt+1 = At xt + Bt ut + at = At xt + Bw,t wt + Bv,t vt + at = At xt + Bw,t wt + av,t . | {z } p ,av,t (3.33) Similarly, by using the partitioning of the control input and the involved matrices in the objective function in the cftoc problem (3.29) gives the expression #T " p # p p " # " N −1 " p #T X Qxw,t x p 1 xt Qx,t l x x,t t +c + t + T p t 2 w p Q p lw,t wt Qw,t wt t xw,t (3.34) t=0 1 pT p p T p p p x Qx,N xN + lx,N xN + cN , 2 N where lx,t , lw,t and ct are defined as p p p lx,t , lx,t + Qxv,t vt , (3.35) p p Qwv,t vt , p lw,t + 1 pT p p p p T p ct , ct + vt Qv,t vt + lv,t vt . 2 lw,t , (3.36) (3.37) Hence, by using this partition of the control input and the involved matrices, the uftoc problem that is solved at as iteration j to compute the Newton step can be written in the form minimize p p x ,w subject to N −1 X t=0 " # 1 xtp T 2 wp t p Qx,t p T Q xw,t # " #T " p # p " Qxw,t xtp l x x,t t p + + p + ct p lw,t wt Qw,t wt 1 pT p p p T p p x Qx,N xN + lx,N xN + cN 2 N p x0 = x̄ p p p p p p xt+1 = At xt + Bw,t wt + av,t , t ∈ Z0,N −1 . (3.38) 3.3 3.3 Newton Step Computation 27 Newton Step Computation As was indicated in the previous section, the Newton step computation plays a fundamental role when using both as and ip methods to solve an cftoc problem in the form (3.1). Both types of methods require a sequence of Newton steps to be computed in order to solve the optimization problem (3.1), and this is where the most computational effort is used (Rao et al., 1998; Vandenberghe et al., 2002; Nocedal and Wright, 2006; Axehill et al., 2007). Hence, efficient numerical algorithms that compute the solution to the corresponding uftoc problems are crucial to achieve high performance in both as and ip methods. The principal form of the optimization problem in both (3.28) and (3.38) can be interpreted as a uftoc problem in the form # " # " #T " # N −1 " #T " X 1 xt Q Q x l x x,t xu,t t x,t t + ct + + minimize T ut lu,t x,u Qxu,t Qu,t ut 2 ut t=0 subject to 1 T T x Q x + lx,N xN + cN 2 N x,N N x0 = x̄ xt+1 = At xt + Bt ut + at , t ∈ Z0,N −1 , (3.39) where xt ∈ Rnx are the states, ut ∈ Rnu,t the control inputs, and the equality constraints are the dynamics constraints of a linear dynamical system. Furthermore, let assumptions 3.4 and 3.5 hold " # Qx,t Qxu,t n +n n Assumption 3.4. Qt , ∈ S+x u,t , t ∈ Z0,N −1 , Qx,N ∈ S+x . T Qxu,t Qu,t n Assumption 3.5. Qu,t ∈ S++u,t , t ∈ Z0,N −1 . Remark 3.6. For notational brevity the time dependence on the control input dimension is explicitly given only when it is of importance for the results. Hence nu will be used instead of nu,t in the rest if this thesis unless stated otherwise. Remark 3.7. As already mentioned, in both ip and as methods for qp problems the solution to the original cftoc problem is obtained by solving a sequence of uftoc problems in the form in (3.39). The number of problems in this sequence is independent of how these uftoc problems are solved and the main computation time is consumed when solving this sequence of uftoc problems. Hence, the overall relative performance gain in terms of computation time for solving the entire sequence of problems in order to solve the cftoc problem is roughly the same as the relative performance gain in terms of computation time obtained when solving a single uftoc problem. In Definition 3.8 the notation ↔ is introduced to indicate the connection between an equality or inequality constraint and the corresponding dual variable in a convex optimization problem. This notation will be used both for scaler and vector valued constraints. 28 3 Model Predictive Control Definition 3.8. Consider a constraint aTi x − bi = 0 or fi (x) ≤ 0 in a convex optimization problem in the form in (2.7). Then the notation γi ↔ aTi x − bi = 0 (or γi ↔ fi (x) ≤ 0), (3.40) means that γi is the dual variable corresponding to constraint i. By extending the notation in Definition 3.8 to vector valued constraints and introducing λ0 , . . . , λN ∈ Rnx as the dual variables corresponding to the equality constraints in (3.39) gives λ0 ↔ − x0 + x̄ = 0, λt+1 ↔ − xt+1 + At xt + Bt ut + at = 0, t ∈ Z0,N −1 . (3.41) Note that the dual variables λt ∈ Rnx are vector valued, whereas in Definition 3.8 γi is a scalar. Furthermore, by also defining λ0 λ , ... , (3.42) λN the kkt conditions (2.15) for the uftoc problem (3.39) is given by Qxu AT x −lx Qx Qxu T Qu BT u = −lu , −a A B 0 λ (3.43) where the highly structured Qx , Qxu , Qu , lx , lu , A, B and a are defined as for problem (3.5) in Appendix 3.A, but without the superscript ”p”. By re-arranging the variables and the equations in (3.43) the kkt system can be written in an equivalent, almost block diagonal, form −x̄ λ0 0 −I −I Qx,0 Qxu,0 A0T 0 x0 −lx,0 T T −l w,0 u0 Qxu,0 Qu,0 B0 0 A B 0 −I −a 0 0 0 λ T 1 −I Qx,1 Qxu,1 A1 0 −lx,1 T x1 Qxu,1 Qu,1 B1T 0 −lw,1 A1 B1 0 −I u1 = −a . λ 1 .. 2 .. . . −I . . −I . T −I Q Q A 0 −lw,N −1 x,N −1 xu,N −1 N −1 T T u Qxu,N −1 Qu,N −1 BN −1 0 N −1 −lw,N −1 λ AN −1 BN −1 0 −I N −aN −1 −I Qx,N xN −lx,N (3.44) According to Theorem 2.8 the solution to the system of equations (3.44) is the optimal solution to the uftoc problem (3.39). Hence, solving the uftoc problem (3.39), i.e., computing the Newton step, corresponds to solving the linear system of equations in (3.44). 3.4 Solving the Karush-Kuhn-Tucker System using the Riccati Recursion 29 When assumptions 3.4 and 3.5 hold, the kkt coefficient matrix is non-singular and there exists a unique solution to (3.44). There exist a vast number of methods to solve the linear systems of equations in (3.44). The naive way to solve (3.44) would be to compute the inverse of the kkt coefficient matrix, but since the inverse is not explicitly needed, some factorization method is used in practise. A good reference on numerical algorithms for solving linear system of equations is Golub and Van Loan (1996). Using a factorization method that does not exploit the special structure in the kkt coefficient matrix, such as the ldl factorization, to compute the solution to (3.44) requires O N 3 complexity. When a sequence of uftoc problems in the form in (3.39) are solved, the solution to the kkt systems in the form in (3.44) can be solved by updating the factorization instead of re-computing it from scratch, which requires O N 2 complexity. However, the kkt coefficient matrix in (3.44) has a special almost block-diagonal structure, and some methods that exploit the sparse structure require only O (N ) operations to solve (3.44). One such method is the Riccati recursion and it will be used in this thesis to exploit the structure in the kkt coefficient matrix to compute the solution efficiently. Remark 3.9. Algorithms for solving problems similar to the uftoc problem (3.39) are also important subroutines when solving Moving Horizon Estimation (mhe) problems (Rao et al., 1998; Rao, 2000; Jørgensen, 2004). Hence, the algorithms presented in this thesis for solving uftoc problems in the form in (3.39) and the corresponding kkt system in (3.44) can be useful also in mhe applications. 3.4 Solving the Karush-Kuhn-Tucker System using the Riccati Recursion The solution to the uftoc problem (3.39) is computed by solving the kkt system (3.44). The special structure of the uftoc problem that is considered in this work corresponds to an almost block diagonal kkt coefficient matrix that can be solved very efficiently using a Riccati recursion (Jonson, 1983; Rao et al., 1998; Vandenberghe et al., 2002; Axehill, 2008). The Riccati recursion factors the kkt coefficient matrix and the factorization is followed by backward and forward substitutions for solving the system of equations. Using the Riccati recursion to compute the solution to (3.39) requires O (N ) computational complexity. 3.4.1 Derivation of the Riccati recursion In this section the derivation of the Riccati recursion that is used to solve (3.44) is presented. The derivation is similar to what is presented in Axehill (2005), but is here given for a uftoc problem in the form in (3.39). The results that are presented in chapters 4 and 6 will be based on the Riccati recursion, and some of the details in the derivation of the Riccati recursion will be used in these chapters. 30 3 Model Predictive Control By inspecting the system of equations (3.44) it can be seen that the kkt system consists of N blocks of equations in the form T # −lx,t 0 " −I Qx,t Qxu,t λt At λ T (3.45) Qu,t xt + BTt 0 Qxu,t 0 t+1 = −lu,t , t ∈ Z0,N −1 , xt+1 ut −at 0 At Bt 0 −I and the two boundary equations x0 = x̄, −λN + Qx,N xN = −lx,N . (3.46) (3.47) n An induction argument will now be used to show that there exists a Pt ∈ S+x and Ψ t ∈ Rnx for t ∈ Z0,N such that Pt xt − λt = Ψ t . (3.48) Furthermore, it will be shown how the property (3.48) can be used to solve the system of equations (3.44). First, note that the choice PN = Qx,N and Ψ N = −lx,N in (3.48) satisfies (3.47). n Now assume that (3.48) holds for some arbitrary t + 1 with Pt+1 ∈ S+x and t ∈ Z0,N −1 . Inserting λt+1 = Pt+1 xt+1 − Ψ t+1 into (3.45) gives T T −I Qx,t Qxu,t λt At Pt+1 At −lx,t T (3.49) Qu,t xt + BTt Pt+1 xt+1 − BTt Ψ t+1 = −lu,t . 0 Qxu,t ut −at 0 At Bt −I 0 By eliminating the dynamics constraints in the last block equation in (3.49) this system of equations can equivalently be written # # λ " # " " −I Qx,t + ATt Pt+1 At Qxu,t + ATt Pt+1 Bt t ATt −lx,t x (P ) . a − Ψ = + t+1 t t+1 T −lu,t 0 Qxu,t + BTt Pt+1 At Qu,t + BTt Pt+1 Bt t BTt ut (3.50) Now introduce the auxiliary variables Ft+1 , Ht+1 and Gt+1 as n Ft+1 , Qx,t + ATt Pt+1 At ∈ S+x , Ht+1 , Gt+1 , Qxu,t + ATt Pt+1 Bt , Qu,t + BTt Pt+1 Bt ∈ (3.51b) n S++u,t . Then, the equations in (3.50) can equivalently be written " # λ " # " # −I Ft+1 Ht+1 t ATt −lx,t . x + T (Pt+1 at − Ψ t+1 ) = T −lu,t 0 Ht+1 Gt+1 t Bt ut n n (3.51a) (3.51c) (3.52) Since Qu,t ∈ S++u,t also Gt+1 ∈ S++u,t and it is possible to compute the control signal ut from the lower block equation in (3.52) as −1 T −1 ut = −Gt+1 Ht+1 xt − Gt+1 lu,t + BTt Pt+1 at − BTt Ψ t+1 , (3.53) 3.4 Solving the Karush-Kuhn-Tucker System using the Riccati Recursion 31 which inserted in the upper block equation in (3.52) gives T −1 −1 lu,t + BTt Pt+1 at − BTt Ψ t+1 + Ht+1 xt − Ht+1 Gt+1 − λt + Ft+1 xt − Ht+1 Gt+1 T −1 (3.54) xt = Ht+1 ATt Pt+1 at − ATt Ψ t+1 = −lx,t ⇐⇒ −λt + Ft+1 − Ht+1 Gt+1 T T T −1 T − lx,t + Ht+1 Gt+1 lu,t + Bt Pt+1 at − Bt Ψ t+1 − At Pt+1 at + At Ψ t+1 . By identifying the terms in (3.54) with the ones in (3.48) it is clear that (3.54) can be written − λt + Pt xt = Ψ t , (3.55) with −1 T Pt , Ft+1 − Ht+1 Gt+1 Ht+1 , (3.56) −1 −1 T lu,t + BTt Pt+1 at − ATt Pt+1 at . Ψ t , −lx,t + ATt − Ht+1 Gt+1 Bt Ψ t+1 + Ht+1 Gt+1 (3.57) Furthermore, since " # " Qx,t Ft+1 Ht+1 Mt+1 , = T T Qxu,t Ht+1 Gt+1 # " T# h Qxu,t A + Tt Pt+1 At Qu,t Bt i n +n Bt ∈ S+x u,t , (3.58) is positive semidefinite by construction, it follows from Theorem A.8 that the Schur complement of Gt+1 in Mt+1 (see Definition A.4) is also symmetric positive semidefinite, and Pt thus satisfies n −1 T Pt = Mt+1 /Gt+1 = Ft+1 − Ht+1 Gt+1 Ht+1 ∈ S+x . (3.59) n Hence, if there exists a Pt+1 ∈ S+x and Ψ t+1 ∈ Rnx such Pt+1 xt+1 − λt+1 = Ψ t+1 for n some t ∈ Z0,N −1 , there also exists a Pt ∈ S+x and Ψ t ∈ Rnx such that Pt xt − λt = Ψ t . This holds for an arbitrary t ∈ Z0,N −1 . Remark 3.10. The matrix Pt in (3.56) is unique, which can be derived from the uniqueness of Ft+1 , Ht+1 and Gt+1 . Furthermore it can be seen, by using the definitions of Ft+1 , Ht+1 and Gt+1 in (3.51a), (3.51b) and (3.51c), respectively, that (3.56) is the discrete-time Riccati recursion −1 T + BTt Pt+1 At . Qxu,t Pt = Qx,t + ATt Pt+1 At − Qxu,t + ATt Pt+1 Bt Qu,t + BTt Pt+1 Bt (3.60) By defining the auxiliary variables Kt+1 and kt+1 as the solutions to the systems of equations T Gt+1 Kt+1 , −Ht+1 , Gt+1 kt+1 , − lu,t + BTt Pt+1 at − BTt Ψ t+1 , (3.61) (3.62) Pt can be expressed as −1 T T Pt = Ft+1 − Ht+1 Gt+1 Ht+1 = Ft+1 − Kt+1 Gt+1 Kt+1 . (3.63) 32 3 Model Predictive Control Hence, when Pt , Ψ t , Kt+1 and kt+1 have been computed using (3.56), (3.57), (3.61) and (3.62), respectively, the solution to the kkt system (3.44) is given by x0 = x̄, ut = kt+1 + Kt+1 xt , t ∈ Z0,N −1, xt+1 = At xt + Bt ut + at , t ∈ Z0,N −1 , λt = Pt xt − Ψ t , t ∈ Z0,N . (3.64a) (3.64b) (3.64c) (3.64d) This is summarized in algorithms 4, 5 and 6. In Algorithm 4 the kkt coefficient matrix is factored using the Riccati recursion. Algorithm 5 is a backward recursion where the variables kt+1 and Ψ t are computed. Finally, to compute the solution, the forward recursion in Algorithm 6 is used. At Line 6 in Algorithm 4 Gt+1 is factored using a suitable factorization like for example the Cholesky factorization. This factorization is used to solve the system of equations at Line 7 in Algorithm 4 and at Line 3 in Algorithm 5. Hence, the matrix Gt+1 is never explicitly inverted and the factorization is reused during several operations. In Algorithm 5 the backward recursion to compute the constant term in the objective function when using the control law (3.64b) is included. Algorithm 4 Factorization (Riccati recursion) 1: 2: 3: 4: 5: 6: 7: 8: 9: PN := Qx,N for t = N − 1, . . . , 0 do Ft+1 := Qx,t + ATt Pt+1 At Gt+1 := Qu,t + BTt Pt+1 Bt Ht+1 := Qxu,t + ATt Pt+1 Bt Compute and store a factorization of Gt+1 Compute a solution Kt+1 to T Gt+1 Kt+1 = −Ht+1 T Pt := Ft+1 − Kt+1 Gt+1 Kt+1 end for Algorithm 5 Backward recursion 1: 2: 3: 4: 5: 6: Ψ N := −lx,N , c̄N := cN for t = N − 1, . . . , 0 do Compute a solution kt+1 to Gt+1 kt+1 = BTt Ψ t+1 − lu,t − BTt Pt+1 at Ψ t := ATt Ψ t+1 − Ht+1 kt+1 − lx,t − ATt Pt+1 at T T at − 12 kt+1 Gt+1 kt+1 c̄t := c̄t+1 + ct + 12 aTt Pt+1 at − Ψ t+1 end for 3.4.2 Handling singular Karush-Kuhn-Tucker systems Some methods for solving cftoc problems require the solution of a uftoc problem in the form in (3.39), but where Assumption 3.5 does not hold. Examples of such methods are dual as methods and dual gradient projection methods as 3.5 33 Computing Eliminated Dual Variables Algorithm 6 Forward recursion 1: 2: 3: 4: 5: 6: 7: x0 := x̄ for t = 0, . . . , N − 1 do ut := kt+1 + Kt+1 xt xt+1 := At xt + Bt ut + at λt := Pt xt − Ψ t end for λN := PN xN − Ψ N the one presented in Axehill (2008); Axehill and Hansson (2008). In such problems the matrices Gt+1 in the Riccati recursion might be singular, and hence the feedback gain matrices Kt+1 might be non-unique. However, Pt is still unique, see Axehill (2008). If Gt+1 is singular, then there might not exist a solution to the system of equations at Line 7 in Algorithm 4, i.e., T Gt+1 Kt+1 = −Ht+1 , (3.65) or if a solution exists it is not unique. However, Theorem A.8 states that the system of equations in (3.65) is solvable since # " F Ht+1 n +n ∈ S+x u,t , (3.66) Mt+1 = t+1 T Ht+1 Gt+1 T and hence Ht+1 ∈ R (Gt+1 ). Furthermore, by using the basic property (A.1) of the pseudo-inverse of Gt+1 , i.e., † Gt+1 = Gt+1 Gt+1 Gt+1 , (3.67) together with (3.61) and (3.63) it can be seen that Pt can be written as T † T T † Ht+1 . Gt+1 Kt+1 = Ft+1 − Ht+1 Gt+1 Pt = Ft+1 − Kt+1 Gt+1 Kt+1 = Ft+1 − Kt+1 Gt+1 Gt+1 (3.68) The expression in (3.68) can be recognized as the generalized Schur complement of Gt+1 in Mt+1 (see Definition A.3), i.e., n Pt = Mt+1 / † Gt+1 ∈ S+x , (3.69) where Theorem A.8 has been used to guarantee positive semidefiniteness of Pt . † Furthermore, since Ft+1 , Ht+1 and Gt+1 are unique, it follows that also Pt is unique. Hence, Pt is unique although Gt+1 is singular and Kt+1 is non-unique. 3.5 Computing Eliminated Dual Variables In Section 3.2.2 it was shown how the Newton step can be computed when using an as method to solve the cftoc problem (3.29). The uftoc problem that is solved as a subproblem in the as method is obtained by eliminating the varip ables vt that are constrained to fixed values by the inequality constraints in the working set. In an as method the dual variables corresponding to the inequality 34 3 Model Predictive Control constraints play an important role, see Section 2.6. In this section it will be shown how to compute these when computing the Newton step as in Section 3.2.2. For notational brevity, the superscript ”p” is omitted. The inequality constraints umin,t ut umax,t in (3.29) can equivalently be written " # " # I umax,t u . (3.70) −I t −umin,t Let the dual variables µt ∈ R2nu corresponding to these constraints be introduced as # " " # umax,t I 0. (3.71) u − µt ↔ −umin,t −I t Now, using a similar partition and notation as in Section 3.2.2, let µv,t be the dual variables corresponding to the constraints in the working set Wj and let µw,t be the dual variables corresponding to the constraints that are temporarily disregarded at as iteration j. The dual variables µw,t are defined to be zero, i.e., µw,t , 0 (Nocedal and Wright, 2006). In order to compute µv,t the kkt system for the equality constrained qp problem (3.38) before eliminating the fixed vt is studied. Let v̄t denote the fixed values of vt , i.e., vt = v̄t . Using the partition of the control input in Section 3.2.2 and the definition of µt and v̄t in this section, it can be seen that a single block of equations in the kkt system for the equality constrained qp problem has the structure .. . . . .. . . .. . λ −I Q Qxw,t Qxv,t 0 ATt 0 . . . t x,t −lx,t x t T T 0 Qxw,t Qw,t Qwv,t 0 Bw,t 0 wt −lw,t 0 Q T T T Q Q −I B 0 v,t xv,t wv,t v,t vt = −lv,t . (3.72) 0 0 −I 0 0 0 0 µv,t −v̄t 0 At Bw,t Bv,t 0 0 −I λt+1 −at −I Q x,t+1 x .. . . t+1 . . .. . The fourth block row in the kkt system (3.72) was used in Section 3.2.2 to eliminate the fixed part of the control signal. From the third block row in (3.72) it follows that µv,t can be computed from T T − µv,t + Qxv,t xt + Qwv,t wt + Qv,t vt + BTv,t λt+1 = −lv,t , (3.73) which is summarized in Algorithm 7. Note that by eliminating vt and µv,t from (3.72) it reduces to the kkt system for the uftoc problem (3.38). 3.5 Computing Eliminated Dual Variables Algorithm 7 Forward recursion - eliminated dual variables 1: 2: 3: 4: for t = 0, . . . , N − 1 do µw,t := 0 T T xt + Qwv,t wt + Qv,t vt + BTv,t λt+1 µv,t := lv,t + Qxv,t end for 35 Appendix In this appendix the matrices, vectors and constants used in problem (3.5) and in (3.43) are defined. 3.A Model Predictive Control Formulations The matrices and vectors of stacked elements in the problem (3.5) are defined as p p p Qxu,0 Q x,0 Qu,0 . .. p p p .. . , . Qx , , Q , , Q , xu u . . p Q p p xu,N −1 Qu,N −1 Qx,N 0 ... 0 (3.74) 0 −I 0 . . . x̄ p p p A0 −I B0 a0 p p p p ap A1 −I B Ap , , B , , a , 1 1 , . .. .. .. . . p p p AN −1 −I BN −1 aN −1 (3.75) Hu,0 h0 Hx,0 . . . . , h , .. , , Hu , .. (3.76) Hx , . H u,N −1 hN Hx,N 0 ... 0 p p p p lx,0 lu,0 x0 u0 N . p . p . p . p X p p lx , .. , lu , .. , x , .. , u , .. , c , ct . p p p p t=0 lx,N lu,N −1 xN uN −1 (3.77) For the uftoc problem (3.39) the matrices and vectors in (3.43) are defined analogously, but dropping the superscript ”p”. 36 4 Low-rank Modifications of Riccati Factorizations In Chapter 3 the mpc problem and its corresponding cftoc problem were introduced, and it was argued that this cftoc problem is solved by computing the solutions to a sequence of uftoc problems. The uftoc problems can be solved using for example Riccati recursions, and some examples of methods for speeding up the optimization using this approach are found in, e.g., Jonson (1983); Rao et al. (1998); Hansson (2000); Åkerblad and Hansson (2004); Vandenberghe et al. (2002); Axehill and Hansson (2006); Axehill et al. (2010); Axehill (2008); Axehill and Hansson (2008); Diehl et al. (2009); Nielsen et al. (2013). In this chapter it will be shown how to exploit low-rank modifications of the Riccati recursion when solving the uftoc problems in an as method. The use of the Riccati recursion in as methods was introduced in Jonson (1983). In this reference a Riccati recursion is used to factor one part of the kkt matrix. For the other part standard low-rank modifications of factorizations are used on a dense system of equations of the size of the number of active inequality constraints. The computational complexity of this algorithm grows quadratically in the number of active inequality constraints. An alternative sparse non-Riccati factorization is used in Kirches et al. (2011), where the factorization is updated after changes in the as iterations. In Nielsen et al. (2013), an algorithm for performing low-rank modifications of the Riccati factorization by exploiting the structured changes in an as iteration is presented. In this reference cftoc problems with non-singular input signal weight matrix and simple upper and lower bounds on the control signal are studied. In as methods it is often crucial to be able to update the factorization of the kkt matrix instead of re-factorizing it, and for this reason the Riccati factorization has been considered more useful in ip methods than in as methods (Kirches et al., 37 38 4 Low-rank Modifications of Riccati Factorizations 2010). However, recently it was shown in Nielsen et al. (2013) that it is also possible to update the Riccati factorization when it is used in an as method. In this chapter, this approach is extended to cover more general cftoc problems, where the corresponding uftoc problem in the as iterations might have a singular kkt matrix. This generalization can be important when using for example dual as solvers similar to the one used in Axehill (2008). Furthermore, in Nielsen et al. (2013) only upper and lower bounds on the control inputs are considered. Here it will be shown how problems with both state and control signal constraints can be handled and how low-rank modifications of the Riccati factorization can improve performance for such problems. 4.1 Problem Formulation For now, consider a cftoc problem in the form (3.29) where Assumption 3.2 does not hold, i.e., a problem where the inequality constraints are given by upper and lower bounds on the control inputs and that might have a singular quadratic weight on the control inputs in the objective function. Note that this is a more general problem description than was made in Section 3.2.2. As was shown in Section 3.2.2 the computation of the search direction in an as methods corresponds to solving a uftoc problem in the form (3.38). This chapter will focus on how to solve this problem and how to exploit the structure in the problem after changing the working set in an as solver. The partitioning of the control input p ut in (3.29) is done as in (3.30). For notational brevity, the superscript p in (3.38) is however omitted. It then follows that the uftoc problem is given by # " # " #T " # N −1 " #T " X 1 xt Qx,t Qxw,t xt xt lx,t + ct + + minimize T w l w w x,w Qxw,t Qw,t 2 t t w,t t t=0 subject to 1 T x Q x + lx,N xN + cN 2 N x,N N x0 = x̄ xt+1 = At xt + Bw,t wt + av,t , t ∈ Z0,N −1 , (4.1) where the problem matrices, vectors and constants are defined as in Section 3.2.2. 4.2 Low-rank Modification of the Riccati Factorization A standard way to improve the performance of an as solver is by modifying the factorization of the kkt coefficient matrix instead of re-computing it between as iterations (Nocedal and Wright, 2006). However, it has not previously been done while simultaneously exploiting the problem structure using Riccati recursions in such a way that the computational complexity grows linearly in the prediction horizon and number of active constraints. In this section it will be shown how to n modify the Riccati factorization efficiently for the general case when Qw,t ∈ S+w in the uftoc problem (4.1). 4.2 39 Low-rank Modification of the Riccati Factorization It was shown in Section 3.4.2 that Pt in Line 8 in Algorithm 4 can be calculated as † T T Pt = Mt+1 / † Gt+1 = Ft+1 − Ht+1 Gt+1 Ht+1 = Ft+1 − Kt+1 Gt+1 Kt+1 , (4.2) when Gt+1 is positive semidefinite and with Mt+1 defined as in (3.58). The relation (4.2) is a key property when deriving the expressions for the low-rank modifications in this chapter. Furthermore, the quotient formula for generalized Schur complements will be used in the derivations of the low-rank modifications of the Riccati factorization and is given in Lemma 4.1. Lemma 4.1. Let the positive semidefinite matrices M 0 and M̄ 0 be partitioned into blocks as " # M11 M12 M13 M22 M23 M T M M = 12 (4.3) 22 M23 , M̄ = M T M . T 33 T 23 M13 M23 M33 Then † T M12 − M/ † M33 / † M̄/ † M33 = M/ † M̄ = M11 − M12 M22 † T T T † T † † , M12 − M23 M22 M23 M13 M22 M23 M33 − M23 M13 − M12 M22 (4.4) with T † T T † T T † M23 0. (4.5) M22 M23 and M33 − M23 M12 ∈ R M33 − M23 M22 M13 − M23 M22 Proof: The proof of Lemma 4.1 is given in Appendix 4.A. For a detailed description of (generalized) Schur complements see, e.g., Carlson et al. (1974); Boyd and Vandenberghe (2004); Zhang (2005). It will now be shown how to perform low-rank modifications of the Riccati factorization after k constraints have been added or removed from the working set of an as solver. A tilde will be used to denote that a matrix has been modified, i.e., the modified version of X will be denoted X̃. 4.2.1 Removing control input constraints from the working set Removing k control input constraints from the working set, i.e., temporarily disregarding these constraints that previously were forced to hold, affects the matrices in the factorization given by Algorithm 4 in the same way as adding k new control inputs. Assume without loss of generality that the k released constraints are all affecting the control input at time t and that the new control inputs are appended at the end of wt . Then the matrices Bw,t , Qw,t and Qxw,t are modified such that " # h i h i Q qw B̃w,t , Bw,t b , Q̃w,t , w,t , Q̃xw,t , Qxw,t qxw , (4.6) T 0 qw qw 40 4 Low-rank Modifications of Riccati Factorizations n +k giving B̃w,t ∈ Rnx ×(nw +k) , Q̃w,t ∈ S+w and Q̃xw,t ∈ Rnx ×(nw +k) . This implies that n +k the modified G̃t+1 ∈ S+w and H̃t+1 ∈ Rnx ×(nw +k) are computed as " # Gt+1 qw + BTw,t Pt+1 b T G̃t+1 = Q̃w,t + B̃w,t Pt+1 B̃w,t = T , (4.7) 0 + bT P qw + b T Pt+1 Bw,t qw t+1 b h i (4.8) H̃t+1 = Q̃xw,t + ATt Pt+1 B̃w,t = Ht+1 qxw + ATt Pt+1 b . By defining the variables g , qw + BTw,t Pt+1 b, (4.9a) 0 g 0 , qw + b T Pt+1 b, h , qxw + (4.9b) ATt Pt+1 b, (4.9c) G̃t+1 and H̃t+1 in (4.7) and (4.8), respectively, can compactly be re-written as " # Gt+1 g G̃t+1 = , (4.10) gT g0 h i H̃t+1 = Ht+1 h . (4.11) In analogy with (3.58) and (4.2), P˜t can be calculated as P˜t = M̃t+1 / † G̃t+1 , where M̃t+1 is the modified version of Mt+1 , i.e., Ft+1 Ht+1 h T M̃t+1 , Ht+1 Gt+1 g . (4.12) T h gT g0 Using Lemma 4.1 with M11 = Ft+1 , M12 = Ht+1 , M13 = h, M22 = Gt+1 , M23 = g and M33 = g 0 , the modified P˜t can be calculated as † T † † T † † , Ht+1 hT − g T Gt+1 g g g 0 − g T Gt+1 Ht+1 − h − Ht+1 Gt+1 P˜t = Ft+1 − Ht+1 Gt+1 {z } | | {z } | {z } {z } | Pt ,Vt− ,Ct− Vt− T (4.13) where it follows from the lemma that Ct− ∈ S+k and Vt− ∈ Rnx ×k with Vt− T ∈ R (Ct− ). Here R (Ct− ) denotes the range space of Ct− . Hence, removing k control input constraints from the working set results in the modification P˜t = Pt − Vt− Ct− † Vt− T , (4.14) which is here denoted a downdate of Pt of at most rank-k. The superscript ”−” is used to denote matrices which are the result after a downdate (removing constraints from the working set). The modifications of Gt+1 and Ht+1 will influence Kt+1 and the modified version K̃t+1 ∈ R(nw +k)×nx can be computed by finding a solution to the system of equations given by " #" # " T # Gt+1 g K 0 Ht+1 T G̃t+1 K̃t+1 = −H̃t+1 ⇐⇒ = − . (4.15) gT g 0 k0 hT 4.2 Low-rank Modification of the Riccati Factorization 41 Remark 4.2. The factorization of G̃t+1 is computed by updating the factorization of Gt+1 . Hence, a solution to (4.15) can be computed without having to re-factorize G̃t+1 , which requires less computations than re-solving (4.15) from scratch. n For the case when G̃t+1 ∈ S++u the result in Theorem A.6 can be used to compute the solution to (4.15). Using the definitions of Ct− and Vt− in (4.13), the solution to (4.15) when G̃t+1 is invertible can be calculated as # " 0# " −1 K Kt+1 + Gt+1 g(Ct− )−1 Vt− T , (4.16) K̃t+1 = 0 = k −(Ct− )−1 Vt− T where K 0 ∈ Rnw ×nx is computed as a modified version of Kt+1 and k 0 ∈ Rk×nx is the feedback for the k added control signals. Remark 4.3. When removing k constraints from the working set also k components in vt in (3.30) (dropping the superscript ”p”) are removed and are instead included in w̃t as described in this section. Hence, the corresponding matrices and vectors Bv,t , av,t , Qxv,t , Qv,t , Qwv,t , lw,t and lv,t in (3.31), (3.32) and (3.33) are also affected accordingly (i.e. the corresponding k columns b in Bv,t are included in B̃w,t etc.). These changes are only affecting the right-hand-side of the system of equations in the kkt system in (3.44), and hence they are not affecting the matrices in the factorization in Algorithm 4. 4.2.2 Adding control input constraints to the working set When k control input constraints are added to the working set at as iteration j, it corresponds to removing these control inputs from the problem. The impact from this modification on Pt is similar to when constraints are removed. Assume, without loss of generality, that the k control input constraints are all affecting the control input at time t and that the control inputs are removed from the k last entries of wt . The matrices Bw,t , Qw,t and Qxw,t are then modified as " # h i h i Q̃w,t qw Bw,t = B̃w,t b , Qw,t = , Q = , (4.17) Q̃ q xw,t xw,t xw T 0 qw qw i.e., the modified matrices are the (1, 1)-block in the partition in (4.17). Analon −k gously, the modified versions G̃t+1 ∈ S+w and H̃t+1 ∈ Rnx ×(nw −k) are computed as the (1,1)-blocks in Gt+1 and Ht+1 , i.e., the partitioning is, " # h i G̃t+1 g Gt+1 = , Ht+1 = H̃t+1 h . (4.18) T 0 g g According to (4.2), Pt can be written as Pt = Mt+1 / † Gt+1 , where Mt+1 is now Ft+1 H̃t+1 h T Mt+1 = H̃t+1 (4.19) G̃t+1 g . T T 0 h g g 42 4 Low-rank Modifications of Riccati Factorizations Hence, by using Lemma 4.1, Pt can be computed by † † T † † † T Pt = Ft+1 − H̃t+1 G̃t+1 H̃t+1 − h − H̃t+1 G̃t+1 g g 0 − g T G̃t+1 g hT − g T G̃t+1 H̃t+1 , | {z } | {z } | {z } | {z } P˜t ,Ct+ ,Vt+ where it follows from the lemma that Ct+ S+k Vt+ T and Vt+ Rnx ×k ∈ ∈ The result (4.20) is similar to (4.13), and it is equivalent to with Vt+ T † T P˜t = Pt + Vt+ Ct+ Vt+ , (4.20) ∈ R (Ct+ ). (4.21) which is here denoted an update of Pt of at most rank-k. Here, the superscript ”+” is used to denote matrices after an update (after adding constraints to the working set). The modified Kt+1 can be computed by solving the system of equations T G̃t+1 K̃t+1 = −H̃t+1 , (4.22) where, as before, the factorization of G̃t+1 is obtained by updating the factorization of Gt+1 . n For the case when Gt+1 ∈ S++w a similar expression to (4.16) can be obtained by solving the system of equations " #" # " T # G̃t g K 0 H̃ , (4.23) = − t+1 g T g 0 k0 hT |{z} Kt+1 using the inverse in Theorem A.6, giving " 0 # " −1 T # −1 g(Ct+ )−1 Vt+ T K −G̃t+1 H̃t+1 + G̃t+1 = . k0 −(Ct+ )−1 Vt+ T (4.24) By identifying the changes in the first block row of (4.24) it can be seen that K̃t+1 can be computed as T −1 K̃t+1 = K 0 − G̃t+1 g(Ct+ )−1 Vt+ , K0 where are the first nw − k rows in Kt+1 and K̃t+1 = computed as a modified version of a part of Kt+1 . −1 T . −G̃t+1 H̃t+1 (4.25) Hence, K̃t+1 is Remark 4.4. When adding k constraints to the working set, also k components in vt in (3.30) are added (dropping the superscript ”p”) and they are removed from wt . Hence, Bv,t , av,t , Qxv,t , Qv,t , Qwv,t , lw,t and lv,t in (3.31), (3.32) and (3.33) are also affected accordingly (i.e. the corresponding k columns b in Bw,t are included in B̃v,t etc.). These changes are only affecting the right-hand-side of the system of equations in the kkt system in (3.44), and hence they are not affecting the matrices in the factorization in Algorithm 4. 4.2 43 Low-rank Modification of the Riccati Factorization 4.2.3 The impact on subsequent time-steps According to sections 4.2.1 and 4.2.2, adding or removing k control input constraints to/from the working set at time tm induces a modification of at most rank-k of Ptm . It will now be shown that these modifications will affect the matrices in the Riccati factorization in a structured way also for time-steps t ∈ Z0,tm −1 . Specifically, it will be shown that the modifications in these subsequent timesteps will have at most rank-k, which is an important property. By inserting (4.14) in the definition of Ft+1 , Ht+1 and Gt+1 in (3.51a), (3.51b) and (3.51c), respectively, straightforward calculations for the rank-k downdate give − − † − T T F̃t+1 = Qx,t + ATt P˜t+1 At = Qx,t + ATt Pt+1 At − ATt Vt+1 Ct+1 Vt+1 At ⇐⇒ − − † − T F̃t+1 = Ft+1 − ATt Vt+1 Ct+1 Vt+1 At , (4.26) − − † − T Ct+1 Vt+1 Bw,t ⇐⇒ G̃t+1 = Qw,t + BTw,t P˜t+1 Bw,t = Qw,t + BTw,t Pt+1 Bw,t − BTw,t Vt+1 − − † − T G̃t+1 = Gt+1 − BTw,t Vt+1 Ct+1 Vt+1 Bw,t , (4.27) − − † − T Ct+1 Vt+1 Bw,t ⇐⇒ H̃t+1 = Qxw,t + ATt P˜t+1 Bw,t = Qxw,t + ATt Pt+1 Bw,t − ATt Vt+1 − − † − T H̃t+1 = Ht+1 − ATt Vt+1 Ct+1 Vt+1 Bw,t . (4.28) This can be written in matrix form as # " # " T # " T − #T " − Ft+1 Ht+1 F̃ H̃t+1 At Vt+1 n +n − † At Vt+1 = − C ∈ S+x w , M̃t+1 = t+1 T − t+1 BT V − Ht+1 Gt+1 Bw,t Vt+1 H̃tT G̃t+1 w,t t+1 (4.29) which is positive semidefinite by construction. Now, define the auxiliary matrices M̂t+1 and M̄t+1 as − " # Ht+1 ATt Vt+1 Ft+1 − Gt+1 BTw,t Vt+1 T T − . M̂t+1 , Ht+1 Gt+1 Bw,t Vt+1 , M̄t+1 , − T − Vt+1 Bw,t Ct+1 − T − T − Vt+1 At Vt+1 Bw,t Ct+1 (4.30) n +n +k Using Theorem A.8 it can be shown that M̂t+1 ∈ S+x w since n +nw − M̃t+1 = M̂t+1 / † Ct+1 ∈ S+x − Ct+1 ∈ S+k , h − T Vt+1 At , (4.31a) (4.31b) i − − T ), (4.31c) Vt+1 Bw,t ∈ R (Ct+1 − T − where (4.31c) follows from the property Vt+1 ∈ R Ct+1 . Since M̂t+1 is positive n +k semidefinite it follows that also M̄t+1 ∈ S+w . Hence, by using (4.31a) and identifying that G̃t+1 in (4.27) can be computed as the generalized Schur complement − − of Ct+1 in M̄t+1 , i.e., G̃t+1 = M̄t+1 / † Ct+1 , the quotient formula in Lemma 4.1 can 44 4 Low-rank Modifications of Riccati Factorizations be used to compute P˜t as − † † T BTw,t Vt+1 Ht+1 − ATt − Ht+1 Gt+1 P˜t =M̃t+1 / † G̃t+1 = M̂t+1 / † M̄t+1 = Ft+1 − Ht+1 Gt+1 | {z } | {z } Pt − − − T † Ct+1 − Vt+1 Bw,t Gt+1 BTw,t Vt+1 | {z } ,Ct− † ,Vt− T † − T BTw,t , Vt+1 ATt − Ht+1 Gt+1 | {z } Vt− T (4.32) where it follows from the lemma that Ct− ∈ S+k , Vt− ∈ Rnx ×k and Vt− T ∈ R (Ct− ). Thus, a downdate of at most rank-k of Pt+1 will result in a downdate of most rank-k also in Pt in the form P˜t = Pt − Vt− Ct− † Vt− T . (4.33) Similarly, the effect of an update of at most rank-k of Pt+1 can be analyzed using analogous calculations as for the downdate. The update of at most rank-k P˜t+1 = + + † + T Pt+1 + Vt+1 Ct+1 Vt+1 results in the modification T † P˜t = Pt + Vt+ Ct+ Vt+ , (4.34) with T + + † + Ct+ , Ct+1 − Vt+1 Bw,t G̃t+1 BTw,t Vt+1 ∈ S+k , † + Vt+ , ATt − H̃t+1 G̃t+1 BTw,t Vt+1 ∈ Rnx ×k , T + Vt+ ∈ R Ct+1 . (4.35a) (4.35b) (4.35c) Hence, also an update of at most rank-k of Pt+1 results in an update of at most rank-k of Pt . This important property is summarized in Theorem 4.5. Theorem 4.5. Consider a modification of at most rank-k of Ptm in Algorithm 4 at a single time instant tm ∈ Z1,N in either of the forms − − † −T P˜tm = Ptm − Vtm Ctm Vtm (downdate) , (4.36) P˜tm = Ptm + Vt+ Ct+ † Vt+ T (update) m m m where Ct−m , Ct+m ∈ S+k , Vt−m , Vt+m ∈ Rnx ×k and Vt−m T ∈ R Ct−m , Vt+m T ∈ R Ct+m , respectively. Then it holds for all t ∈ Z0,tm −1 that Pt is modified as − −† − T P˜t = Pt − Vt Ct Vt (downdate) , (4.37) P˜t = Pt + Vt+ Ct+ † Vt+ T (update) with Ct− , Ct+ ∈ S+k , Vt− , Vt+ ∈ Rnx ×k and Vt− T ∈ R (Ct− ) , Vt+ T ∈ R (Ct+ ), respectively. Proof: From (4.32) and (4.34) it is clear that a modification of at most rank-k of Ptm results in a corresponding modification of at most rank-k of Ptm −1 . Further- 4.2 Low-rank Modification of the Riccati Factorization 45 more, the derivation for the subsequent iterations giving (4.32) and (4.34) are made for an arbitrary t ∈ Z0,tm −1 . Hence, the proof follows by induction. Remark 4.6. In a classic as solver like for example the one in Algorithm 1 only one constraint is removed at each iteration, meaning that k = 1 and Ct− and Ct+ are scalar. The modified K̃t+1 can be computed by solving the system of equations T G̃t+1 K̃t+1 = −H̃t+1 . (4.38) n S++w For the case G̃t+1 ∈ it is possible to use the Sherman-Morrison-Woodbury formula to simplify computations, see, e.g., Golub and Van Loan (1996). 4.2.4 Algorithms for modifying the Riccati factorization In this section, the theory derived in Section 4.2.1-4.2.3 is summarized in Algorithm 8. The algorithm assigns α = 1 for an update and α = −1 for a downdate, and computes the modified matrices at time tm . When t < tm , Theorem 4.5 and the theory in Section 4.2.3 is used to modify the factorization for these subsequent time-steps. At lines 3 and 8 in Algorithm 8, the factorization should not be re-computed from scratch but instead standard methods for up- and downdating for example Cholesky factorizations should be used. By modifying the Riccati factorization instead of re-computing it, the computational complexity is reduced from roughly O N (n3u + n3x + n2u nx + n2x nu ) to O tm (n2u nx + n2u + knu nx + kn2x ) when using the Cholesky factorization at Line 6 in Algorithm 4. The complexity is further reduced to approximately O tm (n2u + kn2u + knu nx + kn2x ) if Line 9 in Algorithm 8 is computed using the Sherman-Morrison-Woodbury formula, see, e.g., Golub and Van Loan (1996). The exact expression for the complexity of the algorithm is dependent on, e.g., the choice of factorization and updating methods in algorithms 4 and 8. Remark 4.7. In Algorithm 8 the superscript ”−” or ”+” for Ct and Vt are not used. Instead, the parameter α determines how Ct and Vt are computed. To compute the solution of the modified uftoc problem after the modification of the factorization in Algorithm 4, the backward and forward recursions in algorithms 5 and 6 need to be re-computed using the modified matrices. Furthermore, Algorithm 7 needs to be re-computed to obtain the dual variables corresponding to the eliminated constraints. However, since the factorization is only affected for time-instances t ∈ Z0,tm , the backward recursion in Algorithm 5 is only recomputed for these time indices using the modified matrices B̃w,tm , G̃t , H̃t and P˜t , which improves performance even more. 46 4 Low-rank Modifications of Riccati Factorizations Algorithm 8 Low-rank modifications of Riccati factorization 1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: Assign α := 1 (update) or α := −1 (downdate) Calculate g, g 0 , h, Vtm , Ctm , k 0 and K 0 Modify the factorization of Gtm +1 and compute H̃tm +1 and K̃tm +1 P˜tm := Ptm + αVtm Ct†m VtTm for t = tm − 1, . . . , 0 do † T F̃t+1 := Ft+1 + αATt Vt+1 Ct+1 Vt+1 At † T T H̃t+1 := Ht+1 + αAt Vt+1 Ct+1 Vt+1 Bw,t Modify factorization for † T G̃t+1 = Gt+1 + αBTw,t Vt+1 Ct+1 Vt+1 Bw,t Compute a solution K̃t+1 to T G̃t+1 K̃t+1 = −H̃t+1 if α = 1 then † T BT Vt+1 Ct := Ct+1 − Vt+1 Bw,t G̃t+1 T w,t † T Vt+1 H̃t+1 Vt := At − Bw,t G̃t+1 else † T Ct := Ct+1 − Vt+1 Bw,t Gt+1 BT Vt+1 T w,t † T Vt+1 Vt := At − Bw,t Gt+1 Ht+1 end if P˜t := Pt + αVt Ct† VtT end for 4.3 Extension to General Constraints The cftoc problem that is the core of many mpc problems in industry is often of a more general type than (3.29) and also includes constraints on the states and the possibility to control only certain states or a combination of states (Maciejowski, 2002). In this section, it is shown how to exploit the low-rank modifications of the Riccati factorization in order to improve performance when solving more general problems than (3.29). 4.3.1 Primal and dual problem In this section a primal cftoc problem of a more general type than (3.1) and a corresponding dual problem is presented. This problem is chosen since it can be shown that for a certain choice of dual variables the dual problem is also in the form of a cftoc problem, see Axehill (2005) and Appendix 4.B. This property will be exploited in this section. A superscript ”p” is used to denote variables in the primal problem, and a superscript ”d” is used to denote variables in the dual problem. Primal problem Consider an mpc problem and its corresponding cftoc problem with states p p p xt ∈ Rnx , controlled variables zt ∈ Rnz and control inputs ut ∈ Rnu , and with 4.3 47 Extension to General Constraints inequality constraints that involve both states and control inputs. This cftoc problem is in a general form that covers many linear mpc applications and is given by the following optimization problem p p " # " p #T " p # N −1 " p #T X Qzu,t ztp Qz,t 1 zt zt p p + lz,t minimize + c T p p p p p t + xp ,zp ,up lu,t ut 2 ut Qzu,t Qu,t ut t=0 subject to 1 pT p p p T p p z Qz,N zN + lz,N zN + cN 2 N p x0 = x̄ p p p p p (4.39) p xt+1 = At xt + Bt ut + at , t ∈ Z0,N −1 p p p zt = Mt xt , t ∈ Z0,N p p p p p Hx,t xt + Hu,t ut + ht 0, t ∈ Z0,N −1 p p p Hx,N xN + hN 0, p p p where Hx,t ∈ Rnc,t ×nx , Hu,t ∈ Rnc,t ×nu and ht ∈ Rnc,t . Here, nc,t is the number of inequality constraints at time t. Furthermore, let Assumption 4.8 hold for the problem in (4.39). Assumption 4.8. p Qz,t p T Q zu,t p Qzu,t nz +nu , t ∈ Z0,N −1 , p ∈ S++ Q u,t p n Qz,N ∈ S++z . (4.40) The cftoc problem (4.39) can be solved by using for example a primal as solver, but the theory presented in this chapter is not directly applicable in that case. Hence, utilizing low-rank modifications of the Riccati factorization instead of recomputing it cannot be exploited to increase performance. However, the primal problem in (4.39) can also be solved using a dual as solver as in Goldfarb and Idnani (1983); Axehill and Hansson (2006), or using a dual gradient projection method as in Axehill (2008). In these types of solvers it is sometimes possible to exploit low-rank modifications of the Riccati factorization to speed up computations. Dual problem In Axehill (2005), an optimization problem which is equivalent to the (Lagrange) dual problem of a slightly less general problem than (4.39) is introduced. The corresponding primal problem does not have any linear or constant terms in the p p objective function and the cross-terms between zt and ut are zero. Furthermore, it is shown that also the dual problem can be interpreted as a cftoc problem using a suitable variable transformation. This dual problem is used in the solvers in Axehill and Hansson (2006); Axehill (2008); Axehill and Hansson (2008). In this thesis a dual problem to (4.39) is derived using analogous calculations as in Axehill (2005). The details of the derivations are presented in Appendix 4.B. 48 4 Low-rank Modifications of Riccati Factorizations The dual problem can be interpreted as a cftoc problem with states xτd ∈ Rnx , control inputs uτd ∈ Rnz +nc,N −τ and prediction horizon N d = N + 1, i.e., minimize xd ,ud subject to d −1 NX " # 1 xτd T 2 ud τ τ=0 T d d lx,N xN d d d Qx,τ d T Q xu,τ " # " #T " # d d d Qxu,τ xτd l x d x,τ τ + d + cτ + d d d lu,τ uτ Qu,τ uτ x0d = 0 d xτ+1 = Adτ xτd + Bdτ uτd , τ ∈ Z0,N d −1 h i 0 −Inc,N −τ uτd 0, τ ∈ Z0,N d −1 , (4.41) where τ = N − t and d Qx,τ T Qd xu,τ d Qxu,τ ∈ S+nx +nz +nc,N −τ , d Q u,τ n d x Qx,N d ∈ S+ . (4.42) The state variables, control inputs and all matrices and vectors in the dual problem are defined in Appendix 4.B. The solution to the primal cftoc problem (4.39) can be derived from the solution to the dual cftoc problem (4.41). The relations between the solutions to the primal and dual problems are given by (4.76) and (4.80) in Appendix 4.B, and are repeated here p xt = −λN +1−t , t ∈ Z0,N , p T T p p p d ut = − Q̄zu,t lz,t − Q̄u,t lu,t − Q̄u,t Bt xN −t + p T d T uN −t , t ∈ Z0,N −1 , −Q̄u,t Hu,t Q̄zu,t (4.43a) (4.43b) where λτ are the dual variables corresponding to the equality constraints in the dual problem and are defined in (4.77a), and Q̄zu,t and Q̄u,t are defined in (4.66). Furthermore, the dual variables µτ corresponding to the inequality constraints in the dual problem are defined in (4.77b). From the relation (4.85), i.e., p p p p Hx,t xt + Hu,t ut + ht = −µN −t , (4.44) it is clear that these dual variables can be interpreted as the slack variables for the inequality constraints in the primal cftoc problem (4.39). 4.3.2 Methods to handle general constraints The primal problem (4.39) can be solved by using for example a dual as type solver as proposed in Axehill and Hansson (2006), or a dual gradient projection method as in Axehill (2008); Axehill and Hansson (2008). In these types of methods, the primal problem is solved by constructing the corresponding dual problem and applying primal methods to solve the dual problem. The solver iterates until dual optimality is obtained, while maintaining dual feasibility in all itera- 4.3 Extension to General Constraints 49 tions. Since Slater’s condition in Definition 2.6 is satisfied for (4.39), strong duality holds. Hence, if the dual problem is bounded from above, the dual optimal point for (4.41) corresponds to a primal feasible and optimal point for (4.39). Remark 4.9. The primal method that is used to solve the dual problem must be able to handle the positive semi-definite case (Goldfarb and Idnani, 1983). In Axehill and Hansson (2006); Axehill (2008); Axehill and Hansson (2008), this is done by imposing extra assumptions on the inequality constraints in (4.39). In both the previously mentioned dual as type solver and the dual gradient projection method the solution to the primal cftoc problem (4.39) is computed by solving a dual problem in the form (4.41). This is done by iteratively changing the working set to find the optimal active set as in a primal as method. The dual cftoc problem (4.41) is in the same form as the cftoc problem (3.29). Hence, it is solved by computing a sequence of Newton steps corresponding to uftoc problems in the form in (4.1). Since these solvers exploit the structure in (4.1) by using a Riccati recursion to compute the Newton steps, the theory presented in this chapter can be used to perform low-rank modifications of the Riccati factorization. A principal outline of a dual as type solver is given in Algorithm 9. Algorithm 9 Outline of dual as type solver 1: 2: 3: 4: 5: 6: 7: Construct the dual problem (4.41) from the primal problem (4.39) Find a dual feasible point (the origin is a trivial choice for a dual as solver and no phase I algorithm is needed) and an initial working set repeat Compute the Newton step by solving a subproblem in the form (4.1) Perform the Newton step in the dual variables xd and ud and update the working set if needed ∗ ∗ until Dual optimal point xd and ud is found Transform the dual optimal point to the primal optimal point according to (4.43a) and (4.43b) However, when a dual solver is used to solve (4.39), primal feasibility is obtained only at the optimum (Goldfarb and Idnani, 1983; Bartlett and Biegler, 2006). In a real-time mpc control loop this might be problematic due to real-time computation time constraints. If the solver used to compute the optimal solution to the primal cftoc problem is forced to terminate before an optimum is found, the control input that is returned by the solver is not necessarily primal feasible. Hence, either a control signal which might lead to violation of constraints is used as input to the plant, or the control signal has to be computed in some alternative way. An approach to address this problem and still be able to exploit the low-rank modifications of the Riccati recursion presented here is to use a primal solver which maintains primal feasibility, but computing the Newton step by solving a dual uftoc problem. This procedure is described for a primal cftoc problem in the form (4.39), and is briefly outlined in Algorithm 10 at the end of this section. 50 4 Low-rank Modifications of Riccati Factorizations When a primal as method like for example the one given in Algorithm 1 is applied to solve the cftoc problem (4.39), an optimization problem in the form p p " # " p #T " p # N −1 " p #T X Qzu,t ztp Qz,t 1 zt zt p p + lz,t minimize + c T p p p p p t + xp ,zp ,up lu,t ut 2 ut Qzu,t Qu,t ut t=0 subject to 1 pT p p p T p p z Qz,N zN + lz,N zN + cN 2 N p x0 = x̄ p p p p p p (4.45) xt+1 = At xt + Bt ut + at , t ∈ Z0,N −1 p p p zt = Mt xt , t ∈ Z0,N p p p p p Hx,i,t xt + Hu,i,t ut + hi,t = 0, ∀(i, t) ∈ Wj p p p Hx,i,N xN + hi,N = 0, ∀(i, N ) ∈ Wj , is solved at each as iteration j. Here, Wj denotes the working set and p p p Hx,1,t Hu,1,t h1,t . p p p . . Hx,t = .. , Hu,t = .. , ht = .. . p p p h Hx,nc,t ,t Hu,nc,t ,t nc,t ,t (4.46) Furthermore, the notation (i, t) ∈ Wj is introduced to denote that the inequality constraint p p p p Hx,i,t xt + Hu,i,t ut + hi,t ≤ 0, (4.47) is in the working set and is hence forced to hold with equality. In principal, it is possible to solve (4.45) by solving the dual uftoc problem and then computing the corresponding primal solution from the solution to the dual problem. The dual uftoc problem is constructed from the problem in (4.41) by letting some of the inequality constraints in (4.41) hold with equality, and temporarily disregarding the rest. For all inequality constraints (i, t) that are forced to hold with equality in (4.45), the corresponding dual variable γi,t (defined in (4.59d) and (4.59e)) is an unconstrained optimization variable. Hence, by using the definition of uτd in (4.72) in Appendix 4.B it follows that undz +i,N −t is also an unconstrained optimization variable in the dual problem. Similarly, if a primal inequality constraint (i, t) is temporarily disregarded, i.e., it is not in the working set, the corresponding dual variable is defined to be γi,t = 0 (Nocedal and Wright, 2006). It then follows that the corresponding uτd is constrained to zero, i.e., undz +i,N −t = 0. To summarize; if the primal constraint (i, t) is in the working set, then the corresponding dual control input is unconstrained in the dual problem, and if the primal constraint (i, t) is not in the working set, the corresponding dual control input is constrained to zero. 4.3 Extension to General Constraints 51 Using the reasoning above, the dual problem of the problem in (4.45) is given by " # " #T " # d −1 " # NX d d d d Qxu,τ 1 xτd T Qx,τ xτd l x d τ +c + T minimize + x,τ τ d d d d d d lu,τ uτ 2 uτ Qxu,τ Qu,τ uτ xd ,ud τ=0 T d d lx,N xN d d subject to x0d = 0 d xτ+1 = Adτ xτd + Bdτ uτd , τ ∈ Z0,N d −1 − undz +i,τ = 0, ∀(i, N − τ) ∈ Wjc . (4.48) The primal solver requests a solution to (4.45) which is computed via (4.48). The solution to (4.45) can easily be recovered from the solution to (4.48). This process is transparent to the primal solver. By eliminating the constrained variables undz +i,τ in (4.48) this problem can be interpreted as a uftoc problem in the same form as (4.1). Hence (4.48) can be solved using a Riccati recursion after eliminating the constrained control inputs. The dual solution is transformed to the primal variables using (4.43a) and (4.43b), and the Newton step can be performed in the primal variables in the as solver, maintaining primal feasibility. Remark 4.10. Performing the Newton step in the primal as solver does not depend on how the step direction is computed. Hence, the logics involved in performing the step and possibly adding or removing constraints from the working set are the same regardless of how the Newton step direction is computed. Furthermore, the dual problem to the primal problem (4.45) is constructed such that adding a primal constraint to the working set corresponds to removing a dual constraint, and vice versa. Hence, the dual problem is changed as in Section 3.2.2 when primal inequality constraints are added or removed from the working set. As a result, the low-rank modification algorithms presented in this chapter can be applied to increase performance when computing the solution to the dual uftoc problem. This solver is outlined in Algorithm 10. Algorithm 10 Outline of primal as solver using dual Newton step computation 1: 2: 3: 4: 5: 6: 7: 8: Construct the dual problem (4.41) from the primal problem (4.39) Find a primal feasible point (for example by using a Phase I approach) and an initial working set repeat Form the dual uftoc problem (4.48) Solve the problem (4.48) Compute the variables xp j+1 and up j+1 using (4.43a) and (4.43b) and, if needed, αj+1 , βj+1 and γj+1 from (4.71) and (4.72) in Appendix 4.B Perform the Newton step in the primal variables xp and up and change the working set if necessary until Primal optimal point xp∗ and up∗ is found 52 4 Low-rank Modifications of Riccati Factorizations Remark 4.11. In Algorithm 10 the dual cftoc problem (4.41) is constructed only once. By inspecting the structure of the dual uftoc problem that is solved at each as iteration, it can be seen that only the equality constraints und +i,τ = 0 are changed between different z iterations. Hence, at Line 4 in Algorithm 10 only computationally cheap operations are needed. 4.4 Numerical Results The proposed algorithms for solving the kkt system of (4.1) by modifying the Riccati factorization have been implemented in Matlab, and a comparison with a Matlab implementation of a standard Riccati recursion has been performed. The focus of the comparison is the relative performance gain in terms of computation time obtained by modifying the Riccati factorization instead of re-computing it. The algorithms are compared by solving random uftoc problems of varying dimensions and the computation times are averaged over fifteen problems of the same dimensions. All simulations were performed on an Intel®Xeon® E5-2650 cpu running Linux (version 2.6.32-504.16.2.el6.x86_64) and Matlab (version 8.0.0.783, R2012b). Remark 4.12. Although no numerical issues have been observed in the double-precision implementation of the algorithms in this chapter, it might occur in implementations using lower-precision arithmetics. For such applications, a square-root implementation of the algorithms can be useful to increase numerical stability (Kailath, 1980). 4.4.1 Modification of Riccati factorization Most of the main operations have been implemented in m-code and the number of computational threads is limited to one to get a comparison of the computational effort that is required by modifying and re-computing the Riccati recursion, respectively. However, standard basic Matlab operations such as matrix multiplications and additions have been used. To get a completely valid comparison of the two approaches, all operations should be implemented in either m-code or in highly efficient linear algebra packages such as blas. The comparison in this section thus shows less performance gains than what is possible since the dominating n3x -complexities are efficiently implemented internally in Matlab using optimized linear algebra routines from commercial software, compared to the n3u -complexities that are implemented by the author in m-code. The prediction horizon has been chosen as N = 100 for all uftoc problems, and one constraint has been removed at different time steps tm ∈ {1, 25, 50, 75, 100}, i.e., ranging from modifying only one step of the factorization to modifying the full factorization (giving the worst-case scenario). The problem dimensions nx and nu have been chosen in the interval [10, 200], and the relative computation times averaged over 15 problems of the same size when tm = 1 and tm = 100 are presented in Figure 4.1. In the figures 4.2 and 4.3 the results when nx is fixed to nx = 20 and nu is fixed to nu = 20, respectively, are presented for different 4.4 53 Numerical Results Recursion, N=100 1 Modified, tm =1 Modified, tm =100 Normalized time 0.8 Standard 0.6 0.4 0.2 200 0 200 100 150 100 nu 50 0 0 nx Figure 4.1: Comparison of the computation time that is required to compute the Riccati recursion using the standard algorithms in Section 3.4 and the modifying algorithms presented in Chapter 4. The computation times are compared when removing a constraint from the working set at tm = 100 = N (worst-case) and tm = 1. values of tm . From these figures, it is clear that modifying the Riccati recursion instead of re-computing it can significantly reduce the required computation time for solving the uftoc problem. This is true especially for larger problem sizes and/or when a small part of the factorization is affected by the change of the working set. 54 4 Low-rank Modifications of Riccati Factorizations Recursion, nx = 20, N = 100 1 Modified, tm =1 Modified, tm =100 Standard Normalized time 0.8 0.6 0.4 0.2 0 0 20 40 60 80 100 120 140 160 180 200 nu Figure 4.2: Comparison of the computation time that is required to compute the Riccati recursion using the standard algorithms in Section 3.4 and the modifying algorithms presented in Chapter 4. The computation times are compared when removing a constraint from the working set at tm = 100 = N (worst-case) and tm = 1 for nx = 20. 4.4 55 Numerical Results Recursion, nu = 20, N = 100 1 Modified, tm =1 Modified, tm =100 Standard Normalized time 0.8 0.6 0.4 0.2 0 0 20 40 60 80 100 120 140 160 180 200 nx Figure 4.3: Comparison of the computation time that is required to compute the Riccati recursion using the standard algorithms in Section 3.4 and the modifying algorithms presented in Chapter 4. The computation times are compared when removing a constraint from the working set at tm = 100 = N (worst-case) and tm = 1 for nu = 20. Appendix In this appendix the proof of Lemma 4.1 is given. Furthermore, the derivation of the dual cftoc problem (4.41) and the definition of the dual variables are presented here. 4.A Proof of Lemma 4.1 Proof: Consider the positive semidefinite matrices M 0 and M̄ 0 which are partitioned as # " # " h i M22 M23 M11 M̂ , M̄ = , where M̂ = M12 M13 . (4.49) M= T T M23 M33 M̂ M̄ From Theorem A.8 on page 115 in Appendix A and M̄ 0 it is clear that T † M̄/ † M22 = M33 − M23 M22 M23 0. (4.50) Furthermore, since M 0 it follows from Theorem A.8 on page 115 that M̂T ∈ R M̄ , and from Theorem A.11 on page 115 it follows that that † T T † T T M22 M23 . (4.51) M22 M12 ∈ R M33 − M23 M13 − M23 By defining the perturbation matrix 0 0 I 0 I 0 Π , , I 0 0 (4.52) the matrix A used in Theorem 4 in Carlson et al. (1974) can be written A = ΠMΠT . (4.53) M/ † M33 / † M̄/ † M33 = M/ † M̄, (4.54) Hence, the relation follows directly from Theorem 4 in Carlson et al. (1974). 56 4.B 57 Derivation of the Dual Problem Furthermore, since M 0 there exists a matrix P such that M̄P = M̂T , and the matrix M can thus be written " M11 M= M̄P (4.55) # P T M̄ . M̄ (4.56) By using this representation the Schur complement M/ † M̄ can be written M/ † M̄ = M11 − P T M̄M̄† M̄P = M11 − P T M̄P . (4.57) Here, the property (A.1) on page 113 of the pseudo inverse has been used. From Theorem A.11 on page 115, the solution to (4.55) can be computed. By inserting this solution into (4.57) and using standard matrix computations gives T † M12 − M/ † M̄ = M11 − P T M̄P = M11 − M12 M22 † T T T † T † † , M12 − M23 M22 M23 M13 M22 M23 M33 − M23 M13 − M12 M22 (4.58) which completes the proof. 4.B Derivation of the Dual Problem The derivation of the dual cftoc problem (4.41) will be similar to the derivation of the dual problem in Axehill (2005). However, the slightly more general cftoc problem (4.39) is considered in this section. 4.B.1 Construct the dual problem Consider a primal cftoc problem given in the form in (4.39) where Assumption 4.8 hold. Introduce the dual variables αt , βt and γt corresponding to the constraints in (4.39) as p α0 ↔ −x0 + x̄ = 0, αt+1 ↔ βt ↔ γt ↔ γN ↔ p p p p p p −xt+1 + At xt + Bt ut + at = 0, t ∈ Z0,N −1 , p p p −zt + Mt xt = 0, t ∈ Z0,N , p p p p p Hx,t xt + Hu,t ut + ht 0, t ∈ Z0,N −1 , p p p Hx,N xN + hN 0, (4.59a) (4.59b) (4.59c) (4.59d) (4.59e) where the symbol ↔ is introduced in Definition 3.8. The first step to derive the dual problem is to use the definitions of these dual variables to form the Lagrangian of the primal cftoc problem. By using the definition of the Lagrangian in (2.8) and the dual variables defined in (4.59), the 58 4 Low-rank Modifications of Riccati Factorizations Lagrangian is given by p p p LP (x , u , z , α, β, γ) = N −1 X t=0 " # 1 ztp T 2 up t p Qz,t p T Q zu,t p " # " p #T " p # Qzu,t ztp lz,t zt p + p + p p + ct p lu,t ut Qu,t ut N −1 X p 1 pT p p p T p p p p p p p T zN Qz,N zN + lz,N zN + cN + −xt+1 + At xt + Bt ut + at + αt+1 2 t=0 p α0T −x0 + x̄ + γNT p p Hx,t xt + N X N −1 X p p p p p p p p γtT Hx,t xt + Hu,t ut + ht + βtT −zt + Mt xt + t=0 t=0 p ht , (4.60) with the corresponding Lagrange dual function g(α, β, γ) = pinf L (xp , up , zp , α, β, γ). p p P (4.61) x ,u ,z To simplify the minimization over the primal variables xp , up , zp in (4.61), the terms in the Lagrangian (4.60) are re-ordered, resulting in p p " # " p #T " p # N −1 " p #T X Qzu,t ztp 1 zt Qz,t l z p p p p z,t t LP (x , u , z , α, β, γ) = + p + ct 2 u p Q p T Q p u p + l p ut t u,t t zu,t u,t t=0 N −1 N t=0 t=0 X X 1 pT p p p T p p p p p p T αt+1 Bt + γtT Hu,t ut − βtT zt + zN Qz,N zN + lz,N zN + cN + 2 N −1 X p p p p p p p T T T + βN MN + γNT Hx,t xN + −αtT + αt+1 At + βtT Mt + γtT Hx,t xt + −αN t=0 α0T x̄ + N −1 X t=0 p T αt+1 at + N −1 X p p γtT ht + γNT ht . t=0 (4.62) When Assumption 4.8 hold it is clear that (4.62) is strictly convex in the primal variables up and zp , and linear in the primal variable xp . Hence, if (4.62) is minimized with respect to all primal variables, the optimal value is not bounded below unless the coefficient in front of xp is zero. As a result, explicit equality constraints that exclude all the values of the dual variables such that g(α, β, γ) = −∞ can be formed as p T p T p T −αt + At αt+1 + Mt βt + Hx,t γt = 0, (4.63a) p T p T −αN + MN βN + Hx,t γN = 0. (4.63b) p These can be identified as the transpose of the coefficient in front of xt and p xN in (4.62), respectively. By inserting (4.63a) and (4.63b) into (4.62), and re- 4.B 59 Derivation of the Dual Problem arringing some terms, the Lagrangian can be written p p " # N −1 " p #T X Qzu,t ztp 1 zt Qz,t p p p + LP (u , z , α, β, γ) = p T p p u 2 ut Qzu,t Q t u,t t=0 T " # p p T p T lz,t − βt ztp (4.64) p p T p T αt+1 + ht γt + p p + ct + at ut lu,t + Bt αt+1 + Hu,t γt p T T p 1 pT p p p p zN Qz,N zN + lz,N − βN zN + cN + hN γN + x̄ T α0 , 2 which is a strictly convex quadratic function of zp and up . From basic optimization results it follows that the minimum of (4.64) with respect to zp and up is obtained at " p# p p −1 p Qzu,t lz,t − βt Qz,t zt , (4.65a) p T p p = − p p T p T ut Qu,t Qzu,t lu,t + Bt αt+1 + Hu,t γt p −1 p p (4.65b) zN = − Qz,N lz,N − βN . Inserting this solution in the Lagrangian (4.64) and introducing the notation p p −1 Q̄zu,t Qz,t Qzu,t Q̄z,t T , p T (4.66) p , Q̄ Q̄u,t Qzu,t Qu,t zu,t to simplify notation gives (after standard, but tedious, matrix algebra and rearrangements) the Lagrange dual function g(α, β, γ) = N −1 α T X 1 t+1 βt − 2 γt t=0 p Bt Q̄u,t Bpt T p T −Q̄ zu,t Bt p p T H Q̄ B u,t u,t t T p −Bt Q̄zu,t Q̄z,t T Q̄zu,t p −Hu,t p T p Bt Q̄u,t Hu,t α p T t+1 βt + −Q̄zu,t Hu,t p T γt p Hu,t Q̄u,t Hu,t T p p p −apt + Bpt Q̄zu,t T lz,t + B Q̄ l u,t t u,t αt+1 " p # Q̄z,t T p p β + lz,t T − Q̄z,t lz,t + Q̄zu,t lu,t t l p Q̄zu,t u,t γ p T t p p p p −ht + Hu,t Q̄zu,t lz,t + Hu,t Q̄u,t lu,t " # p −1 p T " # " #T −1 βN − Q 1 βN Q p lz,N βN 0 z,N + + + z,N p γN 2 γN 0 0 γN −hN 1 p T p −1 p p T lz,N Qz,N lz,N − cN − x̄ α0 , 2 " # Q̄zu,t l p p z,t p − ct l Q̄ u,t u,t (4.67) 60 4 Low-rank Modifications of Riccati Factorizations which is a concave function. Hence, the dual problem to (4.39) can be written as maximize α,β,γ subject to g(α, β, γ) p T p T p T − αt + At αt+1 + Mt βt + Hx,t γt = 0, t ∈ Z0,N −1 p T p T − αN + MN βN + Hx,t γN = 0 γt 0, t ∈ Z0,N , (4.68) or equivalent minimize α,β,γ subject to −g(α, β, γ) p T p T p T − αt + At αt+1 + Mt βt + Hx,t γt = 0, t ∈ Z0,N −1 p T p T − αN + MN βN + Hx,t γN = 0 (4.69) γt 0, t ∈ Z0,N . Here (4.69) is formed by using the fact that maximizing the concave function g(α, β, γ) subject to the constraints corresponds to minimizing the convex function −g(α, β, γ) subject to the same constraints (Boyd and Vandenberghe, 2004). It will now be shown that the dual problem (4.69) can be interpreted as a new cftoc problem in the form in (3.1) by introducing new variables xτd ∈ Rnx and uτd ∈ Rnz +nc,N −τ . The dimensions will be clear from the definitions. Now define τ , N − t, N d , N + 1, and let xτd and uτd be defined as x0d , 0, (4.70) xτd (4.71) , αN +1−τ , τ ∈ Z1,N +1 , # " βN −τ d , τ ∈ Z0,N , uτ , γN −τ (4.72) and define the following matrices, vectors and constants (τ ∈ Z1,N if not stated otherwise) d d d , 0, , 0, lx,0 A0d , 0, Qx,0 , 0, Qxu,0 p T Adτ , AN −τ , T p T p Bdτ , MN , τ ∈ Z0,N , Hx,N −τ −τ p T p d Qx,τ , BN −τ Q̄u,N −τ BN −τ , Q p −1 0 d , z,N Qu,0 , 0 0 p T Q̄ − Q̄ H z,N −τ zu,N −τ u,N −τ d Qu,τ , T T , p p −H p Q̄ H Q̄ H zu,N −τ u,N −τ u,N −τ u,N −τ u,N −τ (4.73a) (4.73b) (4.73c) (4.73d) (4.73e) (4.73f) 4.B 61 Derivation of the Dual Problem T p T p d , −BpN −τ Q̄zu,N −τ , Qxu,τ BN −τ Q̄u,N −τ Hu,N −τ T p p p p p d , −aN −τ + BN −τ Q̄zu,N −τ lz,N −τ + BN −τ Q̄u,N −τ lu,N −τ , lx,τ p −1 p − Q lz,N d z,N lu,0 , , p −hN T p p −Q̄z,N −τ lz,N −τ − Q̄zu,N −τ lu,N −τ d lu,τ , p T p , p p p −h Q̄ + H l + H Q̄ l zu,N −τ u,N −τ N −τ u,N −τ z,N −τ u,N −τ u,N −τ d lx,N d , − x̄, (4.73g) (4.73h) (4.73i) (4.73j) (4.73k) 1 p T p −1 p p lz,N − cN , c0d , lz,N Qz,N 2 " # " p #T Q̄zu,N −τ l p 1 lz,N −τ Q̄z,N −τ d z,N −τ − c p T cτ , p p N −τ . 2 lu,N −τ Q̄zu,N −τ Q̄u,N −τ lu,N −τ (4.73l) (4.73m) Then, the dual problem (4.69) can be equivalently written " # " #T " # d −1 " # NX d d d Qxu,τ 1 xτd T Qx,τ xτd xτd lx,τ d + minimize T d d + d d + cτ d d d d u l u u 2 Q Q x ,u τ u,τ τ τ u,τ xu,τ τ=0 T d d xN lx,N d d subject to x0d = 0 d xτ+1 = Adτ xτd + Bdτ uτd , τ ∈ Z0,N d −1 h i 0 −Inc,N −τ uτd 0, τ ∈ Z0,N d −1 . (4.74) Using these definitions, the dual problem (4.74) can be interpreted as a cftoc problem in the form in (3.1). 4.B.2 Relation between primal and dual variables p p The connection between the primal variables xt and ut , and the solution to the dual problem (4.74) is investigated in this section. The relation between these variables can be used to compute the primal solution from the dual solution. The primal control inputs can be computed using (4.65a) giving T p T p T p T p p ut = − Q̄zu,t lz,t + Q̄zu,t βt − Q̄u,t lu,t − Q̄u,t Bt αt+1 − Q̄u,t Hu,t γt , (4.75) which by using the definition of xτd and uτd in (4.71) and (4.72) is equivalent to T p p T T p T d p p d ut = − Q̄zu,t lz,t − Q̄u,t lu,t − Q̄u,t Bt xN uN −t . −Q̄u,t Hu,t −t + Q̄zu,t (4.76) Hence, given the dual state variables xτd and dual control inputs uτd , the primal control input is computed using (4.76). 62 4 Low-rank Modifications of Riccati Factorizations p To compute the primal state variables xt , the optimality conditions (2.17a) for the dual problem (4.74) is used. Let the dual variables to the dual problem be defined as d λτ+1 ↔ −xτ+1 + Adτ xτd + Bdτ uτd = 0, τ ∈ Z0,N d −1 , h i µτ ↔ 0 −Inc,N −τ uτd 0, τ ∈ Z0,N d −1 . (4.77a) (4.77b) d , Qd d d Then, by using the definition of Qx,τ xu,τ , lx,τ and Aτ in (4.73d), (4.73g), (4.73h) and (4.73b), respectively, the optimality condition (2.17a) gives (for τ ∈ Z0,N d −1 ) T d d d Qx,τ xτd + Qxu,τ uτd + lx,τ + Adτ λτ+1 − λτ = 0 ⇐⇒ p T p T d T p p p uτ + λτ = At λτ+1 + Bt Q̄u,t Bt xτd − Bt Q̄zu,t (4.78) −Q̄u,t Hu,t T p p p p p p p p p Bt Q̄zu,t lz,t + Bt Q̄u,t lu,t − at = At λτ+1 − Bt ut − at . For τ = N d the optimality condition is d d lx,N d − λN d = 0 ⇐⇒ λN d = lx,N d = − x̄, (4.79) d where the definition of lx,N d in (4.73k) has been used. Hence, from (4.78) and p (4.79) it can be seen that if the primal variables xt are computed as p xt = −λN +1−t , (4.80) they will satisfy the dynamics equations in the primal problem (4.39). By inserting this choice of the primal variables into (4.78) and (4.79) gives p p p p p p p p p p p p − xt+1 = −At xt − Bt ut − at , t ∈ Z0,N −1 ⇐⇒ xt+1 = At xt + Bt ut + at , t ∈ Z0,N −1 , (4.81) and p x0 = x̄. (4.82) It can easily be verified that (4.81) and (4.82) are the dynamics constraints in the primal cftoc problem (4.39). p d d , l d and B in (4.73g), (4.73f), Furthermore, by using the definition of Qxu,τ , Qu,τ τ u,τ (4.73j) and (4.73c), respectively, in the optimality condition (2.17a) for the dual problem (4.74) also gives " # T T 0 d d d d d Qxu,τ xτ + Qu,τ uτ + lu,τ + µ + Bdτ λτ+1 = 0 ⇐⇒ −Inc,N −τ τ p T −Q̄zu,t Bp T Q̄z,t −Q̄zu,t Hu,t d t p T xτ + T p T uτd + p p p (4.83) H Q̄ −Hu,t Q̄zu,t Hu,t Q̄u,t Hu,t u,t u,t Bt T p " # " p# p −Q̄z,t lz,t − Q̄zu,t lu,t 0 Mt + T p p −In µτ + H p λτ+1 = 0. p p −h + H p Q̄ c,t x,t lz,t + Hu,t Q̄u,t lu,t zu,t t u,t 4.B 63 Derivation of the Dual Problem The lower block-equations in (4.83) gives p T T p T p T d p p p Hu,t Q̄u,t Bt xτd + Hu,t − Q̄zu,t uτ + Hu,t Q̄zu,t lz,t + Q̄u,t Hu,t p p p p p p Hu,t Q̄u,t lu,t − ht + Hx,t λτ+1 − µτ = 0 ⇐⇒ Hx,t λτ+1 − ht + T p p T T p T d p p uτ + Q̄zu,t lz,t + Q̄u,t lu,t + Q̄u,t Bt xτd = µτ . Hu,t − Q̄zu,t Q̄u,t Hu,t (4.84) p p By using the expressions for xt and ut in (4.80) and (4.76), respectively, together with τ = N − t in (4.84) the following relation is obtained p p p p p p p p − Hx,t xt − Hu,t ut − ht = µN −t ⇐⇒ Hx,t xt + Hu,t ut + ht = −µN −t . (4.85) Hence, the dual variables µτ corresponding to the inequality constraints in the dual problem (4.74) can be interpreted as the slack variables for the inequality constraints in the primal problem (4.39). 5 Parallel Newton Step Computation In recent years much effort has been spent on efficient parallel computations for mpc problems (Constantinides, 2009). In Soudbakhsh and Annaswamy (2013) an extended Parallel Cyclic Reduction algorithm is used to reduce the computation to smaller systems of equations that are solved in parallel. The computational complexity of this algorithm is reported to be O (log N ), where N is the prediction horizon. In Zhu and Laird (2008); Laird et al. (2011); Reuterswärd (2012) a time-splitting approach to split the prediction horizon into blocks is adopted. The subproblems in the blocks are connected through complicating variables and are solved in parallel using Schur complements. The complicating variables are computed via a consensus step where a dense system of equations involving all complicating variables has to be solved sequentially. In O’Donoghue et al. (2013) a splitting method based on Alternating Direction Method of Multipliers (admm) is used, where some steps of the algorithm can be computed in parallel. Stathopoulos et al. (2013) develop an iterative three-set splitting QP solver. In this method the prediction horizon is split into smaller subproblems that can be solved in parallel, and a consensus step using admm is performed to obtain the final solution. In Chapter 3 it was concluded that in both as and ip methods the main computational bottle-neck is computing the Newton step. In this chapter it will be shown how the uftoc problem that corresponds to the Newton step can be solved in parallel on several computational units. Furthermore, it is shown that a uftoc problem of prediction horizon N can be reduced in parallel to a new, smaller uftoc problem in the same form but with prediction horizon p < N . In the algorithm proposed here the solution is computed directly without involving any iterative updates of variables. The material that is presented in this chapter is an extended version of the material presented in Nielsen and Axehill (2014). The 65 66 5 Parallel Newton Step Computation editing has been made to improve the presentation of the results and no technical results are added. The parallel algorithm proposed here is related to nonserial dynamic programming methods that describe the connection between variables in the problem using tree representations, see, e.g., Bertelè and Brioschi (1973); Moallemi (2007); Shcherbina (2007). Nonserial dynamic programming share the basic ideas with serial dynamic programming, see Bertsekas (2000), but can handle more general problem structures. Unlike some nonserial methods in these references, the algorithm presented in this chapter can compute the solution exactly in parallel, and no iterative updates of estimates of the variables are computed. Furthermore, the exact solution can be computed in a finite number of steps, which can be determined a priori to the solution of the problem. The parallel algorithm proposed here and in Nielsen and Axehill (2014) is limited to solving problems in the form (3.39) or a similar form. In Khoshfetrat Pakazad et al. (2015) a more general message-passing algorithm for ip methods has later been presented which extends the results in Nielsen and Axehill (2014). This message-passing algorithm utilizes tree structure representations similar to nonserial dynamic programming and can be used to solve more general problems than (3.39). The uftoc problem that will be focused on in this chapter is given in the form in (3.39) with prediction horizon N , and where assumptions 3.4 and 3.5 are assumed to hold. A problem with this structure will be denoted P (N ), i.e., # " # " #T " # N −1 " #T " X 1 xt Qx,t Qxu,t xt xt lx,t + ct + + minimize T u l u u x,u Q Q 2 t t u,t t u,t xu,t t=0 P (N ) : subject to 1 T T x Q x + lx,N xN + cN 2 N x,N N x0 = x̄ xt+1 = At xt + Bt ut + at , t ∈ Z0,N −1 . (5.1) Hence, using this notation, a uftoc in the principal form (5.1) but with prediction horizon p will be denoted P (p), etc. This will be used to simplify notation in this chapter and in Chapter 6. Remark 5.1. The notation P (N ) is used to denote a family of problems where the instances have the structure of a uftoc problem as the one in (5.1). Hence, two different instances, i.e., uftoc problems with the same structure but different objective functions and constraints, are both denoted P (N ). The following definition of the product operator for matrices will be used Definition 5.2. The product operator for a sequence of matrices Al , Al+1 , . . . , Ak is defined as k Y Ak · · · Al+1 Al , l ≤ k, At , (5.2) I, l > k. t=l 5.1 5.1 67 Problem Decomposition Problem Decomposition The structure of the uftoc problem (5.1) can be exploited by splitting it into smaller subproblems that only share a small number of complicating variables. Given the value of the complicating variables, the subproblems can be solved individually. These smaller subproblems are obtained by splitting the prediction horizon in p + 1 intervals i ∈ Z0,p and introducing local variables x0,i u0,i . . xi , .. , ui , .. , (5.3) uNi−1 ,i xNi ,i and initial constraints x0,i = x̂i for each subproblem, and terminal constraints xNi ,i = di for i ∈ Z0,p−1 . Then, each interval is of length Ni and the relation xNi ,i = x0,i+1 for i ∈ Z0,p−1 holds. Here, di is only used as a dummy variable in an intermediate step. The connections between the subproblems, i.e., xNi ,i = x0,i+1 are introduced as the coupling constraints x̂i+1 = di for i ∈ Z0,p−1 . For notational aspects, and without loss of generality, di is parametrized as di = Âi x̂i + B̂i ûi + âi , where x̂i ∈ Rnx and ûi ∈ Rnû with nû ≤ nx are the complicating variables. How to choose the parametrization Âi , B̂i and âi will soon be shown. Let xt,i and ut,i denote the local states and control inputs in subproblem i. Then, an extended optimization problem that is equivalent to the uftoc problem (5.1) can be constructed as #T " # " #T " #" # " p N i −1 X X Qx,t,i Qxu,t,i xt,i 1 xt,i xt,i lx,t,i + ct,i + minimize + T Qxu,t,i Qu,t,i ut,i ut,i lu,t,i x̂,û,xi ,ui 2 ut,i i=0 t=0 |{z} | {z } ,Qt,i subject to ,lt,i 1 T x Q x + lT x + cNp ,p 2 Np ,p Np ,p Np ,p Np ,p Np ,p x̂0 = x̄0 x0,i = x̂i ∀ i ∈ Z0,p xt+1,i = At,i xt,i + Bt,i ut,i + at,i , t ∈ Z0,Ni −1 xN ,i = Âi x̂i + B̂i ûi + âi , i , p i x̂i+1 = Âi x̂i + B̂i ûi + âi , i ∈ Z0,p−1 , (5.4) where the variables Qt,i , lt,i , ct,i , At,i , Bt,i and at,i are defined conformly. Note that the initial state x̂0 is equal to the initial state of the original problem (5.1). The word ”extended” is used here to indicate that the uftoc problem (5.1) is extended with both extra variables and constraints to form (5.4). The introduction of the terminal constraints might result in infeasible subproblems. Hence, in order to obtain feasible subproblems in (5.4), the parametrizations of the terminal constraints must be chosen such that it is possible to satisfy these constraints. To do this, the dynamics constraints in subproblem i can be 68 5 Parallel Newton Step Computation used to compute the final state in subproblem i given the control signals ui and the initial state x̂i as xNi ,i = Ai x̂i + Si ui + Di ai , (5.5) where Ai , QNi −1 Si , hQ Ni −1 t=0 t=1 At,i , Di , At,i B0,i hQ Ni −1 ··· t=1 At,i ··· i I , ANi −1,i ANi −1,i BNi −2,i i BNi −1,i , (5.6) (5.7) and ai and ui are the stacked at,i and ut,i for t ∈ Z0,Ni −1 , respectively. The product operator is defined in Definition 5.2. The feasibility of the subproblem can be ensured by a careful selection of the parametrization of the problem. Here, this is performed by requiring that the final state satisfies the terminal constraint xNi ,i = di = Âi x̂i + B̂i ûi + âi , where di is in the reachable subspace given by Ai , Si and Di ai . This can be assured by requiring Âi , Ai , B̂i , Ti , âi , Di ai , (5.8) where the columns of Ti form a basis for the range of Si . Remark 5.3. The terminal state xNi ,i in the subproblems i ∈ Z0,p−1 can be discarded, and the two constraints xNi ,i = ANi −1,i xNi −1,i + BNi −1,i uNi −1,i + aNi −1,i , xN ,i = Âi x̂i + B̂i ûi + âi , i (5.9) can be combined into a single constraint Âi x̂i + B̂i ûi + âi = ANi −1,i xNi −1,i + BNi −1,i uNi −1,i + aNi −1,i , (5.10) and the corresponding parts in the objective function are discarded. However, for notational purposes the terminal state xNi ,i will be used as a local variable in the suproblems. For i ∈ Z0,p−1 the individual subproblems in (5.4) are given by minimize xi ,ui subject to N i −1 X t=0 " #T " Qx,t,i 1 xt,i T Qxu,t,i 2 ut,i Qxu,t,i Qu,t,i #" # " #T " # xt,i l xt,i + x,t,i + ct,i ut,i lu,t,i ut,i x0,i = x̂i xt+1,i = At,i xt,i + Bt,i ut,i + at,i , t ∈ Z0,Ni −1 xNi ,i = Âi x̂i + B̂i ûi + âi . (5.11) Here i is the index of the subproblem. The last subproblem i = p is on the same form as in (5.11) but with the additional term 1 T x Q x + lT x + cNp ,p , 2 Np ,p Np ,p Np ,p Np ,p Np ,p (5.12) 5.1 69 Problem Decomposition in the objective function, and no terminal constraint on xNp ,p , i.e., Np −1 minimize xp ,up X 1 "x t=0 subject to #T " t,p 2 ut,p Qx,t,p T Qxu,t,p Qxu,t,p Qu,t,p #" # " #T " # xt,p l xt,p + x,t,p + ct,p + ut,p lu,t,p ut,p 1 T x Q x + lT x + cNp ,p 2 Np ,p Np ,p Np ,p Np ,p Np ,p x0,p = x̂p xt+1,p = At,p xt,p + Bt,p ut,p + at,p , t ∈ Z0,Np −1 . (5.13) Temporarily excluding details, each subproblem (5.11) can be solved parametrically and the solution to each subproblem is a function of the complicating variables x̂i and ûi , and the parametric solution to subproblem (5.13) is a function of x̂p . Furthermore, the value function V̂i (x̂i , ûi ) for each subproblem is also a function of the complicating variables. By inserting these parametric solutions of all subproblems in (5.4) and using the coupling constraints between the subproblems, the extended problem (5.4) can be reduced to the master problem #" # " #T " # " # " p−1 X 1 x̂ T Q̂ Q̂xu,i x̂i lˆ x̂i x,i i + ĉi + + ˆx,i minimize T ûi Q̂xu,i Q̂u,i ûi x̂,û 2 ûi lu,i i=0 |{z} | {z } ,Q̂i P (p) : subject to ,lˆi 1 T x̂ Q̂ x̂ + lˆT x̂ + ĉp 2 p p p p p x̂0 = x̄0 x̂i+1 = Âi x̂i + B̂i ûi + âi , i ∈ Z0,p−1 . (5.14) Here Âi , B̂i , âi , Q̂i , lˆi and ĉi are computed in each subproblem i and represent the constraints and the value function in each subproblem, respectively. The dynamics constraints in the master problem are given by the coupling constraints between the subproblems in (5.4). This new uftoc problem is on the same form as the original uftoc problem (5.1), but with prediction horizon p < N . The reduction of the problem is summarized in Theorem 5.4 and is graphically depicted in Figure 5.1, where the dotted lines represent repetition of the structure. This approach is similar to primal decomposition which is described in Lasdon (1970); Boyd et al. (2008), where the p + 1 subproblems share complicating variables x̂i and ûi that are generally computed iteratively. In the work presented in this chapter it is shown that the master problem that is solved to compute the complicating variables is in the form of a uftoc problem. Hence the complicating variables are determined directly by solving the new, reduced uftoc problem at the upper level in Figure 5.1 directly (non-iteratively). Inserting the optimal x̂i and ûi into the subproblems given by (5.11) and x̂p into the problem (5.13) gives the solution to (5.1). 70 5 P (p) : P (N ) : x̂0 , û0 , V̂0 Parallel Newton Step Computation x̂j , ûj , V̂j P0 (N0 ) x̂p , V̂p Pj (Nj ) Pp (Np ) Figure 5.1: The parameters x̂i and ûi in each subproblem i can be interpreted as new state and control variables in the reduced uftoc problem with prediction horizon p. The value functions V̂i (x̂i , ûi ) are the terms in the new objective function. Theorem 5.4. Consider an optimization problem P (N ) defined in (5.1). Then P (N ) can be reduced to P (p) in parallel, where 1 ≤ p < N . Furthermore, the primal and dual optimal solutions x∗ , u∗ and λ∗ to P (N ) can be computed in parallel from the primal and dual solutions x̂∗ , û∗ and λ̂∗ to P (p). Proof: For the proof of Theorem 5.4, see Appendix 5.A. In the remainder of this section it will be shown how the subproblems (5.11) and (5.13) are solved parametrically and how the matrices in (5.14) are computed. 5.1.1 Solution of the subproblems In this section, it will be shown that each subproblem i ∈ Z0,p can be solved parametrically and that the solution can be expressed as a function of the complicating variables x̂i and ûi for i ∈ Z0,p−1 and x̂p for i = p. For now it is assumed that licq holds for (5.11). By defining the parameter vector θi as " # x̂ θi , i , i ∈ Z0,p−1 , θp , x̂p , (5.15) ûi the optimization problem (5.11) can be cast in a more compact form minimize 1 T X Q X + lT X + ci 2 i i i i i subject to Ai Xi = bi + Gi θi , Xi (5.16) where the optimization variables Xi and the corresponding matrices are defined as x0,i u 0,i .. Xi , . , uN −1,i i xNi ,i Q0,i 0 Qi , .. . 0 0 .. . .. . ··· ··· .. . QNi −1,i 0 0 .. . , 0 0 l0,i . . li , . , lN −1,i i 0 ci , NX i −1 ct,i , t=0 (5.17a) 5.1 71 Problem Decomposition −I A0,i 0 Ai , . .. . . . 0 0 ··· B0,i 0 .. . .. . ··· −I A1,i 0 −a0,i .. bi , , . −aN −1,i i −âi ··· 0 ··· .. . ··· ANi −1,i ··· Gi , −I 0 .. . 0 −Âi BNi −1,i 0 0 .. . , 0 −I −I 0 0 .. . . 0 −B̂i (5.17b) (5.17c) Remark 5.5. For a subproblem where licq holds, Âi = 0, B̂i = I and âi = 0 in the parametrization of the terminal constraint are valid choices since Si has full row rank. The dual variables λi corresponding to the equality constraints in (5.11) are introduced as λ0,i λ 1,i λi , ... , (5.18) λN ,i i λtc,i where λ0,i ↔ −x0,i + x̂i = 0, λt+1,i ↔ −xt+1,i + At,i xt,i + Bt,i ut,i + at,i = 0, t ∈ Z0,Ni −1 , λtc,i ↔ −xNi ,i + Âi x̂i + B̂i ûi + âi = 0. (5.19a) (5.19b) (5.19c) The symbol ↔ is introduced in Definition 3.8. The subscript ”tc” is an abbreviation of ”terminal constraint”. Note that (5.16) is a very simple multiparametric quadratic programming problem with parameters θi and only equality constraints. Hence the optimal primal and dual solution to this problem are both affine functions of the parameters θi (Tøndel et al., 2003). Remark 5.6. Since the simple parametric programming problem (5.16) is only subject to equality constraints, it is not piecewise affine in the parameters. Hence, the solution to this equality constrained problem can be computed cheaply and it does not suffer from the complexity issues of a general multiparametric programming problem. 72 5 Parallel Newton Step Computation Since licq is assumed to hold, the unique optimal primal and dual solution can be expressed as Xi∗ (θi ) = Kix θi + kix , (5.20) λ∗i (θi ) = Kiλ θi + kiλ , (5.21) for some Kix , kix , Kiλ and kiλ (Tøndel et al., 2003). Here i denotes the index of the subproblem. The value function of (5.11) expressed in the parameter θi is obtained by inserting the parametric primal optimal solution (5.20) into the objective function in (5.16), resulting in V̂i (θi ) = 1 T θ Q̂ θ + lˆT θ + ĉi , 2 i i i i i (5.22) where Q̂i , (Kix )T Qi Kix , T T lˆi , Kix li + Kix Qi kix , ĉi , ci + 1 x T (k ) Qi kix + lTi kix . 2 i (5.23a) (5.23b) (5.23c) The last subproblem given by (5.13) is different from the p first subproblems since there is no terminal constraint on xNp ,p . Hence the parametric solution of this subproblem only depends on the initial state x̂p , and λp in (5.18) and Qp , lp , cp , Ap , bp and Gp in (5.17) are modified accordingly. The derivation of the solution is analogous to the one for the subproblems i ∈ Z0,p−1 , but with θp = x̂p . The unique optimal primal and dual solutions to (5.13) are hence given by (5.20) and (5.21), and the value function is given by (5.22) (all with i = p). 5.1.2 Solution of a primal degenerate subproblem The terminal constraint in a subproblem given by (5.11) introduces nx new constraints, which might result in violation of licq for the subproblem even though this is not the case in the original uftoc problem (5.1). According to Definition 2.12, violation of licq is known as primal degeneracy and the dual variables for a primal degenerate problem are non-unique (Tøndel et al., 2003). In this section it will be shown how to choose dual variables in the subproblems that satisfy the optimality conditions of the original uftoc problem (5.1). Remark 5.7. If the subproblem violates licq when xNi ,i is used as a local variable in (5.11), it violates licq even when xNi ,i is excluded as was mentioned in Remark 5.3 and the constraints are combined as in (5.10). The optimal parametric primal solution to a primal degenerate problem in the form (5.16) is given by (5.20) and the optimal dual solution is given by where λN i λ∗i (θi ) = Kiλ θi + kiλ + λN (5.24) i , ∈ N ATi (Tøndel et al., 2003). Here N ATi is the nullspace of ATi , 5.1 73 Problem Decomposition and the expression for N ATi is given by Lemma 5.8. Lemma 5.8. The nullspace of ATi is given by n o N ATi , z | z = Zi wi , ∀wi ∈ N SiT , (5.25) where T −Âi Zi , −DiT , I (5.26) and Âi and D are defined in (5.6) and Si is the reachability matrix defined in (5.7). Proof: For the proof of Lemma 5.8, see Appendix 5.B. Remark 5.9. Note that Zi is computed cheaply since the matrices Âi and Di are already computed. The dual variables of the extended problem (5.4) are introduced by (5.19) for each subproblem, and by λ̂0 ↔ −x̂0 + x̄0 = 0, (5.27a) λ̂i+1 ↔ −x̂i+1 + Âi x̂i + B̂i ûi + âi = 0, i ∈ Z0,p−1 , (5.27b) for the coupling constraints that connect the subproblems in (5.4). Note that λtc,i in (5.19c) is the dual variable corresponding to the terminal constraint in each subproblem, whereas λ̂i+1 in (5.27b) are the dual variables corresponding to the coupling constraints between the subproblems (interpreted as the dynamics constraints in the master uftoc problem (5.14)). Hence, λtc,i is computed in the subproblem, and λ̂i is computed when (5.14) is solved. This is depicted in Figure 5.2 where the upper level corresponds to the master uftoc problem (5.14) and the lower level to problem (5.4) (which is equivalent to P (N )). The purpose in this chapter is to compute a solution to the original uftoc problem (5.1) by computing solutions to the p + 1 subproblems given in the form in (5.11) and (5.13). However, for primal degenerate subproblems the dual solutions are non-unique (Tøndel et al., 2003), and it is necessary to choose dual solutions to the subproblems that satisfy the optimality conditions of the original uftoc problem (5.1). To do this, the relations between the dual variables of different subproblems are exploited and it is shown that it is possible to select the dual solution such that this is achieved. The relation between the dual variables in different subproblems is given by Theorem 5.10 and Corollary 5.11. 74 5 Parallel Newton Step Computation λ̂j+1 =λ̂p λ̂j z P (p) : P (N ) : }| x̂i , ûi x0,i z { }| { x̂p x̂j , ûj xNi ,i x0,j |{z} |{z} |{z} λtc,i λ0,i x0,p xNj ,j xNp ,p |{z} |{z} λtc,j λ0,j λ0,p Figure 5.2: The dual variables λ̂i in the reduced problem are related to the dual variables λtc,i and λ0,i+1 in the subproblems. Theorem 5.10. Consider an optimization problem in the form in (5.4). Let the dual variables be defined by (5.19) and (5.27). Then, the relations between the optimal dual solutions in different subproblems are given by λ0,p = λ̂p , (5.28a) λ0,i = λ̂i − ÂTi λtc,i + λ̂i+1 , i ∈ Z0,p−1 , B̂Ti λtc,i + λ̂i+1 = 0, i ∈ Z0,p−1 , (5.28b) λNi ,i = −λtc,i , i ∈ Z0,p−1 , (5.28d) (5.28c) where Âi and B̂i are defined in (5.8). Proof: For the proof of Theorem 5.10, see Appendix 5.C. Corollary 5.11. Let the assumptions in Theorem 5.10 be satisfied, and let licq hold for all subproblems i ∈ Z0,p . Then the optimal dual variables in the subproblems are unique and the relations between the dual solutions in the subproblems are given by λ0,i = λ̂i , i ∈ Z0,p , (5.29a) λtc,i = −λ̂i+1 = −λ0,i+1 , i ∈ Z0,p−1 , (5.29b) λNi ,i = −λtc,i = λ0,i+1 , i ∈ Z0,p−1 . (5.29c) Proof: Let licq hold for all subproblems i ∈ Z0,p in (5.4). Then N ATi = ∅, i ∈ Z0,p and the dual solutions are unique. Furthermore, (5.28c) rank(Si ) = nx ⇐⇒ Ti = B̂i ∈ Rnx ×nx non-singular ⇒ λtc,i = −λ̂i+1 . (5.30) Inserting (5.30) into (5.28b) and using (5.28a) gives λ0,i = λ̂i , i ∈ Z0,p , which by also inserting (5.30) into (5.28d) gives (5.29c). Lemma 5.8 is used to choose the nullspace element λN i in (5.24) to obtain the correct dual solution for subproblem i. According to the lemma, λN i can be com- 5.2 75 Parallel Computation of Newton Step T puted as λN i = Zi wi , wi ∈ N Si , giving the optimal dual variable for subproblem i as (5.31) λ∗i (θi , wi ) = Kiλ θi + kiλ + Zi wi , wi ∈ N SiT . Let ξi = Kiλ θi + kiλ be the dual solution when the minimum norm nullspace element is selected, and let λ̂i be given by the dual solution to problem (5.14). Then it follows from Theorem 5.10 that ξ0,i = λ̂i − ÂTi (ξtc,i + λ̂i+1 ), i ∈ Z0,p−1 , (5.32a) B̂Ti (ξtc,i + λ̂i+1 ) = 0, i ∈ Z0,p−1 , (5.32b) ξNi ,i = −ξtc,i , i ∈ Z0,p−1 . (5.32c) To obtain a dual solution λi which satisfies the optimality conditions for the original problem (5.1), the freedom in the choice of the dual variables from (5.31) is exploited, i.e., the dual variable is chosen as λi = ξi + Zi wi . (5.33) Theorem 5.10 certifies that the relation λNi ,i = λ̂i+1 = λ0,i+1 holds if λtc,i = −λ̂i+1 holds. This is the same relation as in the non-degenerate case and, hence, satisfies the optimality conditions of (5.1). The last block in (5.26) and (5.33) give λtc,i = ξtc,i + wi and hence, to obtain λtc,i = −λ̂i+1 , wi is chosen as wi = −(ξtc,i + λ̂i+1 ) ∈ N SiT ⇒ λtc,i = −λ̂i+1 . (5.34) Note that (5.32b) gives that wi = −(ξtc,i + λ̂i+1 ) ∈ N B̂Ti = N SiT . By using this choice of wi in the optimal dual solution (5.31) together with (5.26), (5.32a) and (5.32c) the following hold N λ0,i = ξ0,i + λ0,i (5.26) = ξ0,i − ÂTi wi λNi ,i = ξNi ,i + λN Ni ,i (5.26) & (5.32c) = (5.32a) = λ̂i , i ∈ Z0,p−1 , −ξtc,i − wi (5.34) = λ̂i+1 , i ∈ Z0,p−1 . (5.35) (5.36) Hence, the dual solution of subproblem i satisfies the optimality conditions for the uftoc problem (5.1) if it is computed as λ∗i (θi , λ̂i+1 ) = Kiλ θi + kiλ − Zi (ξtc,i + λ̂i+1 ) = ξi − Zi (ξtc,i + λ̂i+1 ). (5.37) The dual solution to the original problem can be retrieved from (5.37) for i ∈ Z0,p−1 and (5.21) for i = p (for which licq always holds). 5.2 Parallel Computation of Newton Step In Section 5.1 it was shown that a uftoc problem P (N ) can be solved by splitting it into subproblems and reducing it to a master uftoc problem P (p) with p < N , and then solve this master problem P (p) to determine the optimal parameters of the subproblems. The master problem P (p) can be solved using any suitable method for equality constrained qps. However, a key feature here is that Theo- 76 5 P (pm−1 ) : P (p0 ) : P (N ) : P00 (N00 ) Parallel Newton Step Computation P0m (N0m ) P01 (N01 ) Pp11 (Np11 ) Pi0 (Ni0 ) Pj0 (Nj0 ) Pp00 (Np00 ) Figure 5.3: The tree structure obtained when the uftoc problems are reduced in several steps. Each level in the tree forms a uftoc problem that is again split into several smaller problems. Pik (Nik ) denotes a subproblem in the form in (5.11) with prediction horizon Nik . rem 5.4 guarantees that the master problem is a uftoc problem in the form (5.1) with prediction horizon p. Hence, instead of solving P (p) completely, it can be reduced again to a uftoc problem with even shorter prediction horizon. In this section it will be shown how Theorem 5.4 can be used repeatedly to obtain a problem structure that can be solved in parallel. Each reduction has the principal structure as is shown in Figure 5.1, and repeatedly reducing the problems thus creates the tree structure that can be seen in Figure 5.3. Let the uftoc problem at level k have prediction horizon pk−1 and be denoted P (pk−1 ), and let Pik (Nik ) be the i:th subproblem in the form (5.11) (or (5.13)) with prediction horizon Nik at level k, where i ∈ Z0,pk . Then each level in the tree is a uftoc problem, and the nodes are its corresponding subproblems. The top node P0m (N0m ) is not reduced further, but instead solved completely, and the leaves at the bottom of the tree are the subproblems of the original uftoc problem P (N ). The problem P (pk−1 ) is reduced to its master problem P (pk ) by solving all subproblems Pik (Nik ), i ∈ Z0,pk parametrically according to Section 5.1. Since all of the subproblems Pik (Nik ) are independent and only communicates with its parent in the tree in Figure 5.3, this can be done in parallel. While repeatedly reducing the uftoc problems, i.e., moving up in the tree in Figure 5.3, the parametric solution that is communicated to its parent consists of the value of the objective function of each subproblem as a function of the complicating variables, and the dynamics equations from the initial state to the terminal state. The reduction of the uftoc problem is continued until the top problem, which has a pre-determined minimum prediction horizon, is obtained. The size of this problem is pre-defined by the user, and hence also the maximum number of levels in the tree is known a priori to the solution. When the top node has been solved, the optimal parameter values are propagated down in the tree to its children. Hence, the original problem P (N ) is solved by first reducing the problem in m steps until P (pm−1 ) is obtained, and thereafter propagating the solution of P (pm−1 ) down to level k = 0. Since information is exchanged between parents 5.2 Parallel Computation of Newton Step 77 and children only, the optimal solution to each Pik (Nik ) can be computed individually from the other subproblems at each level k, meaning that this can be done completely in parallel for each level. The solution to P (N ) can thus be computed directly in parallel without involving any iterative step. Note however that m a priori known and user defined reduction steps and m propagating steps have to be performed for each time the uftoc problem is solved. Remark 5.12. At each level k in the tree in Figure 5.3 the complicating variables for level k − 1 are computed. Hence, the consensus step to decide the complicating variables at each level is done in one iteration, and it is not necessary to iterate to get consensus between the subproblems as in many other parallel methods. The theory presented in this chapter is summarized in algorithms 11 and 12. The algorithms can be used to compute the Newton step, which is defined by the solution to (5.1), in parallel. The computations can be performed using several computational units, and the level of parallelism can be tuned to fit the hardware, e.g., the number of processing units, memory capacity, bus speed and more. The level of parallelism is decided by adjusting the number of subproblems at each level in the tree in Figure 5.3. Similar ideas as is used in partial condensing, introduced in Axehill (2015), can be used to decide the sizes of the subproblems. 5.2.1 Algorithms for parallel Newton step computation The algorithm for solving the uftoc problem P (N ) in parallel is based on two major steps; reduce the uftoc problem in several steps according to the tree structure in Figure 5.3, followed by a propagation of the solution from the top level downwards in the tree to the bottom level. In both steps standard parallel numerical linear algebra can be used to further parallelize for example matrix multiplications, backward and forward substitutions and factorizations. Here, the focus is on parallelization using the inherent structure of the uftoc problem (5.1), and the scope will be limited to this in the thesis. The first step is summarized in Algorithm 11. Since all subproblems at the same level are independent of each other, the parfor-loop on lines 6-10 in Algorithm 11 can be performed in parallel on different computational units. Let pmax be the maximum number of subproblems at any level in the tree. Then, if there are pmax computational units available, all subproblems Pik (Nik ) at level k can be solved simultaneously. The size of the subproblems can be adjusted such that the maximum number of subproblems at the bottom level is equal to the number of available computational units. The second step is to propagate the solution from the top problem down in the tree until the subproblems at the bottom level are solved. The propagation of the solution is summarized in Algorithm 12. Since all subproblems in the tree only use information from their parents, the parfor-loop at lines 4-13 in Algorithm 12 can be computed in parallel. As for the first step, if there is one computational unit for each subproblem, all problems at each level in the tree can be solved simultaneously. 78 5 Parallel Newton Step Computation Algorithm 11 Parallel reduction of uftoc problem 1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: Set the maximum level number m Set the number of subproblems pk + 1 for each level k ∈ Z0,m−1 for k = 0, . . . , m − 1 do Split the prediction horizon into pk + 1 segments 0, . . . , N0k up to 0, . . . , Npkk Create subproblems i = 0, . . . , pk for each time block parfor i = 0, . . . , pk do Solve subproblem i parametrically and store Kix , kix , Kiλ and kiλ Compute Âi , B̂i , âi , Q̂i , lˆi and ĉi for the next level Compute and store Zi end parfor end for Algorithm 12 Parallel propagation of solution 1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: Get maximum level number m from Algorithm 11 Solve the top problem P0m (N0m ) with x0m := x̄ for k = m − 1, . . . , 0 do parfor i = 0, . . . , pk do Compute primal solution given by (5.20) Compute dual solution given by (5.21) if Primal degenerate subproblem Select the dual solution according to (5.37) end if if k > 0 k−1 Send parameters θt,i to each children at level k − 1 end if end parfor end for So far no assumptions on the length of the prediction horizon of each subproblem has been made. If, however, the length of each subproblem is fixed to Ns , and the prediction horizon of the original problem is chosen as N = Nsm+1 for simplicity, then the tree will get m + 1 levels. Furthermore, assume that Nsm processors are available. Then, since m = logNs (N ) − 1, the computational complexity grows logarithmically in the prediction horizon, i.e. as O (log N ). The optimal length Ns of the subproblems can be adjusted to fit the hardware which the algorithms are implemented on. Depending on for example the number of computational units, the available memory and the communication overhead between processors, the size of Ns can be chosen differently. How to optimally adjust the size of the subproblems is not investigated here, but it could possibly be done by for example benchmarking the algorithm using the desired hardware and mapping the performance versus different sizes of the subproblems. Remark 5.13. Since the tree structure in Figure 5.3 is pre-determined by the user, the major parts of lines 4 and 5 in Algorithm 11 can be done prior to the solution. 5.3 Numerical Results 79 Remark 5.14. The sizes of different subproblems in Figure 5.3 can be different, both within the same level and between levels. Hence, depending on for example the communication layout on the computational cluster, different sizes of the subproblems can be used to reduce the total computation time. Remark 5.15. If the parallel algorithm is used to compute uftoc problems in an as method, the eliminated dual variables must be computed as in Section 3.5 using Algorithm 7.Given the primal and dual solution to the uftoc problem, it can be seen that this algorithm can be computed in parallel for the independent intervals i ∈ Z0,p . 5.3 Numerical Results The proposed algorithm for computing the Newton step in parallel has been implemented in Matlab and used to solve random stable uftoc problems in the form (5.1). The algorithm has been implemented serially, and the parallel computation times are simulated by summing over the maximum solution time at each level in the tree. Hence, memory and communication delays have not been addressed here. This approximation is investigated and commented in more detail in Chapter 6. In the implemented algorithm Kix , kix , Kiλ and kiλ are computed using the methods proposed in Tøndel et al. (2003). The implementation faced some numerical issues when unstable lti systems were used. Hence, stable systems have been used to evaluate performance. Remark 5.16. It is possible to use prestabilization to obtain stable lti systems even when the original lti system is unstable. Remark 5.17. Here the structure in the subproblems is not exploited when computing Kix , kix , Kiλ and kiλ , which can be expected to increase performance even more. An alternative algorithm that exploits also the structure in the subproblems is presented in Chapter 6. The numerical results for the algorithm when solving Newton steps for problems with nx = 15, nu = 10 and Ns = 2 are seen in Figure 5.4. The computation times are averaged over fifteen problems of the same size. Here, the proposed algorithm has been compared to a well known state-of-the-art serial algorithm based on the Riccati recursion presented in Section 3.4, which has O (N ) complexity growth. From the figure, the linear complexity of the Riccati based algorithm is evident. It is not obvious from this plot that the complexity grows logarithmically for the implementation of the proposed parallel algorithm. However, it can be observed that the computation time required by the parallel algorithm is significantly less and the growth of the computational complexity is much lower. The simulations were performed on an Intel Core i7-3517U CPU @ 1.9GHz running Windows 7 (version 6.1, build 7601: Service Pack 1) and Matlab (8.0.0.783, R2012b). 80 5 Parallel Newton Step Computation Computation time averaged over 15 runs 101 Parallel: Chapter 5 Serial Riccati Time [s] 100 10−1 10−2 10−3 101 102 Prediction horizon 103 Figure 5.4: Average computation times for the parallel solution of P (N ). It is compared to a serial Riccati algorithm with O (N ) complexity. Here, systems of dimension nx = 15 and nu = 10 have been used. Appendix This appendix contains the proofs of some of the theorems and lemmas presented in this chapter. First, the equations in the kkt system for the uftoc problem (5.1) and the extended uftoc problem (5.4) are presented. These equations are used in several of the proofs in this appendix. The original uftoc problem is given by (5.1). Let the dual variables λt , corresponding to the dynamics constraints, be defined as λ0 ↔ −x0 + x̄ = 0, λt ↔ −xt+1 + At xt + Bt ut + at = 0, t ∈ Z0,N −1 . (5.38a) (5.38b) By writing down the equations of the kkt system it is seen that the following equations hold for an optimal solution to (5.1) Qx,t xt + Qxu,t ut + lx,t − λt + ATt λt+1 = 0, t ∈ Z0,N −1 , (5.39a) T Qxu,t xt (5.39b) (5.39c) (5.39d) (5.39e) BTt λt+1 + Qu,t ut + lu,t + = 0, t ∈ Z0,N −1 , Qx,N xN + lx,N − λN = 0, xt+1 = At xt + Bt ut + at , t ∈ Z0,N −1 , x0 = x̄0 . The extended problem is given in (5.4) and the complicating variables x̂i and ûi are introduced as optimization variables in this extended problem. Let the dual variables corresponding to constraints in the subproblems i ∈ Z0,p be defined by (5.19) and let the dual variables corresponding to the coupling constraints be defined in (5.27). Then, the kkt system for the extended problem consists of the 81 82 5 Parallel Newton Step Computation following equations Qx,t,i xt,i + Qxu,t,i ut,i + lx,t,i − λt,i + ATt,i λt+1,i = 0, t ∈ Z0,Ni −1 , i ∈ Z0,p , (5.40a) T xt,i + Qu,t,i ut,i + lu,t,i + BTt,i λt+1,i = 0, t ∈ Z0,Ni −1 , i ∈ Z0,p , Qxu,t,i (5.40b) QNp ,p xNp ,p + lNp ,p − λNp ,p = 0, (5.40c) x0,i = x̂i , i ∈ Z0,p , (5.40d) xt+1,i = At,i xt,i + Bt,i ut,i + at,i , t ∈ Z0,Ni −1 , i ∈ Z0,p , (5.40e) xNi ,i = Âi x̂i + B̂i ûi + âi , i ∈ Z0,p−1 , (5.40f) x̂0 = x̄, (5.40g) x̂i+1 = Âi x̂i + B̂i ûi + âi , i ∈ Z0,p−1 , (5.40h) λ0,p = λ̂p , (5.40i) λ0,i = λ̂i − ÂTi (λtc,i + λ̂i+1 ), i ∈ Z0,p−1 , (5.40j) B̂Ti (λtc,i + λ̂i+1 ) = 0, i ∈ Z0,p−1 , (5.40k) λNi ,i = −λtc,i , i ∈ Z0,p−1 . (5.40l) 5.A Proof of Theorem 5.4 The proof of Theorem 5.4 is based on the derivation of the kkt systems for the uftoc problem (5.1) and the extended problem (5.4), given in the introduction of this appendix. In the proof it will be shown that the solutions to the subproblems given by (5.20) and (5.37) together satisfy the kkt conditions (5.39) for the original uftoc problem (5.1). Proof: The parallel reduction of P (N ) to P (p) with p < N follows directly from the theory presented in the text in Section 5.1. Let x̂∗ , û∗ and λ̂∗ be the optimal primal and dual solutions to the master problem P (p) in (5.14). By using these optimal parameters, the primal and dual optimal solutions Xi∗ and λi ∗ to each subproblem i ∈ Z0,p−1 are given by (5.20) and (5.37), and by (5.20) and (5.21) for i = p. Hence x̂∗ , û∗ , λ̂∗ , Xi∗ and λ∗i satisfy the kkt conditions in (5.40). For the optimal solution it follows from (5.40d), (5.40f) and (5.40h) that ∗ xN i ,i (5.40f) = Âi x̂i∗ + B̂i ûi∗ + âi (5.40h) = ∗ x̂i+1 (5.40d) = ∗ x0,i+1 , i ∈ Z0,p−1 , (5.41) is satisfied and hence the relation ∗ ∗ xN = x0,i+1 , i ∈ Z0,p−1 , i ,i (5.42) holds between the terminal state in subproblem i and the initial state in subproblem i + 1. Hence, the dynamics equations in (5.40e) and (5.40g) for t ∈ Z0,Ni −1 5.A 83 Proof of Theorem 5.4 and i ∈ Z0,p can be written ∗ x0,0 = x̄, ∗ x1,0 ∗ ∗ x0,i+1 = xN i ,i = (5.43a) ∗ A0,0 x0,0 + ∗ B0,0 u0,0 + a0,0 , (5.43b) .. . ∗ ∗ = ANi −1,i xN + BNi −1,i uN + aNi −1,i , i −1,i i −1,i (5.43c) ∗ ∗ ∗ x1,i+1 = A0,i+1 x0,i+1 + B0,i+1 u0,i+1 + a0,i+1 , ∗ xN p ,p (5.43d) .. . ∗ ∗ = ANp −1,p xN + BNp −1,p uN + aNp −1,p . p −1,p p −1,p (5.43e) Here the relation (5.42) has been used in (5.43c) for all i ∈ Z0,p−1 . Furthermore, At,i , Bt,i and at,i were implicitly defined as At,i , APi−1 N j=0 j +t , Bt,i , BPi−1 N j=0 j +t , at,i , aPi−1 N j=0 j +t , (5.44) when the extended problem (5.4) was constructed. By using these definitions and also defining the variables ∗ ∗ x0,0 u0,0 . . . ∗ .. ∗ . x0 x∗ u0 u ∗ . Ni −1,i . Ni −1,i ∗ ∗ , . . x , . = ∗ (5.45) , u , . = u ∗ x0,i+1 0,i+1 ∗ ∗ . xN u .. N −1 . . . x∗ u ∗ Np −1,p Np ,p it can be seen that the equations in (5.43) can be written x0∗ = x̄, x1∗ = A0 x0∗ + B0 u0∗ + a0 , .. . ∗ ∗ ∗ xN = AN −1 xN −1 + BN −1 uN −1 + aN −1 . (5.46) (5.47) (5.48) These equations can be identified as the dynamics equations in the original uftoc problem (5.1), and hence it is clear that x∗ and u∗ satisfy (5.39d) and (5.39e) in the kkt system for the original uftoc problem. Furthermore, the optimal dual solution λ∗i is computed as in (5.37), and according to the discussion in Section 5.1.2 and specifically (5.34) this solution is chosen such that it satisfies λtc,i = −λ̂i+1 . (5.49) Hence, using this dual solution (5.40j) and (5.40l) gives λ∗Ni ,i (5.40l) = −λ∗tc,i (5.34) = λ̂∗i+1 (5.40j) = λ∗0,i+1 , i ∈ Z0,p−1 , (5.50) 84 5 Parallel Newton Step Computation and (5.40i) gives λ∗0,p = λ̂∗p . (5.51) By using (5.50) it can be seen that (5.40a) and (5.40b) for t = Ni − 1 can be written ∗ ∗ Qx,Ni −1,i xN + Qxu,Ni −1,i uN + lx,Ni −1,i − λ∗Ni −1,i + ATNi −1,i λ∗Ni ,i i −1,i i −1,i ∗ Qx,Ni −1,i xN i −1,i + ∗ Qxu,Ni −1,i uN i −1,i + lx,Ni −1,i − λ∗Ni −1,i + ATNi −1,i λ∗0,i+1 T ∗ Qxu,N x∗ + Qu,Ni −1,i uN + lu,Ni −1,i + BTNi −1,i λ∗Ni ,i i −1,i i −1,i Ni −1,i T Qxu,N x∗ i −1,i Ni −1,i + ∗ Qu,Ni −1,i uN i −1,i + lu,Ni −1,i + λ∗N ,i =λ∗0,i+1 i = = 0, i ∈ Z0,p−1 (5.52) λ∗N ,i =λ∗0,i+1 BTNi −1,i λ∗0,i+1 i = = 0, i ∈ Z0,p−1 . (5.53) Hence (5.40a), (5.40b) and (5.40c) in the kkt system for the extended problem can be written ∗ ∗ T Qx,0,0 x0,0 + Qxu,0,0 u0,0 + lx,0,0 − λ∗0,0 + A0,0 λ∗1,0 = 0, (5.54a) T ∗ Qxu,0,0 x0,0 (5.54b) + ∗ Qu,0,0 u0,0 + lu,0,0 + T B0,0 λ∗1,0 = 0, .. . ∗ ∗ Qx,Ni −1,i xN + Qxu,Ni −1,i uN + lx,Ni −1,i − λ∗Ni −1,i + ATNi −1,i λ∗0,i+1 = 0, (5.54c) i −1,i i −1,i ∗ T + lu,Ni −1,i + BTNi −1,i λ∗0,i+1 = 0, + Qu,Ni −1,i uN Qxu,N x∗ i −1,i i −1,i Ni −1,i (5.54d) T ∗ ∗ λ∗1,i+1 = 0, + lx,0,i+1 − λ∗0,i+1 + A0,i+1 + Qxu,0,i+1 u0,i+1 Qx,0,i+1 x0,i+1 (5.54e) T ∗ Qxu,0,i+1 x0,i+1 (5.54f) + ∗ Qu,0,i+1 u0,i+1 + lu,0,i+1 + T B0,i+1 λ∗1,i+1 = 0, .. . ∗ QNp ,p xNp ,p + lNp ,p − λ∗Np ,p = 0. (5.54g) Here (5.52) and (5.53) have been used in (5.54c) and (5.54d), respectively, for all i ∈ Z0,p−1 . Qt,i and lx,i were implicitly defined as Qt,i , QPi−1 N j=0 j +t , lt,i , lPi−1 N j=0 j +t , (5.55) when the extended problem (5.4) was constructed. By using these definitions and defining the variable ∗ λ0,0 . ∗ .. λ 0 λ∗ . Ni −1,i ∗ λ , .. = ∗ (5.56) , λ0,i+1 ∗ . λN . . ∗ λNp ,p 5.B 85 Proof of Lemma 5.8 together with the definitions of x∗ and u∗ in (5.45) it can be seen that the system of equations (5.54) can be written Qx,0 x0∗ + Qxu,0 u0∗ + lx,0 − λ∗0 + A0T λ∗1 = 0, (5.57a) T Qxu,0 x0∗ + Qu,0 u0∗ + lu,0 + B0T λ∗1 = 0, (5.57b) .. . ∗ Qx,N xN + lx,N − λ∗N = 0. (5.57c) These equations can be recognized as (5.39a), (5.39b) and (5.39c) in the kkt system of the original uftoc problem. Hence, the primal and dual solutions x∗ , u∗ and λ∗ defined in (5.45) and (5.56), respectively, satisfy the kkt system (5.39), and from Theorem 2.8 it follows that x∗ , u∗ and λ∗ are optimal primal and dual solutions to the uftoc problem (5.1). Furthermore, the solution in each subproblem i ∈ Z0,p can be computed completely independent of the other subproblems, and hence the solution x∗ , u∗ and λ∗ to (5.1) can be computed in parallel from the solution x̂∗ , û∗ and λ̂∗ to (5.14). This concludes the proof. 5.B Proof of Lemma 5.8 T N Proof: The nullspace of ATi is given by all λN i such that Ai λi = 0, which by the definition of Ai in (5.17b) can be expressed as T N − λN t,i + At,i λt+1,i = 0, t ∈ Z0,Ni −1 , (5.58a) BTt,i λN t+1,i = 0, N λN Ni ,i = −λtc,i . (5.58b) t ∈ Z0,Ni −1 , (5.58c) Equation (5.58a) and (5.58c) can be combined into N Q λ0,i − Ni −1 At,i T T t=0 −Âi .. . T N .. λN −Di λtc,i , . = = λN tc,i i = λN Ni ,i −I I N I λtc,i (5.59) where Di and Âi are defined as in (5.6) and (5.8), respectively. By combining (5.58a) and (5.58b) it can be seen that N −1 T i Y N T T T λN BTNi −1,i λN A t,i Ni ,i = 0, BNi −2,i ANi −1,i λNi ,i = 0, . . . , B0,i Ni ,i = 0, (5.60) t=1 86 5 Parallel Newton Step Computation which, using also (5.58c), can be expressed as QN −1 T i BT t=1 At,i 0,i . .. N − λtc,i = −SiT λN tc,i = 0, BT T Ni −2,i ANi −1,i BTNi −1,i (5.61) N ∈ N SiT . For notahas to satisfy λ where Si is defined in (5.7). Hence λN tc,i tc,i tional convenience, let wi , λN tc,i and define Zi as T −Âi Zi , −DiT . I Then any nullspace element λN i can be expressed as λN wi ∈ N SiT , i = Zi wi , (5.62) (5.63) which completes the proof. 5.C Proof of Theorem 5.10 Proof: The equations (5.28) are directly given by (5.40i)-(5.40l) in the kkt conditions for the extended problem, which concludes the proof. 6 Parallel Riccati Recursion In this chapter, an algorithm for solving uftoc problems by computing the Riccati recursion in parallel is presented. This algorithm is similar to the one presented in Chapter 5 in the sense that it can be used to compute an optimal solution to the uftoc problem in (3.39) in a fixed number of iterations in parallel. Furthermore, both algorithms use a fixed a priori known communication layout between the computational units. However, the algorithm presented here parallelizes the Riccati recursion itself, and the subproblems are computed by solving parts of the Riccati recursion individually. Hence, in this algorithm the structure in the uftoc problem is exploited even in the individual subproblems. The results in this chapter will later be presented in Nielsen and Axehill (2015). The proposed algorithm has been implemented in Matlab as a proof-of-concept that it works, and a comparison of this implementation and the algorithm in Chapter 5 is presented. In the Matlab implementation the communication overhead is neglected. Furthermore, an ansi-c implementation of the algorithm presented in this chapter has been evaluated truly in parallel on a computational cluster consisting of several multi-core computers. The classical serial Riccati recursion that was introduced in Section 3.4 exploits the causality of the problem. For that reason it is not obvious that it can be split and parallelized in time, especially without involving some form of iterative consensus step. In this chapter it is shown that it in fact is possible to compute the Riccati factorization in Algorithm 4 and the backward and forward recursions in algorithms 5 and 6 directly in parallel in time. The main idea is to exploit the problem structure in time and divide the Riccati recursion into several parts. Each part of the Riccati recursion corresponds to the kkt conditions of a smaller uftoc problem, and it will be shown how to eliminate variables from each of 87 88 6 Parallel Riccati Recursion these parts in parallel in order to obtain a new Riccati recursion but with fewer time-steps. The new Riccati recursion corresponds to the kkt conditions of a master uftoc problem. Hence, the overall structure where a uftoc problem P (N ) is reduced to a master uftoc problem P (p) is similar to the approach presented in Chapter 5. However, some important differences are, e.g., that the method to eliminate variables in the smaller uftoc problems are different and utilizes the structure in those problems, and that there are no difficulties with non-unique dual variables as in the algorithm in Chapter 5. The differences and similarities between the algorithms in chapter 5 and 6 are discussed in more detail in Section 6.4. The parallel algorithm in this chapter is related to nonserial dynamic programming over trees as described in the introduction to Chapter 5. As a reminder, the uftoc problem (3.39) that corresponds to the Newton step that occurs in many ip and as solvers is repeated here # " # " #T " # N −1 " #T " X 1 xt Q Q x l x x,t xu,t t x,t t + ct + + minimize T ut lu,t x,u Qxu,t Qu,t ut 2 ut t=0 subject to 1 T T x Q x + lx,N xN + cN 2 N x,N N x0 = x̄ xt+1 = At xt + Bt ut + at , t ∈ Z0,N −1 . (6.1) As in Chapter 5, let assumptions 3.4 and 3.5 hold and let P (N ) denote an optimization problem with the structure in (6.1). 6.1 Problem Decomposition and Reduction The focus in this section will be to describe how to split the computations of the solution to the problem (6.1) into several smaller independent subproblems by dividing the prediction horizon into several intervals (Section 6.1.1), how to eliminate variables in each independent subproblem using Riccati recursions (Section 6.1.2) and how to combine the reduced subproblems to a master problem (Section 6.1.3). By examining algorithms 4 and 5, it can be seen that given Pt̄ , Ψ t̄ and c̄t̄ the factorization and backward recursion can be computed for 0 ≤ t ≤ t̄. If the factorization and backward recursions are computed, it follows from Algorithm 6 that given xs¯ the forward recursion can be computed for s¯ ≤ t ≤ N . Hence, if Pt̄ , Ψ t̄ , c̄t̄ and xs¯ are known, the Riccati recursion and the primal and dual optimal solutions for the interval s¯ ≤ t ≤ t̄ can be computed using information from this interval only. As a consequence, provided that Pti+1 , Ψ ti+1 , c̄ti+1 and xti are known for i ∈ Z0,p for some p, it is possible to compute the Riccati recursion and the primal and dual optimal solutions in each interval ti ≤ t ≤ ti+1 with i ∈ Z0,p independently from the other intervals. This property will be exploited in Section 6.1.1. 6.1 89 Problem Decomposition and Reduction 6.1.1 Splitting into independent parts To decompose the uftoc problem (6.1), let the prediction horizon be divided into p + 1 intervals, or batches, such that x and u are split into xtp utp x0 u0 . . . .. (6.2) . , . . . , .. , .. , . . . , .. , ut1 −1 x t1 xtp+1 utp+1 −1 where the last state xti+1 in batch i coincides with the first state in batch i + 1. Now introduce the batch-wise variables x0,i xti u0,i uti . . . . xi = .. , .. , ui = .. , .. , i ∈ Z0,p , (6.3) xNi ,i uNi −1,i uti+1 −1 xti+1 where Ni is the length of batch i and t0 = 0. Note that xNi ,i = x0,i+1 . By following the reasoning in the introduction of this section, it is possible to compute the Riccati recursion and the optimal value in batch i if x̂i , xti , Pˆi+1 , Pti+1 , Ψ̂ i+1 , Ψ ti+1 and ĉi+1 , c̄ti+1 are known. Hence, if these variables are known for all batches i ∈ Z0,p , the solution to the original uftoc problem (6.1) can be computed from p + 1 independent subproblems in the uftoc form minimize xi ,ui subject to N i −1 X t=0 " # " 1 xt,i T Qx,t,i T 2 ut,i Qxu,t,i Qxu,t,i Qu,t,i #" #T " # # " xt,i lx,t,i xt,i + ct,i + + ut,i lu,t,i ut,i 1 T ˆ T x P x − Ψ̂ i+1 xNi ,i + ĉi+1 2 Ni ,i i+1 Ni ,i x0,i = x̂i xt+1,i = At,i xt,i + Bt,i ut,i + at,i , t ∈ Z0,Ni −1 , (6.4) using p + 1 individual Riccati recursions. Here Qx,t,i , Qxu,t,i , Qu,t,i , lx,t,i , lu,t,i , ct,i , At,i , Bt,i and at,i are defined consistently. Note that for the final batch it holds that Pˆp+1 = Qx,N , Ψ̂ p+1 = −lx,N and ĉp+1 = cN and they are hence known. Remark 6.1. The individual subproblems in the form in (6.4) do not have any terminal constraints as in the subproblems in (5.11) in Chapter 5. Here the coupling is instead T Pˆ T given by the terminal state cost 12 xN ,i i+1 xNi ,i − Ψ̂ i+1 xNi ,i . i 6.1.2 Eliminate local variables in a subproblem It will now be shown that even when Pˆi+1 , Ψ̂ i+1 and ĉi+1 are not known, it is possible to work on the individual subproblems to eliminate local variables and reduce their sizes. This can be done separately for the p + 1 subproblems, which opens up for a structure that can be solved in parallel. The core idea with this approach is that the unknowns Pˆi+1 and Ψ̂ i+1 will indeed influence the solution 90 6 Parallel Riccati Recursion of the subproblem, but as soon will be shown the resulting degree of freedom is often very limited compared to the dimension of the full control signal vector ui . The constant ĉi+1 affects the optimal value of the cost function but not the solution. It will be shown in this section that the structured perturbation from Pˆi+1 and Ψ̂ i+1 only introduces nû ≤ nx degrees of freedom, and hence the subproblem can be reduced to depend only on the initial state x̂i and the freedom in the structured perturbation, of dimension nx and nû respectively. Lemma 6.2 gives an expression for the cost-to-go at state xt,i in (6.4) for some t when the control inputs uτ,i for τ ∈ Zt,N −1 are computed in a certain way, and the lemma will be used in this section to simplify some key computations. Lemma 6.2. Consider a uftoc problem in the form in (6.4). Assume that uτ,i is computed as uτ,i = kτ+1,i + Kτ+1,i xτ,i + ūτ,i , τ ∈ Zt,N −1 , (6.5) Rnu where ūτ,i ∈ is an arbitrary vector and the preliminary feedback matrices Kτ+1,i and kτ+1,i are computed in algorithms 4 and 5 for fixed Pˆi+1 , Ψ̂ i+1 and ĉi+1 , respectively. Then, the cost-to-go at a state xt,i in (6.4) is given by N −1 1X T 1 T T ū G ū , V̄ xt,i , ūi , xt,i Pt,i xt,i − Ψ t,i xt,i + c̄t,i + 2 2 τ=t τ,i τ+1,i τ,i (6.6) where Pt,i , Ψ t,i , c̄t,i and Gτ+1,i are computed in algorithms 4 and 5. Proof: For the proof of Lemma 6.2, see Appendix 6.A. In the remaining part of this section the subindices i in (6.4) are omitted for notational brevity, meaning that Ψ̂ i+1 is written Ψ̂ , etc. It will now be shown how local variables in a subproblem can be eliminated by exploiting the structure in (6.4). A preliminary feedback given by the Riccati recursion will be used to simplify the reduction of the subproblem. The use of this preliminary feedback is in principle not necessary, but it will later be seen that some computationally demanding key computations can be performed more efficiently by using it. To compute this preliminary feedback, let the uftoc problem (6.4) be factored and solved for Pˆ = 0, Ψ̂ = 0 and ĉ = 0 using the Riccati factorization and backward recursion in algorithms 4 and 5. The resulting optimal control law for Pˆ = 0 and Ψ̂ = 0 is then u0,t = k0,t+1 + K0,t+1 xt for t ∈ Z0,N −1 . The subindex ”0” is used to denote variables that correspond to the solution of the uftoc problem (6.4) when the preliminary Pˆ = 0, Ψ̂ = 0 and ĉ = 0 are used. Hence, k0,t+1 and K0,t+1 define the preliminary feedback and it will be shown that the changes of this preliminary optimal control law are small when Pˆ , 0 and Ψ̂ , 0. Remark 6.3. It is possible to compute the preliminary feedback for other choices than Pˆ = 0 and Ψ̂ = 0 and still simplify the key computations. However, since the notation then becomes tedious, the choice Pˆ = 0 and Ψ̂ = 0 is used here for presentation purposes. 6.1 91 Problem Decomposition and Reduction It will now be investigated how the control signal ut and the cost function are affected when Pˆ , 0, Ψ̂ , 0 and ĉ , 0. Let the contribution to the control signal ut from the unknown Pˆ and Ψ̂ be denoted ūt ∈ Rnu . By using the preliminary feedback, the control law can be written ut = k0,t+1 + K0,t+1 xt + ūt , t ∈ Z0,N −1 . (6.7) Note that ūt is an arbitrary nu -vector and, hence, there is no loss of generality in this assumption. From now on, the control law (6.7) is used in the subproblem, and it will be shown that the degree of freedom in ūt can be reduced. By defining Q̄ū , A, B and a as I G 0,1 A + B K 0 0 0,1 . .. Q̄ū , (6.8a) , A , .. , . G0,N QN −1 t=0 At + Bt K0,t+1 0 B 0 (A1 + B1 K0,2 )B0 B , .. . QN −1 A + Bt K0,t+1 B0 t t=1 0 ... B1 .. . ... 0 .. . , (6.8b) BN −1 0 a0 + B0 k0,1 (A + B K )(a + B k ) + a + B k , 1 1 0,2 0 0 0,1 1 1 0,2 a , .. . PN −1 QN −1 (a + B k ) A + B K τ τ 0,τ+1 t t 0,t+1 τ=0 t=τ+1 (6.8c) and using (6.7), the states x along the prediction horizon can be expressed as x = Ax0 + Bū + a, (6.9) RN nu . The cost function when the control law (6.7) and terminal state where ū ∈ cost Pˆ = 0, Ψ̂ = 0 and ĉ = 0 are used is given by the cost-to-go at x0 given by Lemma 6.2, i.e., V̄ (x0 , ū) = 1 1 T T x0 + ūT Q̄ū ū + c̄0,0 . x P x − Ψ 0,0 2 0 0,0 0 2 (6.10) Here P0,0 , Ψ 0,0 and c̄0,0 are computed by algorithms 4 and 5 with the choice Pˆ = 0, Ψ̂ = 0 and ĉ = 0. Remark 6.4. When using the preliminary feedback to compute the control signal as in (6.7) the cross terms between x0 and ū in the cost function in (6.10) are eliminated. Furthermore, there is no linear penalty term for ū and the quadratic weight matrix Q̄ū is block diagonal as can be seen in (6.8a). These properties will later be important from a computational point of view. 92 6 Parallel Riccati Recursion Let the last block rows in A, a and B be denoted as Â, â and S, respectively. The dynamics equations from x0 to xN are then given by xN = Âx0 + Sū + â. (6.11) ˆ −Ψ̂ and ĉ, is (possibly) non-zero. Hence, The terminal cost in (6.4), given by P, the total cost in the subproblem (6.4) is obtained by adding the non-zero terminal cost to the cost function V̄ (x0 , ū) in (6.10). Note that the influence of a non-zero Pˆ and/or −Ψ̂ on the states and control signals for t < N is incorporated in ū by definition. The uftoc problem (6.4) can then equivalently be written minimize x0 ,ū,xN subject to 1 T 1 T x P x − Ψ 0,0 x0 + ūT Q̄ū ū + c̄0,0 + 2 0 0,0 0 2 1 T ˆ x Px − Ψ̂ T xN + ĉ 2 N N x0 = x̂ (6.12) xN = Âx0 + Sū + â, where the dynamics equations in (6.11) have been used. This is a uftoc problem with prediction horizon 1, i.e., one step from the initial to the final state, and N nu control signals. This problem is obtained similarly as the subproblems in partial condensing which is introduced in Axehill (2015). The equations that define the factorization of the kkt system of this uftoc problem are F̄ = P0,0 + ÂT PˆÂ, Ḡ = Q̄ū + ST Pˆ S, T H̄ = Â Pˆ S, T Ḡ K̄ = −H̄ , Ḡ k̄ = ST Ψ̂ − Pˆâ , (6.13a) (6.13b) (6.13c) (6.13d) (6.13e) and hence (6.13) can be used to compute the optimal solution of (6.12). Remark 6.5. The preliminary feedback in (6.7) eliminates the cross terms between x0 and ū, giving only one term in (6.13c) which simplifies computations. Using (6.13b) and (6.13c), the system of equations (6.13d) can be re-written as (6.14) Q̄ū + ST Pˆ S K̄ = −ST PˆÂ, where K̄ ∈ RN nu ×nx . It will now be shown that it is possible to reduce the number N nu ×n1 of equations by exploiting the structure in (6.14). To do this, let U1 ∈ R T with n1 ≤ nx be an orthonormal basis for R S and let U2 be an orthonormal ⊥ basis of R ST , both given by the singular value decomposition of ST , i.e., " #" T# h i Σ S 0 V1 S T = U1 U2 = U1 ΣS V1T . (6.15) 0 0 V2T Then, U , [U1 U2 ] is an orthonormal basis for RN nu , and by using the identity 6.1 93 Problem Decomposition and Reduction U U T = I and the definitions ˆ 1 ΣS , Σ , ΣS V1T PV Γ , −ΣS V1T PˆÂ, equation (6.14) can equivalently be written U U T Q̄ū + U1 ΣU1T K̄ = U1 Γ . (6.16) (6.17) By multiplying (6.17) with U1T and U2T , respectively, from left gives the two systems of equations (6.18a) U1T Q̄ū + ΣU1T K̄ = Γ , U2T Q̄ū K̄ = 0 ⇐⇒ K̄ = Q̄−1 ū U1 K̂, (6.18b) where K̂ ∈ Rn1 ×nx . Here, U1T U1 = I, U2T U1 = 0 and U2T U2 = I were used to reduce the size of the system of equations. The matrix K̂ is introduced in (6.18b) to parametrize the nullspace of U2T as U1 K̂. Hence, the feedback matrix K̄ is parametrized as K̄ = Q̄−1 ū U1 K̂, and inserting this expression into (6.18a) gives T −1 (6.19) U1T Q̄ū + ΣU1T Q̄−1 ū U1 K̂ = I + ΣU1 Q̄ū U1 K̂ = Γ . This parametrization and reduction of the system of equations is done without any assumptions on Pˆ and Ψ̂ and, hence, the reduction can be performed independently of the unknown Pˆ and Ψ̂ . n 1 Multiplying (6.19) with U1T Q̄−1 ū U1 ∈ S++ from the left gives T −1 T −1 T −1 U1T Q̄−1 ū U1 + U1 Q̄ū U1 ΣU1 Q̄ū U1 K̂ = U1 Q̄ū U1 Γ . (6.20) From the definition of Σ and Γ together with (6.15), this system of equations can be written T −1 T ˆ −1 T −1 T ˆ (6.21) U1T Q̄−1 ū U1 + U1 Q̄ū S P SQ̄ū U1 K̂ = −U1 Q̄ū S P Â. Now, by introducing the variables B̂ , SQ̄−1 Q̂u , U1T Q̄−1 ū U1 , ū U1 , T ˆ T ˆ Ĝ , Q̂u + B̂ P B̂, Ĥ , Â P B̂, (6.22) (6.23) equation (6.21) can be written as Ĝ K̂ = −Ĥ T . (6.24) Remark 6.6. Since using the preliminary feedback in (6.7) results in a block diagonal Q̄ū with the blocks given by G0,t+1 for t ∈ Z0,N −1 , computing Q̂u and B̂ in (6.22) can be efficiently done by block-wise computations. Furthermore, the factorizations of G0,t+1 from the computation of K0,t+1 can be re-used here. Similarly, the structure in (6.13e) can be exploited and this system of equations can be reduced to Ĝ k̂ = B̂T Ψ̂ − Pˆâ , (6.25) 94 6 Parallel Riccati Recursion with k̂ ∈ Rn1 . Hence, by also defining the variables F̂ , F̄, Q̂x , P0,0 , lˆx , −Ψ 0,0 , (6.26) the equations (6.13) can now be written as F̂ = Q̂x + ÂT PˆÂ, Ĝ = Q̂u + B̂T PˆB̂, T Ĥ = Â PˆB̂, T Ĝ K̂ = −Ĥ , Ĝ k̂ = B̂T Ψ̂ − Pˆâ , (6.27a) (6.27b) (6.27c) (6.27d) (6.27e) which can be identified as the factorization of the kkt system of a uftoc problem in the form (6.12) but with control signal nû = n1 ≤ nx . Hence (6.27) define the optimal solution to a smaller uftoc problem in the variables x̂, xN ∈ Rnx and û ∈ Rnû . This reduction is performed by eliminating local variables in the problem (6.4) and by exploiting the structure in the subproblem. This important result is summarized in Theorem 6.7, where the subindices i in (6.4) are again used for completeness. Theorem 6.7. A uftoc problem given in the form (6.4) with unknown Pˆi+1 , Ψ̂ i+1 and ĉi+1 can be reduced to a uftoc problem in the form minimize x0,i , xNi ,i , ûi subject to 1 T 1 T x0,i Q̂x,i x0,i + ûiT Q̂u,i ûi + lˆx,i x0,i + ĉi + 2 2 1 T ˆ T x P x − Ψ̂ i+1 xNi ,i + ĉi+1 2 Ni ,i i+1 Ni ,i x0,i = x̂i (6.28) xNi ,i = Âi x0,i + B̂i ûi + âi , where x̂i , x0,i , xNi ,i ∈ Rnx and ûi ∈ Rnû , with nû ≤ nx . Âi and âi are defined as the last block rows in Ai and ai given (6.8a) and (6.8c), respectively, and Q̂x,i , Q̂u,i , lˆx,i and B̂i are given by (6.22) and (6.26), and ĉi , c̄0,0 where c̄0,0 is defined in (6.10). Proof: Theorem 6.7 follows directly from the derivations that are presented in the text in Section 6.1.2. To avoid computing the orthonormal basis U1 and U2 in practice, a transformation K̂ = T L̂, where T ∈ Rn1 ×nx has full rank, U1 T = ST and L̂ ∈ Rnx ×nx , can be used. By using this choice of K̂ in (6.21) and then multiplying from the left with T T , the matrices Q̂u , B̂ and (6.24) can instead be written T Q̂u = B̂ , SQ̄−1 ū S , (6.29) Ĝ L̂ = −Ĥ T , (6.30) where Ĝ and Ĥ are defined as in (6.23) but with the new Q̂u and B̂. The uftoc problem corresponding to (6.27) then obtains an (possibly) increased control sig- 6.1 95 Problem Decomposition and Reduction nal dimension nû = nx ≥ n1 compared to when Q̂u and B̂ are defined as in (6.22). The advantage by using this choice is that Q̂u and B̂ can be easily computed. Analogously calculations can be made for k̂. Remark 6.8. If ST is rank deficient, then U1 ∈ RN nu ×n1 will have n1 < nx columns. Hence Ĝ is singular and L̂ non-unique in (6.30). How to cope with this case is described in Section 3.4.2 and Axehill (2008). For the last subproblem i = p, the variables Pˆp+1 = Qx,Np ,p , Ψ̂ p+1 = −lx,Np ,p and ĉp+1 = cNp ,p in (6.4) are known. Hence, in the last subproblem all variables but the initial state can be eliminated, giving the (trivial) optimization problem minimize T T x0,p Q̂x,p x0,p + lˆx,p x0,p + ĉp subject to x0,p = x̂p . x0,p (6.31) Here Q̂x,p , P0,p , lˆx,p , −Ψ 0,p and ĉp , c̄0,p are given by algorithms 4 and 5. The formal validity of the reduction of each subproblem i ∈ Z0,p−1 is given by Theorem 6.7, while the computational procedure is summarized in Algorithm 13. This algorithm is basically a Riccati factorization and backward recursion as in algorithms 4 and 5, respectively. Algorithm 13 is used to eliminate the local variables in each subproblem i ∈ Z0,p−1 . Here Q̂u,i and B̂i are computed as in (6.29). 6.1.3 Constructing the master problem According to Theorem 6.7 and Section 6.1.2 all subproblems i ∈ Z0,p−1 can be reduced to uftoc problems in the variables x0,i , xNi ,i and ûi with initial state x̂i , and subproblem i = p depends only on the initial state x̂p . The variable ûi represents the unknown part of the control signals ut,i that are due to the initially unknown Pˆi+1 and Ψ̂ i+1 , and can be interpreted as a new control signal for batch i. By using the definition of the subproblems and Pˆi+1 , Pti +1 , Ψ̂ i+1 , Ψ ti +1 , ĉi+1 , cti +1 together with the relation xNi ,i = x0,i+1 = x̂i+1 between the subproblems that were introduced in Section 6.1.1, the reduced subproblems i ∈ Z0,p can be combined into a master problem. How to do this will now be shown. From the introduction of Section 6.1 it is clear that the optimal solution in the first interval of the prediction horizon can be computed by solving the first subproblem, i.e., by solving the problem minimize x0,0 ,xN0 ,0 ,û0 subject to 1 1 T T x0,0 Q̂x,0 x0,0 + û0T Q̂u,0 û0 + lˆx,0 x0,0 + ĉ0 + 2 2 1 T ˆ x P x − Ψ̂ 1T xN0 ,0 + ĉ1 2 N0 ,0 1 N0 ,0 x0,0 = x̂0 = x̄ (6.32) xN0 ,0 = Â0 x0,0 + B̂0 û0 + â0 , which can be done if Pˆ1 , Ψ̂ 1 and ĉ1 are known. However, these variables are not 96 6 Parallel Riccati Recursion Algorithm 13 Reduction using Riccati factorization 1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: PN := 0, Ψ N := 0, c̄N := 0 Q̂u := 0, DN := I, dN := 0 for t = N − 1, . . . , 0 do Ft+1 := Qx,t + ATt Pt+1 At Gt+1 := Qu,t + BTt Pt+1 Bt Ht+1 := Qxu,t + ATt Pt+1 Bt Compute and store a factorization of Gt+1 Compute a solution Kt+1 to T Gt+1 Kt+1 = −Ht+1 Compute a solution kt+1 to Gt+1 kt+1 = BTt Ψ t+1 − lu,t − BTt Pt+1 at Ψ t := ATt Ψ t+1 − Ht+1 kt+1 − lx,t − ATt Pt+1 at T Pt := Ft+1 − Kt+1 Gt+1 Kt+1 Compute a solution Lt+1 to Gt+1 Lt+1 = −BTt Dt+1 T Dt := ATt + Kt+1 BTt Dt+1 T dt := dt+1 + Dt+1 (at + Bt kt+1 ) T Q̂u := Q̂u + Lt+1 Gt+1 Lt+1 end for Â := D0T , B̂ := Q̂u , â := d0 Q̂x := P0 , lˆx := −Ψ 0 , ĉ := c̄0 known for now, but by using the definition of the local variables in (6.3) it is clear that xN0 ,0 = x0,1 . Hence, it is possible to compute the the terminal state cost in subproblem i = 0, i.e., the term 1 T ˆ P x − Ψ̂ 1T xN0 ,0 + ĉ1 , x 2 N0 ,0 1 N0 ,0 in (6.32) by instead computing (6.33) 1 T ˆ (6.34) x P x − Ψ̂ 1T x0,1 + ĉ1 . 2 0,1 1 0,1 Similarly, from the introduction to Section 6.1 it can be seen that this can be done by solving the second subproblem minimize x0,1 ,xN1 ,1 ,û1 subject to 1 T 1 x Q̂ x + û T Q̂ û + lˆT x + ĉ1 + 2 0,1 x,1 0,1 2 1 u,1 1 x,1 0,1 1 T ˆ x P x − Ψ̂ 2T xN1 ,1 + ĉ2 2 N1 ,1 2 N1 ,1 x0,1 = x̂1 = xN0 ,0 (6.35) xN1 ,1 = Â1 x0,1 + B̂1 û1 + â1 , using the optimal x̂i = xxN ,0 , Pˆ2 , Ψ̂ 2 and ĉ2 . By utilizing these relations between 0 the subproblems, the two subproblems (6.32) and (6.35) can be combined into 6.1 97 Problem Decomposition and Reduction one optimization problem given by minimize x̂0 ,û0 ,x̂1 ,û1 ,xN1 ,1 subject to 1 X 1 i=0 2 x̂iT Q̂x,i x̂i + 1 T T x̂i + ĉi + ûi Q̂u,i ûi + lˆx,i 2 1 T ˆ P x − Ψ̂ 2T xN1 ,1 + ĉ2 x 2 N1 ,1 2 N1 ,1 x̂0 = x̄ (6.36) x̂1 = Â0 x̂0 + B̂0 û0 + â0 xN1 ,1 = Â1 x̂1 + B̂1 û1 + â1 . Here the local variables x0,0 , xN0 ,0 and x0,1 have been trivially eliminated. The problem (6.36) can be solved given that Pˆ2 , Ψ̂ 2 and ĉ2 are known. Hence, by induction, all subproblems i ∈ Z0,p can be combined into one master problem given by #" # p−1 " #T " X 1 x̂i x̂ Q̂ 0 T i x,t minimize + lˆx,i x̂i + ĉi + 0 Q̂u,t ûi x̂,û 2 ûi i=0 subject to 1 T x̂ Q̂ x̂ + lˆT x̂ + ĉp 2 p x,p p x,p p x̂0 = x̄0 (6.37) x̂i+1 = Âi x̂i + B̂i ûi + âi , i ∈ Z0,p−1 . This problem is a uftoc problem in the same form as (6.1) but with shorter prediction horizon p < N and control signal dimension given by nû in each sample i. The dynamics equations x̂i+1 = Âi x̂i + B̂i ûi + âi represent the relation xNi ,i = x0,i+1 between subproblem i and i + 1. Hence, a uftoc problem P (N ) of prediction horizon length N can be reduced, while exploiting the structure by using Riccati recursions in each subproblem, to a uftoc problem P (p) on the same form but with shorter prediction horizon and possibly lower control signal dimension. Figure 6.1 illustrates this reduction procedure, where the notation Pi (Ni ) denotes subproblem i given by (6.4) with prediction horizon Ni . Remark 6.9. The master problem (6.37) is in a similar form as the master problem in (5.14) in Chapter 5. However, here the use of the preliminary feedback results in no cross terms between x̂i and ûi which is an advantage since it decreases the amount of data that needs to be communicated. Remark 6.10. The columns of B̂i in (6.22) form a basis for the reachability matrix Si . However, the reachability matrix is invariant under the variable transformation (6.7). Hence, both B̂i in (6.22) and B̂i in Chapter 5 are bases for the same space. 98 6 P (p) : P (N ) : x̂0 , û0 P0 (N0 ) x̂i , ûi Parallel Riccati Recursion x̂p Pi (Ni ) Pp (Np ) Figure 6.1: The original MPC problem P (N ) can be reduced to a smaller problem P (p) with the same structure but with shorter prediction horizon. 6.2 Computing the Riccati Recursion in Parallel In Section 6.1 it was shown how to split the original uftoc problem (6.1) into several individual subproblems, how to reduce these and how to construct a master problem by combining the individual reduced subproblems. Since all the subproblems are independent of each other, the reduction of these according to Section 6.1.2 to obtain the master problem (6.37) can be performed in parallel. To reach consensus between all subproblems and solve the original problem (6.1), the master problem P (p) can be solved to obtain Pˆi+1 , Ψ̂ i+1 , ĉi+1 and the optimal x̂i for i ∈ Z0,p . When these variables are known, the independent subproblems are solved in parallel using algorithms 4-6 with the initial x0,i = x̂i , Pˆi+1 , Ψ̂ i+1 and ĉi+1 for i ∈ Z0,p . In this section it will be shown how to compute these variables in order to solve (6.1) in parallel. 6.2.1 Parallel computation of the Riccati recursion To compute Pˆi+1 , Ψ̂ i+1 , ĉi+1 and x̂i , the master problem (6.37) can be solved serially using the Riccati recursion. However, similarly as in Chapter 5, the master problem can instead itself be reduced in parallel by repeatedly using the theory presented in Section 6.1 until a uftoc problem with a prediction horizon that is of a pre-determined length is obtained. This top problem is solved, and the solution is propagated down until the subproblems of the original problem (6.1) are solved. This procedure is shown in Figure 6.2, where Pik (Nik ) denotes subproblem i in the form (6.4) at level k in the tree. The overall procedure is similar to what was done in Chapter 5, but the conceptual difference here is the way it is performed using Riccati recursions, which exploits the structure also in the subproblems. The parallel Riccati algorithm thus consists of two steps; reducing the original problem P (N ) in parallel in several steps to the top problem P (pm−1 ), and propagating the solution down in the tree by solving all Pik (Nik ) at each level in parallel. Since the subproblems at each level can be reduced and solved in parallel, and the information flow is between parent and children in the tree, the Riccati recursion can be computed in parallel using the theory proposed in this chapter. 6.2 99 Computing the Riccati Recursion in Parallel P (pm−1 ) : P (p0 ) : P (N ) : P00 (N00 ) P0m (N0m ) P01 (N01 ) Pp11 (Np11 ) Pi0 (Ni0 ) Pj0 (Nj0 ) Pp00 (Np00 ) Figure 6.2: The original uftoc problem P (N ) can be reduced repeatedly. The Riccati recursion is used to exploit the structure in the subproblems. When the solution to the top problem is computed, it can be propagated back in the tree until the bottom level is solved. 6.2.2 Parallel Riccati recursion algorithms In this section algorithms for computing the Riccati recursion in parallel are presented. Beyond what is presented here, as observed already in Axehill and Hansson (2012), standard parallel linear algebra can be used for many computations in the serial Riccati recursion in each subproblem to boost performance even further. This has however not been utilized in this work. In Algorithm 14, the original problem (6.1) is reduced in parallel in several steps to a uftoc problem with pre-defined prediction horizon pm−1 . Assume, for simplicity, that all subproblems are of equal batch length Ns and that N = Nsm+1 for some 1 ≤ m ∈ Z. Then the reduction can be made in m steps, provided that Nsm computational units are available. Hence, the reduction algorithm has O (log N ) complexity growth, which is the same as for the algorithm in Chapter 5. Algorithm 14 Parallel reduction of uftoc problem 1: 2: 3: 4: 5: 6: 7: 8: 9: Set the maximum level number m Set the number of subproblems pk + 1 for each level k ∈ Z0,m , with pm = 0 for k = 0, . . . , m − 1 do parfor i = 0, . . . , pk do Create subproblem Pik (Nik ) Reduce subproblem Pik (Nik ) using Algorithm 13 k k k Send Âki , B̂ki , âki , Q̂x,i , Q̂u,i , lˆx,i and ĉik to parent end parfor end for When the reduction step is complete, each subproblem i ∈ Z0,pk−1 at level k is k+1 k+1 solved in Algorithm 15 using algorithms 4-6 with the optimal x̂ik+1 , Pˆi+1 , Ψ̂ i+1 100 6 Parallel Riccati Recursion k+1 and ĉi+1 from the respective parent. The algorithm starts by solving the top problem P (pm−1 ) in Figure 6.2, and this solution is propagated to its children. By solving the subproblems at each level and propagating the solution to the level below in the tree, the subproblems Pi0 (Ni0 ) for i ∈ Z0,p0 at the bottom level can finally be solved individually. All subproblems can be solved using only information from their parents, and hence each level in the tree can be solved completely in parallel. The optimal primal solution to the original uftoc problem (6.1) can be constructed from the solutions to the subproblems using the definition of the 0 0 local variables in (6.3). The dual variables can be computed from all Pt,i and Ψ t,i from the subproblems at the bottom level using the relation (3.48), and hence there are no complications with non-unique dual variables as in Chapter 5 when using the algorithm presented in this chapter. The propagation of the solution from the top level to the bottom level can be made in m + 1 steps provided that Nsm processing units are available. Since both algorithms 14 and 15 are solved in O (log N ) complexity, the Riccati recursion and the solution to the uftoc problem (6.1) can be computed with O (log N ) complexity growth. Algorithm 15 Parallel solution of uftoc problem 1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: Get the maximum level number m and all pk :s from Algorithm 14 Initialize x̂0m := x̄ for k = m, m − 1, . . . , 0 do parfor i = 0, . . . , pk do Solve subproblem Pik (Nik ) using algorithms 4-6 if k > 0 then k k k k Send Pˆt,i , Ψ̂ t,i , ĉt,i and x̂t,i to each children at level k − 1 end if end parfor end for Retrieve the solution of (6.1) from the solutions of Pi0 (Ni0 ) for i ∈ Z0,p0 Remark 6.11. At Line 5 in Algorithm 15 the dual variables of Pik (Nik ) (λt in Algorithm 6) are only computed if k = 0, since at levels k > 0 the dual variables are not used. If the algorithms are implemented in double precision arithmetics there are 8 bytes of data per number. Hence, on Line 7 in Algorithm 14 and Line 7 in Algorithm 15 the number of sent bytes is 16n2x + 24nx + 8 and 4n2x + 20nx + 8, respectively. This can be compared to the algorithms in Chapter 5 where 32n2x + 32nx + 8 and 24nx bytes of data are sent. The significant decrease in the amount of communication in the algorithm proposed here is due to exploitation of the structure in the subproblems by using Riccati recursions and the fact that B̂i = Q̂u,i . Remark 6.12. If the parallel algorithm is used to compute uftoc problems in an as method, the eliminated dual variables must be computed as in Section 3.5 using Algorithm 7. Given the primal and dual solutions to the uftoc problem, it can be seen that this algorithm can be computed in parallel for the independent intervals i ∈ Z0,p . 6.3 6.3 Numerical Results 101 Numerical Results The algorithms presented in Section 6.2.2 have been implemented in Matlab for development and comparison purposes, and in ansi-c for evaluation on a computational cluster. In Matlab parallel executions of the algorithms are simulated by executing them serially using one computational thread, but still using the same information flow as for an actual parallel execution. The total computation time in Matlab has been estimated by summing over the maximum computation time for each level in the tree, and hence the communication overhead is neglected. The influence of the communication overhead is discussed in the end of this section. The performance of the parallel Riccati algorithm proposed in this chapter is compared to both the serial Riccati recursion, which is considered a state-of-the-art serial method, and the parallel algorithm presented in Chapter 5 (only in Matlab). The numerical results show that the computation time can be significantly decreased when using the parallel Riccati recursion proposed in this chapter compared to the serial Riccati and the parallel algorithm presented in Chapter 5. In all results presented in this section Ns = 2 has been used in all subproblems. Remark 6.13. It is possible to choose different batch lengths for each subproblem and level in the tree. How to make these choices to minimize computation time is not investigated here. However, similarly to what is described in Axehill (2015), the optimal choice depends on, e.g., the problem and the hardware on which the algorithm is implemented. In Matlab the algorithms have been compared when solving problems in the form (6.1) for systems of dimension nx = 7 and nu = 5, see Figure 6.3, and of dimension nx = 20 and nu = 20, see Figure 6.4. From the figures it is clear that the parallel Riccati algorithm outperforms the serial Riccati for N & 18 − 20 for both problem sizes. The parallel Riccati algorithm is outperforming the parallel algorithm in Chapter 5 for both problem sizes, and for the problem in Figure 6.4 the parallel Riccati algorithm is approximately three times faster than the parallel algorithm in Chapter 5. This significant boost in performance is possible since the algorithm proposed in this chapter utilizes the structure in the subproblems. In addition to the Matlab implementation, an ansi-c implemented algorithm has been run on a computational cluster consisting of nodes with 8-core Intel Xeon E5-2660 @ 2.2 GHz cpus and the communication is performed over tcp/ip on Gigabit Ethernet between the nodes, and over the tcp/ip loop-back for communication between different cores on the same node. The computations were performed on resources provided by the Swedish National Infrastructure for Computing (snic) at nsc. The implementation is rudimentary and especially the communication setup can be improved. However, the implemented algorithm serves as a proof-of-concept that the algorithm works and improves performance in terms of computation times for computations on real parallel hardware, taking communication delays into account. The computation times when solving problems in the form (6.1) for systems of order nx = 20 and nu = 20 are seen 102 6 Parallel Riccati Recursion Computation time: MATLAB 100 Parallel Riccati Parallel: Chapter 5 Serial Riccati Time [s] 10−1 10−2 10−3 101 102 Prediction horizon 103 Figure 6.3: Computation times using systems of order nx = 7 and nu = 5. The parallel Riccati outperforms the serial Riccati for N & 18 − 20, and it is always faster than the parallel algorithm proposed in Chapter 5. in Figure 6.5, where it is clear that the parallel algorithm solves a problem with N = 512 approximately as fast as the serial algorithm solves the same one for N = 64, and the break even is at N ≈ 28. This computational speed-up can be important in problems that require long prediction horizons like, e.g., moving horizon estimation problems (Rao et al., 1998) or high-level planners for autonomous vehicles. The communication overhead is approximately 20% for this problem size, and it has been observed that communication times are approximately the same regardless of the problem size which indicates that there is a significant latency in the communication channel. Reducing these latencies, by for example a better communication setup and using more suitable hardware for fast inter process communication, can significantly improve performance of the ansi-c implemented algorithm, especially for small problem dimensions. Remark 6.14. Experimental results have shown that in communication channels with high latencies the total communication time is affected more by the number of times that the nodes communicate with each other than the amount of data sent at each instant. Hence, for such communication networks, algorithms that send more data fewer times might perform better in terms of computation time than methods that send small amounts of data frequently. 6.3 103 Numerical Results Computation time: MATLAB 100 Parallel Riccati Parallel: Chapter 5 Serial Riccati Time [s] 10−1 10−2 10−3 101 102 Prediction horizon 103 Figure 6.4: Computation times using systems of order nx = 20 and nu = 20. The parallel Riccati outperforms the serial Riccati for N & 18 − 20, and it is significantly faster than the parallel algorithm in Chapter 5. 104 6 Parallel Riccati Recursion Computation time: ANSI-C Parallel Riccati Serial Riccati Time [s] 10−5 10−6 101 102 Prediction horizon Figure 6.5: Computation times for the ansi-c implementation using systems of order nx = 20 and nu = 20. The communication overhead is approximately 20% of the total computation time for this problem size. 6.4 6.4 Comparison with Chapter 5 105 Comparison with Chapter 5 The basic idea with both the algorithm presented in this chapter and in Chapter 5 is to split the prediction horizon into several smaller parts, and performing computations in each part in parallel to reduce the overall computation time. Hence, the two algorithms share similarities but there are also important differences. In this section a brief comparison of the two algorithms is presented. In the algorithm in Chapter 5, the original uftoc problem (5.1) is explicitly extended to the problem (5.4) by introducing the parameters x̂i and ûi as optimization variables together with extra equality constraints. The terminal constraint in each subproblem is parameterized by x̂i and ûi , and the parametrization is chosen such that only reachable terminal states are obtained for all values of the parameters. This is done by choosing B̂i in (5.8) as any basis for the reachability matrix (5.7). The value function is then computed by solving the subproblem parametrically using a standard nullspace method as in Tøndel et al. (2003). By combining the value functions from all individual subproblems with the extra equality constraints in the extended problem (5.4), the extended problem is reduced to the master problem (5.14). This master problem is a uftoc problem in the paramaters x̂i and ûi . After the master problem has been solved, the optimal x̂i∗ and ûi∗ are used in the subproblems to compute the optimal solution. In the algorithm in this chapter no extra constraints are imposed on the terminal states in the subproblems, but instead a variable terminal cost is used to incorporate information from other batches. The states in the subproblem can be eliminated in a similar way as in partial condensing which is introduced in Axehill (2015), and the control signals can be parametrized by the parameter ûi by exploiting the structure in the subproblem. This parametrization computes B̂i in (6.22) as a specific basis for the reachability matrix Si in this chapter. The value function of a subproblem can be computed as a function of the initial value of each subproblem and the parameter ûi by using the Riccati recursion as in Lemma 6.2. When the states and control signals have been eliminated in the subproblems, these reduced problems can be combined into a new uftoc problem by using the definition of the splitting of the prediction horizon (as described in Section 6.1.3). When the new uftoc problem has been solved, the optimal x̂∗ Pˆi i and Ψ̂ i are used in the individual subproblems to compute the optimal primal and dual solutions. Hence, in both algorithms the freedom in the subproblems are parameterized such that only reachable terminal states can be obtained in the master problem, and the value function is computed as a function of the parameters. However, the parametrization is introduced in different ways; in Chapter 5 the freedom is introduced as a freedom in the terminal state in each subproblem, whereas it is described as a freedom in the terminal cost in each subproblem in this chapter. The algorithm in this chapter exploits the structure in the subproblems by eliminating variables using a preliminary feedback that is computed with a Riccati recursion. Furthermore, it exploits the structure also by solving the subproblems 106 6 Parallel Riccati Recursion using Riccati recursions. The algorithm in Chapter 5 does not exploit any structure in the subproblem when the parametric solution is computed. The extra constraint on the terminal state in the subproblems in Chapter 5 might introduce primal degeneracy, which results in non-unique dual variables. This was solved by choosing dual variables that satisfy the optimality condition of the original uftoc problem. In the algorithm in this section this problem is evaded, and primal degeneracy does not appear in the subproblems. Here, the dual variables are computed using the uniquely defined Pt,i and Ψ t,i for each subproblem. Furthermore, the information that is used by the subproblems to compute the solution is different in the two algorithms; in Chapter 5 the optimal parameters are used, and in this chapter the optimal initial parameter x̂∗ , and Pˆi i and Ψ̂ i are used to compute the feedback matrices and optimal solution in the subproblems. The numerical results in Section 6.3 confirms that the Matlab implementations of the algorithm proposed in this chapter outperforms the algorithm in Chapter 5 in terms of computation time. In a truly parallel implementation the difference would probably be even larger, since more data is communicated in the algorithm in Chapter 5. Appendix In this appendix the proof of Lemma 6.2 is given. 6.A Proof of Lemma 6.2 The subindices i are omitted for notational brevity in the proof. Proof: Assume that (6.6) holds for an arbitrary t + 1 ∈ Z1,N −1 . Then the cost at time t is given by # " # " #T " # " #T " 1 xt Qx,t Qxu,t xt xt l + ct + V̄ (xt+1 , ū) . (6.38) + x,t T ut lu,t Qxu,t Qu,t ut 2 ut Inserting the expression of V̄ (xt+1 , ū) from (6.6) and xt+1 = At xt + Bt ut + at into (6.38) gives " #T " # " # " #T " # N −1 1 xt 1 X T Ft+1 Ht+1 xt l¯x,t xt (6.39) ūt Gt+1 ūt , + + c̃ + t T ut l¯u,t Gt+1 ut Ht+1 2 ut 2 t=t+1 where Ft+1 , Ht+1 and Gt+1 are defined by (3.51a), (3.51b) and (3.51c), respectively, and l¯x,t , lx,t + AT Pt+1 at − AT Ψ t+1 , t t l¯u,t , lu,t + BTt Pt+1 at − BTt Ψ t+1 , (6.40) 1 T T c̃t , c̄t+1 + ct + at Pt+1 at − Ψ t+1 at . 2 Finally, using the control law ut = kt+1 + Kt+1 xt + ūt and the definition of Pt , Ψ t , kt+1 and Kt+1 from algorithms 4 and 5, together with l¯x,t and l¯u,t gives the cost function N −1 1 1X T V̄ (xt , ū) = xtT Pt xt − Ψ tT xt + ū G ū + c̄t , (6.41) 2 2 t=t t t+1 t 107 108 6 Parallel Riccati Recursion where 1 T k G k + l¯T k . (6.42) 2 t+1 t+1 t+1 u,t t+1 Note that the linear terms for ūt and the cross terms between xt and ū in the T cost function (6.39) vanishes since Gt+1 kt+1 = −l¯u,t and Gt+1 Kt+1 = −Ht+1 . Equation (6.6) holds specifically for t = N − 1 and hence Lemma 6.2 follows by induction. c̄t , c̃t + 7 Conclusions and Further Work The aim of this thesis is to present numerical algorithms for important subroutines in solvers for mpc problems. Developing a complete solver is outside the scope of the thesis, and the focus is instead on the linear algebra that is used in the solvers. The performance gains in terms of computation time are evaluated using mostly Matlab implementations of the proposed algorithms. No comparisons of complete solvers are made due to the limitation of the scope of the thesis. 7.1 Conclusions In this thesis, different numerical algorithms for computing the Newton steps in both ip and as methods for mpc are presented. This is often where the most computational effort is spent in these types of methods. It is shown in Matlab evaluations that the performance in terms of computational complexity and computation time can be significantly reduced in an as solver by modifying the Riccati factorization between changes to the working set instead of re-computing it. This results in quadratic complexity growth in the problem size instead of cubic, which can be a crucial decrease in complexity in order to solve large mpc problems when the structure is exploited using Riccati recursions. Furthermore, it is shown how to compute the Newton step in parallel on several computational units by exploiting the structure in the mpc problem in time. Two different approaches are presented, where both exploit the special structure in the mpc problem. The first approach adds additional complicating variables and constraints and divides the mpc problem into several smaller subproblems. These are solved parametrically in parallel to obtain a master mpc problem with shorter prediction horizon. By repeating this procedure, the original problem can 109 110 7 Conclusions and Further Work be solved with logarithmic complexity in the prediction horizon length, provided that enough computational units are available. The second approach is similar to the first, but the way the subproblems are solved is different. Here the Riccati recursion is used to solve the mpc problem, and it is shown how to compute the Riccati recursion in parallel by dividing the prediction horizon into several smaller intervals. In each interval most of the variables are eliminated, and the remaining variables are combined into a new mpc problem. As for the first algorithm, this procedure can be repeated to obtain mpc problems with shorter prediction horizons, which results in logarithmic complexity growth in the prediction horizon length, provided that enough computational units are available. 7.2 Further Work In this thesis, contributions to the area of numerical algorithms for mpc are presented, and some possibilities for future work in this field are presented here. There are interesting and challenging theoretical and practical extensions of the work presented in this thesis. Some of the interesting topics for future work are listed below • Using the results from Chapter 4 in the dual gradient projection method presented in Axehill (2008). • Implementing the algorithms presented in Chapter 4 in ansi-c. • Develop a square-root implementation of the algorithms in Chapter 4. • Including the results in chapters 5 and 6 in a complete ip or as solver to further utilize structure and parallel computations. • Extending the results to cover also estimation and system identification problems. • Combining the theory in chapters 4 and 6 to perform modifications of the Riccati factorization in parallel. • Investigate how the size of the subproblems in chapters 5 and 6 should be chosen to minimize the total computation time. • Improving the ansi-c implementation of the parallel Riccati recursion in Chapter 6. • Reducing the communication latencies in the parallel algorithms by using suitable parallel hardware such as Graphics Processing Units (gpus) or Field Programmable Gate Arrays (fpgas). Appendix A Linear Algebra In this appendix, some linear algebra notation and results that are used throughout the thesis are listed. For further results in linear algebra, the reader is referred to standard literature such as Lancaster and Tismenetsky (1985). Definition A.1 (Moore-Penrose pseudo-inverse). Consider a matrix A ∈ Rm×n . Then the matrix A† ∈ Rn×m that satisfies the four equations AA† A = A, † † † A AA = A , T AA† = AA† , T A† A = A† A, (A.1) (A.2) (A.3) (A.4) is the Moore-Penrose pseudo-inverse, or simply the pseudo-inverse of A. Furthermore, A† is unique. Remark A.2. If A is non-singular, then A† = A−1 . Now study a square matrix M which is partitioned into blocks as " # M11 M12 M, , M21 M22 (A.5) where M11 and M22 are square matrices. Definition A.3 is repeated from Carlson et al. (1974), but with slightly different notation. 113 114 A Linear Algebra Definition A.3 (Generalized Schur complement). The generalized Schur complement of M22 in M is denoted M/ † M22 and is defined as † M/ † M22 , M11 − M12 M22 M21 . (A.6) Similarly, the generalized Schur complement of M11 in M is defined as † M/ † M11 , M22 − M21 M11 M12 . (A.7) When M22 , or M11 , is non-singular, the Schur complement is defined as in Definition A.4. Definition A.4 (Schur complement). The Schur complement of M22 in M is denoted M/M22 and is defined as −1 M/M22 , M11 − M12 M22 M21 . (A.8) Similarly, the Schur complement of M11 in M is defined as −1 M/M11 , M22 − M21 M11 M12 . (A.9) Assumption A.5. The matrix M in (A.5) is non-singular. Theorem A.6. Let Assumption A.5 hold. Then the inverse of M in (A.5) is " −1 # −1 −1 −1 M11 + M11 M12 (M/M11 )−1 M21 M11 −M11 M12 (M/M11 )−1 M −1 = . (A.10) −1 (M/M11 )−1 − (M/M11 )−1 M21 M11 Proof: Write M as " # " I M11 M12 = −1 M21 M22 M21 M11 #" 0 M11 0 I 0 M/M11 #" I 0 # −1 M11 M12 , I (A.11) where the outer matrices on the right-hand-side are invertible. Taking the inverse of both sides gives " #−1 " # " −1 #" # −1 0 I 0 M11 M12 I −M11 M12 M11 = = −1 M21 M22 0 I I (M/M11 )−1 −M21 M11 0 " −1 # −1 −1 −1 M11 + M11 M12 (M/M11 )−1 M21 M11 −M11 M12 (M/M11 )−1 , −1 (M/M11 )−1 − (M/M11 )−1 M21 M11 (A.12) which completes the proof. Assumption A.7. The matrix M is symmetric, giving T M21 = M12 , T M11 = M11 , T M22 = M22 . (A.13) 115 The following theorem is repeated from Albert (1969). Theorem A.8. Consider a block partitioned matrix M in (A.5) where Assumption A.7 holds. Then the following hold † T † M 0 ⇐⇒ M11 0, (I − M11 M11 )M12 = 0, M/ † M11 = M22 − M12 M11 M12 0, (A.14) † T † T M 0 ⇐⇒ M22 0, (I − M22 M22 )M12 = 0, M/ † M22 = M11 − M12 M22 M12 0. (A.15) Proof: The proof follows from Theorem 1 in Albert (1969). Now consider the system of equations " # " #" # A1 A2 X1 H1 . = H2 A2T A3 X2 | {z } |{z} |{z} X A (A.16) H Assumption A.9. The system of equations given in (A.16) is solvable, i.e., H ∈ R (A) ⇐⇒ AA† H = H. (A.17) Assumption A.10. A 0. Theorem A.11. Consider the system of equations in (A.16) under assumptions A.9 and A.10. Then one solution X ∗ is given by † " # † " ∗ # † A1 + A†1 A2 A/ † A1 A2T A†1 −A†1 A2 A/ † A1 H1 X1 , (A.18) = † † X2∗ H2 − A/ † A1 A2T A†1 A/ † A1 and the following properties hold (H1 − A2 A†3 H2 ) ∈ R A1 − A2 A†3 A2T , (H2 − A2T A†1 H1 ) ∈ R A3 − A2T A†1 A2 . Proof: Factor A as " # " #" #" I 0 A1 0 A1 A2 I = A2T A3 A2T A†1 I 0 A/ † A1 0 | {z } | {z } ,U ,Ā # A†1 A2 = U ĀU T . I (A.19) (A.20) (A.21) 116 A Linear Algebra Note that U is invertible and " U −1 = I −A2T A†1 # 0 . I (A.22) Using this factorization, re-write the system of equations (A.16) as " #" #" #" # " # I 0 A1 0 H I A†1 A2 X1 AX = T † = 1 . X2 H2 A2 A1 I 0 A/ † A1 0 I Since U is invertible, R (A) = R Ā and the system of equations #" # " # " A1 0 W1 Z1 , = W2 0 A/ † A1 Z2 (A.23) (A.24) with # X1 + A†1 A2 X2 , Z,U X= X2 " " T W ,U −1 # H1 H= , −A2T A†1 H1 + H2 is solvable. The solution Z ∗ is " ∗# A†1 W1 + ν1 Z1 , ν1 ∈ N (A1 ) , ν2 ∈ N A/ † A1 . † ∗ = † Z2 A/ A1 W2 + ν2 (A.25) (A.26) By using the definition of Z and W this gives † " # " † " ∗ # † #" # A1 + A†1 A2 A/ † A1 A2T A†1 −A†1 A2 A/ † A1 H1 X1 I −A†1 A2 ν1 . + = † † ν2 X2∗ H2 0 I A/ † A1 − A/ † A1 A2T A†1 (A.27) Hence, by choosing the solution corresponding to ν = 0 it is clear that one solution to (A.16) is given by (A.18). Furthermore, (A.20) follows from the fact that (A.24) is solvable. Analogous calculation proves (A.19). This concludes the proof. Remark A.12. Note that the solution (A.18) is not in general the same as X ∗ = A† H. The requirements for them to coincide are listen in for example Burns et al. (1974). Bibliography M. Åkerblad and A. Hansson. Efficient solution of second order cone program for model predictive control. International Journal of Control, 77(1):55–77, 2004. Cited on page 37. A. Albert. Conditions for positive and nonnegative definiteness in terms of pseudoinverses. SIAM Journal on Applied Mathematics, 17(2):434–440, 1969. doi: 10.1137/0117041. Cited on page 115. D. Axehill. Applications of Integer Quadratic Programming in Control and Communication. Number 1218 in Linköping Studies in Science and Technology. Thesis. 2005. Cited on pages 29, 46, 47, and 57. D. Axehill. Integer Quadratic Programming for Control and Communication. PhD thesis, Linköping University, 2008. Cited on pages 13, 20, 21, 29, 33, 37, 38, 47, 48, 49, 95, and 110. D. Axehill. Controlling the level of sparsity in MPC. Systems & Control Letters, 76:1–7, 2015. Cited on pages 77, 92, 101, and 105. D. Axehill and A. Hansson. A mixed integer dual quadratic programming algorithm tailored for MPC. In Proceedings of the 45th IEEE Conference on Decision and Control, pages 5693–5698, San Diego, USA, December 2006. Cited on pages 20, 37, 47, 48, and 49. D. Axehill and A. Hansson. A dual gradient projection quadratic programming algorithm tailored for model predictive control. In Proceedings of the 47th IEEE Conference on Decision and Control, pages 3057–3064, Cancun, Mexico, 2008. Cited on pages 20, 33, 37, 47, 48, and 49. D. Axehill and A. Hansson. Towards parallel implementation of hybrid MPC – a survey and directions for future research. In Rolf Johansson and Anders Rantzer, editors, Distributed Decision Making and Control, volume 417 of Lecture Notes in Control and Information Sciences, pages 313–338. Springer Verlag, 2012. Cited on page 99. 117 118 Bibliography D. Axehill, A. Hansson, and L. Vandenberghe. Relaxations applicable to mixed integer predictive control – comparisons and efficient computations. In Proceedings of the 46th IEEE Conference on Decision and Control, pages 4103–4109, New Orleans, USA, 2007. Cited on pages 22, 25, and 27. D. Axehill, L. Vandenberghe, and A. Hansson. Convex relaxations for mixed integer predictive control. Automatica, 46(9):1540–1545, 2010. Cited on pages 20 and 37. R.A. Bartlett and L.T. Biegler. Qpschur: A dual, active-set, schur-complement method for large-scale and structured convex quadratic programming. Optimization and Engineering, 7(1):5–32, 2006. ISSN 1389-4420. doi: 10.1007/ s11081-006-6588-z. Cited on page 49. A. Bemporad, A. Morari, V. Dua, and E.N. Pistikopoulos. The explicit linear quadratic regulator for constrained systems. Automatica, 38(1):3 – 20, 2002. ISSN 0005-1098. doi: 10.1016/S0005-1098(01)00174-1. Cited on page 19. U. Bertelè and F. Brioschi. On non-serial dynamic programming. Journal of Combinatorial Theory, Series A, 14(2):137 – 148, 1973. ISSN 0097-3165. doi: 10.1016/0097-3165(73)90016-2. Cited on page 66. D.P. Bertsekas. Dynamic Programming and Optimal Control. Athena Scientific, 2nd edition, 2000. ISBN 1886529094. Cited on page 66. S. Boyd and L. Vandenberghe. Convex Optimization. Cambridge University Press, 2004. Cited on pages 6, 7, 8, 9, 15, 16, 39, and 60. S. Boyd, L. Xiao, A. Mutapcic, and J. Mattingley. Notes on decomposition methods. Technical report, Stanford University, 2008. URL http://see.stanford.edu/materials/lsocoee364b/ \08-decomposition_notes.pdf. Cited on page 69. F. Burns, D. Carlson, E. Haynsworth, and T. Markham. Generalized inverse formulas using the schur complement. SIAM Journal on Applied Mathematics, 26(2):pp. 254–259, 1974. ISSN 00361399. Cited on page 116. D. Carlson, E. Haynsworth, and T. Markham. A generalization of the schur complement by means of the moore-penrose inverse. SIAM Journal on Applied Mathematics, 26(1):pp. 169–175, 1974. ISSN 00361399. Cited on pages 39, 56, and 113. G.A. Constantinides. Tutorial paper: Parallel architectures for model predictive control. In Proceedings of the European Control Conference, pages 138–143, Budapest, Hungary, 2009. Cited on page 65. M. Diehl, H.J. Ferreau, and N. Haverbeke. Nonlinear Model Predictive Control, chapter Efficient Numerical Methods for Nonlinear MPC and Moving Horizon Estimation, pages 391–417. Springer Berlin / Heidelberg, 2009. Cited on pages 20 and 37. Bibliography 119 D. Goldfarb and A. Idnani. A numerically stable dual method for solving strictly convex quadratic programs. Mathematical Programming, 27(1):1–33, 1983. ISSN 0025-5610. doi: 10.1007/BF02591962. Cited on pages 14, 47, and 49. G.H. Golub and C.F. Van Loan. Matrix Computations. Johns Hopkins Studies in the Mathematical Sciences. Johns Hopkins University Press, 1996. ISBN 9780801854149. Cited on pages 29 and 45. A. Grancharova, T.A. Johansen, J. Kocijan, and D. Vrancic. Design of reduced dimension explicit model predictive controller for a gas-liquid separation plant. In EUROCON 2003. Computer as a Tool. The IEEE Region 8, volume 1, pages 391–395 vol.1, Sept 2003. doi: 10.1109/EURCON.2003.1248050. Cited on page 19. A. Hansson. A primal-dual interior-point method for robust optimal control of linear discrete-time systems. IEEE Transactions on Automatic Control, 45(9): 1639–1655, September 2000. Cited on pages 20, 22, and 37. H. Jonson. A Newton method for solving non-linear optimal control problems with general constraints. PhD thesis, Linköpings Tekniska Högskola, 1983. Cited on pages 20, 29, and 37. J.B. Jørgensen. Moving Horizon Estimation and Control. PhD thesis, Technical University of Denmark (DTU), 2004. Cited on page 29. T. Kailath. Linear Systems. Information and System Sciences Series. PrenticeHall, 1980. ISBN 9780135369616. Cited on page 52. S. Khoshfetrat Pakazad, A. Hansson, and M.S. Andersen. Distributed primaldual interior-point methods for solving loosely coupled problems using message passing. arXiv:1502.06384v2, 2015. Cited on page 66. C. Kirches, L. Wirsching, S. Sager, and H.G. Bock. Efficient numerics for nonlinear model predictive control. In M. Diehl, F. Glineur, E. Jarlebring, and W. Michiels, editors, Recent Advances in Optimization and its Applications in Engineering, pages 339–359. Springer, 2010. ISBN 978-3-6421-2597-3. Cited on page 37. C. Kirches, H.G. Bock, J.P. Schlöder, and S. Sager. A factorization with update procedures for a KKT matrix arising in direct optimal control. Mathematical Programming Computation, 3(4):319–348, 2011. Cited on page 37. C.D. Laird, A.V. Wong, and J. Akesson. Parallel solution of large-scale dynamic optimization problems. In 21st European Symposium on Computer Aided Process Engineering, volume 21, 2011. Cited on page 65. P. Lancaster and M. Tismenetsky. The Theory of Matrices: With Applications. Academic Press, 1985. ISBN 9780124355606. Cited on page 113. L. Lasdon. Optimization theory for large systems. DoverPublications. com, 1970. Cited on page 69. 120 Bibliography J.M. Maciejowski. Predictive control with constraints. Prentice Hall, 2002. Cited on pages 1, 19, and 46. C.C. Moallemi. A message-passing paradigm for optimization. PhD thesis, Stanford University, 2007. Cited on page 66. I. Nielsen and D. Axehill. An O(log N) parallel algorithm for Newton step computation in model predictive control. In Proceedings of the 19th IFAC World Congress, pages 10505–10511, Cape Town, South Africa, August 2014. Cited on pages 20, 65, and 66. I. Nielsen and D. Axehill. A parallel structure-exploiting factorization algorithm with applications to model predictive control. Accepted for publication at the 54th IEEE Conference on Decision and Control, December 2015. Cited on page 87. I. Nielsen, D. Ankelhed, and D. Axehill. Low-rank modification of Riccati factorizations with applications to model predictive control. In Proceedings of the 52nd IEEE Conference on Decision and Control, pages 3684–3690, Firenze, Italy, December 2013. Cited on pages 20, 37, and 38. J. Nocedal and S. Wright. Numerical Optimization. Springer-Verlag, 2006. Cited on pages 9, 10, 11, 13, 14, 16, 27, 34, 38, and 50. B. O’Donoghue, G. Stathopoulos, and S. Boyd. A splitting method for optimal control. In IEEE Transactions on Control Systems Technology, volume 21, pages 2432–2442. IEEE, 2013. Cited on page 65. C.V. Rao. Moving Horizon Strategies for the Constrained Monitoring and Control of Nonlinear Discrete-Time Systems. PhD thesis, University of WisconsinMadison, 2000. Cited on page 29. C.V. Rao, S.J. Wright, and J.B. Rawlings. Application of interior-point methods to model predictive control. Journal of Optimization Theory and Applications, 99(3):723–757, December 1998. Cited on pages 20, 22, 27, 29, 37, and 102. P. Reuterswärd. Towards Pseudospectral Control and Estimation. ISSN 0280– 5316. 2012. Licentiate Thesis. Cited on page 65. O. Shcherbina. Nonserial dynamic programming and tree decomposition in discrete optimization. In Karl-Heinz Waldmann and Ulrike M. Stocker, editors, Operations Research Proceedings 2006, volume 2006 of Operations Research Proceedings, pages 155–160. Springer Berlin Heidelberg, 2007. ISBN 978-3540-69994-1. doi: 10.1007/978-3-540-69995-8_26. Cited on page 66. D. Soudbakhsh and A.M. Annaswamy. Parallelized model predictive control. In Proceedings of the American Control Conference, pages 1715–1720, Washington, DC, USA, 2013. Cited on page 65. G. Stathopoulos, T. Keviczky, and Y. Wang. A hierarchical time-splitting approach for solving finite-time optimal control problems. In Proceedings of Bibliography 121 the European Control Conference, pages 3089–3094, Zurich, Switzerland, July 2013. Cited on page 65. P. Tøndel, T.A. Johansen, and A. Bemporad. Further results on multiparametric quadratic programming. In Proceedings of the 42nd IEEE European Control Conference, pages 3173–3178, 2003. Cited on pages 71, 72, 73, 79, and 105. L. Vandenberghe, S. Boyd, and M. Nouralishahi. Robust linear programming and optimal control. Technical report, Department of Electrical Engineering, University of California Los Angeles, 2002. Cited on pages 20, 27, 29, and 37. S.J. Wright. Interior point methods for optimal control of discrete-time systems. Journal of Optimization Theory and Applications, 77:161–187, 1993. Cited on page 22. F. Zhang. The Schur complement and its applications, volume 4. Springer, 2005. Cited on page 39. Y. Zhu and C.D. Laird. A parallel algorithm for structured nonlinear programming. In 5th International Conference on Foundations of Computer-Aided Process Operations, volume 5, pages 345–348, 2008. Cited on page 65. Licentiate Theses Division of Automatic Control Linköping University P. Andersson: Adaptive Forgetting through Multiple Models and Adaptive Control of Car Dynamics. Thesis No. 15, 1983. B. Wahlberg: On Model Simplification in System Identification. Thesis No. 47, 1985. A. Isaksson: Identification of Time Varying Systems and Applications of System Identification to Signal Processing. Thesis No. 75, 1986. G. Malmberg: A Study of Adaptive Control Missiles. Thesis No. 76, 1986. S. Gunnarsson: On the Mean Square Error of Transfer Function Estimates with Applications to Control. Thesis No. 90, 1986. M. Viberg: On the Adaptive Array Problem. Thesis No. 117, 1987. K. Ståhl: On the Frequency Domain Analysis of Nonlinear Systems. Thesis No. 137, 1988. A. Skeppstedt: Construction of Composite Models from Large Data-Sets. Thesis No. 149, 1988. P. A. J. Nagy: MaMiS: A Programming Environment for Numeric/Symbolic Data Processing. Thesis No. 153, 1988. K. Forsman: Applications of Constructive Algebra to Control Problems. Thesis No. 231, 1990. I. Klein: Planning for a Class of Sequential Control Problems. Thesis No. 234, 1990. F. Gustafsson: Optimal Segmentation of Linear Regression Parameters. Thesis No. 246, 1990. H. Hjalmarsson: On Estimation of Model Quality in System Identification. Thesis No. 251, 1990. S. Andersson: Sensor Array Processing; Application to Mobile Communication Systems and Dimension Reduction. Thesis No. 255, 1990. K. Wang Chen: Observability and Invertibility of Nonlinear Systems: A Differential Algebraic Approach. Thesis No. 282, 1991. J. Sjöberg: Regularization Issues in Neural Network Models of Dynamical Systems. Thesis No. 366, 1993. P. Pucar: Segmentation of Laser Range Radar Images Using Hidden Markov Field Models. Thesis No. 403, 1993. H. Fortell: Volterra and Algebraic Approaches to the Zero Dynamics. Thesis No. 438, 1994. T. McKelvey: On State-Space Models in System Identification. Thesis No. 447, 1994. T. Andersson: Concepts and Algorithms for Non-Linear System Identifiability. Thesis No. 448, 1994. P. Lindskog: Algorithms and Tools for System Identification Using Prior Knowledge. Thesis No. 456, 1994. J. Plantin: Algebraic Methods for Verification and Control of Discrete Event Dynamic Systems. Thesis No. 501, 1995. J. Gunnarsson: On Modeling of Discrete Event Dynamic Systems, Using Symbolic Algebraic Methods. Thesis No. 502, 1995. A. Ericsson: Fast Power Control to Counteract Rayleigh Fading in Cellular Radio Systems. Thesis No. 527, 1995. M. Jirstrand: Algebraic Methods for Modeling and Design in Control. Thesis No. 540, 1996. K. Edström: Simulation of Mode Switching Systems Using Switched Bond Graphs. Thesis No. 586, 1996. J. Palmqvist: On Integrity Monitoring of Integrated Navigation Systems. Thesis No. 600, 1997. A. Stenman: Just-in-Time Models with Applications to Dynamical Systems. Thesis No. 601, 1997. M. Andersson: Experimental Design and Updating of Finite Element Models. Thesis No. 611, 1997. U. Forssell: Properties and Usage of Closed-Loop Identification Methods. Thesis No. 641, 1997. M. Larsson: On Modeling and Diagnosis of Discrete Event Dynamic systems. Thesis No. 648, 1997. N. Bergman: Bayesian Inference in Terrain Navigation. Thesis No. 649, 1997. V. Einarsson: On Verification of Switched Systems Using Abstractions. Thesis No. 705, 1998. J. Blom, F. Gunnarsson: Power Control in Cellular Radio Systems. Thesis No. 706, 1998. P. Spångéus: Hybrid Control using LP and LMI methods – Some Applications. Thesis No. 724, 1998. M. Norrlöf: On Analysis and Implementation of Iterative Learning Control. Thesis No. 727, 1998. A. Hagenblad: Aspects of the Identification of Wiener Models. Thesis No. 793, 1999. F. Tjärnström: Quality Estimation of Approximate Models. Thesis No. 810, 2000. C. Carlsson: Vehicle Size and Orientation Estimation Using Geometric Fitting. Thesis No. 840, 2000. J. Löfberg: Linear Model Predictive Control: Stability and Robustness. Thesis No. 866, 2001. O. Härkegård: Flight Control Design Using Backstepping. Thesis No. 875, 2001. J. Elbornsson: Equalization of Distortion in A/D Converters. Thesis No. 883, 2001. J. Roll: Robust Verification and Identification of Piecewise Affine Systems. Thesis No. 899, 2001. I. Lind: Regressor Selection in System Identification using ANOVA. Thesis No. 921, 2001. R. Karlsson: Simulation Based Methods for Target Tracking. Thesis No. 930, 2002. P.-J. Nordlund: Sequential Monte Carlo Filters and Integrated Navigation. Thesis No. 945, 2002. M. Östring: Identification, Diagnosis, and Control of a Flexible Robot Arm. Thesis No. 948, 2002. C. Olsson: Active Engine Vibration Isolation using Feedback Control. Thesis No. 968, 2002. J. Jansson: Tracking and Decision Making for Automotive Collision Avoidance. Thesis No. 965, 2002. N. Persson: Event Based Sampling with Application to Spectral Estimation. Thesis No. 981, 2002. D. Lindgren: Subspace Selection Techniques for Classification Problems. Thesis No. 995, 2002. E. Geijer Lundin: Uplink Load in CDMA Cellular Systems. Thesis No. 1045, 2003. M. Enqvist: Some Results on Linear Models of Nonlinear Systems. Thesis No. 1046, 2003. T. Schön: On Computational Methods for Nonlinear Estimation. Thesis No. 1047, 2003. F. Gunnarsson: On Modeling and Control of Network Queue Dynamics. Thesis No. 1048, 2003. S. Björklund: A Survey and Comparison of Time-Delay Estimation Methods in Linear Systems. Thesis No. 1061, 2003. M. Gerdin: Parameter Estimation in Linear Descriptor Systems. Thesis No. 1085, 2004. A. Eidehall: An Automotive Lane Guidance System. Thesis No. 1122, 2004. E. Wernholt: On Multivariable and Nonlinear Identification of Industrial Robots. Thesis No. 1131, 2004. J. Gillberg: Methods for Frequency Domain Estimation of Continuous-Time Models. Thesis No. 1133, 2004. G. Hendeby: Fundamental Estimation and Detection Limits in Linear Non-Gaussian Systems. Thesis No. 1199, 2005. D. Axehill: Applications of Integer Quadratic Programming in Control and Communication. Thesis No. 1218, 2005. J. Sjöberg: Some Results On Optimal Control for Nonlinear Descriptor Systems. Thesis No. 1227, 2006. D. Törnqvist: Statistical Fault Detection with Applications to IMU Disturbances. Thesis No. 1258, 2006. H. Tidefelt: Structural algorithms and perturbations in differential-algebraic equations. Thesis No. 1318, 2007. S. Moberg: On Modeling and Control of Flexible Manipulators. Thesis No. 1336, 2007. J. Wallén: On Kinematic Modelling and Iterative Learning Control of Industrial Robots. Thesis No. 1343, 2008. J. Harju Johansson: A Structure Utilizing Inexact Primal-Dual Interior-Point Method for Analysis of Linear Differential Inclusions. Thesis No. 1367, 2008. J. D. Hol: Pose Estimation and Calibration Algorithms for Vision and Inertial Sensors. Thesis No. 1370, 2008. H. Ohlsson: Regression on Manifolds with Implications for System Identification. Thesis No. 1382, 2008. D. Ankelhed: On low order controller synthesis using rational constraints. Thesis No. 1398, 2009. P. Skoglar: Planning Methods for Aerial Exploration and Ground Target Tracking. Thesis No. 1420, 2009. C. Lundquist: Automotive Sensor Fusion for Situation Awareness. Thesis No. 1422, 2009. C. Lyzell: Initialization Methods for System Identification. Thesis No. 1426, 2009. R. Falkeborn: Structure exploitation in semidefinite programming for control. Thesis No. 1430, 2010. D. Petersson: Nonlinear Optimization Approaches to H2 -Norm Based LPV Modelling and Control. Thesis No. 1453, 2010. Z. Sjanic: Navigation and SAR Auto-focusing in a Sensor Fusion Framework. Thesis No. 1464, 2011. K. Granström: Loop detection and extended target tracking using laser data. Thesis No. 1465, 2011. J. Callmer: Topics in Localization and Mapping. Thesis No. 1489, 2011. F. Lindsten: Rao-Blackwellised particle methods for inference and identification. Thesis No. 1480, 2011. M. Skoglund: Visual Inertial Navigation and Calibration. Thesis No. 1500, 2011. S. Khoshfetrat Pakazad: Topics in Robustness Analysis. Thesis No. 1512, 2011. P. Axelsson: On Sensor Fusion Applied to Industrial Manipulators. Thesis No. 1511, 2011. A. Carvalho Bittencourt: On Modeling and Diagnosis of Friction and Wear in Industrial Robots. Thesis No. 1516, 2012. P. Rosander: Averaging level control in the presence of frequent inlet flow upsets. Thesis No. 1527, 2012. N. Wahlström: Localization using Magnetometers and Light Sensors. Thesis No. 1581, 2013. R. Larsson: System Identification of Flight Mechanical Characteristics. Thesis No. 1599, 2013. Y. Jung: Estimation of Inverse Models Applied to Power Amplifier Predistortion. Thesis No. 1605, 2013. M. Syldatk: On Calibration of Ground Sensor Networks. Thesis No. 1611, 2013. M. Roth: Kalman Filters for Nonlinear Systems and Heavy-Tailed Noise. Thesis No. 1613, 2013. D. Simon: Model Predictive Control in Flight Control Design — Stability and Reference Tracking. Thesis No. 1642, 2014. J. Dahlin: Sequential Monte Carlo for inference in nonlinear state space models. Thesis No. 1652, 2014. M. Kok: Probabilistic modeling for positioning applications using inertial sensors. Thesis No. 1656, 2014. J. Linder: Graybox Modelling of Ships Using Indirect Input Measurements. Thesis No. 1681, 2014. G. Mathai: Direction of Arrival Estimation of Wideband Acoustic Wavefields in a Passive Sensing Environment. Thesis No. 1721, 2015.

* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project

### Related manuals

Download PDF

advertisement