1Simplex(3) User Contributed Perl Documentation Simplex(3)
2
3
4
6 PDL::Opt::Simplex -- Simplex optimization routines
7
9 use PDL::Opt::Simplex;
10
11 ($optimum,$ssize,$optval) = simplex($init,$initsize,$minsize,
12 $maxiter,
13 sub {evaluate_func_at($_[0])},
14 sub {display_simplex($_[0])}
15 );
16
18 This package implements the commonly used simplex optimization
19 algorithm. The basic idea of the algorithm is to move a "simplex" of
20 N+1 points in the N-dimensional search space according to certain
21 rules. The main benefit of the algorithm is that you do not need to
22 calculate the derivatives of your function.
23
24 $init is a 1D vector holding the initial values of the N fitted
25 parameters, $optimum is a vector holding the final solution. $optval
26 is the evaluation of the final solution.
27
28 $initsize is the size of $init (more...)
29
30 $minsize is some sort of convergence criterion (more...) - e.g.
31 $minsize = 1e-6
32
33 The sub is assumed to understand more than 1 dimensions and threading.
34 Its signature is 'inp(nparams); [ret]out()'. An example would be
35
36 sub evaluate_func_at {
37 my($xv) = @_;
38 my $x1 = $xv->slice("(0)");
39 my $x2 = $xv->slice("(1)");
40 return $x1**4 + ($x2-5)**4 + $x1*$x2;
41 }
42
43 Here $xv is a vector holding the current values of the parameters being
44 fitted which are then sliced out explicitly as $x1 and $x2.
45
46 $ssize gives a very very approximate estimate of how close we might be
47 - it might be miles wrong. It is the euclidean distance between the
48 best and the worst vertices. If it is not very small, the algorithm has
49 not converged.
50
52 simplex
53 Simplex optimization routine
54
55 ($optimum,$ssize,$optval) = simplex($init,$initsize,$minsize,
56 $maxiter,
57 sub {evaluate_func_at($_[0])},
58 sub {display_simplex($_[0])}
59 );
60
61 See module "PDL::Opt::Simplex" for more information.
62
64 Do not use the simplex method if your function has local minima. It
65 will not work. Use genetic algorithms or simulated annealing or
66 conjugate gradient or momentum gradient descent.
67
68 They will not really work either but they are not guaranteed not to
69 work ;) (if you have infinite time, simulated annealing is guaranteed
70 to work but only after it has visited every point in your space).
71
73 Ron Shaffer's chemometrics web page and references therein:
74 "http://chem1.nrl.navy.mil/~shaffer/chemoweb.html".
75
76 Numerical Recipes (bla bla bla XXX ref).
77
78 The demonstration (Examples/Simplex/tsimp.pl and tsimp2.pl).
79
81 Copyright(C) 1997 Tuomas J. Lukka. All rights reserved. There is no
82 warranty. You are allowed to redistribute this software / documentation
83 under certain conditions. For details, see the file COPYING in the PDL
84 distribution. If this file is separated from the PDL distribution, the
85 copyright notice should be included in the file.
86
87
88
89perl v5.32.1 2021-02-15 Simplex(3)