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-15 23:09:01 +04:00
|
|
|
class Point:public parameters_t{
|
2008-05-15 14:57:20 +04:00
|
|
|
friend class Optimizer;
|
|
|
|
private:
|
|
|
|
/**The indices over which we optimize*/
|
|
|
|
static vector<unsigned> optindices;
|
|
|
|
/**dimension of optindices and of the parent vector*/
|
|
|
|
static unsigned dim;
|
|
|
|
/**fixed weights in case of partial optimzation*/
|
2008-05-15 23:09:01 +04:00
|
|
|
static map<unsigned,parameter_t> fixedweights;
|
2008-05-15 14:57:20 +04:00
|
|
|
/**total size of the parameter space; we have pdim=FixedWeight.size()+optinidices.size()*/
|
|
|
|
static unsigned pdim;
|
2008-05-15 18:17:34 +04:00
|
|
|
static unsigned ncall;
|
2008-05-14 15:32:17 +04:00
|
|
|
public:
|
2008-05-15 14:57:20 +04:00
|
|
|
static unsigned getdim(){return dim;}
|
|
|
|
static unsigned getpdim(){return pdim;}
|
|
|
|
static bool OptimizeAll(){return fixedweights.empty();};
|
2008-05-15 23:09:01 +04:00
|
|
|
statscore_t score;
|
|
|
|
Point():parameters_t(dim){};
|
|
|
|
Point(parameters_t init):parameters_t(init){assert(init.size()==dim);};
|
|
|
|
void Randomize(const parameters_t& min,const parameters_t& max);
|
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-15 14:57:20 +04:00
|
|
|
void Normalize();
|
|
|
|
/**return a vector of size pdim where all weights have been put*/
|
2008-05-15 23:09:01 +04:00
|
|
|
parameters_t GetAllWeights()const;
|
2008-05-14 15:32:17 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|
2008-05-15 14:57:20 +04:00
|
|
|
|