simplex.h

Go to the documentation of this file.
00001 /* Numerical Methods, S06
00002  * Note 8, Function optimization using the downhill simplex method.
00003  * Peter Seidler                */
00004 
00005 #ifndef _SIMPLEX_H_
00006 #define _SIMPLEX_H_
00007 
00008 #include "yang.h"
00009 
00010 
00011 // forward declarations
00012 class CoordCalcFunction;
00013 
00014 
00015 
00016 class Simplex
00017 {
00018 private:
00019     int nverts;         // Number of vertices.
00020     Vec_DP** verts;             // Array of pointers to vertices.
00021     int dim;            // Dimension of points.
00022 
00023 public:
00024     CoordCalcFunction *functionObject;
00025 
00026     Simplex(int dimension);
00027     ~Simplex();
00028 
00029     Vec_DP& operator[](int i) const {return *verts[i];}
00030 
00031     // Returns different characteristic properties.
00032     int high(double* val = 0) const;
00033     int low(double* val = 0) const;
00034     void centroid(Vec_DP& vec) const;
00035     double size() const;
00036 
00037     // Operations that can be performed on simplex.
00038     int reflect();                      // Returns index of vertex reflected.
00039     int reflect_exp();          // Returns index of vertex reflected.
00040     int contract();                     // Returns index of vertex contracted.
00041     void reduce();
00042 };
00043 
00044 /* Finds minimum of f using the downhill simplex method.
00045  * init: Initial guess on minimum.
00046  * res:  Point of calculated minimum.
00047  * accf: Desired accuracy: Max diff. between function values at highest
00048  *       and lowest point of simplex. On return the variable
00049  *       is updated with the actual difference.
00050  * accx: Desired accuracy: Max size of simplex. On return updated with
00051  *       actual size.
00052  * nmax: Max no. of iterations. On return updated with actual no.
00053  *       of iterations.
00054  * Return value: Function value at minimum.             */
00055 
00056 
00057 #endif // _SIMPLEX_H
Generated on Wed May 26 16:21:15 2010 for OverSim by  doxygen 1.6.3