diff options
author | phkoehn <phkoehn@1f5c12ca-751b-0410-a591-d2e778427230> | 2011-07-23 04:24:45 +0400 |
---|---|---|
committer | phkoehn <phkoehn@1f5c12ca-751b-0410-a591-d2e778427230> | 2011-07-23 04:24:45 +0400 |
commit | 1bd74fc87fc3ce0b56f981e0196b47c464ecd12f (patch) | |
tree | 28b4b43040d1a7ecf7624976820d8f346710d899 /mert/Optimizer.h | |
parent | 6a27dc4f17e0e0af785611470196f91f38e80c74 (diff) |
added random directions [Cer&al.,2008] and historic best as starting points [Foster&Kuhn,2009] to MERT
git-svn-id: https://mosesdecoder.svn.sourceforge.net/svnroot/mosesdecoder/trunk@4086 1f5c12ca-751b-0410-a591-d2e778427230
Diffstat (limited to 'mert/Optimizer.h')
-rw-r--r-- | mert/Optimizer.h | 30 |
1 files changed, 19 insertions, 11 deletions
diff --git a/mert/Optimizer.h b/mert/Optimizer.h index 95a9a3ef6..9920be77f 100644 --- a/mert/Optimizer.h +++ b/mert/Optimizer.h @@ -11,8 +11,6 @@ typedef float featurescore; - - using namespace std; /**abstract virtual class*/ class Optimizer @@ -20,8 +18,9 @@ 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 + unsigned int number_of_random_directions; public: - Optimizer(unsigned Pd,vector<unsigned> i2O,vector<parameter_t> start); + Optimizer(unsigned Pd,vector<unsigned> i2O,vector<parameter_t> start,unsigned int nrandom); void SetScorer(Scorer *S); void SetFData(FeatureData *F); virtual ~Optimizer(); @@ -46,24 +45,33 @@ public: }; -/**default basic optimizer*/ +/**default basic optimizer*/ class SimpleOptimizer: public Optimizer { private: - static float eps; + static float eps; public: - SimpleOptimizer(unsigned dim,vector<unsigned> i2O,vector<parameter_t> start):Optimizer(dim,i2O,start) {}; + SimpleOptimizer(unsigned dim,vector<unsigned> i2O,vector<parameter_t> start,unsigned int nrandom):Optimizer(dim,i2O,start,nrandom) {}; virtual statscore_t TrueRun(Point&)const; }; -class RandomOptimizer: public Optimizer +/**optimizer with random directions*/ +class RandomDirectionOptimizer: public Optimizer { +private: + static float eps; public: - RandomOptimizer(unsigned dim,vector<unsigned> i2O,vector<parameter_t> start):Optimizer(dim,i2O,start) {}; + RandomDirectionOptimizer(unsigned dim,vector<unsigned> i2O,vector<parameter_t> start,unsigned int nrandom):Optimizer(dim,i2O,start,nrandom) {}; virtual statscore_t TrueRun(Point&)const; }; - +/**dumb baseline optimizer: just picks a random point and quits*/ +class RandomOptimizer: public Optimizer +{ +public: + RandomOptimizer(unsigned dim,vector<unsigned> i2O,vector<parameter_t> start, unsigned int nrandom):Optimizer(dim,i2O,start,nrandom) {}; + virtual statscore_t TrueRun(Point&)const; +}; class OptimizerFactory { @@ -71,9 +79,9 @@ public: // unsigned dim; //Point Start; static vector<string> GetTypeNames(); - static Optimizer* BuildOptimizer(unsigned dim,vector<unsigned>tooptimize,vector<parameter_t> start,string type); + static Optimizer* BuildOptimizer(unsigned dim,vector<unsigned>tooptimize,vector<parameter_t> start,string type,unsigned int nrandom); private: - enum OptType {POWELL=0,RANDOM,NOPTIMIZER}; //Add new optimizer here BEFORE NOPTIMZER + enum OptType {POWELL=0,RANDOM_DIRECTION=1,RANDOM,NOPTIMIZER}; //Add new optimizer here BEFORE NOPTIMZER static OptType GetOType(string); static vector<string> typenames; static void SetTypeNames(); |