diff --git a/gtsam/discrete/DecisionTree-inl.h b/gtsam/discrete/DecisionTree-inl.h index 541bd77f4..413b4a924 100644 --- a/gtsam/discrete/DecisionTree-inl.h +++ b/gtsam/discrete/DecisionTree-inl.h @@ -149,8 +149,7 @@ namespace gtsam { } /** choose a branch, create new memory ! */ - NodePtr choose(const L& label, size_t index, - bool make_unique = true) const override { + NodePtr choose(const L& label, size_t index) const override { return NodePtr(new Leaf(constant(), 1)); } @@ -469,22 +468,16 @@ namespace gtsam { } /** choose a branch, recursively */ - NodePtr choose(const L& label, size_t index, - bool make_unique = true) const override { + NodePtr choose(const L& label, size_t index) const override { if (label_ == label) return branches_[index]; // choose branch // second case, not label of interest, just recurse auto r = std::make_shared(label_, branches_.size()); for (auto&& branch : branches_) { - r->push_back(branch->choose(label, index, make_unique)); + r->push_back(branch->choose(label, index)); } - if (make_unique) { - return Unique(r); - } else { - return r; - } - // return Unique(r); + return Unique(r); } private: @@ -1006,9 +999,9 @@ namespace gtsam { template DecisionTree DecisionTree::combine(const L& label, size_t cardinality, const Binary& op) const { - DecisionTree result = choose(label, 0, false); + DecisionTree result = choose(label, 0); for (size_t index = 1; index < cardinality; index++) { - DecisionTree chosen = choose(label, index, false); + DecisionTree chosen = choose(label, index); result = result.apply(chosen, op); } return result; diff --git a/gtsam/discrete/DecisionTree.h b/gtsam/discrete/DecisionTree.h index 7761de84e..48a1a4596 100644 --- a/gtsam/discrete/DecisionTree.h +++ b/gtsam/discrete/DecisionTree.h @@ -129,8 +129,7 @@ namespace gtsam { virtual Ptr apply_f_op_g(const Node&, const Binary&) const = 0; virtual Ptr apply_g_op_fL(const Leaf&, const Binary&) const = 0; virtual Ptr apply_g_op_fC(const Choice&, const Binary&) const = 0; - virtual Ptr choose(const L& label, size_t index, - bool make_unique = true) const = 0; + virtual Ptr choose(const L& label, size_t index) const = 0; virtual bool isLeaf() const = 0; private: @@ -404,9 +403,8 @@ namespace gtsam { /** create a new function where value(label)==index * It's like "restrict" in Darwiche09book pg329, 330? */ - DecisionTree choose(const L& label, size_t index, - bool make_unique = true) const { - NodePtr newRoot = root_->choose(label, index, make_unique); + DecisionTree choose(const L& label, size_t index) const { + NodePtr newRoot = root_->choose(label, index); return DecisionTree(newRoot); }