From dd70ee8222449d0618326155ec6db208d1c25dc9 Mon Sep 17 00:00:00 2001 From: wcancino Date: Fri, 23 Jan 2009 14:15:17 +0000 Subject: [PATCH] Small modifications git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@1366 331e1502-861f-0410-8da2-ba01fb791d7f --- .../PhyloMOEA/PhyloMOEA/PhyloMOEA.cpp | 20 +++++++++++++++---- .../PhyloMOEA/PhyloMOEA/likoptimizer.cpp | 16 ++++++++++++--- 2 files changed, 29 insertions(+), 7 deletions(-) diff --git a/contribution/branches/PhyloMOEA/PhyloMOEA/PhyloMOEA.cpp b/contribution/branches/PhyloMOEA/PhyloMOEA/PhyloMOEA.cpp index 38bbf847f..c4c434dc3 100644 --- a/contribution/branches/PhyloMOEA/PhyloMOEA/PhyloMOEA.cpp +++ b/contribution/branches/PhyloMOEA/PhyloMOEA/PhyloMOEA.cpp @@ -22,7 +22,7 @@ RandomNr *rn; //Sequences *seq; long seed; //vector arbores; -string datafile,usertree, expid, path; +string datafile,usertree, expid, path, algotype; double pcrossover, pmutation, kappa, alpha; unsigned int ngenerations, popsize, ncats; ofstream exp_data,evolution_data, best_media_scores, final_trees, final_pareto_trees, clades_pareto, clades_final,final_scores,pareto_scores; @@ -47,6 +47,7 @@ int main(int argc, char *argv[]) datafile = parser.createParam(string(), "data", "Datafile", 'd',"Param").value(); usertree = parser.createParam(string(), "treef", "Treefile", 't',"Param").value(); path = parser.createParam(string(), "path", "Treefile", 'p',"Param").value(); + algotype = parser.createParam(string("nsgaii"), "algo", "Algorith, Type", 'b',"Param").value(); ostringstream convert; convert << seed; expid = parser.createParam(convert.str(), "expid", "Experiment ID", 'e',"Param").value(); @@ -158,9 +159,20 @@ int main(int argc, char *argv[]) // apply ( byobj, population ); // population.printOn(cout); - moeoNSGAII2 < PhyloMOEO > nsgaII (cp, byobj, operadores); - - nsgaII(population); + if(algotype == "ibea") + { + moeoAdditiveEpsilonBinaryMetric < ObjectiveVector > metric; + moeoIBEA < PhyloMOEO > algo (cp, byobj, operadores, metric); + cout << "\n\nRunning IBEA ..." << endl; + algo(population); + } + else + { + moeoNSGAII < PhyloMOEO > algo (cp, byobj, operadores); + cout << "\n\nRunning NSGA-II ..." << endl; + algo(population); + + } cout << "\nCalculating Final Solutions..."; cout << " done\n"; diff --git a/contribution/branches/PhyloMOEA/PhyloMOEA/likoptimizer.cpp b/contribution/branches/PhyloMOEA/PhyloMOEA/likoptimizer.cpp index 25e8b0c79..c3ccd20ca 100644 --- a/contribution/branches/PhyloMOEA/PhyloMOEA/likoptimizer.cpp +++ b/contribution/branches/PhyloMOEA/PhyloMOEA/likoptimizer.cpp @@ -31,10 +31,11 @@ void Step_LikOptimizer::optimize() oldroot = invalid_node; // calculate conditional likelihood + double likinit=Lik_calc->calculate_likelihood(); //cout << "likelihood inicial" << Lik_calc->calculate_likelihood() << endl; graph::edge_iterator it_end = tree_ptr->TREE.edges_end(); - + int niterations=0; double sum,aux; do{ it = tree_ptr->TREE.edges_begin(); @@ -70,9 +71,18 @@ void Step_LikOptimizer::optimize() oldroot = a; ++it; } - cout << '.'; + if(niterations>=30) + { + if(niterations == 30)cout << "\n probable problematic tree we will print the sum value for ten iterations more and quit this tree\n"; + cout << sum << endl; + } + else cout << '.'; cout.flush(); - }while(sum>=0.0001); + niterations++; + + }while(sum>=0.0001 && niterations<40); + double likfin = Lik_calc->calculate_likelihood(); + cout << likinit << " -->" << likfin << endl; //cout << "\nlikelihood final" << Lik_calc->calculate_likelihood() << endl; }