From 86d98de271fe4554baed33085f51f5fbb8e9c7fa Mon Sep 17 00:00:00 2001 From: MatPont Date: Mon, 11 Dec 2023 17:16:16 +0100 Subject: [PATCH 01/20] [MergeTreeDistance] disable tree structure verification if input is persistence diagram --- core/base/mergeTreeClustering/MergeTreeDistance.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/base/mergeTreeClustering/MergeTreeDistance.h b/core/base/mergeTreeClustering/MergeTreeDistance.h index 2b43efaff8..0ce6bb929f 100644 --- a/core/base/mergeTreeClustering/MergeTreeDistance.h +++ b/core/base/mergeTreeClustering/MergeTreeDistance.h @@ -582,7 +582,7 @@ namespace ttk { ftm::MergeTree &mTree2Int = (saveTree_ ? mTree2Copy : mTree2); ftm::FTMTree_MT *tree1 = &(mTree1Int.tree); ftm::FTMTree_MT *tree2 = &(mTree2Int.tree); - if(not isCalled_) { + if(not isCalled_ and not isPersistenceDiagram_) { verifyMergeTreeStructure(tree1); verifyMergeTreeStructure(tree2); } From 4b93f774ba0d1b9a4e125f01b11c5a24f29de39d Mon Sep 17 00:00:00 2001 From: MatPont Date: Mon, 11 Dec 2023 18:28:14 +0100 Subject: [PATCH 02/20] [MergeTreeBarycenter] add debug messages --- .../mergeTreeClustering/MergeTreeBarycenter.h | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/core/base/mergeTreeClustering/MergeTreeBarycenter.h b/core/base/mergeTreeClustering/MergeTreeBarycenter.h index b946bf3ecf..89cc9388a5 100644 --- a/core/base/mergeTreeClustering/MergeTreeBarycenter.h +++ b/core/base/mergeTreeClustering/MergeTreeBarycenter.h @@ -660,6 +660,22 @@ namespace ttk { baryTree->getChildren(node, children); for(auto child : children) queue.emplace(child); + + // Print + std::stringstream ss; + ss << node << " : (" << nodeScalar << ", " << nodeOriginScalar << ")"; + printMsg(ss.str(), debug::Priority::INFO); + ss.str(""); + ss << " - "; + for(unsigned int i = 0; i < baryMatching[node].size(); ++i) { + if(baryMatching[node][i] != std::numeric_limits::max()) { + auto birthDeath = getParametrizedBirthDeath( + trees[i], baryMatching[node][i]); + ss << baryMatching[node][i] << " (" << std::get<0>(birthDeath) + << ", " << std::get<1>(birthDeath) << ") ; "; + } + } + printMsg(ss.str(), debug::Priority::INFO); } if(baryMergeTree.tree.isFullMerge()) { @@ -800,6 +816,12 @@ namespace ttk { #ifdef TTK_ENABLE_OPENMP4 } // pragma omp parallel #endif + for(unsigned int i = 0; i < distances.size(); ++i) { + std::stringstream ss; + ss << i << " : distance=" << distances[i] << " (" + << distances[i] * distances[i] << ")"; + printMsg(ss.str(), debug::Priority::INFO); + } } template From f92c84dd0b0260fd54edafd382d854084da1e3f3 Mon Sep 17 00:00:00 2001 From: MatPont Date: Thu, 20 Jun 2024 16:13:49 +0200 Subject: [PATCH 03/20] [MergeTree] debug messages --- .../mergeTreeClustering/MergeTreeBarycenter.h | 13 +++++++-- .../mergeTreeClustering/MergeTreeDistance.h | 29 +++++++++++++++++-- 2 files changed, 37 insertions(+), 5 deletions(-) diff --git a/core/base/mergeTreeClustering/MergeTreeBarycenter.h b/core/base/mergeTreeClustering/MergeTreeBarycenter.h index 89cc9388a5..54a4f647f7 100644 --- a/core/base/mergeTreeClustering/MergeTreeBarycenter.h +++ b/core/base/mergeTreeClustering/MergeTreeBarycenter.h @@ -663,7 +663,9 @@ namespace ttk { // Print std::stringstream ss; - ss << node << " : (" << nodeScalar << ", " << nodeOriginScalar << ")"; + ss << node << " : (" << baryTree->getValue(node) << ", " + << baryTree->getValue(baryTree->getNode(node)->getOrigin()) + << ") -> (" << nodeScalar << ", " << nodeOriginScalar << ")"; printMsg(ss.str(), debug::Priority::INFO); ss.str(""); ss << " - "; @@ -671,8 +673,9 @@ namespace ttk { if(baryMatching[node][i] != std::numeric_limits::max()) { auto birthDeath = getParametrizedBirthDeath( trees[i], baryMatching[node][i]); - ss << baryMatching[node][i] << " (" << std::get<0>(birthDeath) - << ", " << std::get<1>(birthDeath) << ") ; "; + ss << i << "_" << baryMatching[node][i] << " (" + << std::get<0>(birthDeath) << ", " << std::get<1>(birthDeath) + << ") ; "; } } printMsg(ss.str(), debug::Priority::INFO); @@ -695,6 +698,10 @@ namespace ttk { &(baryMergeTree.tree), 0, deletedNodesT); limitSizeBarycenter(baryMergeTree, trees); ftm::cleanMergeTree(baryMergeTree); + + std::cout + << baryMergeTree.tree.template printPairsFromTree(true).str() + << std::endl; } template diff --git a/core/base/mergeTreeClustering/MergeTreeDistance.h b/core/base/mergeTreeClustering/MergeTreeDistance.h index 0ce6bb929f..c396b6a95f 100644 --- a/core/base/mergeTreeClustering/MergeTreeDistance.h +++ b/core/base/mergeTreeClustering/MergeTreeDistance.h @@ -205,8 +205,8 @@ namespace ttk { template dataType forestAssignmentProblem( - ftm::FTMTree_MT *ttkNotUsed(tree1), - ftm::FTMTree_MT *ttkNotUsed(tree2), + ftm::FTMTree_MT *tree1, + ftm::FTMTree_MT *tree2, std::vector> &treeTable, std::vector &children1, std::vector &children2, @@ -217,6 +217,31 @@ namespace ttk { nRows + 1, std::vector(nCols + 1)); createCostMatrix(treeTable, children1, children2, costMatrix); + bool found = false; + std::stringstream ss; + ss << "===========================================================" + "====================" + << std::endl; + for(unsigned int i = 0; i < costMatrix.size(); ++i) { + if(children1[i] != 463 and children1[i] != 485) + continue; + ss << children1[i] << " : (" << tree1->getValue(i) << ", " + << tree1->getValue(tree1->getNode(i)->getOrigin()) << ")" + << std::endl; + found = true; + for(unsigned int j = 0; j < costMatrix[i].size(); ++j) + if(children2[j] != 237 and children2[j] != 229) { + continue; + ss << children2[j] << " : (" << tree2->getValue(j) << ", " + << tree2->getValue(tree1->getNode(j)->getOrigin()) + << ")" << std::endl; + ss << costMatrix[i][j] << " "; + } + ss << std::endl; + } + if(found) + std::cout << ss.str(); + // assignmentProblemSize[costMatrix.size()*costMatrix[0].size()]++; // --- Solve assignment problem From fe9bf94175c07378245abc953bffb8856d8ed561 Mon Sep 17 00:00:00 2001 From: MatPont Date: Tue, 2 Jul 2024 15:36:11 +0200 Subject: [PATCH 04/20] [MergeTree] debug messages --- .../mergeTreeClustering/MergeTreeDistance.h | 24 +++++++++++-------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/core/base/mergeTreeClustering/MergeTreeDistance.h b/core/base/mergeTreeClustering/MergeTreeDistance.h index c396b6a95f..4d62783c5e 100644 --- a/core/base/mergeTreeClustering/MergeTreeDistance.h +++ b/core/base/mergeTreeClustering/MergeTreeDistance.h @@ -225,18 +225,22 @@ namespace ttk { for(unsigned int i = 0; i < costMatrix.size(); ++i) { if(children1[i] != 463 and children1[i] != 485) continue; - ss << children1[i] << " : (" << tree1->getValue(i) << ", " - << tree1->getValue(tree1->getNode(i)->getOrigin()) << ")" - << std::endl; + ss << children1[i] << " : (" << tree1->getValue(children1[i]) + << ", " + << tree1->getValue( + tree1->getNode(children1[i])->getOrigin()) + << ")" << std::endl; found = true; - for(unsigned int j = 0; j < costMatrix[i].size(); ++j) - if(children2[j] != 237 and children2[j] != 229) { + for(unsigned int j = 0; j < costMatrix[i].size(); ++j) { + if(children2[j] != 237 and children2[j] != 229) continue; - ss << children2[j] << " : (" << tree2->getValue(j) << ", " - << tree2->getValue(tree1->getNode(j)->getOrigin()) - << ")" << std::endl; - ss << costMatrix[i][j] << " "; - } + ss << children2[j] << " : (" + << tree2->getValue(children2[j]) << ", " + << tree2->getValue( + tree2->getNode(children2[j])->getOrigin()) + << ")" << std::endl; + ss << costMatrix[i][j] << std::endl; + } ss << std::endl; } if(found) From d4b25c16ebf8b9d34c8a36a875ecab795faf977f Mon Sep 17 00:00:00 2001 From: MatPont Date: Wed, 14 Aug 2024 13:29:46 +0200 Subject: [PATCH 05/20] [MergeTree] remove some debug messages --- .../mergeTreeClustering/MergeTreeDistance.h | 33 ++----------------- 1 file changed, 2 insertions(+), 31 deletions(-) diff --git a/core/base/mergeTreeClustering/MergeTreeDistance.h b/core/base/mergeTreeClustering/MergeTreeDistance.h index 4d62783c5e..0ce6bb929f 100644 --- a/core/base/mergeTreeClustering/MergeTreeDistance.h +++ b/core/base/mergeTreeClustering/MergeTreeDistance.h @@ -205,8 +205,8 @@ namespace ttk { template dataType forestAssignmentProblem( - ftm::FTMTree_MT *tree1, - ftm::FTMTree_MT *tree2, + ftm::FTMTree_MT *ttkNotUsed(tree1), + ftm::FTMTree_MT *ttkNotUsed(tree2), std::vector> &treeTable, std::vector &children1, std::vector &children2, @@ -217,35 +217,6 @@ namespace ttk { nRows + 1, std::vector(nCols + 1)); createCostMatrix(treeTable, children1, children2, costMatrix); - bool found = false; - std::stringstream ss; - ss << "===========================================================" - "====================" - << std::endl; - for(unsigned int i = 0; i < costMatrix.size(); ++i) { - if(children1[i] != 463 and children1[i] != 485) - continue; - ss << children1[i] << " : (" << tree1->getValue(children1[i]) - << ", " - << tree1->getValue( - tree1->getNode(children1[i])->getOrigin()) - << ")" << std::endl; - found = true; - for(unsigned int j = 0; j < costMatrix[i].size(); ++j) { - if(children2[j] != 237 and children2[j] != 229) - continue; - ss << children2[j] << " : (" - << tree2->getValue(children2[j]) << ", " - << tree2->getValue( - tree2->getNode(children2[j])->getOrigin()) - << ")" << std::endl; - ss << costMatrix[i][j] << std::endl; - } - ss << std::endl; - } - if(found) - std::cout << ss.str(); - // assignmentProblemSize[costMatrix.size()*costMatrix[0].size()]++; // --- Solve assignment problem From f3a1e80cad2eebd3da1d621f8a8db6c50c8b1fe3 Mon Sep 17 00:00:00 2001 From: MatPont Date: Wed, 14 Aug 2024 13:41:24 +0200 Subject: [PATCH 06/20] [MergeTree] debug messages --- .../base/mergeTreeClustering/MergeTreeBarycenter.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/core/base/mergeTreeClustering/MergeTreeBarycenter.h b/core/base/mergeTreeClustering/MergeTreeBarycenter.h index 54a4f647f7..a51282e87e 100644 --- a/core/base/mergeTreeClustering/MergeTreeBarycenter.h +++ b/core/base/mergeTreeClustering/MergeTreeBarycenter.h @@ -693,10 +693,24 @@ namespace ttk { setTreeScalars(baryMergeTree, newScalarsVector); + std::cout + << baryMergeTree.tree.template printPairsFromTree(true).str() + << std::endl; + std::vector deletedNodesT; persistenceThresholding( &(baryMergeTree.tree), 0, deletedNodesT); + + std::cout + << baryMergeTree.tree.template printPairsFromTree(true).str() + << std::endl; + limitSizeBarycenter(baryMergeTree, trees); + + std::cout + << baryMergeTree.tree.template printPairsFromTree(true).str() + << std::endl; + ftm::cleanMergeTree(baryMergeTree); std::cout From 15c7f7a67b710b70cad173a5e19b6eb526b8631a Mon Sep 17 00:00:00 2001 From: MatPont Date: Wed, 21 Aug 2024 13:51:54 +0200 Subject: [PATCH 07/20] [MergeTree] debug messages --- core/base/ftmTree/FTMTreeUtils.h | 15 +++++++++++++++ .../mergeTreeClustering/MergeTreeBarycenter.h | 8 ++++++++ 2 files changed, 23 insertions(+) diff --git a/core/base/ftmTree/FTMTreeUtils.h b/core/base/ftmTree/FTMTreeUtils.h index f3dacda04e..594019999a 100644 --- a/core/base/ftmTree/FTMTreeUtils.h +++ b/core/base/ftmTree/FTMTreeUtils.h @@ -143,8 +143,23 @@ namespace ttk { std::vector &scalarsVector) { mergeTree.scalarsValues = std::make_shared>(scalarsVector); + + std::cout << std::endl << "before void *" << std::endl; + for(unsigned int i = 0; i < mergeTree.scalarsValues->size(); ++i) + std::cout << (*mergeTree.scalarsValues)[i] << std::endl; + mergeTree.scalars->values = (void *)(mergeTree.scalarsValues->data()); mergeTree.scalars->size = mergeTree.scalarsValues->size(); + + std::cout << std::endl << "after void *" << std::endl; + for(unsigned int i = 0; i < mergeTree.scalarsValues->size(); ++i) + std::cout << static_cast(mergeTree.scalars->values)[i] + << std::endl; + + auto temp = static_cast(mergeTree.scalarsValues->data()); + std::cout << std::endl << "after temp" << std::endl; + for(unsigned int i = 0; i < mergeTree.scalarsValues->size(); ++i) + std::cout << static_cast(temp)[i] << std::endl; } template diff --git a/core/base/mergeTreeClustering/MergeTreeBarycenter.h b/core/base/mergeTreeClustering/MergeTreeBarycenter.h index a51282e87e..da3e0129c6 100644 --- a/core/base/mergeTreeClustering/MergeTreeBarycenter.h +++ b/core/base/mergeTreeClustering/MergeTreeBarycenter.h @@ -691,8 +691,13 @@ namespace ttk { newScalarsVector[mergedRootOrigin] = mergedRootOriginScalar; } + std::cout << std::endl << "before setTreeScalars" << std::endl; + for(unsigned int i = 0; i < newScalarsVector.size(); ++i) + std::cout << newScalarsVector[i] << std::endl; + setTreeScalars(baryMergeTree, newScalarsVector); + std::cout << std::endl << "before persistenceThresholding" << std::endl; std::cout << baryMergeTree.tree.template printPairsFromTree(true).str() << std::endl; @@ -701,18 +706,21 @@ namespace ttk { persistenceThresholding( &(baryMergeTree.tree), 0, deletedNodesT); + std::cout << std::endl << "before limitSizeBarycenter" << std::endl; std::cout << baryMergeTree.tree.template printPairsFromTree(true).str() << std::endl; limitSizeBarycenter(baryMergeTree, trees); + std::cout << std::endl << "before cleanMergeTree" << std::endl; std::cout << baryMergeTree.tree.template printPairsFromTree(true).str() << std::endl; ftm::cleanMergeTree(baryMergeTree); + std::cout << std::endl << "after cleanMergeTree" << std::endl; std::cout << baryMergeTree.tree.template printPairsFromTree(true).str() << std::endl; From 39e87490a54c533ad97c60611590bc271b8686b2 Mon Sep 17 00:00:00 2001 From: MatPont Date: Wed, 21 Aug 2024 14:50:49 +0200 Subject: [PATCH 08/20] [MergeTree] debug messages --- core/base/ftmTree/FTMTreeUtils.h | 29 +++++++++++-------- .../mergeTreeClustering/MergeTreeBarycenter.h | 5 +++- 2 files changed, 21 insertions(+), 13 deletions(-) diff --git a/core/base/ftmTree/FTMTreeUtils.h b/core/base/ftmTree/FTMTreeUtils.h index 594019999a..4c4c7f208b 100644 --- a/core/base/ftmTree/FTMTreeUtils.h +++ b/core/base/ftmTree/FTMTreeUtils.h @@ -140,26 +140,31 @@ namespace ttk { template void setTreeScalars(MergeTree &mergeTree, - std::vector &scalarsVector) { + std::vector &scalarsVector, + bool debug = false) { mergeTree.scalarsValues = std::make_shared>(scalarsVector); - std::cout << std::endl << "before void *" << std::endl; - for(unsigned int i = 0; i < mergeTree.scalarsValues->size(); ++i) - std::cout << (*mergeTree.scalarsValues)[i] << std::endl; + if(debug) { + std::cout << std::endl << "before void *" << std::endl; + for(unsigned int i = 0; i < mergeTree.scalarsValues->size(); ++i) + std::cout << (*mergeTree.scalarsValues)[i] << std::endl; + } mergeTree.scalars->values = (void *)(mergeTree.scalarsValues->data()); mergeTree.scalars->size = mergeTree.scalarsValues->size(); - std::cout << std::endl << "after void *" << std::endl; - for(unsigned int i = 0; i < mergeTree.scalarsValues->size(); ++i) - std::cout << static_cast(mergeTree.scalars->values)[i] - << std::endl; + if(debug) { + std::cout << std::endl << "after void *" << std::endl; + for(unsigned int i = 0; i < mergeTree.scalarsValues->size(); ++i) + std::cout << static_cast(mergeTree.scalars->values)[i] + << std::endl; - auto temp = static_cast(mergeTree.scalarsValues->data()); - std::cout << std::endl << "after temp" << std::endl; - for(unsigned int i = 0; i < mergeTree.scalarsValues->size(); ++i) - std::cout << static_cast(temp)[i] << std::endl; + auto temp = static_cast(mergeTree.scalarsValues->data()); + std::cout << std::endl << "after temp" << std::endl; + for(unsigned int i = 0; i < mergeTree.scalarsValues->size(); ++i) + std::cout << static_cast(temp)[i] << std::endl; + } } template diff --git a/core/base/mergeTreeClustering/MergeTreeBarycenter.h b/core/base/mergeTreeClustering/MergeTreeBarycenter.h index da3e0129c6..3e5dd3716d 100644 --- a/core/base/mergeTreeClustering/MergeTreeBarycenter.h +++ b/core/base/mergeTreeClustering/MergeTreeBarycenter.h @@ -609,6 +609,9 @@ namespace ttk { unsigned int indexAddedNodes, std::vector>> &matchings) { + + std::cout << std::setprecision(15) << std::endl; + ftm::FTMTree_MT *baryTree = &(baryMergeTree.tree); bool const isJT = baryTree->isJoinTree(); @@ -695,7 +698,7 @@ namespace ttk { for(unsigned int i = 0; i < newScalarsVector.size(); ++i) std::cout << newScalarsVector[i] << std::endl; - setTreeScalars(baryMergeTree, newScalarsVector); + setTreeScalars(baryMergeTree, newScalarsVector, true); std::cout << std::endl << "before persistenceThresholding" << std::endl; std::cout From bdc8bc6f5e5a71ede637403cf6a40604e507eb66 Mon Sep 17 00:00:00 2001 From: MatPont Date: Wed, 21 Aug 2024 18:05:06 +0200 Subject: [PATCH 09/20] [MergeTree] debug messages --- core/base/ftmTree/FTMTreeUtils.h | 22 +-------- .../mergeTreeClustering/MergeTreeBarycenter.h | 49 +++++++++++-------- 2 files changed, 30 insertions(+), 41 deletions(-) diff --git a/core/base/ftmTree/FTMTreeUtils.h b/core/base/ftmTree/FTMTreeUtils.h index 4c4c7f208b..f3dacda04e 100644 --- a/core/base/ftmTree/FTMTreeUtils.h +++ b/core/base/ftmTree/FTMTreeUtils.h @@ -140,31 +140,11 @@ namespace ttk { template void setTreeScalars(MergeTree &mergeTree, - std::vector &scalarsVector, - bool debug = false) { + std::vector &scalarsVector) { mergeTree.scalarsValues = std::make_shared>(scalarsVector); - - if(debug) { - std::cout << std::endl << "before void *" << std::endl; - for(unsigned int i = 0; i < mergeTree.scalarsValues->size(); ++i) - std::cout << (*mergeTree.scalarsValues)[i] << std::endl; - } - mergeTree.scalars->values = (void *)(mergeTree.scalarsValues->data()); mergeTree.scalars->size = mergeTree.scalarsValues->size(); - - if(debug) { - std::cout << std::endl << "after void *" << std::endl; - for(unsigned int i = 0; i < mergeTree.scalarsValues->size(); ++i) - std::cout << static_cast(mergeTree.scalars->values)[i] - << std::endl; - - auto temp = static_cast(mergeTree.scalarsValues->data()); - std::cout << std::endl << "after temp" << std::endl; - for(unsigned int i = 0; i < mergeTree.scalarsValues->size(); ++i) - std::cout << static_cast(temp)[i] << std::endl; - } } template diff --git a/core/base/mergeTreeClustering/MergeTreeBarycenter.h b/core/base/mergeTreeClustering/MergeTreeBarycenter.h index 3e5dd3716d..513c016115 100644 --- a/core/base/mergeTreeClustering/MergeTreeBarycenter.h +++ b/core/base/mergeTreeClustering/MergeTreeBarycenter.h @@ -548,6 +548,9 @@ namespace ttk { } double const projec = (tempBirth + tempDeath) / 2; + std::stringstream ss, ss2; + ss.precision(64); + ss2.precision(64); // Compute newBirth and newDeath for(unsigned int i = 0; i < trees.size(); ++i) { double iBirth = projec, iDeath = projec; @@ -560,7 +563,19 @@ namespace ttk { } newBirth += alphas[i] * iBirth; newDeath += alphas[i] * iDeath; + + ss << iBirth << " + "; + ss2 << iDeath << " + "; } + + printMsg(ss.str(), debug::Priority::INFO); + std::cout << newBirth << std::endl; + printMsg(ss2.str(), debug::Priority::INFO); + std::cout << newDeath << std::endl; + + std::cout << static_cast(newBirth) << std::endl; + std::cout << static_cast(newDeath) << std::endl; + if(normalizedWasserstein_) { newBirth = newBirth * (mu_max - mu_min) + mu_min; newDeath = newDeath * (mu_max - mu_min) + mu_min; @@ -639,9 +654,19 @@ namespace ttk { std::queue queue; queue.emplace(root); while(!queue.empty()) { + std::stringstream ss; + ftm::idNode const node = queue.front(); queue.pop(); std::tuple newBirthDeath; + + ss << "================================================================" + "===============" + << std::endl + << node; + printMsg(ss.str(), debug::Priority::INFO); + ss.str(""); + if(node < indexAddedNodes) { newBirthDeath = interpolation(baryMergeTree, node, newScalarsVector, @@ -665,7 +690,9 @@ namespace ttk { queue.emplace(child); // Print - std::stringstream ss; + std::cout << std::get<0>(newBirthDeath) << std::endl; + std::cout << std::get<1>(newBirthDeath) << std::endl; + ss.precision(64); ss << node << " : (" << baryTree->getValue(node) << ", " << baryTree->getValue(baryTree->getNode(node)->getOrigin()) << ") -> (" << nodeScalar << ", " << nodeOriginScalar << ")"; @@ -698,32 +725,14 @@ namespace ttk { for(unsigned int i = 0; i < newScalarsVector.size(); ++i) std::cout << newScalarsVector[i] << std::endl; - setTreeScalars(baryMergeTree, newScalarsVector, true); - - std::cout << std::endl << "before persistenceThresholding" << std::endl; - std::cout - << baryMergeTree.tree.template printPairsFromTree(true).str() - << std::endl; + setTreeScalars(baryMergeTree, newScalarsVector); std::vector deletedNodesT; persistenceThresholding( &(baryMergeTree.tree), 0, deletedNodesT); - - std::cout << std::endl << "before limitSizeBarycenter" << std::endl; - std::cout - << baryMergeTree.tree.template printPairsFromTree(true).str() - << std::endl; - limitSizeBarycenter(baryMergeTree, trees); - - std::cout << std::endl << "before cleanMergeTree" << std::endl; - std::cout - << baryMergeTree.tree.template printPairsFromTree(true).str() - << std::endl; - ftm::cleanMergeTree(baryMergeTree); - std::cout << std::endl << "after cleanMergeTree" << std::endl; std::cout << baryMergeTree.tree.template printPairsFromTree(true).str() << std::endl; From 327945a66bef3edb9dd5518d632e116aeb48dc70 Mon Sep 17 00:00:00 2001 From: MatPont Date: Fri, 23 Aug 2024 17:36:41 +0200 Subject: [PATCH 10/20] [MergeTree] first barycenter fix attempt --- .../mergeTreeClustering/MergeTreeBarycenter.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/core/base/mergeTreeClustering/MergeTreeBarycenter.h b/core/base/mergeTreeClustering/MergeTreeBarycenter.h index 513c016115..f24dec06ae 100644 --- a/core/base/mergeTreeClustering/MergeTreeBarycenter.h +++ b/core/base/mergeTreeClustering/MergeTreeBarycenter.h @@ -526,10 +526,10 @@ namespace ttk { baryTree, nodeId, newScalarsVector, false); dataType mu_min = getMinMaxLocalFromVector( baryTree, nodeId, newScalarsVector); - double newBirth = 0, newDeath = 0; + dataType newBirth = 0, newDeath = 0; // Compute projection - double tempBirth = 0, tempDeath = 0; + dataType tempBirth = 0, tempDeath = 0; double alphaSum = 0; for(unsigned int i = 0; i < trees.size(); ++i) if(nodes[i] != std::numeric_limits::max()) @@ -539,21 +539,21 @@ namespace ttk { if(nodes[i] != std::numeric_limits::max()) { auto iBirthDeath = getParametrizedBirthDeath(trees[i], nodes[i]); - double tTempBirth = 0, tTempDeath = 0; + dataType tTempBirth = 0, tTempDeath = 0; tTempBirth += std::get<0>(iBirthDeath); tTempDeath += std::get<1>(iBirthDeath); tempBirth += tTempBirth * alphas[i] / alphaSum; tempDeath += tTempDeath * alphas[i] / alphaSum; } } - double const projec = (tempBirth + tempDeath) / 2; + dataType const projec = (tempBirth + tempDeath) / 2; std::stringstream ss, ss2; ss.precision(64); ss2.precision(64); // Compute newBirth and newDeath for(unsigned int i = 0; i < trees.size(); ++i) { - double iBirth = projec, iDeath = projec; + dataType iBirth = projec, iDeath = projec; // if node is matched in trees[i] if(nodes[i] != std::numeric_limits::max()) { auto iBirthDeath @@ -599,9 +599,9 @@ namespace ttk { = getMinMaxLocalFromVector(baryTree, nodeB, newScalarsVector); auto birthDeath = getParametrizedBirthDeath(tree, nodeId); - double newBirth = std::get<0>(birthDeath); - double newDeath = std::get<1>(birthDeath); - double const projec = (newBirth + newDeath) / 2; + dataType newBirth = std::get<0>(birthDeath); + dataType newDeath = std::get<1>(birthDeath); + dataType const projec = (newBirth + newDeath) / 2; newBirth = alpha * newBirth + (1 - alpha) * projec; newDeath = alpha * newDeath + (1 - alpha) * projec; From 7b9a82043bb0a12f410428f156a1bfb8d0f0c41f Mon Sep 17 00:00:00 2001 From: MatPont Date: Thu, 29 Aug 2024 13:15:12 +0200 Subject: [PATCH 11/20] [MergeTreeBarycenter] remove debug messages --- .../mergeTreeClustering/MergeTreeBarycenter.h | 60 ------------------- 1 file changed, 60 deletions(-) diff --git a/core/base/mergeTreeClustering/MergeTreeBarycenter.h b/core/base/mergeTreeClustering/MergeTreeBarycenter.h index f24dec06ae..5d5891e527 100644 --- a/core/base/mergeTreeClustering/MergeTreeBarycenter.h +++ b/core/base/mergeTreeClustering/MergeTreeBarycenter.h @@ -563,19 +563,7 @@ namespace ttk { } newBirth += alphas[i] * iBirth; newDeath += alphas[i] * iDeath; - - ss << iBirth << " + "; - ss2 << iDeath << " + "; } - - printMsg(ss.str(), debug::Priority::INFO); - std::cout << newBirth << std::endl; - printMsg(ss2.str(), debug::Priority::INFO); - std::cout << newDeath << std::endl; - - std::cout << static_cast(newBirth) << std::endl; - std::cout << static_cast(newDeath) << std::endl; - if(normalizedWasserstein_) { newBirth = newBirth * (mu_max - mu_min) + mu_min; newDeath = newDeath * (mu_max - mu_min) + mu_min; @@ -624,9 +612,6 @@ namespace ttk { unsigned int indexAddedNodes, std::vector>> &matchings) { - - std::cout << std::setprecision(15) << std::endl; - ftm::FTMTree_MT *baryTree = &(baryMergeTree.tree); bool const isJT = baryTree->isJoinTree(); @@ -654,19 +639,9 @@ namespace ttk { std::queue queue; queue.emplace(root); while(!queue.empty()) { - std::stringstream ss; - ftm::idNode const node = queue.front(); queue.pop(); std::tuple newBirthDeath; - - ss << "================================================================" - "===============" - << std::endl - << node; - printMsg(ss.str(), debug::Priority::INFO); - ss.str(""); - if(node < indexAddedNodes) { newBirthDeath = interpolation(baryMergeTree, node, newScalarsVector, @@ -688,27 +663,6 @@ namespace ttk { baryTree->getChildren(node, children); for(auto child : children) queue.emplace(child); - - // Print - std::cout << std::get<0>(newBirthDeath) << std::endl; - std::cout << std::get<1>(newBirthDeath) << std::endl; - ss.precision(64); - ss << node << " : (" << baryTree->getValue(node) << ", " - << baryTree->getValue(baryTree->getNode(node)->getOrigin()) - << ") -> (" << nodeScalar << ", " << nodeOriginScalar << ")"; - printMsg(ss.str(), debug::Priority::INFO); - ss.str(""); - ss << " - "; - for(unsigned int i = 0; i < baryMatching[node].size(); ++i) { - if(baryMatching[node][i] != std::numeric_limits::max()) { - auto birthDeath = getParametrizedBirthDeath( - trees[i], baryMatching[node][i]); - ss << i << "_" << baryMatching[node][i] << " (" - << std::get<0>(birthDeath) << ", " << std::get<1>(birthDeath) - << ") ; "; - } - } - printMsg(ss.str(), debug::Priority::INFO); } if(baryMergeTree.tree.isFullMerge()) { @@ -721,10 +675,6 @@ namespace ttk { newScalarsVector[mergedRootOrigin] = mergedRootOriginScalar; } - std::cout << std::endl << "before setTreeScalars" << std::endl; - for(unsigned int i = 0; i < newScalarsVector.size(); ++i) - std::cout << newScalarsVector[i] << std::endl; - setTreeScalars(baryMergeTree, newScalarsVector); std::vector deletedNodesT; @@ -732,10 +682,6 @@ namespace ttk { &(baryMergeTree.tree), 0, deletedNodesT); limitSizeBarycenter(baryMergeTree, trees); ftm::cleanMergeTree(baryMergeTree); - - std::cout - << baryMergeTree.tree.template printPairsFromTree(true).str() - << std::endl; } template @@ -857,12 +803,6 @@ namespace ttk { #ifdef TTK_ENABLE_OPENMP4 } // pragma omp parallel #endif - for(unsigned int i = 0; i < distances.size(); ++i) { - std::stringstream ss; - ss << i << " : distance=" << distances[i] << " (" - << distances[i] * distances[i] << ")"; - printMsg(ss.str(), debug::Priority::INFO); - } } template From 24a2b7b675ee1c0311af51369694b836f4e17627 Mon Sep 17 00:00:00 2001 From: MatPont Date: Thu, 29 Aug 2024 14:32:11 +0200 Subject: [PATCH 12/20] [MergeTreeBarycenter] remove debug messages --- core/base/mergeTreeClustering/MergeTreeBarycenter.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/core/base/mergeTreeClustering/MergeTreeBarycenter.h b/core/base/mergeTreeClustering/MergeTreeBarycenter.h index 5d5891e527..e014add590 100644 --- a/core/base/mergeTreeClustering/MergeTreeBarycenter.h +++ b/core/base/mergeTreeClustering/MergeTreeBarycenter.h @@ -548,9 +548,6 @@ namespace ttk { } dataType const projec = (tempBirth + tempDeath) / 2; - std::stringstream ss, ss2; - ss.precision(64); - ss2.precision(64); // Compute newBirth and newDeath for(unsigned int i = 0; i < trees.size(); ++i) { dataType iBirth = projec, iDeath = projec; From 29e819f8895189b94bded8d7d0b5a55922d808ea Mon Sep 17 00:00:00 2001 From: MatPont Date: Thu, 29 Aug 2024 17:57:29 +0200 Subject: [PATCH 13/20] [MergeTreeBarycenter] remove double to template function --- .../mergeTreeClustering/MergeTreeBarycenter.h | 2 +- .../base/mergeTreeClustering/MergeTreeUtils.h | 20 ------------------- 2 files changed, 1 insertion(+), 21 deletions(-) diff --git a/core/base/mergeTreeClustering/MergeTreeBarycenter.h b/core/base/mergeTreeClustering/MergeTreeBarycenter.h index e014add590..3ae2978013 100644 --- a/core/base/mergeTreeClustering/MergeTreeBarycenter.h +++ b/core/base/mergeTreeClustering/MergeTreeBarycenter.h @@ -506,7 +506,7 @@ namespace ttk { std::tuple birthDeath; // Normalized Wasserstein if(normalizedWasserstein_) - birthDeath = getNormalizedBirthDeathDouble(tree1, nodeId1); + birthDeath = getNormalizedBirthDeath(tree1, nodeId1); // Classical Wasserstein else birthDeath = tree1->getBirthDeath(nodeId1); diff --git a/core/base/mergeTreeClustering/MergeTreeUtils.h b/core/base/mergeTreeClustering/MergeTreeUtils.h index b1ae2d28bd..56d97b19e2 100644 --- a/core/base/mergeTreeClustering/MergeTreeUtils.h +++ b/core/base/mergeTreeClustering/MergeTreeUtils.h @@ -60,26 +60,6 @@ namespace ttk { return std::make_tuple(min, max); } - template - std::tuple - getNormalizedBirthDeathDouble(ftm::FTMTree_MT *tree, - ftm::idNode nodeId, - dataType newMin = 0.0, - dataType newMax = 1.0) { - auto birthDeath = tree->getBirthDeath(nodeId); - double birth = std::get<0>(birthDeath); - double death = std::get<1>(birthDeath); - dataType shiftMin = getMinMaxLocal(tree, nodeId); - dataType shiftMax = getMinMaxLocal(tree, nodeId, false); - if((shiftMax - shiftMin) == 0) - return std::make_tuple(0, 0); - birth = (newMax - newMin) * (birth - shiftMin) - / (shiftMax - shiftMin); // + newMin; - death = (newMax - newMin) * (death - shiftMin) - / (shiftMax - shiftMin); // + newMin; - return std::make_tuple(birth, death); - } - template std::tuple getNormalizedBirthDeath(ftm::FTMTree_MT *tree, ftm::idNode nodeId, From bbeabb3707bd47cdf10e2ad05a0397b798e40a04 Mon Sep 17 00:00:00 2001 From: MatPont Date: Thu, 29 Aug 2024 18:27:09 +0200 Subject: [PATCH 14/20] Revert "[MergeTreeBarycenter] remove debug messages" This reverts commit 24a2b7b675ee1c0311af51369694b836f4e17627. Revert "[MergeTreeBarycenter] remove debug messages" This reverts commit 7b9a82043bb0a12f410428f156a1bfb8d0f0c41f. --- .../mergeTreeClustering/MergeTreeBarycenter.h | 63 +++++++++++++++++++ 1 file changed, 63 insertions(+) diff --git a/core/base/mergeTreeClustering/MergeTreeBarycenter.h b/core/base/mergeTreeClustering/MergeTreeBarycenter.h index 3ae2978013..1414ae6333 100644 --- a/core/base/mergeTreeClustering/MergeTreeBarycenter.h +++ b/core/base/mergeTreeClustering/MergeTreeBarycenter.h @@ -548,6 +548,9 @@ namespace ttk { } dataType const projec = (tempBirth + tempDeath) / 2; + std::stringstream ss, ss2; + ss.precision(64); + ss2.precision(64); // Compute newBirth and newDeath for(unsigned int i = 0; i < trees.size(); ++i) { dataType iBirth = projec, iDeath = projec; @@ -560,7 +563,19 @@ namespace ttk { } newBirth += alphas[i] * iBirth; newDeath += alphas[i] * iDeath; + + ss << iBirth << " + "; + ss2 << iDeath << " + "; } + + printMsg(ss.str(), debug::Priority::INFO); + std::cout << newBirth << std::endl; + printMsg(ss2.str(), debug::Priority::INFO); + std::cout << newDeath << std::endl; + + std::cout << static_cast(newBirth) << std::endl; + std::cout << static_cast(newDeath) << std::endl; + if(normalizedWasserstein_) { newBirth = newBirth * (mu_max - mu_min) + mu_min; newDeath = newDeath * (mu_max - mu_min) + mu_min; @@ -609,6 +624,9 @@ namespace ttk { unsigned int indexAddedNodes, std::vector>> &matchings) { + + std::cout << std::setprecision(15) << std::endl; + ftm::FTMTree_MT *baryTree = &(baryMergeTree.tree); bool const isJT = baryTree->isJoinTree(); @@ -636,9 +654,19 @@ namespace ttk { std::queue queue; queue.emplace(root); while(!queue.empty()) { + std::stringstream ss; + ftm::idNode const node = queue.front(); queue.pop(); std::tuple newBirthDeath; + + ss << "================================================================" + "===============" + << std::endl + << node; + printMsg(ss.str(), debug::Priority::INFO); + ss.str(""); + if(node < indexAddedNodes) { newBirthDeath = interpolation(baryMergeTree, node, newScalarsVector, @@ -660,6 +688,27 @@ namespace ttk { baryTree->getChildren(node, children); for(auto child : children) queue.emplace(child); + + // Print + std::cout << std::get<0>(newBirthDeath) << std::endl; + std::cout << std::get<1>(newBirthDeath) << std::endl; + ss.precision(64); + ss << node << " : (" << baryTree->getValue(node) << ", " + << baryTree->getValue(baryTree->getNode(node)->getOrigin()) + << ") -> (" << nodeScalar << ", " << nodeOriginScalar << ")"; + printMsg(ss.str(), debug::Priority::INFO); + ss.str(""); + ss << " - "; + for(unsigned int i = 0; i < baryMatching[node].size(); ++i) { + if(baryMatching[node][i] != std::numeric_limits::max()) { + auto birthDeath = getParametrizedBirthDeath( + trees[i], baryMatching[node][i]); + ss << i << "_" << baryMatching[node][i] << " (" + << std::get<0>(birthDeath) << ", " << std::get<1>(birthDeath) + << ") ; "; + } + } + printMsg(ss.str(), debug::Priority::INFO); } if(baryMergeTree.tree.isFullMerge()) { @@ -672,6 +721,10 @@ namespace ttk { newScalarsVector[mergedRootOrigin] = mergedRootOriginScalar; } + std::cout << std::endl << "before setTreeScalars" << std::endl; + for(unsigned int i = 0; i < newScalarsVector.size(); ++i) + std::cout << newScalarsVector[i] << std::endl; + setTreeScalars(baryMergeTree, newScalarsVector); std::vector deletedNodesT; @@ -679,6 +732,10 @@ namespace ttk { &(baryMergeTree.tree), 0, deletedNodesT); limitSizeBarycenter(baryMergeTree, trees); ftm::cleanMergeTree(baryMergeTree); + + std::cout + << baryMergeTree.tree.template printPairsFromTree(true).str() + << std::endl; } template @@ -800,6 +857,12 @@ namespace ttk { #ifdef TTK_ENABLE_OPENMP4 } // pragma omp parallel #endif + for(unsigned int i = 0; i < distances.size(); ++i) { + std::stringstream ss; + ss << i << " : distance=" << distances[i] << " (" + << distances[i] * distances[i] << ")"; + printMsg(ss.str(), debug::Priority::INFO); + } } template From 7e3bd1399dc99936d08ad1a05acabb1b41b4ab6d Mon Sep 17 00:00:00 2001 From: MatPont Date: Fri, 30 Aug 2024 09:45:59 +0200 Subject: [PATCH 15/20] [MergeTreeBarycenter] debug messages --- core/base/mergeTreeClustering/MergeTreeBarycenter.h | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/core/base/mergeTreeClustering/MergeTreeBarycenter.h b/core/base/mergeTreeClustering/MergeTreeBarycenter.h index 1414ae6333..ef7d50adee 100644 --- a/core/base/mergeTreeClustering/MergeTreeBarycenter.h +++ b/core/base/mergeTreeClustering/MergeTreeBarycenter.h @@ -569,17 +569,20 @@ namespace ttk { } printMsg(ss.str(), debug::Priority::INFO); - std::cout << newBirth << std::endl; printMsg(ss2.str(), debug::Priority::INFO); + std::cout << newBirth << std::endl; std::cout << newDeath << std::endl; - std::cout << static_cast(newBirth) << std::endl; - std::cout << static_cast(newDeath) << std::endl; - if(normalizedWasserstein_) { + std::cout << mu_max << std::endl; + std::cout << mu_min << std::endl; + std::cout << (mu_max - mu_min) << std::endl; newBirth = newBirth * (mu_max - mu_min) + mu_min; newDeath = newDeath * (mu_max - mu_min) + mu_min; } + + std::cout << newBirth << std::endl; + std::cout << newDeath << std::endl; return std::make_tuple(newBirth, newDeath); } From 53c0ded953a082f939b04e22dd0a3ad5a46c5bb3 Mon Sep 17 00:00:00 2001 From: MatPont Date: Fri, 30 Aug 2024 09:59:30 +0200 Subject: [PATCH 16/20] [MergeTreeBarycenter] debug messages --- core/base/mergeTreeClustering/MergeTreeBarycenter.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/core/base/mergeTreeClustering/MergeTreeBarycenter.h b/core/base/mergeTreeClustering/MergeTreeBarycenter.h index ef7d50adee..10961224c6 100644 --- a/core/base/mergeTreeClustering/MergeTreeBarycenter.h +++ b/core/base/mergeTreeClustering/MergeTreeBarycenter.h @@ -577,10 +577,12 @@ namespace ttk { std::cout << mu_max << std::endl; std::cout << mu_min << std::endl; std::cout << (mu_max - mu_min) << std::endl; + std::cout << newBirth * (mu_max - mu_min) << std::endl; + std::cout << newDeath * (mu_max - mu_min) << std::endl; newBirth = newBirth * (mu_max - mu_min) + mu_min; newDeath = newDeath * (mu_max - mu_min) + mu_min; } - + std::cout << newBirth << std::endl; std::cout << newDeath << std::endl; From 003752e6721ef1c0023063df8dfabd46a7e2aca5 Mon Sep 17 00:00:00 2001 From: MatPont Date: Fri, 30 Aug 2024 10:24:26 +0200 Subject: [PATCH 17/20] [MergeTreeBarycenter] debug --- core/base/mergeTreeClustering/MergeTreeBarycenter.h | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/core/base/mergeTreeClustering/MergeTreeBarycenter.h b/core/base/mergeTreeClustering/MergeTreeBarycenter.h index 10961224c6..d118fbed50 100644 --- a/core/base/mergeTreeClustering/MergeTreeBarycenter.h +++ b/core/base/mergeTreeClustering/MergeTreeBarycenter.h @@ -577,10 +577,11 @@ namespace ttk { std::cout << mu_max << std::endl; std::cout << mu_min << std::endl; std::cout << (mu_max - mu_min) << std::endl; - std::cout << newBirth * (mu_max - mu_min) << std::endl; - std::cout << newDeath * (mu_max - mu_min) << std::endl; - newBirth = newBirth * (mu_max - mu_min) + mu_min; - newDeath = newDeath * (mu_max - mu_min) + mu_min; + // std::cout << newBirth * (mu_max - mu_min) << std::endl; + // std::cout << newDeath * (mu_max - mu_min) << std::endl; + auto diff = (mu_max - mu_min); + newBirth = newBirth * diff + mu_min; + newDeath = newDeath * diff + mu_min; } std::cout << newBirth << std::endl; @@ -616,9 +617,7 @@ namespace ttk { newDeath = newDeath * (mu_max - mu_min) + mu_min; } - dataType newBirthT = newBirth; - dataType newDeathT = newDeath; - return std::make_tuple(newBirthT, newDeathT); + return std::make_tuple(newBirth, newDeath); } template From fd701c09093906ce605803e7ab8ab1d4ed4df90e Mon Sep 17 00:00:00 2001 From: MatPont Date: Fri, 30 Aug 2024 10:28:59 +0200 Subject: [PATCH 18/20] [MergeTreeBarycenter] debug --- core/base/mergeTreeClustering/MergeTreeBarycenter.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/core/base/mergeTreeClustering/MergeTreeBarycenter.h b/core/base/mergeTreeClustering/MergeTreeBarycenter.h index d118fbed50..8321201117 100644 --- a/core/base/mergeTreeClustering/MergeTreeBarycenter.h +++ b/core/base/mergeTreeClustering/MergeTreeBarycenter.h @@ -580,8 +580,10 @@ namespace ttk { // std::cout << newBirth * (mu_max - mu_min) << std::endl; // std::cout << newDeath * (mu_max - mu_min) << std::endl; auto diff = (mu_max - mu_min); - newBirth = newBirth * diff + mu_min; - newDeath = newDeath * diff + mu_min; + newBirth = newBirth * diff; + newBirth += mu_min; + newDeath = newDeath * diff; + newDeath += mu_min; } std::cout << newBirth << std::endl; From 872689b92fcbaa24f02f33d4201551e8654cacac Mon Sep 17 00:00:00 2001 From: MatPont Date: Fri, 30 Aug 2024 12:56:54 +0200 Subject: [PATCH 19/20] [MergeTreeBarycenter] remove debug messages --- .../mergeTreeClustering/MergeTreeBarycenter.h | 75 +------------------ 1 file changed, 2 insertions(+), 73 deletions(-) diff --git a/core/base/mergeTreeClustering/MergeTreeBarycenter.h b/core/base/mergeTreeClustering/MergeTreeBarycenter.h index 8321201117..6cf598f575 100644 --- a/core/base/mergeTreeClustering/MergeTreeBarycenter.h +++ b/core/base/mergeTreeClustering/MergeTreeBarycenter.h @@ -548,9 +548,6 @@ namespace ttk { } dataType const projec = (tempBirth + tempDeath) / 2; - std::stringstream ss, ss2; - ss.precision(64); - ss2.precision(64); // Compute newBirth and newDeath for(unsigned int i = 0; i < trees.size(); ++i) { dataType iBirth = projec, iDeath = projec; @@ -563,32 +560,12 @@ namespace ttk { } newBirth += alphas[i] * iBirth; newDeath += alphas[i] * iDeath; - - ss << iBirth << " + "; - ss2 << iDeath << " + "; } - - printMsg(ss.str(), debug::Priority::INFO); - printMsg(ss2.str(), debug::Priority::INFO); - std::cout << newBirth << std::endl; - std::cout << newDeath << std::endl; - if(normalizedWasserstein_) { - std::cout << mu_max << std::endl; - std::cout << mu_min << std::endl; - std::cout << (mu_max - mu_min) << std::endl; - // std::cout << newBirth * (mu_max - mu_min) << std::endl; - // std::cout << newDeath * (mu_max - mu_min) << std::endl; - auto diff = (mu_max - mu_min); - newBirth = newBirth * diff; - newBirth += mu_min; - newDeath = newDeath * diff; - newDeath += mu_min; + newBirth = newBirth * (mu_max - mu_min) + mu_min; + newDeath = newDeath * (mu_max - mu_min) + mu_min; } - std::cout << newBirth << std::endl; - std::cout << newDeath << std::endl; - return std::make_tuple(newBirth, newDeath); } @@ -630,9 +607,6 @@ namespace ttk { unsigned int indexAddedNodes, std::vector>> &matchings) { - - std::cout << std::setprecision(15) << std::endl; - ftm::FTMTree_MT *baryTree = &(baryMergeTree.tree); bool const isJT = baryTree->isJoinTree(); @@ -660,19 +634,9 @@ namespace ttk { std::queue queue; queue.emplace(root); while(!queue.empty()) { - std::stringstream ss; - ftm::idNode const node = queue.front(); queue.pop(); std::tuple newBirthDeath; - - ss << "================================================================" - "===============" - << std::endl - << node; - printMsg(ss.str(), debug::Priority::INFO); - ss.str(""); - if(node < indexAddedNodes) { newBirthDeath = interpolation(baryMergeTree, node, newScalarsVector, @@ -694,27 +658,6 @@ namespace ttk { baryTree->getChildren(node, children); for(auto child : children) queue.emplace(child); - - // Print - std::cout << std::get<0>(newBirthDeath) << std::endl; - std::cout << std::get<1>(newBirthDeath) << std::endl; - ss.precision(64); - ss << node << " : (" << baryTree->getValue(node) << ", " - << baryTree->getValue(baryTree->getNode(node)->getOrigin()) - << ") -> (" << nodeScalar << ", " << nodeOriginScalar << ")"; - printMsg(ss.str(), debug::Priority::INFO); - ss.str(""); - ss << " - "; - for(unsigned int i = 0; i < baryMatching[node].size(); ++i) { - if(baryMatching[node][i] != std::numeric_limits::max()) { - auto birthDeath = getParametrizedBirthDeath( - trees[i], baryMatching[node][i]); - ss << i << "_" << baryMatching[node][i] << " (" - << std::get<0>(birthDeath) << ", " << std::get<1>(birthDeath) - << ") ; "; - } - } - printMsg(ss.str(), debug::Priority::INFO); } if(baryMergeTree.tree.isFullMerge()) { @@ -727,10 +670,6 @@ namespace ttk { newScalarsVector[mergedRootOrigin] = mergedRootOriginScalar; } - std::cout << std::endl << "before setTreeScalars" << std::endl; - for(unsigned int i = 0; i < newScalarsVector.size(); ++i) - std::cout << newScalarsVector[i] << std::endl; - setTreeScalars(baryMergeTree, newScalarsVector); std::vector deletedNodesT; @@ -738,10 +677,6 @@ namespace ttk { &(baryMergeTree.tree), 0, deletedNodesT); limitSizeBarycenter(baryMergeTree, trees); ftm::cleanMergeTree(baryMergeTree); - - std::cout - << baryMergeTree.tree.template printPairsFromTree(true).str() - << std::endl; } template @@ -863,12 +798,6 @@ namespace ttk { #ifdef TTK_ENABLE_OPENMP4 } // pragma omp parallel #endif - for(unsigned int i = 0; i < distances.size(); ++i) { - std::stringstream ss; - ss << i << " : distance=" << distances[i] << " (" - << distances[i] * distances[i] << ")"; - printMsg(ss.str(), debug::Priority::INFO); - } } template From 569a8e2d8d03ad9b45d0e804a004e7c9f6360318 Mon Sep 17 00:00:00 2001 From: MatPont Date: Fri, 30 Aug 2024 13:29:14 +0200 Subject: [PATCH 20/20] [MergeTreeBarycenter] volatile update --- .../mergeTreeClustering/MergeTreeBarycenter.h | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/core/base/mergeTreeClustering/MergeTreeBarycenter.h b/core/base/mergeTreeClustering/MergeTreeBarycenter.h index 6cf598f575..f74f1f6a28 100644 --- a/core/base/mergeTreeClustering/MergeTreeBarycenter.h +++ b/core/base/mergeTreeClustering/MergeTreeBarycenter.h @@ -562,8 +562,12 @@ namespace ttk { newDeath += alphas[i] * iDeath; } if(normalizedWasserstein_) { - newBirth = newBirth * (mu_max - mu_min) + mu_min; - newDeath = newDeath * (mu_max - mu_min) + mu_min; + // Forbid compiler optimization to have same results on different + // computers + volatile dataType tempBirthT = newBirth * (mu_max - mu_min); + volatile dataType tempDeathT = newDeath * (mu_max - mu_min); + newBirth = tempBirthT + mu_min; + newDeath = tempDeathT + mu_min; } return std::make_tuple(newBirth, newDeath); @@ -592,8 +596,12 @@ namespace ttk { newDeath = alpha * newDeath + (1 - alpha) * projec; if(normalizedWasserstein_) { - newBirth = newBirth * (mu_max - mu_min) + mu_min; - newDeath = newDeath * (mu_max - mu_min) + mu_min; + // Forbid compiler optimization to have same results on different + // computers + volatile dataType tempBirthT = newBirth * (mu_max - mu_min); + volatile dataType tempDeathT = newDeath * (mu_max - mu_min); + newBirth = tempBirthT + mu_min; + newDeath = tempDeathT + mu_min; } return std::make_tuple(newBirth, newDeath);