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
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.
26
27 $initsize is the size of $init (more...)
28
29 $minsize is some sort of convergence criterion (more...) - e.g.
30 $minsize = 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 Simplex optimization routine
53
54 ($optimum,$ssize) = simplex($init,$initsize,$minsize,
55 $maxiter,
56 sub {evaluate_func_at($_[0])},
57 sub {display_simplex($_[0])}
58 );
59
60 See module "PDL::Opt::Simplex" for more information.
61
63 Do not use the simplex method if your function has local minima. It
64 will not work. Use genetic algorithms or simulated annealing or
65 conjugate gradient or momentum gradient descent.
66
67 They will not really work either but they are not guaranteed not to
68 work ;) (if you have infinite time, simulated annealing is guaranteed
69 to work but only after it has visited every point in your space).
70
72 Ron Shaffer's chemometrics web page and references therein:
73 "http://chem1.nrl.navy.mil/~shaffer/chemoweb.html".
74
75 Numerical Recipes (bla bla bla XXX ref).
76
77 The demonstration (Examples/Simplex/tsimp.pl and tsimp2.pl).
78
80 Copyright(C) 1997 Tuomas J. Lukka. All rights reserved. There is no
81 warranty. You are allowed to redistribute this software / documentation
82 under certain conditions. For details, see the file COPYING in the PDL
83 distribution. If this file is separated from the PDL distribution, the
84 copyright notice should be included in the file.
85
86
87
88perl v5.12.3 2009-10-17 Simplex(3)