get rid of setData and make prune() imperative for non-factors
parent
7cb818136f
commit
d39641d8ac
|
@ -478,11 +478,6 @@ double DiscreteConditional::evaluate(const HybridValues& x) const {
|
|||
return this->evaluate(x.discrete());
|
||||
}
|
||||
|
||||
/* ************************************************************************* */
|
||||
void DiscreteConditional::setData(const DiscreteConditional::shared_ptr& dc) {
|
||||
this->root_ = dc->root_;
|
||||
}
|
||||
|
||||
/* ************************************************************************* */
|
||||
DiscreteConditional::shared_ptr DiscreteConditional::max(
|
||||
const Ordering& keys) const {
|
||||
|
@ -491,10 +486,10 @@ DiscreteConditional::shared_ptr DiscreteConditional::max(
|
|||
}
|
||||
|
||||
/* ************************************************************************* */
|
||||
DiscreteConditional::shared_ptr DiscreteConditional::prune(
|
||||
size_t maxNrAssignments) const {
|
||||
return std::make_shared<DiscreteConditional>(
|
||||
this->nrFrontals(), BaseFactor::prune(maxNrAssignments));
|
||||
void DiscreteConditional::prune(size_t maxNrAssignments) {
|
||||
// Get as DiscreteConditional so the probabilities are normalized
|
||||
DiscreteConditional pruned(nrFrontals(), BaseFactor::prune(maxNrAssignments));
|
||||
this->root_ = pruned.root_;
|
||||
}
|
||||
|
||||
/* ************************************************************************* */
|
||||
|
|
|
@ -276,11 +276,8 @@ class GTSAM_EXPORT DiscreteConditional
|
|||
*/
|
||||
double negLogConstant() const override;
|
||||
|
||||
/// Set the data from another DiscreteConditional.
|
||||
virtual void setData(const DiscreteConditional::shared_ptr& dc);
|
||||
|
||||
/// Prune the conditional
|
||||
virtual DiscreteConditional::shared_ptr prune(size_t maxNrAssignments) const;
|
||||
virtual void prune(size_t maxNrAssignments);
|
||||
|
||||
/// @}
|
||||
|
||||
|
|
|
@ -122,21 +122,8 @@ DiscreteConditional::shared_ptr TableDistribution::max(
|
|||
}
|
||||
|
||||
/* ****************************************************************************/
|
||||
void TableDistribution::setData(const DiscreteConditional::shared_ptr& dc) {
|
||||
if (auto dtc = std::dynamic_pointer_cast<TableDistribution>(dc)) {
|
||||
this->table_ = dtc->table_;
|
||||
} else {
|
||||
this->table_ = TableFactor(dc->discreteKeys(), *dc);
|
||||
}
|
||||
}
|
||||
|
||||
/* ****************************************************************************/
|
||||
DiscreteConditional::shared_ptr TableDistribution::prune(
|
||||
size_t maxNrAssignments) const {
|
||||
TableFactor pruned = table_.prune(maxNrAssignments);
|
||||
|
||||
return std::make_shared<TableDistribution>(this->discreteKeys(),
|
||||
pruned.sparseTable());
|
||||
void TableDistribution::prune(size_t maxNrAssignments) {
|
||||
table_ = table_.prune(maxNrAssignments);
|
||||
}
|
||||
|
||||
} // namespace gtsam
|
||||
|
|
|
@ -145,12 +145,8 @@ class GTSAM_EXPORT TableDistribution : public DiscreteConditional {
|
|||
/// @name Advanced Interface
|
||||
/// @{
|
||||
|
||||
/// Set the underlying data from the DiscreteConditional
|
||||
virtual void setData(const DiscreteConditional::shared_ptr& dc) override;
|
||||
|
||||
/// Prune the conditional
|
||||
virtual DiscreteConditional::shared_ptr prune(
|
||||
size_t maxNrAssignments) const override;
|
||||
virtual void prune(size_t maxNrAssignments) override;
|
||||
|
||||
/// Get a DecisionTreeFactor representation.
|
||||
DecisionTreeFactor toDecisionTreeFactor() const override {
|
||||
|
|
Loading…
Reference in New Issue