Page 185 - Compact Numerical Methods For Computers
P. 185

174               Compact numerical methods for computers

                            Algorithm 19. A Nelder-Mead minimisation procedure (cont.)
                                C : integer; {pointer column in workspace P which stores the
                                               centroid of the polytope. C is set to n+2) here.}
                                calcvert : boolean; {true if vertices to be calculated, as at start
                                               or after a shrink operation}
                                convtol : real; {a convergence tolerance based on function
                                               value differences}
                                f : real; {temporary function value}
                                funcount : integer; {count of function evaluations}
                                H : integer; {pointer to highest vertex in polytope}
                                i,j : integer; {working integers}
                                L : integer; {pointers to lowest vertex in polytope}
                                notcomp : boolean; {non-computability flag}
                                n1 : integer; {n+l}
                                oldsize : real; {former size measure of polytope}
                                P : array[l..Prow,1..Pcol] of real; {polytope workspace}
                                shrinkfail: boolean; {true if shrink has not reduced polytope size}
                                size : real; {a size measure for the polytope}
                                step : real; {stepsize used to build polytope}
                                temp : real; {a temporary variable}
                                trystep : real; {a trial stepsize}
                                tstr : string[5]; {storage for function counter in string form
                                               to control display width}
                                VH,VL,VN : real; {function values of ‘highest’,‘lowest’ and
                                               *next’ vertices}
                                VR : real; {function value at Reflection}
                              begin
                                writeln(‘Nash Algorithm 19 version 2 1988-03-17’);
                                writeln(‘Nelder Mead polytope direct search function minimiser’);
                                fail := false; {the method has not yet failed!}
                                f := fminfn(n,Bvec,Workdata,notcomp); {initial fn calculation -- STEP 1}
                                if notcomp then
                                begin
                                   writeln(‘**** Function cannot be evaluated at initial parameters ****‘);
                                   fail := true; {method has failed -- cannot get started}
                                end
                                else
                                begin {proceed with minimisation}
                                   writeln(‘Function value for initial parameters = ‘,f);
                                   if intol<0.0 then intol := Calceps;
                                   funcount := 1; {function count initialized to 1}
                                   convtol := intol*(abs(f)+intol); {ensures small value relative to
                                               function value -- note that we can restart the procedure if
                                               this is too big due to a large initial function value.}
                                   writeln(‘Scaled convergence tolerance is ‘,convtol);
                                   n1 := n+1; C := n+2; P[n1,1] := f; {STEP 2}
                                   for i := 1 to n do P[i,1] := Bvec[i];
                                   {This saves the initial point as vertex 1 of the polytope.}
                                   L := 1; {We indicate that it is the ‘lowest’ vertex at the moment, so
                                               that its funtion value is not recomputed later in STEP 10}
                                   size := 0.0; {STEP 3}
                                   {STEP 4: build the initial polytope using a fixed step size}
                                   step := 0.0;
   180   181   182   183   184   185   186   187   188   189   190