diff --git a/gtsam/discrete/DecisionTreeFactor.cpp b/gtsam/discrete/DecisionTreeFactor.cpp index 19cc8e230..7ba4c9011 100644 --- a/gtsam/discrete/DecisionTreeFactor.cpp +++ b/gtsam/discrete/DecisionTreeFactor.cpp @@ -196,18 +196,12 @@ namespace gtsam { /* ************************************************************************ */ std::vector DecisionTreeFactor::probabilities() const { - std::vector probs; - - // Get all the key cardinalities - std::map cardins; - for (auto [key, cardinality] : discreteKeys()) { - cardins[key] = cardinality; - } // Set of all keys std::set allKeys(keys().begin(), keys().end()); + std::vector probs; + // Go through the tree - std::vector ys; this->apply([&](const Assignment a, double p) { // Get all the keys in the current assignment std::set assignment_keys; @@ -224,7 +218,7 @@ namespace gtsam { // Compute the total number of assignments in the (pruned) subtree size_t nrAssignments = 1; for (auto&& k : diff) { - nrAssignments *= cardins.at(k); + nrAssignments *= cardinalities_.at(k); } probs.insert(probs.end(), nrAssignments, p); return p;