new scaledProduct method instead of DiscreteProduct
parent
90825b96af
commit
82dba6322f
|
@ -124,11 +124,10 @@ namespace gtsam {
|
||||||
* @param factors The factors to multiply as a DiscreteFactorGraph.
|
* @param factors The factors to multiply as a DiscreteFactorGraph.
|
||||||
* @return DiscreteFactor::shared_ptr
|
* @return DiscreteFactor::shared_ptr
|
||||||
*/
|
*/
|
||||||
static DiscreteFactor::shared_ptr DiscreteProduct(
|
DiscreteFactor::shared_ptr DiscreteFactorGraph::scaledProduct() const {
|
||||||
const DiscreteFactorGraph& factors) {
|
|
||||||
// PRODUCT: multiply all factors
|
// PRODUCT: multiply all factors
|
||||||
gttic(product);
|
gttic(product);
|
||||||
DiscreteFactor::shared_ptr product = factors.product();
|
DiscreteFactor::shared_ptr product = this->product();
|
||||||
gttoc(product);
|
gttoc(product);
|
||||||
|
|
||||||
// Max over all the potentials by pretending all keys are frontal:
|
// Max over all the potentials by pretending all keys are frontal:
|
||||||
|
@ -145,7 +144,7 @@ namespace gtsam {
|
||||||
std::pair<DiscreteConditional::shared_ptr, DiscreteFactor::shared_ptr> //
|
std::pair<DiscreteConditional::shared_ptr, DiscreteFactor::shared_ptr> //
|
||||||
EliminateForMPE(const DiscreteFactorGraph& factors,
|
EliminateForMPE(const DiscreteFactorGraph& factors,
|
||||||
const Ordering& frontalKeys) {
|
const Ordering& frontalKeys) {
|
||||||
DiscreteFactor::shared_ptr product = DiscreteProduct(factors);
|
DiscreteFactor::shared_ptr product = factors.scaledProduct();
|
||||||
|
|
||||||
// max out frontals, this is the factor on the separator
|
// max out frontals, this is the factor on the separator
|
||||||
gttic(max);
|
gttic(max);
|
||||||
|
@ -223,7 +222,7 @@ namespace gtsam {
|
||||||
std::pair<DiscreteConditional::shared_ptr, DiscreteFactor::shared_ptr> //
|
std::pair<DiscreteConditional::shared_ptr, DiscreteFactor::shared_ptr> //
|
||||||
EliminateDiscrete(const DiscreteFactorGraph& factors,
|
EliminateDiscrete(const DiscreteFactorGraph& factors,
|
||||||
const Ordering& frontalKeys) {
|
const Ordering& frontalKeys) {
|
||||||
DiscreteFactor::shared_ptr product = DiscreteProduct(factors);
|
DiscreteFactor::shared_ptr product = factors.scaledProduct();
|
||||||
|
|
||||||
// sum out frontals, this is the factor on the separator
|
// sum out frontals, this is the factor on the separator
|
||||||
gttic(sum);
|
gttic(sum);
|
||||||
|
|
|
@ -150,6 +150,11 @@ class GTSAM_EXPORT DiscreteFactorGraph
|
||||||
/** return product of all factors as a single factor */
|
/** return product of all factors as a single factor */
|
||||||
DiscreteFactor::shared_ptr product() const;
|
DiscreteFactor::shared_ptr product() const;
|
||||||
|
|
||||||
|
/** Return product of all factors as a single factor,
|
||||||
|
* which is scaled by the max to prevent underflow
|
||||||
|
*/
|
||||||
|
DiscreteFactor::shared_ptr scaledProduct() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Evaluates the factor graph given values, returns the joint probability of
|
* Evaluates the factor graph given values, returns the joint probability of
|
||||||
* the factor graph given specific instantiation of values
|
* the factor graph given specific instantiation of values
|
||||||
|
|
Loading…
Reference in New Issue