Use simpler normalization for max-product.

release/4.3a0
Kevin 2023-02-08 08:55:03 -05:00
parent 571b0f5e90
commit 9d0be8f2b2
1 changed files with 4 additions and 3 deletions

View File

@ -121,9 +121,10 @@ namespace gtsam {
for (auto&& factor : factors) product = (*factor) * product;
gttoc(product);
// Normalize the product factor to prevent underflow
Ordering ordering = Ordering::Colamd(DiscreteFactorGraph{product});
DecisionTreeFactor::shared_ptr normalization = product.sum(ordering);
// Sum all the potentials by pretending all keys are frontal:
auto normalization = product.sum(product.size());
// Normalize the product factor to prevent underflow.
product = product / (*normalization);
// max out frontals, this is the factor on the separator