Skip to content

Commit 8bf3c3e

Browse files
committed
update debug messages
1 parent 555a0ea commit 8bf3c3e

File tree

2 files changed

+32
-12
lines changed

2 files changed

+32
-12
lines changed

tree/tree.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -825,6 +825,14 @@ void cmaple::Tree::doPlacementTemplate(std::ostream& out_stream) {
825825
// update model parameters after rerooting the tree
826826
updateModelLhAfterLoading<num_states>();
827827

828+
// show info for debugging
829+
if (cmaple::verbose_mode >= cmaple::VB_DEBUG)
830+
{
831+
std::cout << std::setprecision(10)
832+
<< "Tree log likelihood (after updating model parameters (post re-rooting)): "
833+
<< computeLh() << std::endl;
834+
}
835+
828836
// need to re-seek a new root
829837
need_seeking_new_root = true;
830838
}
@@ -838,6 +846,14 @@ void cmaple::Tree::doPlacementTemplate(std::ostream& out_stream) {
838846
cout << " - Time spent on building an initial tree: "
839847
<< std::setprecision(3) << end - start << endl;
840848
}
849+
850+
851+
// output log-likelihood of the tree
852+
if (cmaple::verbose_mode >= cmaple::VB_DEBUG) {
853+
std::cout << std::setprecision(10)
854+
<< "Tree log likelihood (of the initial tree): "
855+
<< computeLh() << std::endl;
856+
}
841857

842858
// Output the initial tree for debugging
843859
if (cmaple::verbose_mode >= cmaple::VB_DEBUG) {

tree/tree.h

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2308,14 +2308,14 @@ RealNumType cmaple::Tree::improveEntireTreeParallel(const TreeSearchType tree_se
23082308
#pragma omp critical
23092309
{
23102310
all_SPR_found_vec.insert(all_SPR_found_vec.end(), SPR_found_vec.begin(), SPR_found_vec.end());
2311-
if (cmaple::verbose_mode >= cmaple::VB_DEBUG)
2311+
if (cmaple::verbose_mode >= cmaple::VB_DEBUG && tree_search_type != FAST_TREE_SEARCH)
23122312
{
23132313
std::cout << "Thread " << thread_id << " found " << SPR_found_vec.size() << " SPR moves." << std::endl;
23142314
}
23152315
}
23162316
}
23172317

2318-
if (cmaple::verbose_mode >= cmaple::VB_DEBUG)
2318+
if (cmaple::verbose_mode >= cmaple::VB_DEBUG && tree_search_type != FAST_TREE_SEARCH)
23192319
{
23202320
std::cout << "All threads found " << all_SPR_found_vec.size() << " SPR moves." << std::endl;
23212321
}
@@ -2333,19 +2333,23 @@ RealNumType cmaple::Tree::improveEntireTreeParallel(const TreeSearchType tree_se
23332333
RealNumType total_improvement = 0;
23342334

23352335
// sequentially search and apply SPRs on nodes found in the above step
2336-
for (const auto &item : all_SPR_found_vec) {
2337-
const cmaple::Index& index = item.first;
2338-
PhyloNode& node = nodes[index.getVectorIndex()];
2339-
2340-
// search and apply SPR on that node
2341-
std::vector<std::pair<cmaple::Index, double>> SPR_found_vec;
2342-
RealNumType improvement =
2336+
if (tree_search_type != FAST_TREE_SEARCH)
2337+
{
2338+
for (const auto &item : all_SPR_found_vec) {
2339+
const cmaple::Index& index = item.first;
2340+
PhyloNode& node = nodes[index.getVectorIndex()];
2341+
2342+
// search and apply SPR on that node
2343+
std::vector<std::pair<cmaple::Index, double>> SPR_found_vec;
2344+
RealNumType improvement =
23432345
improveSubTree<num_states>(index, node,
23442346
tree_search_type, short_range_search, SPR_found_vec);
2345-
2346-
// update total_improvement
2347-
total_improvement += improvement;
2347+
2348+
// update total_improvement
2349+
total_improvement += improvement;
2350+
}
23482351
}
2352+
23492353

23502354
return total_improvement;
23512355
}

0 commit comments

Comments
 (0)