@node Math/Amoeba, Math/Approx, Make, Module List
@unnumberedsec SYNOPSIS

@example
use Math::Amoeba qw(ConstructVertices EvaluateVertices Amoeba MinimiseND);
my ($vertice,$y)=MinimiseND(\@@guess,\@@scales,\&func,$tol,$itmax);
my @@vertices=ConstructVertices(\@@vector,\@@offsets);
my @@y=EvaluateVertices(\@@vertices,\&func);
my ($vertice,$y)=Amoeba(\@@vertices,\@@y,\&func,$tol,$itmax);
@end example

@unnumberedsec DESCRIPTION

This is an implimenation of the Downhill Simpex Method in
Multidimensions (Nelder and Mead) for finding the (local) minimum of a
function. Doing this in Perl makes it easy for that function to
actually be the output of another program such as a simulator.

Arrays and the function are passed by reference to the routines.

The simplest use is the @strong{MinimiseND} function. This takes a reference
to an array of guess values for the parameters at the function
minimum, a reference to an array of scales for these parameters
(sensible ranges around the guess in which to look), a reference to
the function, a convergence tolerence for the minimum and the maximum
number of iterations to be taken. It returns an array consisting of a
reference to the function parameters at the minimum and the value
there.

The @strong{Amoeba} function is the actual implimentation of the Downhill
Simpex Method in Multidimensions. It takes a reference to an array of
references to arrays which are the initial n+1 vertices (where n is
the number of function parameters), a reference to the function
valuation at these vertices, a reference to the function, a
convergence tolerence for the minimum and the maximum number of
iterations to be taken. It returns an array consisting of a reference
to the function parameters at the minimum and the value there.

The @strong{ConstructVertices} is used by @strong{MinimiseND} to construct the
initial vertices for @strong{Amoeba} as the initial guess plus the parameter
scale parameters as vectors along the parameter axis.

The @strong{EvaluateVertices} takes these set of vertices, calling the
function for each one and returning the vector of results.

@unnumberedsec EXAMPLE

@example
use Math::Amoeba qw(MinimiseND);
sub afunc @{
  my ($a,$b)=@@_;
  print "$a\t$b\n";
  return ($a-7)**2+($b+3)**2;
@}
my @@guess=(1,1);
my @@scale=(1,1);
($p,$y)=MinimiseND(\@@guess,\@@scale,\&afunc,1e-7,100);
print "(",join(@',@',@@@{$p@}),")=$y\n";
@end example

produces the output

(6.99978191653352,-2.99981241563247)=1.00000008274829

@unnumberedsec HISTORY

$Log: Amoeba.pm,v $
Revision 1.2  1995/12/24 12:37:46  willijar
General fixup. Added documentation.

@unnumberedsec BUGS

If the function value converges to exactly zero then the condition for
convergence fails and maximum iterations will be exceeded or there
will be a divide by zero error. There is no obvious way to test for
convergence in this case however adding 1 onto the function value
gives expected behaviour. i.e. replace @'\&afunc@' with @'sub @{
1+afunc(@@_); @}@' when calling the routines.

Let me know.

@unnumberedsec AUTHOR

John A.R. Williams <J.A.R.Williams@@aston.ac.uk>

@unnumberedsec SEE ALSO

"Numerical Recipies: The Art of Scientific Computing"
W.H. Press, B.P. Flannery, S.A. Teukolsky, W.T. Vetterling.
Cambridge University Press. ISBN 0 521 30811 9.

