diff options
author | jfouet <jfouet@1f5c12ca-751b-0410-a591-d2e778427230> | 2008-05-14 15:00:59 +0400 |
---|---|---|
committer | jfouet <jfouet@1f5c12ca-751b-0410-a591-d2e778427230> | 2008-05-14 15:00:59 +0400 |
commit | f9448b76a084db8cc2ed2e662f21d40ddd48ad3a (patch) | |
tree | d317e6802aecd127d4651b819c30f04b223af68f /mert/Optimizer.h | |
parent | eb2d6e971d5f00d7e7fa705871704501758e2014 (diff) |
objet code for the Optimzer algorithm
git-svn-id: https://mosesdecoder.svn.sourceforge.net/svnroot/mosesdecoder/trunk@1637 1f5c12ca-751b-0410-a591-d2e778427230
Diffstat (limited to 'mert/Optimizer.h')
-rw-r--r-- | mert/Optimizer.h | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/mert/Optimizer.h b/mert/Optimizer.h new file mode 100644 index 000000000..98ba8519a --- /dev/null +++ b/mert/Optimizer.h @@ -0,0 +1,55 @@ +#ifndef OPTIMIZER_H +#define OPTIMIZER_H +#include<vector> +#include "FeatureStats.h" +#include "FeatureData.h" +#include "FeatureArray.h" +#include "scorer.h" +#include "point.h" + + + +typedef float featurescore; + + + + +using namespace std; +/**virtual class*/ +class Optimizer{ + public: + Scorer * scorer; + FeatureData * FData; + /**number of lambda parameters*/ + unsigned dimension; + Optimizer(unsigned d):dimension(d),scorer(NULL),FData(NULL){}; + void SetScorer(Scorer *S); + void SetFData(FeatureData *F); + ~Optimizer(){ + delete scorer; + delete FData; + } + /**Number of sentences in the tuning set*/ + unsigned N; + /**main function that perform an optimization*/ + virtual point run(const point& init); + /**given a set of lambdas, get the nbest for each sentence*/ + vector<unsigned> Get1bests(const point& param); + /**given a set of nbests, get the Statistical score*/ + statscore Getstatscore(vector<unsigned> nbests){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 +} + +using namespace std; +/**default basic optimizer*/ +class SimpleOptimizer: public Optimizer{ +private: float eps; +public: + SimpleOptimizer(unsigned dim,float _eps):Optimizer(dim),eps(_eps){}; + point run(const point& init); +} + +#endif + |