You are on page 1of 31

The Geometry of Quadratic Programming

Mara M. Seron September 2004

Centre for Complex Dynamic Systems and Control

Outline

Introduction

The Geometry of Quadratic Programming QP Solution for N = 2 QP Solution for Arbitrary N

Solution Using the KKT Optimality Conditions

Centre for Complex Dynamic Systems and Control

Introduction

In the previous lecture we saw how dynamic programming can be used to derive a simple parameterisation of a nite horizon optimal control problem and its RHC implementation. Here we will analyse the geometric structure of the nite horizon optimal control problem when seen as a quadratic programme [QP]. Using this geometric structure, we will re-derive in the next lecture the result obtained via dynamic programming. We start with a simple case of horizon N = 2 and input constraints and then show how the same ideas extend to more general cases.

Centre for Complex Dynamic Systems and Control

The Finite Horizon Optimal Control Problem


Let the system be given by

xk +1 = Axk + Buk ,

|uk | ,

(1)

where xk Rn and > 0 is the input constraint level. Consider the following xed horizon optimal control problem

P2 (x ) :

V 2 (x )

min V2 ({xk }, {uk }),

(2)

subject to:

xk +1 = Axk + Buk x0 = x , uk U

for k = 0, 1,

[, ] for k = 0, 1,
1 xk Qxk + uk Ruk .

where the objective function in (2) is

V2 ({xk }, {uk })

1 1 x Px2 + 2 2 2

(3)

k =0
Centre for Complex Dynamic Systems and Control

The Finite Horizon Optimal Control Problem

To compare with the results previously obtained using Dynamic Programming, in the objective function

V2 ({xk }, {uk })

1 1 x2 Px2 + 2 2

1 xk Qxk + uk Ruk ,

k =0

we select Q > 0, R > 0 and P satisfying the algebraic Riccati equation P = A PA + Q K RK , where

(4) (5)

R 1 B PA ,

R + B PB .

Centre for Complex Dynamic Systems and Control

The Associated Quadratic Program


For the above problem, the corresponding QP optimal solution is QP: where u=
2 u0 1 + (KB ) ,H=R u1 KB

1 u (x ) = arg min u H u + u Fx , uR 2

(6)

KB K + KBKA , ,F =R 1 KA

(7)

and R is the square

u .

Note that the Hessian H is positive denite since R > 0 and hence R = R + B PB > 0.
Centre for Complex Dynamic Systems and Control

The Geometry of Quadratic Programming


The QP in (6) has a nice geometric interpretation in the u-space. Consider the equation 1 u H u + u Fx = c , 2

c constant .

(8)

u1
u (x )

ments

This denes ellipsoids in R2 centred at u (x ) = H 1 Fx . Then the QP in (6) amounts to nding the smallest ellipsoid that intersects the boundary of R , and u (x ) is the point of intersection.

u (x )

u0

Centre for Complex Dynamic Systems and Control

Coordinate Transformation
The problem can be simplied if we make a coordinate transformation via the square root of the Hessian, that is,

u = H 1/2 u.

(9)

In the new u-coordinates (9), the constraint set R is mapped into another set (denoted also by R ). The ellipsoids (8) are now circles centred at u (x ) = H 1/2 Fx .
Thus the QP (6) is transformed into the problem of nding the point in R that is closest to u (x ) in the Euclidean distance. This is qualitatively illustrated in the following gure.
Centre for Complex Dynamic Systems and Control

Geometry cements
R1 R2 R3 R4 R5 R6 R7 R8

of QP as Minimum Euclidean Distance

u1 u (x )

In the new coordinates, the level sets are circles in R2 centred at u (x ) = H 1/2 Fx . Then the QP in (6) amounts to nding the point in R that is closest to u (x ) in the Euclidean distance.

u (x ) u0

This transformed geometric picture allows us to immediately write down the solution to the QP for this special case.
Centre for Complex Dynamic Systems and Control

Solution Using Geometry


u1
R8
The solution of the QP is obtained by partitioning R2 into nine regions. The rst region is the polytope R .

ents

u (x ) u (x )
R6 R R5 R4 R3

R7

R1 R2

u0

Regions R1 to R8 are delimited by lines that are normal to the faces of R and pass through its vertices.

Centre for Complex Dynamic Systems and Control

Solution Using Geometry

The optimal constrained solution u (x ) is determined by the region in which the optimal unconstrained solution u (x ) lies, in the following way: ents u1
R2 R4 R6 R8 R7
u (x )

R1

First, the solution in R is u (x ) = u (x ); Next, the solution in regions R1 , R3 , R5 and R7 is simply equal to the vertex that is contained in the region. Finally, the solution in regions R2 , R4 , R6 and R8 is dened by the orthogonal projection of u (x ) onto the faces of R .
Centre for Complex Dynamic Systems and Control

u (x )

R5

R3

u0

Geometric QP Characterisation

As a result of above procedure, we obtain a characterisation of the QP solution in an active region Ri as

u (x ) = H 1/2 u (x ) if

u (x ) Ri ,

where u (x ) is an afne function of x and u (x ) = H 1/2 Fx .


We next proceed to nd an algebraic description of a particular region and an expression for u (x ) in it.

Centre for Complex Dynamic Systems and Control

Region Calculation
u1
R8 n1
Consider the active region R8 associated with face f4 . It is delimited by face f4 and its normals n1 and n4 passing through the vertices v1 and v4 .

n4

u (x )

f4
u

v1

v4

(x )

The line that contains face f4 corresponds to the second control u1 equal to the saturation level , that is u1 = [0 1]u = in the original u-coordinates.

u0

In the new u-coordinates (9), it is then dened by the equation


f4 :

[0 1]H 1/2 u = .
Centre for Complex Dynamic Systems and Control

Region Calculation
n4

u1
R8

n1
Hence, face f4 is:

f4 :

[0 1]H 1/2 u = .

u (x )
f4

v4

u (x ) u0

Combining the above three equations, region R8 is

R8 :

The normal lines n1 and n2 are:

v1 n1 : n4 :

[1 0]H 1/2 u = H1 [1 1] . [1 0]H 1/2 u = H1 [1 1] .

[0 1]H 1/2 u H [1 1] [1 0]H 1/2 u H [1 1] 1 1

Centre for Complex Dynamic Systems and Control

Solution Calculation

n4

u1
R8

n1

The optimal constrained solution in R8 is given by the normal projection of the unconstrained solution u (x ) onto face f4 .

u (x )

f4

v4

u (x )

v1

That is, u (x ) satises the equation of face f4 and that of the normal to it passing through u (x ): [0 1]H 1/2 u (x ) = , [1 0]H 1/2 u (x ) = [1 0]H 1/2 u (x ).

u0

Centre for Complex Dynamic Systems and Control

Solution Calculation
Hence, u (x ) satises: [0 1]H 1/2 u (x ) = , [1 0]H 1/2 u (x ) = [1 0]H 1/2 u (x ).

Using u = H 1/2 u = H 1/2 [u0 (x ) u1 (x )] and u (x ) = H 1/2 Fx in the above equations, and solving for the rst component u0 (x ) yields u0 (x ) = Gx h .

(10)

where

G=

K + KBKA 1 + (KB )2

h=

KB . 1 + (KB )2

Note that the above matrices coincide with the previously derived using Dynamic Programming.
Centre for Complex Dynamic Systems and Control

Recapitulation

The solution in active region R8 is u (x ) = if

Gx h

R8 :

where u (x ) = H 1 Fx .

[0 1]u (x ) H [1 1] [1 0]H u (x ) H [1 1] . 1 1

A similar characterisation can be derived in the remaining regions.

Centre for Complex Dynamic Systems and Control

Geometric QP Characterisation. More General Cases

We will now consider arbitrary horizon N , m 1 inputs, and more general constraints, leading to a QP of the form u (x ) = arg min
ux

1 u H u + u Fx , 2

(11)

where u RNm , and where the constraint set

u x ,
is a polyhedron in RNm .

RqNm

(12)

Centre for Complex Dynamic Systems and Control

Geometric QP Characterisation. More General Cases


Again, it is convenient to work in the u-coordinates u = H 1/2 u to turn the QP into a minimum Euclidean distance problem.
Hence the constraint set, R , is the polyhedron given by:

u x ,

H 1/2 .

R
PSfrag replacements

Figure: Example of constraint set u x in R3

Centre for Complex Dynamic Systems and Control

Active Regions
The procedure is the same as for N = 2, that is, we associate an active region to each face of the constraint set (before we associated region R8 to face f4 ). The active region is determined by the constraints that are active on the face. For example:

Edge e1 (two active constraints) Face f1 (one active constraint) and ements associated active region R1 . and PSfrag replacements associated active region R2 .

R1 R2 R f2 f3 f1 R e1 v1 v2 R1

Centre for Complex Dynamic Systems and Control

f3 e1 v f2 1 f 1

v2

R2

Region Calculation
Recall the constraint set

u x ,

RqNm .

A face is determined by a subset of the above q inequality constraints that are active, that is, they hold as equality constraints:

u = x,

(13)

{1, 2, . . . , q} is the set of indices of active constraints and the notation M indicates selection of rows of M with indices in .
The active region associated with face (13) is

where s is the set of indices of inactive constraints.

[ ]1 u [ ]1 [ x ] [I [ ]1 ]u x [ ]1 [ x ], s s s s

(14)

Centre for Complex Dynamic Systems and Control

Solution Calculation
The optimal constrained solution u (x ) in the above active region is given by the point of the corresponding face that is closest to the unconstrained solution u (x ) = H 1/2 Fx .
This point is given by

u (x ) = [ ]1 ( x ) [I [ ]1 ]H 1/2 Fx .

In the original coordinates u = H 1/2 u we have u (x ) = H 1/2 [ ]1 ( x ) H 1/2 [I [ ]1 ]H 1/2 Fx ,


G x +h .

Centre for Complex Dynamic Systems and Control

Recapitulation
The solution in an active region is

u (x ) = [ ]1 ( x ) [I [ ]1 ]H 1/2 Fx (15)
H 1/2 (G x + h ).
if

(16) where u (x ) = H 1/2 Fx and and s are the indices of active and inactive constraints, respectively.
Centre for Complex Dynamic Systems and Control

[ ]1 u (x ) [ ]1 [ x ] s [I [ ]1 ] u (x ) [s + s [ ]1 ]x +s + s [ ]1 ,

Solution Using the KKT Optimality Conditions

The geometric structure of QP has allowed us to derive its solution in an active region. The same solution can be derived using the KKT optimality conditions, as we show next.

Centre for Complex Dynamic Systems and Control

The KKT Optimality Conditions


Consider the following nonlinear programming problem: minimise f (z ), subject to:

g (z ) 0,
where f : Rr R, g = [g1 , . . . , gq ] : Rr Rq are differentiable.

Let z be a feasible solution, and let Suppose that gi (z ) for i g [ g1 , . . . , gq ].

= {i : gi (z ) = 0}.

are linearly independent and let

If z is a local optimal solution, then there exist Lagrange multipliers = [1 , . . . , q ] such that the following KKT conditions hold: f (z ) + g (z ) = 0, g (z ) = 0, 0.
Centre for Complex Dynamic Systems and Control

(KKT)

KKT Conditions for QP


For the QP problem 1 z Hz + z c , 2 subject to: minimise

Lz W ,
the KKT conditions (KKT) are:

W, 0, 0, 0. Complementary Slackness (CS): (17) If H is positive denite, the KKT conditions are necessary and sufcient for z to be the unique global minimum.
Primal Feasibility (PF): Dual Feasibility (DF):

Lz Hz + c + L (L z W )

= =

Centre for Complex Dynamic Systems and Control

QP Characterisation Using KKT Conditions


Recall the QP (11) used in MPC: In the original coordinates 1 u H u + u Fx , 2 subject to: minimise

In the u-coordinates u = H 1/2 u


minimise 1 u u + u H 1/2 Fx , 2 subject to:

u x .

u x .

When solved for different values of x , the above problem is referred to as a multiparametric quadratic program [mp-QP]. An mp-QP is a QP in which the linear term in the objective function and the right hand side of the constraints depend linearly on a vector of parameters (the state vector x in this case).
Centre for Complex Dynamic Systems and Control

QP Characterisation Using KKT Conditions


Let u (x ) be the optimal solution of the above problem. The KKT conditions (17) then are u (x ) + x , u (x ) + H 1/2 Fx + = 0, 0, [ u (x ) + x ] = 0 .

(PF) (DF1) (DF2) (CS)

Consider now an active set of indices for u (x ), and let s be the corresponding inactive set. We then have that u (x ) satises the equality constraints (13), that is, u (x ) = x .
From (18), (CS) and (DF2), we have that (18)

s = 0,

0.
Centre for Complex Dynamic Systems and Control

QP Characterisation Using KKT Conditions


Using s = 0, 0 in the (rst) dual feasibility condition (DF1) and solving for u (x ) yields

u (x ) = H 1/2 Fx .

(19)

Using (19) in the active constraint equality (18) and solving for gives = [ ]1 [ H 1/2 Fx + x ]. (20) Substituting the above equation into (19) we obtain

u (x ) = [ ]1 ( x ) [I [ ]1 ]H 1/2 Fx , (21)
which is identical to (15).

Centre for Complex Dynamic Systems and Control

QP Characterisation Using KKT Conditions


The inequalities (16) that dene the region in the state space where the solution (21) is valid can be recovered as follows: Combining the expression for the Lagrange multipliers (20)

= [ ]1 [ H 1/2 Fx + x ].
and the sign condition 0 yields the rst inequality in (16) . Finally, the second inequality in (16) follows from primal feasibility (see (PF)) of the inactive constraints, that is,

s u (x ) + s x s ,
upon substitution of the expression (21) for the optimal solution.

Centre for Complex Dynamic Systems and Control

Connection Between Geometry and KKT


In summary, we can see that the geometric characterisation given before is a particular arrangement of the KKT optimality conditions.

ements

n4

u1
R8

n1

In particular: The halfspace above a face (for example, f4 ) is given by the nonnegativity of the Lagrange multipliers corresponding to active constraints on the face.

f4


u0

The band between normals to the face (for example, between n1 and n4 ) is given by feasibility of the inactive constraints on the face.
Centre for Complex Dynamic Systems and Control

You might also like