Skip to content

Commit

Permalink
emplace then prune
Browse files Browse the repository at this point in the history
  • Loading branch information
varunagrawal committed Jan 4, 2025
1 parent 07a6829 commit bcc52be
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions gtsam/hybrid/HybridBayesNet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,15 @@ HybridBayesNet HybridBayesNet::prune(size_t maxNrLeaves) const {
}
}

// Create the result starting with the pruned joint.
HybridBayesNet result;
result.emplace_shared<DiscreteConditional>(joint);
// Prune the joint. NOTE: imperative and, again, possibly quite expensive.
DiscreteConditional pruned(joint);
pruned.prune(maxNrLeaves);
result.back()->asDiscrete()->prune(maxNrLeaves);

// Create a the result starting with the pruned joint.
HybridBayesNet result;
result.push_back(std::make_shared<DiscreteConditional>(pruned));
// Get pruned discrete probabilities so
// we can prune HybridGaussianConditionals.
DiscreteConditional pruned = *result.back()->asDiscrete();

/* To prune, we visitWith every leaf in the HybridGaussianConditional.
* For each leaf, using the assignment we can check the discrete decision tree
Expand Down

0 comments on commit bcc52be

Please sign in to comment.