Skip to content

Commit 3460147

Browse files
authored
Merge pull request #1390 from borglab/hybrid/simplify-2
2 parents 0571af9 + 7849cf4 commit 3460147

File tree

3 files changed

+11
-7
lines changed

3 files changed

+11
-7
lines changed

gtsam/hybrid/GaussianMixture.cpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -299,19 +299,19 @@ void GaussianMixture::prune(const DecisionTreeFactor &decisionTree) {
299299
/* *******************************************************************************/
300300
AlgebraicDecisionTree<Key> GaussianMixture::logProbability(
301301
const VectorValues &continuousValues) const {
302-
// functor to calculate to double logProbability value from
302+
// functor to calculate (double) logProbability value from
303303
// GaussianConditional.
304-
auto errorFunc =
304+
auto probFunc =
305305
[continuousValues](const GaussianConditional::shared_ptr &conditional) {
306306
if (conditional) {
307307
return conditional->logProbability(continuousValues);
308308
} else {
309-
// Return arbitrarily large logProbability if conditional is null
309+
// Return arbitrarily small logProbability if conditional is null
310310
// Conditional is null if it is pruned out.
311-
return 1e50;
311+
return -1e20;
312312
}
313313
};
314-
return DecisionTree<Key, double>(conditionals_, errorFunc);
314+
return DecisionTree<Key, double>(conditionals_, probFunc);
315315
}
316316

317317
/* *******************************************************************************/

gtsam/hybrid/HybridBayesNet.cpp

+5-2
Original file line numberDiff line numberDiff line change
@@ -76,13 +76,16 @@ std::function<double(const Assignment<Key> &, double)> prunerFunc(
7676
auto pruner = [prunedDecisionTree, decisionTreeKeySet, conditionalKeySet](
7777
const Assignment<Key> &choices,
7878
double probability) -> double {
79+
// This corresponds to 0 probability
80+
double pruned_prob = 0.0;
81+
7982
// typecast so we can use this to get probability value
8083
DiscreteValues values(choices);
8184
// Case where the Gaussian mixture has the same
8285
// discrete keys as the decision tree.
8386
if (conditionalKeySet == decisionTreeKeySet) {
8487
if (prunedDecisionTree(values) == 0) {
85-
return 0.0;
88+
return pruned_prob;
8689
} else {
8790
return probability;
8891
}
@@ -133,7 +136,7 @@ std::function<double(const Assignment<Key> &, double)> prunerFunc(
133136
}
134137
// If we are here, it means that all the sub-branches are 0,
135138
// so we prune.
136-
return 0.0;
139+
return pruned_prob;
137140
}
138141
};
139142
return pruner;

gtsam/hybrid/HybridNonlinearISAM.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ void HybridNonlinearISAM::update(const HybridNonlinearFactorGraph& newFactors,
3939
if (newFactors.size() > 0) {
4040
// Reorder and relinearize every reorderInterval updates
4141
if (reorderInterval_ > 0 && ++reorderCounter_ >= reorderInterval_) {
42+
// TODO(Varun) Relinearization doesn't take into account pruning
4243
reorder_relinearize();
4344
reorderCounter_ = 0;
4445
}

0 commit comments

Comments
 (0)