Page 190 - Compact Numerical Methods For Computers
P. 190
Direct search methods 179
Algorithm 20. Axial search
procedure axissrch(n: integer; {the number of parameters in the
function to be minimised}
var Bvec: rvector; {the parameter values on
input (Bvec) and output (X) from minmeth}
var Fmin: real; {‘minimum’ function value}
var lowerfn: boolean; {set true if lower value
is found during the axial search}
Workdata: probdata); {user defined data area}
{alg20.pas == axial search verification of function minimum
for a function of n parameters.
Note: in this version, function evaluations are not counted.
Copyright 1988 J.C.Nash
}
var
cradius, eps, f, fplus, step, temp, tilt : real;
i : integer;
notcomp : boolean;
begin
writeln(‘alg20.pas--axial search’);
eps := calceps; {machine precision}
eps := sqrt(eps); {take its square root for a step scaling}
writeln(‘Axis’:6,’ Stepsize ‘: 14,‘function + ‘: 14,
‘function - ‘: 14,’ rad. of cur-v.‘: 14,’ tilt’);
lowerfn := false; {initially no lower function value than fmin exists
for the function at hand}
for i := 1 to n do {STEP 1}
begin
if (not lowerfn) then
begin {STEP 2}
temp := Bvec[i]; {to save the parameter value}
step := eps*(abs(temp)+eps); {the change in the parameter -- STEP 3}
Bvec[i] := temp+step; {STEP 4}
f := fminfn(n, Bvec, Workdata, notcomp); {function calculation}
if notcomp then f := big; {substitution of a large value for
non-computable function}
write(i:5,’’,step:12,’’,f:12,’’);
end; {step forwards}
if f<fmin then lowerfn := true; {STEP 5}
if {not lowerfn} then
begin
fplus := f; {to save the function value after forward step}
Bvec[i] := temp-step; {STEP 6}
f := fminfn(n,Bvec,Workdata,notcomp); {function calculation}
if notcomp then f := big; {substitution of a large value for
non-computable function}
write(f:12,’’);
end; {step backwards}
if f<fmin then lowerfn := true; {STEP 7}
if (not lowerfn) then {STEP 8}
begin
Bvec[i] := temp; {to restore parameter value}
{compute tilt and radius of curvature}