diff --git a/gtsam/inference/ClusterTree-inst.h b/gtsam/inference/ClusterTree-inst.h index 13130bf2e..a94baaf6c 100644 --- a/gtsam/inference/ClusterTree-inst.h +++ b/gtsam/inference/ClusterTree-inst.h @@ -99,7 +99,7 @@ namespace gtsam // Do dense elimination step std::pair, boost::shared_ptr > eliminationResult = - eliminationFunction(gatheredFactors, Ordering(node->keys)); + eliminationFunction(gatheredFactors, Ordering(node->orderedFrontalKeys)); // Store conditional in BayesTree clique, and in the case of ISAM2Clique also store the remaining factor myData.bayesTreeNode->setEliminationResult(eliminationResult); @@ -123,7 +123,7 @@ namespace gtsam const std::string& s, const KeyFormatter& keyFormatter) const { std::cout << s; - BOOST_FOREACH(Key j, keys) + BOOST_FOREACH(Key j, orderedFrontalKeys) std::cout << j << " "; std::cout << "problemSize = " << problemSize_ << std::endl; } diff --git a/gtsam/inference/ClusterTree.h b/gtsam/inference/ClusterTree.h index 09bec7452..435631b21 100644 --- a/gtsam/inference/ClusterTree.h +++ b/gtsam/inference/ClusterTree.h @@ -41,7 +41,7 @@ namespace gtsam typedef FastVector Factors; typedef FastVector > Children; - Keys keys; ///< Frontal keys of this node + Keys orderedFrontalKeys; ///< Frontal keys of this node Factors factors; ///< Factors associated with this node Children children; ///< sub-trees int problemSize_; diff --git a/gtsam/inference/JunctionTree-inst.h b/gtsam/inference/JunctionTree-inst.h index 9d96c5b9c..f12e5afd2 100644 --- a/gtsam/inference/JunctionTree-inst.h +++ b/gtsam/inference/JunctionTree-inst.h @@ -49,7 +49,7 @@ namespace gtsam { // structure with its own JT node, and create a child pointer in its parent. ConstructorTraversalData myData = ConstructorTraversalData(&parentData); myData.myJTNode = boost::make_shared::Node>(); - myData.myJTNode->keys.push_back(node->key); + myData.myJTNode->orderedFrontalKeys.push_back(node->key); myData.myJTNode->factors.insert(myData.myJTNode->factors.begin(), node->factors.begin(), node->factors.end()); parentData.myJTNode->children.push_back(myData.myJTNode); return myData; @@ -101,13 +101,20 @@ namespace gtsam { const typename JunctionTree::Node& childToMerge = *myData.myJTNode->children[child - nrMergedChildren]; // Merge keys, factors, and children. - myData.myJTNode->keys.insert(myData.myJTNode->keys.begin(), childToMerge.keys.begin(), childToMerge.keys.end()); - myData.myJTNode->factors.insert(myData.myJTNode->factors.end(), childToMerge.factors.begin(), childToMerge.factors.end()); - myData.myJTNode->children.insert(myData.myJTNode->children.end(), childToMerge.children.begin(), childToMerge.children.end()); + myData.myJTNode->orderedFrontalKeys.insert( + myData.myJTNode->orderedFrontalKeys.begin(), + childToMerge.orderedFrontalKeys.begin(), + childToMerge.orderedFrontalKeys.end()); + myData.myJTNode->factors.insert(myData.myJTNode->factors.end(), + childToMerge.factors.begin(), + childToMerge.factors.end()); + myData.myJTNode->children.insert(myData.myJTNode->children.end(), + childToMerge.children.begin(), + childToMerge.children.end()); // Increment problem size combinedProblemSize = std::max(combinedProblemSize, childToMerge.problemSize_); // Increment number of frontal variables - myNrFrontals += childToMerge.keys.size(); + myNrFrontals += childToMerge.orderedFrontalKeys.size(); // Remove child from list. myData.myJTNode->children.erase(myData.myJTNode->children.begin() + (child - nrMergedChildren)); // Increment number of merged children diff --git a/gtsam/symbolic/tests/testSymbolicJunctionTree.cpp b/gtsam/symbolic/tests/testSymbolicJunctionTree.cpp index 49b14bc07..f2d891827 100644 --- a/gtsam/symbolic/tests/testSymbolicJunctionTree.cpp +++ b/gtsam/symbolic/tests/testSymbolicJunctionTree.cpp @@ -46,10 +46,10 @@ TEST( JunctionTree, constructor ) frontal1 = list_of(2)(3), frontal2 = list_of(0)(1), sep1, sep2 = list_of(2); - EXPECT(assert_container_equality(frontal1, actual.roots().front()->keys)); + EXPECT(assert_container_equality(frontal1, actual.roots().front()->orderedFrontalKeys)); //EXPECT(assert_equal(sep1, actual.roots().front()->separator)); LONGS_EQUAL(1, (long)actual.roots().front()->factors.size()); - EXPECT(assert_container_equality(frontal2, actual.roots().front()->children.front()->keys)); + EXPECT(assert_container_equality(frontal2, actual.roots().front()->children.front()->orderedFrontalKeys)); //EXPECT(assert_equal(sep2, actual.roots().front()->children.front()->separator)); LONGS_EQUAL(2, (long)actual.roots().front()->children.front()->factors.size()); EXPECT(assert_equal(*simpleChain[2], *actual.roots().front()->factors[0]));