Correct the second term in the pruner value so that the minNegLogConstant term is set correctly
parent
67495babae
commit
9be3f41ca2
|
@ -322,8 +322,11 @@ HybridGaussianConditional::shared_ptr HybridGaussianConditional::prune(
|
||||||
const GaussianFactorValuePair &pair) -> GaussianFactorValuePair {
|
const GaussianFactorValuePair &pair) -> GaussianFactorValuePair {
|
||||||
if (max->evaluate(choices) == 0.0)
|
if (max->evaluate(choices) == 0.0)
|
||||||
return {nullptr, std::numeric_limits<double>::infinity()};
|
return {nullptr, std::numeric_limits<double>::infinity()};
|
||||||
else
|
else {
|
||||||
return pair;
|
// Add negLogConstant_ back so that the minimum negLogConstant in the
|
||||||
|
// HybridGaussianConditional is set correctly.
|
||||||
|
return {pair.first, pair.second + negLogConstant_};
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
FactorValuePairs prunedConditionals = factors().apply(pruner);
|
FactorValuePairs prunedConditionals = factors().apply(pruner);
|
||||||
|
|
|
@ -275,6 +275,11 @@ TEST(HybridGaussianConditional, Prune) {
|
||||||
|
|
||||||
// Check that the pruned HybridGaussianConditional has 2 conditionals
|
// Check that the pruned HybridGaussianConditional has 2 conditionals
|
||||||
EXPECT_LONGS_EQUAL(2, pruned->nrComponents());
|
EXPECT_LONGS_EQUAL(2, pruned->nrComponents());
|
||||||
|
|
||||||
|
// Check that the minimum negLogConstant is set correctly
|
||||||
|
EXPECT_DOUBLES_EQUAL(
|
||||||
|
hgc.conditionals()({{M(1), 0}, {M(2), 1}})->negLogConstant(),
|
||||||
|
pruned->negLogConstant(), 1e-9);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
const std::vector<double> potentials{0.2, 0, 0.3, 0, //
|
const std::vector<double> potentials{0.2, 0, 0.3, 0, //
|
||||||
|
@ -285,6 +290,9 @@ TEST(HybridGaussianConditional, Prune) {
|
||||||
|
|
||||||
// Check that the pruned HybridGaussianConditional has 3 conditionals
|
// Check that the pruned HybridGaussianConditional has 3 conditionals
|
||||||
EXPECT_LONGS_EQUAL(3, pruned->nrComponents());
|
EXPECT_LONGS_EQUAL(3, pruned->nrComponents());
|
||||||
|
|
||||||
|
// Check that the minimum negLogConstant is correct
|
||||||
|
EXPECT_DOUBLES_EQUAL(hgc.negLogConstant(), pruned->negLogConstant(), 1e-9);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue