Docsity

Conjugate Gradient, Lecture Notes - Mathematics -, Study notes of Mathematical Methods

Toggle sidebar
bg1
C12.1B: CONTINUOUS OPTIMISATION
LECTURE 5: CONJUGATE GRADIENTS
RAPHAEL HAUSER
MATHEMATICAL INSTITUTE, UNIVERSITY OF OXFORD
1. The Need for Further Methods. In Lecture 4 we motivated quasi-Newton
methods by a reduced complexity per iteration as compared to the Newton-Raphson
method. The notion of complexity we used was based on counting ”basic computer
operations”, without taking into account that some operations are less costly than
others. It is possible to be more rigorous and introduce mathematical models of
computers, so-called Turing machines, that can operate on rational, real or complex
numbers directly, but developing the necessary theory would lead us too far astray.
For our purposes it usually suffices to think of a computer as being able to operate
on real numbers, and occasionally we will take roundoff errors into account.
Any notion of complexity obtained in the framework of such a computational
model reflects the running time of the implementation of an algorithm on an actual
computer only to a first approximation. Real existing computers work with floating
point numbers and have multiple levels of memory. When the data that needs to be
carried over between iterations exceeds the active memory of the central processor,
data has to be shifted back and forth between different levels of memory (for example
between CPU and hard drive) and the machine can end up spending most of its pro-
cessing time on data transfers rather than actual computations. In addition, different
kinds of operations take different amounts of time: divisions are usually more costly
than multiplications which are themselves more costly than additions. In practical
implementations, these issues have to be taken into account in order to produce fast
and reliable computer programs.
Quasi-Newton methods are amongst the most widely used algorithms in uncon-
strained optimisation, but any practical implementation makes it necessary to keep
an×nmatrix Hk(the inverse of the approximate Hessian Bk) or Lk(the Cholesky
factor of Bk) in the computer memory. In other words, there is an O(n2)memory
requirement for quasi-Newton methods. In comparison, the steepest descent method
only occupies O(n) memory at any given time: after xk+1 has been computed, the
registers that were previously used to store the ncomponents of ∇f(xk) can be over-
written with the data ∇f(xk+1), then xk+1 can be overwritten with xk+2 etc.
In situations where nis very large, the steepest descent method can therefore still
cope with keeping all the necessary data in the main memory when quasi-Newton
methods have long ceased to be effective and spend most of their time in data trans-
fers. In this lecture we will analyse the conjugate gradient method which has the same
memory requirements and complexity per iteration as the steepest descent method
but typically converges much faster.
2. The Conjugate Gradient Method. We first develop the method in the
context of minimising convex quadratic functions. Later, we will generalise the ap-
proach to arbitrary objective functions and call it Fletcher–Reeves method.
Let us consider the minimisation of a strictly convex quadratic objective function
(P) min
x∈Rnf(x) = xTBx +bTx+a,
where Bis a symmetric positive definite matrix. Using the first order necessary
1
pf3
pf4
pf5

Partial preview of the text

Download Conjugate Gradient, Lecture Notes - Mathematics - and more Study notes Mathematical Methods in PDF only on Docsity!

C12.1B: CONTINUOUS OPTIMISATION

LECTURE 5: CONJUGATE GRADIENTS

RAPHAEL HAUSER MATHEMATICAL INSTITUTE, UNIVERSITY OF OXFORD

  1. The Need for Further Methods. In Lecture 4 we motivated quasi-Newton methods by a reduced complexity per iteration as compared to the Newton-Raphson method. The notion of complexity we used was based on counting ”basic computer operations”, without taking into account that some operations are less costly than others. It is possible to be more rigorous and introduce mathematical models of computers, so-called Turing machines, that can operate on rational, real or complex numbers directly, but developing the necessary theory would lead us too far astray. For our purposes it usually suffices to think of a computer as being able to operate on real numbers, and occasionally we will take roundoff errors into account. Any notion of complexity obtained in the framework of such a computational model reflects the running time of the implementation of an algorithm on an actual computer only to a first approximation. Real existing computers work with floating point numbers and have multiple levels of memory. When the data that needs to be carried over between iterations exceeds the active memory of the central processor, data has to be shifted back and forth between different levels of memory (for example between CPU and hard drive) and the machine can end up spending most of its pro- cessing time on data transfers rather than actual computations. In addition, different kinds of operations take different amounts of time: divisions are usually more costly than multiplications which are themselves more costly than additions. In practical implementations, these issues have to be taken into account in order to produce fast and reliable computer programs. Quasi-Newton methods are amongst the most widely used algorithms in uncon- strained optimisation, but any practical implementation makes it necessary to keep a n × n matrix Hk (the inverse of the approximate Hessian Bk) or Lk (the Cholesky factor of Bk) in the computer memory. In other words, there is an O(n^2 ) memory requirement for quasi-Newton methods. In comparison, the steepest descent method only occupies O(n) memory at any given time: after xk+1 has been computed, the registers that were previously used to store the n components of ∇f (xk) can be over- written with the data ∇f (xk+1), then xk+1 can be overwritten with xk+2 etc. In situations where n is very large, the steepest descent method can therefore still cope with keeping all the necessary data in the main memory when quasi-Newton methods have long ceased to be effective and spend most of their time in data trans- fers. In this lecture we will analyse the conjugate gradient method which has the same memory requirements and complexity per iteration as the steepest descent method but typically converges much faster.
  2. The Conjugate Gradient Method. We first develop the method in the context of minimising convex quadratic functions. Later, we will generalise the ap- proach to arbitrary objective functions and call it Fletcher–Reeves method. Let us consider the minimisation of a strictly convex quadratic objective function

(P) min x∈Rn^

f (x) = xTBx + bTx + a,

where B is a symmetric positive definite matrix. Using the first order necessary

optimality conditions from Lecture 2, we find that (P) is equivalent to the problem of solving the linear system 2Bx = −b. Here are a few facts about real symmetric matrices that you should remem- ber from your course on linear algebra: let A ∈ Rn×n. If A is symmetric, then A can be written in decomposed form as A = QDQT, where QTQ = I (that is, Q is orthogonal), and D is the diagonal matrix D = Diag(λ(A)) which has the vector λ(A) = [ λ 1 (A)^ ... λn(A)^ ]T^ ∈ Rn^ of eigenvalues of A on its diagonal, and where the com- ponents of λ(A) are ordered in nonincreasing order: λ 1 (A) ≥ · · · ≥ λn(A). All eigen- values are real. The columns of Q form an orthogonal basis of eigenvectors of A. A is invertible if and only if D is, and then A−^1 = QD−^1 QT, where D−^1 = Diag(λ(A)−^1 ) is simply obtained as the component-wise inverse of D. A is positive semidefinite (respectively positive definite) if and only if λi(A) ≥ 0 (respectively λi(A) > 0) for all i. In these cases the matrix D (^12) := Diag(

λ(A)), obtained as the component-wise square root of D, is well-defined, and we can set A (^12) := QD (^12) QT. A (^12) is the unique symmetric positive semidefinite matrix for which the identity A (^12) A (^12) = A holds. Let us now return to our optimisation problem (P) and observe that an additive constant in the objective function does not change its minimiser. Therefore, we can reformulate the problem as

(P’) min f (x) = (x − x∗)TB(x − x∗) = yTy = g(y),

where x∗^ = −(1/2)B−^1 b and y = B (^12) (x − x∗). Thus, the objective function of our minimisation problem looks particularly simple in the transformed variables y. Of course, transforming the problem into y-coordinates is the same as solving the original problem: we would first have to find x∗, which is precisely the minimiser of (P)! So, there seems to be no gain from considering (P’). Nevertheless, we can use y-coordinates conceptually to understand how the con- jugate gradient algorithm works in the original coordinates x: we would like to construct an iterative sequence (xk)k∈N such that the corresponding sequence of yk = B (^12) (xk − x∗) behaves sensibly. Let us assume that the current iterate is xk and that the search direction dk has been computed. The exact line search αk = arg minα f (xk +αdk) is the same as αk = arg minα g(yk +αpk), where pk = B

1 (^2) dk is the search direction in y-coordinates. Therefore,

αk = arg min α ‖yk‖^2 + 2αpT k yk + α^2 ‖pk‖^2.

Since this is a univariate quadratic minimisation problem, it is trivial to establish that

αk = −

pT k yk ‖pk‖^2

If we set yk+1 = yk + αkpk, then we find

yT k+1pk =

y −

pT k yk ‖pk‖^2

pk

)T

pk = yT k pk − y kT pk = 0. (2.1)

2.1. A key observation. A key observation is that the relation (2.1) is inde- pendent of the location of xk: as long as we use the same search direction d = ±dk but an arbitrary starting point x ∈ Rn^ for the line search

α∗^ = arg min α∈R

f (x + αd),

Theorem 2.1. Let f (x) = xTBx + bTx + a be defined on Rn^ with B ≻ 0 , let x 0 ∈ Rn^ be a starting point and dk ∈ Rn^ \ { 0 } (k = 0,... , n − 1) mutually B-conjugate search directions. Furthermore, for (k = 0,... , n − 1) let xk+1 = xk + αkdk, where αk = arg minα∈R f (xk + αdk). Then xn is the global minimiser of f.

Note that since B is nonsingular, there cannot exist more than n mutually B- conjugate search directions dk. This yields an alternative argument for the proof of termination after n steps.

2.2. How to choose B-conjugate search directions. So far we have a finite termination result for a family of algorithms that iterate over exact line searches along mutually conjugate search directions. We did not otherwise specify how to compute these directions. In general, we could do this by choosing any descent direction vk and then applying a procedure that corresponds to a Gram–Schmidt orthogonalisation in the transformed space:

Lemma 2.2. Let v 0 ,... , vn− 1 ∈ Rn^ be linearly independent vectors, and let d 0 ,... , dn− 1 be recursively defined as follows,

dk = vk −

k∑− 1

j=

dT j Bvk dT j Bdj

dj. (2.3)

Then dT i Bdk = 0 for all i 6 = k.

Proof. We proceed by induction over k and show that all distinct di with i ≤ k are mutually B-conjugate. For k = 0 there is nothing to prove. We may therefore assume that dT i Bdj = 0 for all i, j ∈ { 0 ,... , k − 1 }, i 6 = j. Let i < k. Then

dT i Bdk = dT i Bvk −

k∑− 1

j=

dT j Bvk dT j Bdj

dT i Bdj = dT i Bvk − dT i Bvk = 0.

Note that the linear independence of the vj guarantees that none of the dj is zero, and hence that dT j Bdj > 0 for all j.

Unfortunately, this procedure would require that we hold the vectors dj (j < k) in the computer memory. Thus, as k approaches n the method would require O(n^2 ) memory, defying one of the main purposes of the new algorithm. Luckily, a second key observation shows that we can get away with O(n) storage if we choose the steepest descent direction as vk:

Lemma 2.3. Let the procedure of Theorem 2.1 be applied to the B-conjugate search directions dk (k = 0,... , n − 1), where d 0 = −∇f (x 0 ) and dk is computed via (2.3) with vk = −∇f (xk) (k = 1,... , n − 1). Then ∇f (xj )T∇f (xk) = 0 for (j = 0,... , k − 1), and (k = 1,... , n − 1).

Proof. First, note that ∇f (xk) = 2Bxk + b for all k. We claim that this implies that dT j ∇f (xk) = 0 for (j = 0,... , k − 1). In order to prove this claim, we proceed by induction over k. The statement holds trivially true for k = 0. We can therefore

assume that it holds for k, and it suffices to prove that it holds for k + 1 too. By the induction hypothesis we have

dT j ∇f (xk+1) = dT j (2B(xk + αkdk) + b) = dT j ∇f (xk) + 2αkdT j Bdk = 0, (j = 0,... , k − 1).

On the other hand, dT k ∇f (xk+1) = 0 is the first order optimality condition for the line search minα f (xk + αdk) that defines xk+1. Hence, our claim is true. Next, note that (2.3) implies that

span(d 0 ,... , dk) = span(∇f (x 0 ),... , ∇f (xk)) (k = 0,... , n − 1).

For j < k there exist therefore λ 1 ,... , λj such that ∇f (xj ) =

∑j i=0 λidi, and we have

∇f (xj )T∇f (xk) =

∑^ j

i=

λdT i ∇f (xk) = 0.

We are now ready to put all the pieces of the conjugate gradient algorithm to- gether: substituting ∇f (xj+1) − ∇f (xj ) = 2αj Bdj into (2.3) with vk = −∇f (xk), we obtain

dk = −∇f (xk) +

k∑− 1

j=

∇f (xj+1)T∇f (xk) − ∇f (xj )T∇f (xk) ∇f (xj+1)Tdj − ∇f (xj )Tdj

dj.

Lemma 2.3 implies that all but the last summand in the the right hand side expression are zero. Moreover, multiplying Equation (2.3) by ∇f (xk)T^ and then replacing k by k − 1, we deduce from Lemma 2.3 that dT k− 1 ∇f (xk− 1 ) = −‖∇f (xk− 1 )‖^2. Together with dT k− 1 ∇f (xk) = 0 this implies that

dk = −∇f (xk) + ‖∇f (xk)‖^2 ‖∇f (xk− 1 )‖^2

dk− 1. (2.4)

This is the conjugate gradient rule for updating the search direction. Note that for the computation of dk we only need to keep two vectors and one number stored in the main memory: dk− 1 , xk and ‖∇f (xk− 1 )‖^2 , which can be over- written when the corresponding new data are computed. Let us now summarise the conjugate gradient algorithm: