Math::Amoeba(3pm)

πŸ“¦
version 0.05 Β· 2 versions
, in debian trixie, ubuntu resolute, ubuntu stonking

🌸 NAME 🌸

Math::Amoeba β€” Multidimensional Function Minimisation πŸ’…

okay so bestie, this is the perl documentation for Math::Amoeba β€” it lives in the User Contributed Perl Documentation section, aka manual page 3pm. it finds minimums. in many dimensions. she's versatile like that. ✨


πŸ¦‹ SYNOPSIS πŸ¦‹

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);

πŸ‘‘ DESCRIPTION πŸ‘‘

ok so this is an implementation of the Downhill Simplex Method in Multidimensions (Nelder and Mead) for finding the (local) minimum of a function. yes, "local" β€” she's not promising you the whole globe, just the neighborhood. 🫢

and here's the iconic part: doing it in Perl makes it easy for that function to literally just be the output of another program, like a simulator. main character behaviour fr fr. πŸ’–

one more thing before we go: arrays and the function are passed by reference to the routines. that's the vibe. that's the rule. periodt. πŸ’…

πŸŽ€ "MinimiseND" πŸŽ€

the simplest use is the MinimiseND function. she 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 (aka sensible ranges around the guess in which to look πŸ”)
  • a reference to the function
  • a convergence tolerence for the minimum
  • the maximum number of iterations to be taken
  • and the verbose flag (default ON, she's chatty πŸ—£οΈ)

she returns an array consisting of a reference to the function parameters at the minimum and the value there. iconic return shape. ✨

πŸ”₯ "Amoeba" πŸ”₯

the Amoeba function is the actual implimentation of the Downhill Simpex Method in Multidimensions. the real one. the blueprint. πŸ‘‘

she 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
  • the maximum number of iterations to be taken
  • and the verbose flag (default ON)

she returns an array consisting of a reference to the function parameters at the minimum and the value there. same energy as her sister, different starting point πŸ’œ

🧚 "ConstructVertices" 🧚

ConstructVertices is used by MinimiseND to construct the initial vertices for Amoeba as the initial guess plus the parameter scale parameters as vectors along the parameter axis. she's the little prep squad building the setup before the main event πŸŽ€

πŸ’œ "EvaluateVertices" πŸ’œ

EvaluateVertices takes these set of vertices, calling the function for each one and returning the vector of results. one vertex, one call, collect the receipts. 🧾✨


πŸ“ 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";

and this little cutie produces the output:

(6.99978191653352,-2.99981241563247)=1.00000008274829

look at that. she found it. no cap. πŸ˜­πŸ’…


🌈 LICENSE 🌈

PERL


πŸ“œ HISTORY πŸ“œ

See "REAME". (yes, spelled exactly like that πŸ™ˆ β€” i am simply relaying the message, bestie)


πŸ’€ BUGS πŸ’€

Let me know.

(that's it. that's the whole section. she's confident, she's humble, she's available. 🫢)


πŸ‘‘ AUTHOR πŸ‘‘

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

Tom Chau <tom@cpan.org>


⭐ 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.


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.


okay that's the whole page, bestie πŸ¦‹βœ¨ this was Math::Amoeba(3pm) from perl v5.40.1, dated 2025-05-04. now go minimise something. mwah πŸ’–πŸ’…

πŸ“¦ where this page comes from