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) = 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 algo‐
19 rithm. The basic idea of the algorithm is to move a "simplex" of N+1
20 points in the N-dimensional search space according to certain rules.
21 The main benefit of the algorithm is that you do not need to calculate
22 the derivatives of your function.
23
24 $init is a 1D vector holding the initial values of the N fitted parame‐
25 ters, $optimum is a vector holding the final solution.
26
27 $initsize is the size of $init (more...)
28
29 $minsize is some sort of convergence criterion (more...) - e.g. $min‐
30 size = 1e-6
31
32 The sub is assumed to understand more than 1 dimensions and threading.
33 Its signature is 'inp(nparams); [ret]out()'. An example would be
34
35 sub evaluate_func_at {
36 my($xv) = @_;
37 my $x1 = $xv->slice("(0)");
38 my $x2 = $xv->slice("(1)");
39 return $x1**4 + ($x2-5)**4 + $x1*$x2;
40 }
41
42 Here $xv is a vector holding the current values of the parameters being
43 fitted which are then sliced out explicitly as $x1 and $x2.
44
45 $ssize gives a very very approximate estimate of how close we might be
46 - it might be miles wrong. It is the euclidean distance between the
47 best and the worst vertices. If it is not very small, the algorithm has
48 not converged.
49
51 simplex
52
53 Simplex optimization routine
54
55 ($optimum,$ssize) = 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 conju‐
66 gate 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.8.8 2004-12-04 Simplex(3)