parent
32b6bc0a37
commit
38563da342
|
|
@ -169,6 +169,9 @@ namespace gtsam {
|
|||
}
|
||||
}
|
||||
|
||||
/// Convert into a decision tree
|
||||
DecisionTreeFactor toDecisionTreeFactor() const override { return *this; }
|
||||
|
||||
/// Create new factor by summing all values with the same separator values
|
||||
DiscreteFactor::shared_ptr sum(size_t nrFrontals) const override {
|
||||
return combine(nrFrontals, ADT::Ring::add);
|
||||
|
|
|
|||
|
|
@ -113,6 +113,8 @@ class GTSAM_EXPORT DiscreteFactor : public Factor {
|
|||
virtual DiscreteFactor::shared_ptr operator*(
|
||||
const DiscreteFactor::shared_ptr&) const = 0;
|
||||
|
||||
virtual DecisionTreeFactor toDecisionTreeFactor() const = 0;
|
||||
|
||||
/// Create new factor by summing all values with the same separator values
|
||||
virtual DiscreteFactor::shared_ptr sum(size_t nrFrontals) const = 0;
|
||||
|
||||
|
|
|
|||
|
|
@ -180,6 +180,20 @@ DiscreteFactor::shared_ptr TableFactor::operator*(
|
|||
}
|
||||
}
|
||||
|
||||
/* ************************************************************************ */
|
||||
DecisionTreeFactor TableFactor::toDecisionTreeFactor() const {
|
||||
DiscreteKeys dkeys = discreteKeys();
|
||||
std::vector<double> table;
|
||||
for (auto i = 0; i < sparse_table_.size(); i++) {
|
||||
table.push_back(sparse_table_.coeff(i));
|
||||
}
|
||||
gttic_(toDecisionTreeFactor_Constructor);
|
||||
// NOTE(Varun): This constructor is really expensive!!
|
||||
DecisionTreeFactor f(dkeys, table);
|
||||
gttoc_(toDecisionTreeFactor_Constructor);
|
||||
return f;
|
||||
}
|
||||
|
||||
/* ************************************************************************ */
|
||||
TableFactor TableFactor::choose(const DiscreteValues parent_assign,
|
||||
DiscreteKeys parent_keys) const {
|
||||
|
|
|
|||
|
|
@ -207,6 +207,9 @@ class GTSAM_EXPORT TableFactor : public DiscreteFactor {
|
|||
}
|
||||
}
|
||||
|
||||
/// Convert into a decisiontree
|
||||
DecisionTreeFactor toDecisionTreeFactor() const override;
|
||||
|
||||
/// Create a TableFactor that is a subset of this TableFactor
|
||||
TableFactor choose(const DiscreteValues assignments,
|
||||
DiscreteKeys parent_keys) const;
|
||||
|
|
|
|||
Loading…
Reference in New Issue