Prune graphs with nulls on the fly
parent
1365a0904a
commit
2c9665fae6
|
@ -367,10 +367,7 @@ HybridGaussianFactorGraph::eliminate(const Ordering &keys) const {
|
||||||
// any difference in noise models used.
|
// any difference in noise models used.
|
||||||
HybridGaussianProductFactor productFactor = collectProductFactor();
|
HybridGaussianProductFactor productFactor = collectProductFactor();
|
||||||
|
|
||||||
// Convert factor graphs with a nullptr to an empty factor graph.
|
auto isNull = [](const GaussianFactor::shared_ptr& ptr) { return !ptr; };
|
||||||
// This is done after assembly since it is non-trivial to keep track of which
|
|
||||||
// FG has a nullptr as we're looping over the factors.
|
|
||||||
auto prunedProductFactor = productFactor.removeEmpty();
|
|
||||||
|
|
||||||
// This is the elimination method on the leaf nodes
|
// This is the elimination method on the leaf nodes
|
||||||
bool someContinuousLeft = false;
|
bool someContinuousLeft = false;
|
||||||
|
@ -378,7 +375,7 @@ HybridGaussianFactorGraph::eliminate(const Ordering &keys) const {
|
||||||
[&](const std::pair<GaussianFactorGraph, double> &pair) -> Result {
|
[&](const std::pair<GaussianFactorGraph, double> &pair) -> Result {
|
||||||
const auto &[graph, scalar] = pair;
|
const auto &[graph, scalar] = pair;
|
||||||
|
|
||||||
if (graph.empty()) {
|
if (graph.empty() || std::any_of(graph.begin(), graph.end(), isNull)) {
|
||||||
return {nullptr, 0.0, nullptr, 0.0};
|
return {nullptr, 0.0, nullptr, 0.0};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -394,7 +391,7 @@ HybridGaussianFactorGraph::eliminate(const Ordering &keys) const {
|
||||||
};
|
};
|
||||||
|
|
||||||
// Perform elimination!
|
// Perform elimination!
|
||||||
const ResultTree eliminationResults(prunedProductFactor, eliminate);
|
const ResultTree eliminationResults(productFactor, eliminate);
|
||||||
|
|
||||||
// If there are no more continuous parents we create a DiscreteFactor with the
|
// If there are no more continuous parents we create a DiscreteFactor with the
|
||||||
// error for each discrete choice. Otherwise, create a HybridGaussianFactor
|
// error for each discrete choice. Otherwise, create a HybridGaussianFactor
|
||||||
|
|
Loading…
Reference in New Issue