MPC Handling Thomas Wiese, TU Munich, KU Leuven supervised by H.J. Ferreau, Prof. M. Diehl (both KUL) and Dr. H. Gräb (TUM) October 9, 2008 1 / 42
MPC General MPC Strategies 2 / 42
Linear Discrete-Time Dynamic Systems - Simple Car Model - Quarter Car Model Linear Model Predictive Control Receding Horizon - Receding Horizon MPC General 3 / 42
Linear Discrete-Time Dynamic Systems Linear Discrete-Time Dynamic Systems - Simple Car Model - Quarter Car Model Linear Model Predictive Control Receding Horizon - Receding Horizon We consider the following linear discrete-time dynamic system which shall be steered to a setpoint: x k+1 = Ax k + Bu k x and u are referred to as states and inputs of the system. example car and quarter car MPC General 4 / 42
- Simple Car Model Linear Discrete-Time Dynamic Systems - Simple Car Model - Quarter Car Model Linear Model Predictive Control Receding Horizon - Receding Horizon (ẋ ) ẍ = ( ) ( ) 0 1 x 0 0 ẋ + ( ) 0 u 1 MPC General 5 / 42
- Quarter Car Model Linear Discrete-Time Dynamic Systems - Simple Car Model - Quarter Car Model Linear Model Predictive Control Receding Horizon - Receding Horizon MPC General 6 / 42
Linear Model Predictive Control Linear Discrete-Time Dynamic Systems - Simple Car Model - Quarter Car Model Linear Model Predictive Control Receding Horizon - Receding Horizon State-space approach Prediction of system behavior Quadratic cost function Hard input and output constraints Results in a nonlinear control law MPC General 7 / 42
Linear Discrete-Time Dynamic Systems - Simple Car Model - Quarter Car Model Linear Model Predictive Control Receding Horizon - Receding Horizon MPC General The linear MPC can be formulated as follows: minimize a cost function Φ(u 0,u 1,...) = k=0,1,... such that the constraints x k+1 x ref,k+1 2 W x + u k 2 W u G u u k b u G x x k+1 b x are satisfied for all future k and the x k are determined by the system dynamics and where x 0 is known. 8 / 42
Receding Horizon Linear Discrete-Time Dynamic Systems - Simple Car Model - Quarter Car Model Linear Model Predictive Control Receding Horizon - Receding Horizon MPC General Infinitely many optimization variables Solution Cut off the sum at term N (N = horizon ) Apply only the first control Repeat at every time step The solution can be found by solving a Quadratic Program (QP) and must be available within the sampling time. 9 / 42
- Receding Horizon Linear Discrete-Time Dynamic Systems - Simple Car Model - Quarter Car Model Linear Model Predictive Control Receding Horizon - Receding Horizon MPC General 10 / 42
MPC - Short Horizon - Car Model - Measurement noise General MPC 11 / 42
MPC - Short Horizon - Car Model - Measurement noise General An MPC problem is called infeasible at time step t (t = 0 in the following) if the constraints cannot be satisfied. How can this happen? The problem is ill-posed The states are subject to measurement errors The prediction or control horizon is too short The predictions are not correct (model/plant mismatch) 12 / 42
- Short Horizon - Car Model MPC - Short Horizon - Car Model - Measurement noise General 13 / 42
- Measurement noise MPC - Short Horizon - Car Model - Measurement noise General 14 / 42
MPC of MPC General 15 / 42
of MPC MPC By elminating the states, the MPC can be expressed as a parametric Quadratic Program (QP): of MPC General subject to 1 min x 2 xt Qx + gx T 0 x Gx b x0 where the gradient g x0 and b x0 depend linearly on the parameter x 0. 16 / 42
MPC General Relaxation Exactness Guaranteeing Exactness 1/2 Guaranteeing Exactness 2/2 Many Objectives General 17 / 42
Relaxation MPC General Relaxation Exactness Guaranteeing Exactness 1/2 Guaranteeing Exactness 2/2 Many Objectives Reformulate MPC such that it is guaranteed to be feasible: min Φ(u 0,...,u N ) = N x k+1 x ref,k+1 2 W x + u k 2 W u k=0 such that the relaxed constraints G u u k ub u + ε G x x k+1 ub x + ε are satisfied for all k {0,...,N} and the x k are determined by the system dynamics and where x 0 is known. 18 / 42
Exactness MPC General Relaxation Exactness Guaranteeing Exactness 1/2 Guaranteeing Exactness 2/2 Many Objectives Strength of MPC: Hard Constraints. To preserve hard constraints the infeasibility handling strategy must be exact. A strategy is called exact if it only relaxes the constraints when the problem is infeasible. 19 / 42
Guaranteeing Exactness 1/2 MPC Embed MPC into a bigger optimization problem: First check for feasibility (e.g. by solving a Linear Program) General Relaxation Exactness Guaranteeing Exactness 1/2 Guaranteeing Exactness 2/2 Many Objectives If feasible: solve original problem Else: solve relaxed problem = 2-step algorithm 20 / 42
Guaranteeing Exactness 2/2 MPC General Relaxation Exactness Guaranteeing Exactness 1/2 Guaranteeing Exactness 2/2 Many Objectives Relax original MPC problem: Formulate the MPC problem with soft constraints Introduce a big linear penalty for slack variables that guarantees exactness (Exact Soft Constraints) : Finding lower bound for the linear penalty 21 / 42
Many Objectives MPC General Relaxation Exactness Guaranteeing Exactness 1/2 Guaranteeing Exactness 2/2 Many Objectives How to return to feasibility? Regain feasibility as quick as possible Minimize total anticipated duration of constraint violations Minimize the maximal amplitude of constraint violations Minimize quadratic sum of constraint violations etc. 22 / 42
MPC General l Penalty l Penalty - l Penalty - Minimum Time l 1 Penalty l 1 Penalty - l 1 Penalty - Other Approaches 23 / 42
l Penalty One slack variable ε is introduced and the constraints are relaxed by ε. MPC General l Penalty l Penalty - l Penalty - Minimum Time l 1 Penalty l 1 Penalty - l 1 Penalty - Other Approaches Only one additional optimization variable Minimizes the maximum violation : Can result in large open-/closed-loop mismatch 24 / 42
l Penalty - MPC General l Penalty l Penalty - l Penalty - Minimum Time l 1 Penalty l 1 Penalty - l 1 Penalty - Other Approaches Before solving the original MPC problem, the following LP must be solved: subject to min ε x 0 = x 0 ε x k+1 = Ax k + Bu k G u u k b u + ε G x x k+1 b x + ε ε 0 k {0,...,N} 25 / 42
l Penalty - MPC General l Penalty l Penalty - l Penalty - Minimum Time l 1 Penalty l 1 Penalty - l 1 Penalty - Other Approaches 26 / 42
Minimum Time The minimal time τ min after which the problem is feasible again can be computed (solution of a QP and several LPs). MPC General l Penalty l Penalty - l Penalty - Minimum Time l 1 Penalty l 1 Penalty - l 1 Penalty - Other Approaches only relax constraints before τ min Time-optimal relaxation : Can result in large violations at the start High additional computational cost 27 / 42
MPC General l Penalty l Penalty - l Penalty - Minimum Time l 1 Penalty l 1 Penalty - l 1 Penalty - Other Approaches Before solving the original MPC problem, τ min must be computed (QP + several LPs). Then the following LP has to be solved: subject to x 0 = x 0 x k+1 = Ax k + Bu k G u u k b u + ε k G x x k+1 b x + ε k ε k 0 G u u k b u G x x k+1 b x min ε s T ε, s 0 k = 0,...,N k = 0,...,τ min k = 0,...,τ min k = 0,...,τ min k = τ min + 1,...,N k = τ min + 1,...,N 28 / 42
MPC General l Penalty l Penalty - l Penalty - Minimum Time l 1 Penalty l 1 Penalty - l 1 Penalty - Other Approaches 29 / 42
l 1 Penalty MPC Introduce independent slack variables ε k for each constraint. Minimizes the total sum of constraint violations General l Penalty l Penalty - l Penalty - Minimum Time l 1 Penalty l 1 Penalty - l 1 Penalty - Other Approaches : High additional computational cost 30 / 42
l 1 Penalty - MPC General l Penalty l Penalty - l Penalty - Minimum Time l 1 Penalty l 1 Penalty - l 1 Penalty - Other Approaches Before solving the original MPC problem, the following LP must be solved: subject to min ε s T ε, s 0 x 0 = x 0 x k+1 = Ax k + Bu k G u u k b u + ε k G x x k+1 b x + ε k ε k 0 k {0,...,N} 31 / 42
l 1 Penalty - MPC General l Penalty l Penalty - l Penalty - Minimum Time l 1 Penalty l 1 Penalty - l1 Penalty - Other Approaches 32 / 42
Other Approaches MPC General l Penalty l Penalty - l Penalty - Minimum Time l 1 Penalty l 1 Penalty - l 1 Penalty - Other Approaches priority based approach: remove constraints in hierarchical order only relax constraints which are later in time (e.g. if infeasibility due to model/plant mismatch) 33 / 42
MPC General Active Set QP Solver Feasible Parameter Space and Critical Regions Homotopy Infeasible Parameter Relaxed QP Relaxed KKT-System Continuity of the Solution Summary 34 / 42
Active Set QP Solver MPC General Active Set QP Solver Feasible Parameter Space and Critical Regions Homotopy Infeasible Parameter Relaxed QP Relaxed KKT-System Continuity of the Solution Summary At the optimal solution, several constraints are active, others inactive. If the set of active constraints is known beforehand, the QP can be reformulated: 1 min x 2 xt Qx + gx T 0 x s.t. G A x = b A,x0 ignoring the inactive constraints. The optimal solution can be found by solving the KKT-system: ( ) ( ) ( ) Q G T A x gx0 = G A 0 λ b A,x0 35 / 42
Feasible Parameter Space and Critical Regions MPC General The parameter space can be divided into critical regions. Each critical region has a certain set G CR A of active constraints at the optimal solution. Active Set QP Solver Feasible Parameter Space and Critical Regions Homotopy Infeasible Parameter Relaxed QP Relaxed KKT-System Continuity of the Solution Summary 36 / 42
Homotopy MPC If we know the optimal solution at x 0, a homotopy to the new optimal solution at x new 0 can be performed. General Active Set QP Solver Feasible Parameter Space and Critical Regions Homotopy Infeasible Parameter Relaxed QP Relaxed KKT-System Continuity of the Solution Summary At each boundary one constraint is added or removed from the active set. 37 / 42
Infeasible Parameter What happens, if a parameter is not inside the feasible set? MPC General Active Set QP Solver Feasible Parameter Space and Critical Regions Homotopy Infeasible Parameter Relaxed QP Relaxed KKT-System Continuity of the Solution Summary 38 / 42
Relaxed QP MPC Only the newly active constraint c j is relaxed, the following optimization problem is solved: General Active Set QP Solver Feasible Parameter Space and Critical Regions Homotopy Infeasible Parameter Relaxed QP Relaxed KKT-System Continuity of the Solution Summary subject to Gx b 1 min x 2 xt Qx + g T x + 1 2 h εε 2 c T j x b j + ε row j dropped 39 / 42
Relaxed KKT-System MPC General Active Set QP Solver Feasible Parameter Space and Critical Regions Homotopy Infeasible Parameter Relaxed QP Relaxed KKT-System Continuity of the Solution Summary The KKT-system is modified accordingly: h ε 1 1 ε 0 Q G T A c j x λ = g b A µ b j G A c T j ε and µ can be eliminated from the system: ε = c T j x b j, µ = h ε ε = h ε (c T j x b j ) ( Q + hε c j c T j G T A G A 0 ) ( ) x λ = ( ) g + hε b j c j b A 40 / 42
Continuity of the Solution MPC General Active Set QP Solver Feasible Parameter Space and Critical Regions Homotopy Infeasible Parameter Relaxed QP Relaxed KKT-System Continuity of the Solution Summary The solutions of the old system and the modified system coincide at the boundary. The homotopy can be continued with a modified Hessian matrix. The Cholesky decomposition of Q can be updated by a rank-1 update, which is computationally cheap. ε will be supervised and removed when it becomes zero. Removal of an infeasible constraint works exactly as addition, but with inverse signs. 41 / 42
Summary MPC General Active Set QP Solver Feasible Parameter Space and Critical Regions Homotopy Infeasible Parameter Relaxed QP Relaxed KKT-System Continuity of the Solution Summary The strategy is exact (as long as the problem is feasible) Very low additional computational cost No additional computational cost when the problem is feasible Possible open-/closed-loop mismatch (open question) 42 / 42