1 Quadratic Programming 5
1 Quadratic Programming 5
1 Quadratic Programming 5
1 Quadratic Programming 5
1.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
1.2 Equality-constrained quadratic programming . . . . . . . . . . 7
1.3 Active set method for quadratic programming problems . . . 10
1.3.1 Problem formulation . . . . . . . . . . . . . . . . . . . . 10
1.3.2 The active set method . . . . . . . . . . . . . . . . . . . 13
3
Contents
4
Chapter 1
Quadratic Programming
1.1 Introduction
1
min f (x) = xT Qx + cT x (1.1)
x 2
subject to
Ax = b (1.2)
Dx ≤ g (1.3)
where:
x is a n × 1 vector: x = [x1 x2 . . . xn ]T
Q is a symmetric n × n matrix
c is an n × 1 vector
A is a m × n matrix
b is an m × 1 vector
D is a p × n matrix
g is an p × 1 vector
5
Chapter 1. Quadratic Programming
Example 1.1 (Nocedal and Wright, 1999) Consider the following QP problem:
min f (x) = 3x21 + 2x1 x2 + x1 x3 + 2.5x22 + 2x2 x3 + 2x23 − 8x1 − 3x2 − 3x3 (1.4)
x
subject to
x1 + x3 = 3 (1.5)
x2 + x3 = 0 (1.6)
6
1.2. Equality-constrained quadratic programming
We consider first the case when the problem has only equality constraints.
The QP-problem is stated as:
1
min xT Qx + cT x (1.11)
x 2
subject to
Ax = b (1.12)
1
L(x, λ) = xT Qx + cT x + λT (Ax − b) (1.13)
2
∂L
= Qx + c + AT λ = 0 (1.14)
∂x
and
∂L
= Ax − b = 0 (1.15)
∂λ
7
Chapter 1. Quadratic Programming
Qx + AT λ = −c
Ax − 0 · λ = b (1.16)
subject to
x1 + x2 = 5 (1.20)
The objective function and the constraint can be written in the general matrix
form as: " #
1 T 2 0
f (x1 , x2 ) = f (x) = x x + [0 0]T x (1.21)
2 0 2
" #
x1
[1 1] =5 (1.22)
x2
The necessary condition for optimum is obtained from the linear system (1.17)
given by:
2 0 1 x1 0
0 2 1 · x2 = 0 (1.23)
1 1 0 λ 5
8
1.2. Equality-constrained quadratic programming
The sufficient condition for minimum is given by the sign of the determinant (??)
which, in this example, is:
¯ ¯
¯ 2 0 1 ¯
¯ ¯
1¯ ¯
(−1) ¯ 0 2 1 ¯=4>0 (1.25)
¯ ¯
¯ 1 1 0 ¯
The point is a unique minimizer of the objective function subject to the given con-
straint, because the determinant is positive.
Figure 1.1 shows the contour plot of the objective function and the constraint.
The solution is the tangent point of one level curve and the constraint line.
4
x2
2
x +x =5
1 2
0
0 1 2 3 4 5 6
x1
9
Chapter 1. Quadratic Programming
1
min xT Qx + cT x (1.26)
x 2
subject to
aiT x = bi , i = 1, m (1.27)
ajT x ≤ bj , j = m + 1, m + p (1.28)
where:
x is the n × 1 vector of unknowns
Q is a symmetric n × n positive semidefinite matrix
c is an n × 1 vector
bi are scalars, i = 1, m + p
ai are n × 1 vectors, i = 1, m + p
The vectors aTi are the rows of the matrices A and D from (1.2) and (1.3).
We define the active set, A(x∗ ), at an optimal point x∗ as the indices of the
constraints at which equality holds, that is (Nocedal and Wright, 1999):
m
X m+p
X
1 T T T
L(x, λ) = x Qx + c x + λi (ai x − bi ) + λj (aTj x − bj ) (1.30)
2
i=1 j=m+1
10
1.3. Active set method for quadratic programming problems
∂L
= 0 (1.31)
∂x
aTi x = bi , i = 1, m (1.32)
aTj x ≤ bj , j = m + 1, m + p (1.33)
λj (aTj x − bj ) = 0, j = m + 1, m + p (1.34)
λj ≥ 0, j = m + 1, m + p (1.35)
λi , i = 1, m unrestricted in sign (1.36)
subject to
x1 + x2 = 3
x1 ≥ 1
x2 ≤ 3 (1.38)
−x1 + 3x2 ≥ −1
x1 + x2 ≤ 5
We shall illustrate the feasible region and write the problem in the general form
(1.26), (1.27), (1.28).
The inequality constraints form the convex gray region illustrated in Figure 1.2.
The minimizer of the objective function subject to the constraints must be located
in the interior of the feasible region, on the straight line x1 + x2 = 3 (the equality
constraint).
If we denote x = [x1 x2 ]T , the quadratic objective function is written in the
matrix form as:
" #
1 T 2 0
f (x) = x x + [−1 − 2]x
2 0 4
1 T
= x Qx + cT x (1.39)
2
11
Chapter 1. Quadratic Programming
Figure 1.2: The feasible region and the contour plot of the objective function
thus: " #
1
a1 = and b1 = 3 (1.41)
1
Some of the inequality constraints will be multiplied by (−1) so all the left hand sides
are less or equal than the right hand side:
−x1 ≤ −1
x2 ≤ 3 (1.42)
x1 − 3x2 ≤ 1
x1 + x2 ≤ 5
12
1.3. Active set method for quadratic programming problems
b2 = −1, b3 = 3, b4 = 1, b5 = 5 (1.44)
We shall not give a solution for this problem, but it is clear from the Figure 1.2
that the optimum is located in the interior of the feasible region, at some point where
the equality-constraint line is tangent to a level curve of the objective function. Since
at this point, all the inequality constraints are inactive (none of them is satisfied as
an equality), the optimal active set is A(x∗ ) = {1}, which is the index of the only
constraint fulfilled as equality.
The active set method is one of the most popular approaches for solving small
and medium scale QP problems. The idea behind the method may be sum-
marized as follows (Nocedal and Wright, 1999; Bhatti, 2000):
• Start with a guess of the optimal active set A and calculate a feasible
initial iterate x0 .
xk+1 = xk + αk dk (1.45)
• New iterates are calculated and the working set is modified until the
optimality conditions are satisfied, or all Lagrange multipliers are pos-
itive as required by the KKT conditions.
Let xk be the current iterate. At this point, some of the inequality con-
straints may be active (or satisfied as equalities). Together with the equality
13
Chapter 1. Quadratic Programming
For the current point, we check whether xk minimizes the quadratic ob-
jective function in the subspace defined by the working set, i.e. the Lagrange
multipliers corresponding to the inequality constraints are positive. This is a
direct consequence of the KKT conditions.
If the optimality conditions are not satisfied, we compute a direction, dk ,
to move to the next point xk+1 = xk + dk such that the new iterate is feasible
in Wk and the objective function is minimized at xk + dk . Since xk is known
at the current stage, it will be regarded as a constant vector and the unknown
vector is only dk . The problem is stated as:
1
min f (dk ) = (xk + dk )T Q(xk + dk ) + cT (xk + dk ) (1.47)
dk 2
subject to:
aTi (xk + dk ) = bi , i ∈ Wk (1.48)
1 1
f (dk ) = xTk Qxk + dTk Qdk + xTk Qdk + cT xk + cT dk (1.49)
2 2
The term 12 xTk Qxk +cT xk is constant for a given xk , thus it can be removed
from the objective function without changing the solution.
We denote:
gk = Qxk + c (1.50)
1 1
f (dk ) = dTk Qdk + (xTk Q + cT )dk = dTk Qdk + gkT dk (1.51)
2 2
14
1.3. Active set method for quadratic programming problems
is satisfied. From (1.52) and (1.48) we obtain the equality constraint of the
new QP subproblem. It will be formulated as:
1
min dTk Qdk + gkT dk (1.53)
dk 2
subject to:
aTi dk = 0, i ∈ Wk (1.54)
1
L(dk , λ) = dTk Qdk + gkT dk + λT Adk (1.56)
2
∂L
= Qdk + gk + AT λ = 0 (1.57)
∂dk
Adk = 0 (1.58)
The direction dk and the multipliers are the solution of the linear system
(1.59).
• If dk is nonzero we shall move in this direction. Note that for all indices
i in the working set Wk , the term aTi xk does not change as we move
along dk because:
15
Chapter 1. Quadratic Programming
or:
bi − aTi xk
αk ≤ (1.63)
aTi dk
• If dk is zero we have to check for optimality, i.e. all the Lagrange mul-
tipliers for the inequality constraints must be positive. If this is not the
16
1.3. Active set method for quadratic programming problems
The iterations are continued until we reach a point that minimizes the
objective over the current working set. In this case the directions dk will be
zero and the Lagrange multipliers are positive.
An algorithm for the active set method is described in Algorithm 1.
Example 1.4 Solve the following QP problem using the active set method:
subject to
(1) : x1 + x2 ≤ 2
(2) : x1 − 2x2 ≤ 2
(3) : −x1 − x2 ≤ 1 (1.70)
(4) : −2x1 + x2 ≤ 2
subject to h i
(1) : 1 1 x ≤2
h i
(2) : 1 −2 x ≤2
h i (1.72)
(3) : −1 −1 x ≤ 1
h i
(4) : −2 1 x ≤ 2
17
Chapter 1. Quadratic Programming
Set k = 0
while not all λi ≥ 0, i ∈ Wk ∩ {1, 2, ..., m} or dk 6= 0 do
if dk = 0 then
Check optimality:
if λi ≥ 0, i ∈ Wk ∩ {1, 2, ..., m} then
Stop and return the current point xk
else
Find the most negative λj
Remove constraint j from the working set Wk
Keep the same point for the next step: xk+1 = xk
end if
else
Compute the step length αk from:
µ ¶
bi − aTi xk
αk = min 1, (1.66)
/ k , aT
i∈W i dk >0
aTi dk
gk = Qxk + c (1.67)
1.5 (1)
(4)
1 STOP
x2
0.5
0
(3)
(2)
−0.5
START
−1
−1 −0.5 0 0.5 1 1.5 2
x1
For the initial point selected as the vertex (0, -1), (or as the intersection of the
lines x1 = 2x2 = 2 and −x1 − x2 = 1), the constraints (2) and (3) are active.
The initial working set is then W0 = {2, 3}. We may choose W0 = {2}, or
{3}, or an empty set, and the algorithm will return the same result, but the
iterates will follow another trajectory.
19
Chapter 1. Quadratic Programming
The gradient g0 is obtained from Q, c and x0 and the solution of the linear
system (1.65) is: " # " #
0 −0.6667
d0 = , λ= (1.78)
0 −4.6667
Step 1. The vector d0 is zero, thus we check optimality: all λ-multipliers are
negative. We remove the constraint (3) from the working set since it has
the most negative multiplier and obtain W1 = {2}. The matrix A is
now: A = [1 − 2] and the linear system (1.68) has the solution:
" #
2.8
d1 = , λ = −1.6 (1.79)
1.4
Step 2. The vector d1 is nonzero. The step length formula (1.66) yields: α =
0.7143. The only positive product aTi d1 where i ∈/ Wk is obtained for
i = 1. The first constraint will be added to the working set and W2 =
{2, 1}.
The new iterate is: " #
2
x2 = x1 + αd1 = (1.80)
0
and the solution of (1.68) result as:
" # " #
0 −1.3333
d2 = , λ= (1.81)
0 1.3333
Step 3. The vector d2 is zero, thus we check optimality: the first multiplier
is negative and the constraint (2) will be removed from the working set
which becomes: W3 = {1}. The iterate x3 is the same as in the previous
step, the matrix A = [1 1] and the linear system (1.68) has the solution:
" #
−1
d3 = , λ=2 (1.82)
1
20
1.3. Active set method for quadratic programming problems
Step 4. The vector d1 is nonzero although the multiplier is positive. The step
length formula (1.66) yields: α = 1. The working set in the same as
before W4 = {1} and the new iterate is:
" #
1
x4 = x3 + d3 = (1.83)
1
The steps taken in this procedure are shown in Figure 1.3. The same result
is obtained if the initial point is changed to another feasible location, or if we
choose another initial working set, as shown in the following cases:
• We select as the starting point x0 = [−0.2 − 0.8]T and the initial working
set W0 = {3}. The objective function, the constraints and the iterates are
illustrated in Figure 1.4.
• If the initial point is x0 = [0 − 1]T and the initial working set W0 = {3},
the result is the same as in previous cases, as shown in Figure 1.5.
• Another test was performed for an initial point x0 = [0 − 1]T and an empty
working set W0 = {∅}. The trajectory of the iterates is different from previous
cases, but the final point is the same as shown in Figure 1.6.
21
Chapter 1. Quadratic Programming
1.5
(1)
(4)
1 STOP
x2
0.5
0
(3)
−0.5
(2)
START
−1
−1 −0.5 0 0.5 1 1.5 2
x1
Figure 1.4: Active set method with x0 = [−0.2 − 0.8]T and W0 = {3}
1.5 (1)
(4)
1 STOP
x2
0.5
0
(3)
(2)
−0.5
START
−1
−1 −0.5 0 0.5 1 1.5 2
x1
22
1.3. Active set method for quadratic programming problems
1.5 (1)
(4)
1 STOP
x2
0.5
0
(3)
(2)
−0.5
START
−1
−1 −0.5 0 0.5 1 1.5 2
x1
23
Chapter 1. Quadratic Programming
24
Bibliography
25