Page 206 - Compact Numerical Methods For Computers
P. 206

Descent to a minimum I: variable metric algorithms    195

                       Algorithm 21. Variable metric minimiser (cont.)
                                       end; {loop on i}
                                       if D1>0 then {STEP 14} {test if update is possible}
                                       begin {update}
                                          D2:=0.0; {STEP 15 -- computation of B*y, yT*B*y}
                                          for i:=1 to n do
                                          begin
                                             s:=0.0;
                                             for j:=1 to n do s:=s+B[i, j]*c[j];
                                             X[i]:=s; D2:=D2+s*c[i];
                                          end; {loop on i}
                                          D2:=1.0+D2/D1; {STEP 16 -- complete update}
                                          for i:=1 to n do
                                          begin
                                             for j:=1 to n do
                                             begin
                                               B[i,j]:=B[i,j]-(t[i]*X[j]+X[i]*t[j]-D2*t[i]*t[j])/D1;
                                             end; {loop on j}
                                          end; {loop on i -- Update is now complete.}
                                       end {update}
                                       else
                                       begin
                                          writeln(‘ UPDATE NOT POSSIBLE*);
                                          ilast:=gradcount; {to force a restart with B = l(n)}
                                       end;
                                    end {if count<n} {STEP 17}
                                    else {count<n, cannot proceed}
                                    begin
                                       if ilast<gradcount then
                                       begin
                                          count:=0; {to force a steepest descent try}
                                          ilast:=gradcount; {to reset to steepest descent search}
                                       end; {if ilast}
                                    end; {count=n}
                                 end {if gradproj<0 ... do linear search}
                                 else
                                 begin
                                    writeln(‘UPHILL SEARCH DIRECTION’);
                                    ilast:=gradcount; {(to reset B to unit matrix}
                                    count:=0; {to ensure we try again}
                                 end,
                              until (count=n) and (ilast=gradcount);
                           end, {minimisation -- STEP 18}
                           {STEP 31 -- save best parameters and function value found}
                           writeln(‘Exiting from alg21.pas variable metric minimiser’);
                           writeln(‘ ‘, funcount,’ function evaluations used’);
                           writeln(‘ ‘, gradcount,’ gradient evaluations used’);
                         end; {alg21.pas == vmmin}
   201   202   203   204   205   206   207   208   209   210   211