4F3 Predictive Control - Lecture 3 p 1/21 4F3 - Predictive Control Lecture 3 - Predictive Control with Constraints Jan Maciejowski jmm@engcamacuk
4F3 Predictive Control - Lecture 3 p 2/21 Constraints on System Variables In practice, system variables are always constrained by: Physical limitations Input constraints eg actuator limits State constraints eg reservoir capacities Safety considerations (eg critical temperatures/pressures) Performance specifications (eg limit overshoot) constraints 1 y 1 4 output set point 1 y 2 3 1 y 3 3 15 y 4 3 15 y 5 3 time
4F3 Predictive Control - Lecture 3 p 3/21 Systems with Input Saturation A common system nonlinearity is input saturation x(k + 1) = Ax(k) + B sat(u(k)) y(k) = Cx(k) (nonlinear) Easily transformed into a constraint on a linear system: u {i} u {i} ū {i} u sat (u) where v {i} is the i th component (row) of a column vector v
4F3 Predictive Control - Lecture 3 p 4/21 Constrained LQR Problem Problem: Given an initial state x(0) at time k = 0, compute and implement an input sequence {u(0),u(1),,} that minimizes the infinite horizon cost function ( ) x(k) T Qx(k) + u(k) T Ru(k) i=0 while guaranteeing that constraints are satisfied for all time It is usually impossible to solve this problem Predictive control provides an approximate solution RHC laws with constraints will be nonlinear
4F3 Predictive Control - Lecture 3 p 5/21 Constrained Finite Horizon Optimal Control Problem: Given an initial state x = x(k), compute a finite horizon input sequence {u 0,u 1,,u N 1 } that minimizes the finite horizon cost function x T NPx N + N 1 ) (x Ti Qx i + u Ti Ru i i=0 where x 0 = x x i+1 = Ax i + Bu i, i = 0, 1,,N 1 while guaranteeing that all constraints are satisfied over the prediction horizon i 0, 1,,N
4F3 Predictive Control - Lecture 3 p 6/21 Receding Horizon Control input output set point constraint constraint time k k + 1 time 1 Obtain measurement of current output/state 2 Compute optimal finite horizon input sequence subject to constraints 3 Implement first part of optimal input sequence 4 Return to step 1
4F3 Predictive Control - Lecture 3 p 6/21 Receding Horizon Control input output set point constraint constraint time k k + 1 time 1 Obtain measurement of current output/state 2 Compute optimal finite horizon input sequence subject to constraints 3 Implement first part of optimal input sequence 4 Return to step 1
4F3 Predictive Control - Lecture 3 p 6/21 Receding Horizon Control input output set point constraint constraint time k k + 1 time 1 Obtain measurement of current output/state 2 Compute optimal finite horizon input sequence subject to constraints 3 Implement first part of optimal input sequence 4 Return to step 1
4F3 Predictive Control - Lecture 3 p 6/21 Receding Horizon Control input output set point constraint constraint time k k + 1 time 1 Obtain measurement of current output/state 2 Compute optimal finite horizon input sequence subject to constraints 3 Implement first part of optimal input sequence 4 Return to step 1
4F3 Predictive Control - Lecture 3 p 7/21 Prediction Matrices Recall that we previously solved for the sequence of predicted states X in terms of the stacked inputs U: x 1 x 2 x N := A A 2 A N x 0 + B 0 0 AB B 0 A N 1 B A N 2 B B u 0 u 1 u N 1 or, defining x := x 0, X := Φx + ΓU The matrices Φ and Γ are the prediction matrices
4F3 Predictive Control - Lecture 3 p 8/21 Incorporating Constraints Now incorporate a set of linear inequality constraints on the predicted states x i and inputs u i M i x i + E i u i b i, for all i = 0, 1,,N 1 M N x N b N Many constraints take this form: M s = 0 Input constraints only E s = 0 State constraints only Can include constraints on outputs or controlled variables For simplicity, assume that E i = E, M i = M and b i = b for i = 0, 1,,N 1
4F3 Predictive Control - Lecture 3 p 9/21 Writing Constraints in Standard Form Suppose we have the following input and output constraints: u low u i u high, i = 0, 1,,N 1 y low y i y high, i = 0, 1,,N Recalling that y i = Cx i, this is equivalent to: 0 0 C +C x i + I +I 0 u i 0 u low +u high y low +y high for i = 0, 1,,N 1 Similar expression for terminal constraint (in terms of x N only)
4F3 Predictive Control - Lecture 3 p 10/21 Writing Constraints in Standard Form From the previous example, we can write the constraints in the form: by defining: M i x i + E i u i b i, for all i = 0, 1,,N 1 M N x N b N 0 I 0 +I M i :=, E i :=, b i := C 0 +C 0 u low +u high y low +y high, for i = 0, 1,,N 1 and M N := C, b N := +C y low +y high
Writing Constraints in Terms of x, X and U Taking all of the constraints together: M 0 0 0 x 0 + 0 0 M 1 0 0 M N x 1 x N + E 0 0 0 E N 1 0 0 u 0 u N 1 b 0 b 1 u N By appropriately defining D, M, E and c (recalling x := x 0 ): Dx + MX + EU c Next, will eliminate X using prediction matrices 4F3 Predictive Control - Lecture 3 p 11/21
4F3 Predictive Control - Lecture 3 p 12/21 Writing Constraints in Terms of x and U Substitute X = Φx + ΓU into Dx + MX + EU c and collect terms The constraints can be written in the form: where and JU c + Wx J := MΓ + E W := D MΦ Our constraints are now in terms of the input sequence U and the initial state x = x 0 = x(k)
4F3 Predictive Control - Lecture 3 p 13/21 Writing Constraints in Terms of x and U In summary, the basic procedure is: Define linear inequalities in u i, x i, y i and z i Write the constraints in the form: M i x i + E i u i b i, for all i = 0, 1,,N 1 M N x N b N Stack the constraints to get them in the form: Dx + MX + EU c Substitute X = Φx + ΓU and rearrange to the form: JU c + Wx
4F3 Predictive Control - Lecture 3 p 14/21 Cost Function Recall that the cost function V (x,u) := x T NPx N + N 1 ) (x Ti Qx i + u Ti Ru i i=0 can be rewritten (with x := x 0 ) as V (x,u) = 1 2 UT GU + U T Fx + x T (Q + Φ T ΩΦ)x }{{} not dependent on U for some matrices F, G and Ω (defined in lecture 2) Remember that G 0 if P 0, Q 0 and R 0
4F3 Predictive Control - Lecture 3 p 15/21 Quadratic Programming Definition Quadratic Program (QP) Given matrices Q and A and vectors c and b, the optimization problem: subject to: is called a quadratic program (QP) 1 min θ 2 θt Qθ + c T θ Aθ b Proposition If Q 0 in the above quadratic program, then 1) The optimization problem is strictly convex 2) A global minimizer can always be found 3) The global minimizer is unique
4F3 Predictive Control - Lecture 3 p 16/21 Nature of Solutions to QPs θ 2 constrained minimum constraints Aθ b level set of cost function unconstrained minimum θ 1
4F3 Predictive Control - Lecture 3 p 17/21 Writing Problems as QPs Many problem types can be cast as QPs: Example: Nonlinear constraint subject to: 1 min θ 2 θt Qθ + c T θ max{e T θ,f T θ} b subject to: 1 min θ 2 θt Qθ + c T θ e T θ b, f T θ b Example: Nonlinear cost function subject to: min θ c T θ Aθ b subject to: min θ,δ δ Aθ b c T θ δ 0 c T θ δ 0
4F3 Predictive Control - Lecture 3 p 18/21 Constrained Optimal Control as a QP Our constrained optimal control problem is: min U subject to: 1 2 UT GU + U T Fx JU c + Wx This is a quadratic program in standard form Substitute θ U Q G c Fx A J b (c + Wx) The optimal solution is 1 A global minimum (when G 0) 2 Unique (when G 0)
4F3 Predictive Control - Lecture 3 p 19/21 Solution via Quadratic Programming Some QP parameters are functions of the current state x Without constraints, U (x) is a linear function of x With constraints, U (x) is nonlinear Must calculate U (x) by solving a QP online for each x See JMM 32 and 33 for an introduction to solving QPs In Matlab, our QP can be solved using U = quadprog(g,f*x,j,c+wx)
4F3 Predictive Control - Lecture 3 p 20/21 Implementing the RHC Law The RHC input is the first part of the optimal input sequence: ( ) κ rhc (x) := u 0(x) = I m 0 0 U (x) Since U (x) is no longer linear, κ rhc : R n R m is a nonlinear control law The dynamics of the closed loop system are nonlinear x(k + 1) = Ax(k) + Bκ rhc (x) κ rhc ( ) (QP Solver) u(k) DT System x(k)
4F3 Predictive Control - Lecture 3 p 21/21 Complexity of Solutions Example: Double integrator x(k + 1) = 1 1 x(k) + 0 u(k) 0 1 1 Constraints: 6 4 Solution: Controller with 57 regions Each region i has u 0(x) = v i + K i x u 1, y 12 Horizon length = 12 Quadratic cost with Q = 1 0, R = 1, P = 1 0 1 x {2} 2 0 2 4 6 x {1} 10 5 0 5 10