handj()
is a Fortran subroutine that minimizes a given
function using the algorithm
of Hooke
& Jeeves (1961).
handj_ext
is a programme that uses handj()
with an externally computed function.
Have available a programme or script that can also be invoked from the command line and that evaluates the function to be minimized. The programme or script should read the function parameters from a single-line text file in the directory from which it is run, and should write the resulting function value into a single-line text file in the same directory.
Sample function script for Octave:
p = load ('handj_ext_param.txt');
nparams = length(p);
f = 100*(p(2) - p(1)^2)^2 + (1.-p(1))^2;
save -ascii handj_ext_result.txt f;
Run handj_ext
from the command line. You will be asked
for
octave -q handj_ext.m > /dev/null
,
where the -q
just tells Octave not to print the usual
messages when it starts)
handj_ext_param.txt
)
handj_ext_result.txt
)
You will then be asked for
handj()
subroutine will then be called repeatedly
until Δ < δ. Note that a single Δ applies to
all of the function's parameters, so the function should be defined
so that all of its parameters are of the same order of magnitude.
During the search, some progress messages will be displayed. Pressing any key on the keyboard will terminate the search.
Once the search has finished, the final parameter values will be printed.
A log will be dumped to the file handj_ext.log
. For each
function evaluation the log will contain the sequence number;
the function value; a code that indicates what mode the algorithm was
in when it called the function; and the values of the parameters.
The mode codes are the following:
The programme will then offer to graphically display the evolution of two of the parameters. You will be asked which parameters to plot. Type control-Z if you do not want a graphical display.