pccg()

function [out, Elist]=pccg(W,Nit,cgform)

Input:

Output:

Implement the preconditioned conjugate-gradients algorithm discussed in lecture,

  1. Initialize $W_0$
  2. Evaluate gradient: $g_n=\nabla_W E(W_n)$
  3. If not first iteration, do ``linmin test'': check $(g_n \cdot
d_{n-1})/\sqrt{(g_n \cdot g_n) (d_{n-1} \cdot d_{n-1})}$ for $d$ being the previous search direction
  4. If not first iteration, do ``cg test'': check $(g_n \cdot K
g_{n-1})/\sqrt{(g_n \cdot K g_n) (g_{n-1} \cdot K g_{n-1})}$ for $d$ being the previous search direction
  5. Set search direction: $d_n=-K g_n+\beta d_{n-1}$, where
    1. Fletcher-Reeves: $\beta=(g_n \cdot K g_n)/(g_{n-1} \cdot K g_{n-1})$
    2. Polak-Ribiere: $\beta=([g_n-g_{n-1}] \cdot K g_n)/([g_n-g_{n-1}] \cdot K g_{n-1})$
    3. Hestenes-Stiefel: $\beta=([g_n-g_{n-1}] \cdot K g_n)/([g_n-g_{n-1}] \cdot d_{n-1})$
  6. Evaluate gradient at trial step: $g_t=\nabla_W E(W_n+\alpha_t d_n)$
  7. Compute estimate of best step: $\alpha=\alpha_t (g \cdot
d)/([g-g_tt] \cdot d_n)$
  8. $W_{n+1}=W_n+\alpha d_n$
  9. Repeat (2-8)
with a function of the above prototype in the file ``pccg.m''.
Hint: You may wish to use the ``if ... elseif ... elseif ... end'' octave contstruct.



Subsections
Tomas Arias 2004-05-04