// $Id: bestAlphaManyTrees.h 962 2006-11-07 15:13:34Z privmane $ #ifndef ___BEST_ALPHA_MANY_TREES #define ___BEST_ALPHA_MANY_TREES #include "definitions.h" #include "computePijComponent.h" #include "sequenceContainer.h" #include "bblEM.h" #include "gammaDistribution.h" #include "likelihoodComputation.h" #include "logFile.h" using namespace likelihoodComputation; //#define VERBOS namespace bestAlpha { /* void optimizeAlpha1G_EM( tree& et, const sequenceContainer& sc, const stochasticProcess& sp, const Vdouble * weights, MDOUBLE & bestAlpha, MDOUBLE & likelihoodScore, const int maxIterations=1000, const MDOUBLE epsilon=0.05); */ void optimizeAlphaNG_EM_SEP(vector& et, vector& sc, vector &sp, const vector * weights, MDOUBLE & bestAlpha, MDOUBLE & likelihoodScore, const int maxIterations=1000, const MDOUBLE epsilon=0.05); void optimizeAlphaNG_EM_PROP(tree& et,// 1 alpha for all trees! vector& sc, vector& sp, const vector * weights, MDOUBLE & bestAlpha, MDOUBLE & likelihoodScore, const int maxIterations=1000, const MDOUBLE epsilon=0.05); void optimizeAlphaNG_EM_PROP_n_alpha(tree& et,// alpha for each trees! vector& sc, vector& sp, const vector * weights, vector & bestAlpha, MDOUBLE & likelihoodScore, const int maxIterations=1000, const MDOUBLE epsilon=0.05); }; #include // for debugging using namespace std; // for debugging class C_evalAlphaManyTrees{ public: C_evalAlphaManyTrees(tree& et, vector& sc, vector& sp, const vector * weights) : _et(et),_sc(sc),_sp(sp),_weights(weights) {}; private: const tree& _et; const vector& _sc; vector& _sp; const vector * _weights; public: MDOUBLE operator() (MDOUBLE alpha) { #ifdef VERBOS LOG(5,<<"trying alpha: "<(_sp[i].distr()))->setAlpha(alpha); res += likelihoodComputation::getTreeLikelihoodAllPosAlphTheSame(_et,_sc[i],_sp[i],_weights?(*_weights)[i]:NULL); } #ifdef VERBOS LOG(5,<<"likelihood = "<<-res<& et, vector& sc, vector& sp, const vector * weights) : _et(et),_sc(sc),_sp(sp),_weights(weights) {}; private: const vector& _et; const vector& _sc; vector& _sp; const vector * _weights; public: MDOUBLE operator() (MDOUBLE alpha) { //LOG(5,<<"trying alpha: "<(_sp[i].distr()))->setAlpha(alpha); res += likelihoodComputation::getTreeLikelihoodAllPosAlphTheSame(_et[i],_sc[i],_sp[i],_weights?(*_weights)[i]:NULL); } // LOG(5,<<" with alpha = "<