2008-05-14 15:32:17 +04:00
|
|
|
#ifndef POINT_H
|
|
|
|
#define POINT_H
|
|
|
|
#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*/
|
|
|
|
|
2008-05-16 14:57:24 +04:00
|
|
|
class Point:public vector<parameter_t>{
|
2008-05-15 14:57:20 +04:00
|
|
|
friend class Optimizer;
|
|
|
|
private:
|
|
|
|
/**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;
|
2008-05-14 15:32:17 +04:00
|
|
|
public:
|
2008-05-23 15:48:16 +04:00
|
|
|
static unsigned int getdim(){return dim;}
|
|
|
|
static unsigned int getpdim(){return pdim;}
|
2008-05-15 14:57:20 +04:00
|
|
|
static bool OptimizeAll(){return fixedweights.empty();};
|
2008-05-15 23:09:01 +04:00
|
|
|
statscore_t score;
|
2008-05-16 14:57:24 +04:00
|
|
|
Point():vector<parameter_t>(dim){};
|
|
|
|
Point(const vector<parameter_t>& init);
|
|
|
|
void Randomize(const vector<parameter_t>& min,const vector<parameter_t>& max);
|
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;
|
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);
|
2008-05-27 20:50:52 +04:00
|
|
|
void Normalize(){ NormalizeL2(); };
|
|
|
|
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;
|
2008-05-23 15:48:16 +04:00
|
|
|
statscore_t GetScore()const { return score; };
|
2008-05-14 15:32:17 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|
2008-05-15 14:57:20 +04:00
|
|
|
|