remove previously added code
parent
f85284afb2
commit
5e86f7ee51
|
|
@ -82,17 +82,6 @@ namespace gtsam {
|
|||
ADT::print("", formatter);
|
||||
}
|
||||
|
||||
/* ************************************************************************ */
|
||||
DiscreteFactor::shared_ptr DecisionTreeFactor::operator*(
|
||||
const DiscreteFactor::shared_ptr& f) const {
|
||||
if (auto derived = std::dynamic_pointer_cast<DecisionTreeFactor>(f)) {
|
||||
return std::make_shared<DecisionTreeFactor>(this->operator*(*derived));
|
||||
} else {
|
||||
throw std::runtime_error(
|
||||
"Cannot convert DiscreteFactor to DecisionTreeFactor");
|
||||
}
|
||||
}
|
||||
|
||||
/* ************************************************************************ */
|
||||
DecisionTreeFactor DecisionTreeFactor::apply(Unary op) const {
|
||||
// apply operand
|
||||
|
|
|
|||
|
|
@ -145,13 +145,10 @@ namespace gtsam {
|
|||
double error(const DiscreteValues& values) const override;
|
||||
|
||||
/// multiply two factors
|
||||
DecisionTreeFactor operator*(const DecisionTreeFactor& f) const {
|
||||
DecisionTreeFactor operator*(const DecisionTreeFactor& f) const override {
|
||||
return apply(f, Ring::mul);
|
||||
}
|
||||
|
||||
DiscreteFactor::shared_ptr operator*(
|
||||
const DiscreteFactor::shared_ptr& f) const override;
|
||||
|
||||
static double safe_div(const double& a, const double& b);
|
||||
|
||||
/// divide by factor f (safely)
|
||||
|
|
@ -159,17 +156,6 @@ namespace gtsam {
|
|||
return apply(f, safe_div);
|
||||
}
|
||||
|
||||
/// divide by factor f (pointer version)
|
||||
DiscreteFactor::shared_ptr operator/(
|
||||
const DiscreteFactor::shared_ptr& f) const override {
|
||||
if (auto derived = std::dynamic_pointer_cast<DecisionTreeFactor>(f)) {
|
||||
return std::make_shared<DecisionTreeFactor>(apply(*derived, safe_div));
|
||||
} else {
|
||||
throw std::runtime_error(
|
||||
"Cannot convert DiscreteFactor to Table Factor");
|
||||
}
|
||||
}
|
||||
|
||||
/// Convert into a decision tree
|
||||
DecisionTreeFactor toDecisionTreeFactor() const override { return *this; }
|
||||
|
||||
|
|
|
|||
|
|
@ -38,7 +38,8 @@ using std::vector;
|
|||
namespace gtsam {
|
||||
|
||||
// Instantiate base class
|
||||
template class GTSAM_EXPORT Conditional<DecisionTreeFactor, DiscreteConditional>;
|
||||
template class GTSAM_EXPORT
|
||||
Conditional<DecisionTreeFactor, DiscreteConditional>;
|
||||
|
||||
/* ************************************************************************** */
|
||||
DiscreteConditional::DiscreteConditional(const size_t nrFrontals,
|
||||
|
|
@ -152,11 +153,11 @@ void DiscreteConditional::print(const string& s,
|
|||
/* ************************************************************************** */
|
||||
bool DiscreteConditional::equals(const DiscreteFactor& other,
|
||||
double tol) const {
|
||||
if (!dynamic_cast<const DecisionTreeFactor*>(&other)) {
|
||||
if (!dynamic_cast<const BaseFactor*>(&other)) {
|
||||
return false;
|
||||
} else {
|
||||
const DecisionTreeFactor& f(static_cast<const DecisionTreeFactor&>(other));
|
||||
return DecisionTreeFactor::equals(f, tol);
|
||||
const BaseFactor& f(static_cast<const BaseFactor&>(other));
|
||||
return BaseFactor::equals(f, tol);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -377,7 +378,7 @@ std::string DiscreteConditional::markdown(const KeyFormatter& keyFormatter,
|
|||
ss << "*\n" << std::endl;
|
||||
if (nrParents() == 0) {
|
||||
// We have no parents, call factor method.
|
||||
ss << DecisionTreeFactor::markdown(keyFormatter, names);
|
||||
ss << BaseFactor::markdown(keyFormatter, names);
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
|
|
@ -429,7 +430,7 @@ string DiscreteConditional::html(const KeyFormatter& keyFormatter,
|
|||
ss << "</i></p>\n";
|
||||
if (nrParents() == 0) {
|
||||
// We have no parents, call factor method.
|
||||
ss << DecisionTreeFactor::html(keyFormatter, names);
|
||||
ss << BaseFactor::html(keyFormatter, names);
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -110,16 +110,16 @@ class GTSAM_EXPORT DiscreteConditional
|
|||
* @brief construct P(X|Y) = f(X,Y)/f(Y) from f(X,Y) and f(Y)
|
||||
* Assumes but *does not check* that f(Y)=sum_X f(X,Y).
|
||||
*/
|
||||
DiscreteConditional(const DiscreteFactor::shared_ptr& joint,
|
||||
const DiscreteFactor::shared_ptr& marginal);
|
||||
DiscreteConditional(const DecisionTreeFactor& joint,
|
||||
const DecisionTreeFactor& marginal);
|
||||
|
||||
/**
|
||||
* @brief construct P(X|Y) = f(X,Y)/f(Y) from f(X,Y) and f(Y)
|
||||
* Assumes but *does not check* that f(Y)=sum_X f(X,Y).
|
||||
* Makes sure the keys are ordered as given. Does not check orderedKeys.
|
||||
*/
|
||||
DiscreteConditional(const DiscreteFactor::shared_ptr& joint,
|
||||
const DiscreteFactor::shared_ptr& marginal,
|
||||
DiscreteConditional(const DecisionTreeFactor& joint,
|
||||
const DecisionTreeFactor& marginal,
|
||||
const Ordering& orderedKeys);
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ void DiscreteLookupTable::print(const std::string& s,
|
|||
}
|
||||
}
|
||||
cout << "):\n";
|
||||
ADT::print("", formatter);
|
||||
BaseFactor::print("", formatter);
|
||||
cout << endl;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue