/** \description The is the main for the new version of the mert algorithm develloppped during the 2nd MT marathon */ #include #include "Data.h" #include "Point.h" #include "Scorer.h" #include "ScoreData.h" #include "FeatureData.h" #include "Optimizer.h" #include "getopt.h" #include "Types.h" #include #include #include #include #include #include "Timer.h" #include "Util.h" float min_interval = 1e-3; using namespace std; void usage(void) { cerr<<"usage: mert -d (mandatory )"< tooptimize; vector start; while ((c=getopt_long (argc, argv, "d:n:t:s:S:F:v:", long_options, &option_index)) != -1) { switch (c) { case 'd': pdim = strtol(optarg, NULL, 10); break; case 'n': ntry=strtol(optarg, NULL, 10); break; case 't': type=string(optarg); break; case's': scorertype=string(optarg); break; case 'S': scorerfile=string(optarg); break; case 'F': featurefile=string(optarg); break; case 'i': initfile=string(optarg); break; case 'v': setverboselevel(strtol(optarg,NULL,10)); break; default: usage(); } } if (pdim < 0) usage(); Timer timer; timer.start("Starting..."); if(tooptimize.empty()){ tooptimize.resize(pdim);//We'll optimize on everything for(i=0;i>start[j]; if(jload(scorerfile); cerr<<"Loading FeatureData from: "<< featurefile << endl; FeatureData *FD=new FeatureData(); FD->load(featurefile); Optimizer *O=OptimizerFactory::BuildOptimizer(pdim,tooptimize,start,type); O->SetScorer(TheScorer); O->SetFData(FD); Point P(start);//Generate from the full feature set. Warning: must ne done after Optimiezr initialiazation statscore_t best=O->Run(P); Point bestP=P; statscore_t mean=best; statscore_t var=best*best; vector min(Point::getdim()); vector max(Point::getdim()); for(unsigned int d=0;dRun(P); if(score>best){ best=score; bestP=P; } mean+=score; var+=(score*score); } mean/=(float)ntry; var/=(float)ntry; var=sqrt(abs(var-mean*mean)); if(ntry>1) cerr<<"variance of the score (for "< " << best << endl; ofstream res("weights.txt"); res<