evaluate (interesting that this is not even defined in BayesNet, should move there?)

release/4.3a0
Frank Dellaert 2012-09-15 11:48:21 +00:00
parent b819b7c446
commit 8b6c1a0b9d
2 changed files with 13 additions and 1 deletions

View File

@ -36,6 +36,15 @@ namespace gtsam {
bayesNet.push_back(boost::make_shared<DiscreteConditional>(s));
}
/* ************************************************************************* */
double evaluate(const DiscreteBayesNet& bn, const DiscreteConditional::Values & values) {
// evaluate all conditionals and multiply
double result = 1.0;
BOOST_FOREACH(DiscreteConditional::shared_ptr conditional, bn)
result *= (*conditional)(values);
return result;
}
/* ************************************************************************* */
DiscreteFactor::sharedValues optimize(const DiscreteBayesNet& bn) {
// solve each node in turn in topological sort order (parents first)

View File

@ -33,7 +33,10 @@ namespace gtsam {
/** Add a DiscreteCondtional in front, when listing parents first*/
void add_front(DiscreteBayesNet&, const Signature& s);
/** Optimize function for back-substitution. */
//** evaluate for given Values */
double evaluate(const DiscreteBayesNet& bn, const DiscreteConditional::Values & values);
/** Optimize function for back-substitution. */
DiscreteFactor::sharedValues optimize(const DiscreteBayesNet& bn);
/** Do ancestral sampling */