Math::Amoeba(3pm) | User Contributed Perl Documentation | Math::Amoeba(3pm) |
Math::Amoeba - Multidimensional Function Minimisation
use Math::Amoeba qw(ConstructVertices EvaluateVertices Amoeba MinimiseND); my ($vertice,$y)=MinimiseND(\@guess,\@scales,\&func,$tol,$itmax,$verbose); my @vertices=ConstructVertices(\@vector,\@offsets); my @y=EvaluateVertices(\@vertices,\&func); my ($vertice,$y)=Amoeba(\@vertices,\@y,\&func,$tol,$itmax,$verbose);
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.
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";
produces the output
(6.99978191653352,-2.99981241563247)=1.00000008274829
PERL
See "REAME".
Let me know.
John A.R. Williams <J.A.R.Williams@aston.ac.uk>
Tom Chau <tom@cpan.org>
"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.
Copyright (c) 1995 John A.R. Williams. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Since 2005, this module was co-developed with Tom.
2023-01-03 | perl v5.36.0 |