Direct Graphical Models  v.1.7.0
Powell.h
1 // The Powell search method class for random model parameters trainig
2 // Written by Sergey G. Kosov in 2013, 2016 for Project X
3 #pragma once
4 
5 #include "types.h"
6 
7 namespace DirectGraphicalModels
8 {
9  // ================================ Powell Class ===============================
37  class CPowell
38  {
39  public:
44  DllExport CPowell(size_t nParams);
45  DllExport CPowell(const CPowell&) = delete;
46  DllExport ~CPowell(void) = default;
47  DllExport const CPowell& operator=(const CPowell&) = delete;
48 
52  DllExport void reset(void);
59  DllExport void setInitParams(const vec_float_t& vParams);
66  DllExport void setDeltas(const vec_float_t& vDeltas);
73  DllExport void setMinParams(const vec_float_t& vMinParam);
80  DllExport void setMaxParams(const vec_float_t& vMaxParam);
87  DllExport void setAcceleration(float acceleration);
95  DllExport vec_float_t getParams(float val);
101  DllExport bool isConverged(void) const;
102 
103 
104  private:
105  size_t m_nParams; // number of parameters (arguments of the objective function)
106  size_t m_paramID; // index of a currently adjusting argument
107  size_t m_nSteps; // number of adjustments for one argument
108  float m_midPoint; // parameter value for kappa: 0
109  float m_koeff; // koefficient for optimized Powell search method
110  float m_acceleration; // acceleration of search along one direction
111 
112  vec_float_t m_vParams; // array of the parameters
113  vec_float_t m_vDeltas; // array of the delta values for each parameter
114  vec_float_t m_vMin; // array of minimal parameter values
115  vec_float_t m_vMax; // array of maximal parameter values
116  vec_float_t m_vKappa; // method's auxilary array
117  vec_bool_t m_vConverged; // array of flags, indicating converged variables
118 
119 
120  // Simplified accessors for current argument
121  #define curArg m_vParams[m_paramID]
122  #define delta m_vDeltas[m_paramID]
123  #define minArg m_vMin[m_paramID]
124  #define maxArg m_vMax[m_paramID]
125  #define convArg m_vConverged[m_paramID]
126 
127 
128  private:
130  enum {
131  mD,
132  oD,
133  pD
134  };
135  };
136 
137 }
138 
139 
void setMinParams(const vec_float_t &vMinParam)
Sets the lower boundary for parameters (arguments) search.
Definition: Powell.cpp:52
void setDeltas(const vec_float_t &vDeltas)
Sets the searching steps along the parameters (arguments)
Definition: Powell.cpp:74
null Delta (current position)
Definition: Powell.h:132
CPowell(size_t nParams)
Constructor.
Definition: Powell.cpp:7
void setAcceleration(float acceleration)
Sets the acceleration coefficient.
Definition: Powell.cpp:81
vec_float_t getParams(float val)
Gets the updated parameters (arguments)
Definition: Powell.cpp:87
void setInitParams(const vec_float_t &vParams)
Sets the initial parameters (arguments) for the search algorithm.
Definition: Powell.cpp:34
bool isConverged(void) const
Indicates weather the method has converged.
Definition: Powell.cpp:176
The Powell search method class.
Definition: Powell.h:37
const CPowell & operator=(const CPowell &)=delete
void reset(void)
Resets class variables.
Definition: Powell.cpp:19
void setMaxParams(const vec_float_t &vMaxParam)
Sets the upper boundary for parameters (arguments) search.
Definition: Powell.cpp:63