2008-05-14 15:32:17 +04:00
|
|
|
#ifndef POINT_H
|
|
|
|
#define POINT_H
|
2011-11-12 02:59:50 +04:00
|
|
|
|
2008-05-14 15:32:17 +04:00
|
|
|
#include <vector>
|
2008-05-15 23:09:01 +04:00
|
|
|
#include "Types.h"
|
2008-05-14 15:32:17 +04:00
|
|
|
#include "FeatureStats.h"
|
2008-05-15 14:57:20 +04:00
|
|
|
#include <cassert>
|
2008-05-14 15:32:17 +04:00
|
|
|
|
2008-05-15 14:57:20 +04:00
|
|
|
|
|
|
|
class Optimizer;
|
|
|
|
|
|
|
|
/**class that handle the subset of the Feature weight on which we run the optimization*/
|
|
|
|
|
2011-02-24 15:42:19 +03:00
|
|
|
class Point:public vector<parameter_t>
|
|
|
|
{
|
2008-05-15 14:57:20 +04:00
|
|
|
friend class Optimizer;
|
2011-02-24 15:42:19 +03:00
|
|
|
private:
|
2008-05-15 14:57:20 +04:00
|
|
|
/**The indices over which we optimize*/
|
2008-05-23 15:48:16 +04:00
|
|
|
static vector<unsigned int> optindices;
|
2008-05-15 14:57:20 +04:00
|
|
|
/**dimension of optindices and of the parent vector*/
|
2008-05-23 15:48:16 +04:00
|
|
|
static unsigned int dim;
|
2008-05-15 14:57:20 +04:00
|
|
|
/**fixed weights in case of partial optimzation*/
|
2008-05-23 15:48:16 +04:00
|
|
|
static map<unsigned int,parameter_t> fixedweights;
|
2008-05-15 14:57:20 +04:00
|
|
|
/**total size of the parameter space; we have pdim=FixedWeight.size()+optinidices.size()*/
|
2008-05-23 15:48:16 +04:00
|
|
|
static unsigned int pdim;
|
|
|
|
static unsigned int ncall;
|
2011-07-04 01:01:16 +04:00
|
|
|
/**The limits for randomization, both vectors are of full length, pdim*/
|
|
|
|
static vector<parameter_t> m_min;
|
|
|
|
static vector<parameter_t> m_max;
|
2011-02-24 15:42:19 +03:00
|
|
|
public:
|
|
|
|
static unsigned int getdim() {
|
|
|
|
return dim;
|
|
|
|
}
|
|
|
|
static unsigned int getpdim() {
|
|
|
|
return pdim;
|
|
|
|
}
|
2011-09-15 21:45:35 +04:00
|
|
|
static void setpdim(size_t pd) {
|
|
|
|
pdim = pd;
|
|
|
|
}
|
|
|
|
static void setdim(size_t d) {
|
|
|
|
dim = d;
|
|
|
|
}
|
2011-02-24 15:42:19 +03:00
|
|
|
static bool OptimizeAll() {
|
|
|
|
return fixedweights.empty();
|
|
|
|
};
|
2008-05-15 23:09:01 +04:00
|
|
|
statscore_t score;
|
2011-02-24 15:42:19 +03:00
|
|
|
Point():vector<parameter_t>(dim) {};
|
2011-07-04 01:01:16 +04:00
|
|
|
Point(const vector<parameter_t>& init,
|
|
|
|
const vector<parameter_t>& min,
|
|
|
|
const vector<parameter_t>& max
|
|
|
|
);
|
|
|
|
void Randomize();
|
2008-05-16 11:09:15 +04:00
|
|
|
|
2008-05-15 14:57:20 +04:00
|
|
|
double operator*(const FeatureStats&)const;//compute the feature function
|
2008-05-14 18:25:07 +04:00
|
|
|
Point operator+(const Point&)const;
|
2011-09-15 21:45:35 +04:00
|
|
|
void operator+=(const Point&);
|
2008-05-15 14:57:20 +04:00
|
|
|
Point operator*(float)const;
|
2008-05-15 18:04:42 +04:00
|
|
|
/**write the Whole featureweight to a stream (ie pdim float)*/
|
|
|
|
friend ostream& operator<<(ostream& o,const Point& P);
|
2011-02-24 15:42:19 +03:00
|
|
|
void Normalize() {
|
|
|
|
NormalizeL2();
|
|
|
|
};
|
2008-05-27 20:50:52 +04:00
|
|
|
void NormalizeL2();
|
|
|
|
void NormalizeL1();
|
2008-05-16 14:57:24 +04:00
|
|
|
/**return a vector of size pdim where all weights have been put(including fixed ones)*/
|
|
|
|
vector<parameter_t> GetAllWeights()const;
|
2011-02-24 15:42:19 +03:00
|
|
|
statscore_t GetScore()const {
|
|
|
|
return score;
|
|
|
|
};
|
2008-05-14 15:32:17 +04:00
|
|
|
};
|
|
|
|
|
2011-11-12 02:59:50 +04:00
|
|
|
#endif // POINT_H
|