fix return value of pruned factors
parent
94fda5dd5a
commit
873b2a7142
|
@ -240,7 +240,9 @@ discreteElimination(const HybridGaussianFactorGraph &factors,
|
||||||
// In this case, compute discrete probabilities.
|
// In this case, compute discrete probabilities.
|
||||||
auto logProbability =
|
auto logProbability =
|
||||||
[&](const GaussianFactor::shared_ptr &factor) -> double {
|
[&](const GaussianFactor::shared_ptr &factor) -> double {
|
||||||
if (!factor) return 0.0;
|
// If the factor is null, it is has been pruned hence return ∞
|
||||||
|
// so that the exp(-∞)=0.
|
||||||
|
if (!factor) return std::numeric_limits<double>::infinity();
|
||||||
return factor->error(VectorValues());
|
return factor->error(VectorValues());
|
||||||
};
|
};
|
||||||
AlgebraicDecisionTree<Key> logProbabilities =
|
AlgebraicDecisionTree<Key> logProbabilities =
|
||||||
|
@ -300,8 +302,9 @@ static std::shared_ptr<Factor> createDiscreteFactor(
|
||||||
auto negLogProbability = [&](const Result &pair) -> double {
|
auto negLogProbability = [&](const Result &pair) -> double {
|
||||||
const auto &[conditional, factor] = pair;
|
const auto &[conditional, factor] = pair;
|
||||||
static const VectorValues kEmpty;
|
static const VectorValues kEmpty;
|
||||||
// If the factor is not null, it has no keys, just contains the residual.
|
// If the factor is null, it has been pruned, hence return ∞
|
||||||
if (!factor) return 1.0; // TODO(dellaert): not loving this.
|
// so that the exp(-∞)=0.
|
||||||
|
if (!factor) return std::numeric_limits<double>::infinity();
|
||||||
|
|
||||||
// Negative logspace version of:
|
// Negative logspace version of:
|
||||||
// exp(-factor->error(kEmpty)) / conditional->normalizationConstant();
|
// exp(-factor->error(kEmpty)) / conditional->normalizationConstant();
|
||||||
|
|
Loading…
Reference in New Issue