remove make_unique flag
parent
4580c510ea
commit
8cb33dd4f8
|
@ -149,8 +149,7 @@ namespace gtsam {
|
||||||
}
|
}
|
||||||
|
|
||||||
/** choose a branch, create new memory ! */
|
/** choose a branch, create new memory ! */
|
||||||
NodePtr choose(const L& label, size_t index,
|
NodePtr choose(const L& label, size_t index) const override {
|
||||||
bool make_unique = true) const override {
|
|
||||||
return NodePtr(new Leaf(constant(), 1));
|
return NodePtr(new Leaf(constant(), 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -469,22 +468,16 @@ namespace gtsam {
|
||||||
}
|
}
|
||||||
|
|
||||||
/** choose a branch, recursively */
|
/** choose a branch, recursively */
|
||||||
NodePtr choose(const L& label, size_t index,
|
NodePtr choose(const L& label, size_t index) const override {
|
||||||
bool make_unique = true) const override {
|
|
||||||
if (label_ == label) return branches_[index]; // choose branch
|
if (label_ == label) return branches_[index]; // choose branch
|
||||||
|
|
||||||
// second case, not label of interest, just recurse
|
// second case, not label of interest, just recurse
|
||||||
auto r = std::make_shared<Choice>(label_, branches_.size());
|
auto r = std::make_shared<Choice>(label_, branches_.size());
|
||||||
for (auto&& branch : branches_) {
|
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);
|
return Unique(r);
|
||||||
} else {
|
|
||||||
return r;
|
|
||||||
}
|
|
||||||
// return Unique(r);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -1006,9 +999,9 @@ namespace gtsam {
|
||||||
template<typename L, typename Y>
|
template<typename L, typename Y>
|
||||||
DecisionTree<L, Y> DecisionTree<L, Y>::combine(const L& label,
|
DecisionTree<L, Y> DecisionTree<L, Y>::combine(const L& label,
|
||||||
size_t cardinality, const Binary& op) const {
|
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++) {
|
for (size_t index = 1; index < cardinality; index++) {
|
||||||
DecisionTree chosen = choose(label, index, false);
|
DecisionTree chosen = choose(label, index);
|
||||||
result = result.apply(chosen, op);
|
result = result.apply(chosen, op);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
|
|
@ -129,8 +129,7 @@ namespace gtsam {
|
||||||
virtual Ptr apply_f_op_g(const Node&, const Binary&) const = 0;
|
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_fL(const Leaf&, const Binary&) const = 0;
|
||||||
virtual Ptr apply_g_op_fC(const Choice&, 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,
|
virtual Ptr choose(const L& label, size_t index) const = 0;
|
||||||
bool make_unique = true) const = 0;
|
|
||||||
virtual bool isLeaf() const = 0;
|
virtual bool isLeaf() const = 0;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -404,9 +403,8 @@ namespace gtsam {
|
||||||
|
|
||||||
/** create a new function where value(label)==index
|
/** create a new function where value(label)==index
|
||||||
* It's like "restrict" in Darwiche09book pg329, 330? */
|
* It's like "restrict" in Darwiche09book pg329, 330? */
|
||||||
DecisionTree choose(const L& label, size_t index,
|
DecisionTree choose(const L& label, size_t index) const {
|
||||||
bool make_unique = true) const {
|
NodePtr newRoot = root_->choose(label, index);
|
||||||
NodePtr newRoot = root_->choose(label, index, make_unique);
|
|
||||||
return DecisionTree(newRoot);
|
return DecisionTree(newRoot);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue