00001 #ifndef MERT_POINT_H_
00002 #define MERT_POINT_H_
00003
00004 #include <ostream>
00005 #include <map>
00006 #include <vector>
00007 #include "Types.h"
00008
00009 namespace MosesTuning
00010 {
00011
00012
00013 class FeatureStats;
00014 class Optimizer;
00015
00020 class Point : public std::vector<parameter_t>
00021 {
00022 friend class Optimizer;
00023
00024 private:
00028 static std::vector<unsigned int> m_opt_indices;
00029
00033 static unsigned int m_dim;
00034
00038 static std::map<unsigned int,parameter_t> m_fixed_weights;
00039
00044 static unsigned int m_pdim;
00045 static unsigned int m_ncall;
00046
00050 static std::vector<parameter_t> m_min;
00051 static std::vector<parameter_t> m_max;
00052
00053 statscore_t m_score;
00054
00055 public:
00056 static unsigned int getdim() {
00057 return m_dim;
00058 }
00059 static void setdim(std::size_t d) {
00060 m_dim = d;
00061 }
00062
00063 static unsigned int getpdim() {
00064 return m_pdim;
00065 }
00066 static void setpdim(std::size_t pd) {
00067 m_pdim = pd;
00068 }
00069
00070 static void set_optindices(const std::vector<unsigned int>& indices) {
00071 m_opt_indices = indices;
00072 }
00073
00074 static const std::vector<unsigned int>& get_optindices() {
00075 return m_opt_indices;
00076 }
00077
00078 static bool OptimizeAll() {
00079 return m_fixed_weights.empty();
00080 }
00081
00082 Point();
00083 Point(const std::vector<parameter_t>& init,
00084 const std::vector<parameter_t>& min,
00085 const std::vector<parameter_t>& max);
00086 ~Point();
00087
00088 void Randomize();
00089
00090
00091 double operator*(const FeatureStats&) const;
00092 const Point operator+(const Point&) const;
00093 void operator+=(const Point&);
00094 const Point operator*(float) const;
00095
00099 friend std::ostream& operator<<(std::ostream& o,const Point& P);
00100
00101 void Normalize() {
00102 NormalizeL2();
00103 }
00104 void NormalizeL2();
00105 void NormalizeL1();
00106
00111 void GetAllWeights(std::vector<parameter_t>& w) const;
00112
00113 statscore_t GetScore() const {
00114 return m_score;
00115 }
00116 void SetScore(statscore_t score) {
00117 m_score = score;
00118 }
00119 };
00120
00121 }
00122
00123 #endif // MERT_POINT_H