Skip to content

Commit

Permalink
Merge pull request #2004 from borglab/hybrid-fixes
Browse files Browse the repository at this point in the history
Hybrid Fixes
  • Loading branch information
varunagrawal authored Jan 26, 2025
2 parents 131f51a + 087c0cc commit 648c68d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
5 changes: 5 additions & 0 deletions gtsam/hybrid/HybridBayesTree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,11 @@ VectorValues HybridBayesTree::optimize(const DiscreteValues& assignment) const {

/* ************************************************************************* */
void HybridBayesTree::prune(const size_t maxNrLeaves) {
if (!this->roots_.at(0)->conditional()->asDiscrete()) {
// Root of the BayesTree is not a discrete clique, so we do nothing.
return;
}

auto prunedDiscreteProbs =
this->roots_.at(0)->conditional()->asDiscrete<TableDistribution>();

Expand Down
3 changes: 2 additions & 1 deletion gtsam/hybrid/HybridNonlinearFactor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@ AlgebraicDecisionTree<Key> HybridNonlinearFactor::errorTree(
auto errorFunc =
[continuousValues](const std::pair<sharedFactor, double>& f) {
auto [factor, val] = f;
return factor->error(continuousValues) + val;
return factor ? factor->error(continuousValues) + val
: std::numeric_limits<double>::infinity();
};
return {factors_, errorFunc};
}
Expand Down

0 comments on commit 648c68d

Please sign in to comment.