tdownhill_simplex.h - numeric - C++ library with numerical algorithms
HTML git clone git://src.adamsgaard.dk/numeric
DIR Log
DIR Files
DIR Refs
DIR LICENSE
---
tdownhill_simplex.h (1099B)
---
1 #ifndef DOWNHILL_SIMPLEX_H_
2 #define DOWNHILL_SIMPLEX_H_
3
4 #include <functional>
5 #include <vector>
6 #include <armadillo>
7 using namespace std;
8 using namespace arma;
9
10 class amoeba {
11
12 public:
13
14 // Constructor
15 amoeba(function<double(vec)> fun, vector<vec> simplex);
16
17 // Return lowest simplex position
18 vec low();
19
20 // Move amoeba downhill with relevant method
21 void downhill(double simplex_size_goal);
22
23 // Move amoeba downhill with relevant method, modified method
24 void downhill_mod(double simplex_size_goal);
25
26 private:
27
28 // Number of vertexes
29 int d;
30
31 // Maxima points of function
32 int hi, lo;
33
34 // Vertex points
35 vector<vec> p;
36
37 // Functions to be evaluated
38 std::function<double(vec)> f;
39
40 // Function values at points
41 vec value;
42
43 // Centroid
44 vec p_ce;
45
46 // Centroid from previous step
47 vec p_ce_o;
48
49 // Filename of output file
50
51 // Private class functions
52 void update();
53
54 // Returns size of the amoeba
55 double size();
56
57 // Write amoeba position vertexes to stderr
58 void pos();
59 };
60
61 #endif