diff options
author | jfouet <jfouet@1f5c12ca-751b-0410-a591-d2e778427230> | 2008-05-15 14:57:20 +0400 |
---|---|---|
committer | jfouet <jfouet@1f5c12ca-751b-0410-a591-d2e778427230> | 2008-05-15 14:57:20 +0400 |
commit | bfe36611108453efefa0ae0cba384c4f7dac4ebb (patch) | |
tree | c714cbaf181b3dddd873e31e67c8c195777eccce /mert/Optimizer.h | |
parent | c2c30717e07b5ef3ef7b8f48e29f364c92e71d82 (diff) |
implementation of optimization on a subset of the parameters + debug mode in the makefile
git-svn-id: https://mosesdecoder.svn.sourceforge.net/svnroot/mosesdecoder/trunk@1695 1f5c12ca-751b-0410-a591-d2e778427230
Diffstat (limited to 'mert/Optimizer.h')
-rw-r--r-- | mert/Optimizer.h | 39 |
1 files changed, 19 insertions, 20 deletions
diff --git a/mert/Optimizer.h b/mert/Optimizer.h index ee43eaf32..0bd4cceeb 100644 --- a/mert/Optimizer.h +++ b/mert/Optimizer.h @@ -13,43 +13,42 @@ typedef float featurescore; - using namespace std; /**virtual class*/ class Optimizer{ + protected: + Scorer * scorer; //no accessor for them only child can use them + FeatureData * FData;//no accessor for them only child can use them + Point init; public: - Scorer * scorer; - FeatureData * FData; - /**number of lambda parameters*/ - const unsigned dimension; - Optimizer(unsigned d):dimension(d),scorer(NULL),FData(NULL){}; + Optimizer(unsigned Pd,vector<unsigned> i2O,vector<lambda> start); void SetScorer(Scorer *S); void SetFData(FeatureData *F); - ~Optimizer(){ - delete scorer; - delete FData; - } - unsigned size(){return (FData?FData->size():0);} + virtual ~Optimizer(); + + unsigned size()const{return (FData?FData->size():0);} /**Generic wrapper around TrueRun to check a few things. Non virtual*/ - Point Run(const Point& init); + Point Run()const; /**main function that perform an optimization*/ - virtual Point TrueRun(const Point& init); + virtual Point TrueRun()const=0; /**given a set of lambdas, get the nbest for each sentence*/ - vector<unsigned> Get1bests(const Point& param); + void Get1bests(const Point& param,vector<unsigned>& bests)const; /**given a set of nbests, get the Statistical score*/ - statscore GetStatScore(vector<unsigned> nbests){scorer->score(nbests);}; + statscore GetStatScore(const vector<unsigned>& nbests)const{scorer->score(nbests);}; /**given a set of lambdas, get the total statistical score*/ - statscore GetStatScore(const Point& param){return GetStatScore(Get1bests(param));}; - statscore LineOptimize(const Point& start,Point direction,Point& best);//Get the optimal Lambda and the best score in a particular direction from a given Point + statscore GetStatScore(const Point& param)const; + vector<statscore> GetIncStatScore(vector<unsigned> ref,vector<vector <pair<unsigned,unsigned> > >)const; + + statscore LineOptimize(const Point& start,const Point& direction,Point& best)const;//Get the optimal Lambda and the best score in a particular direction from a given Point }; -using namespace std; + /**default basic optimizer*/ class SimpleOptimizer: public Optimizer{ private: float eps; public: - SimpleOptimizer(unsigned dim,float _eps):Optimizer(dim),eps(_eps){}; - virtual Point TrueRun(const Point& init); + SimpleOptimizer(unsigned dim,vector<unsigned> i2O,vector<lambda> start,float _eps):Optimizer(dim,i2O,start),eps(_eps){}; + virtual Point TrueRun()const; }; #endif |