Only eliminate variables that are in newFactors
parent
a96c3db29e
commit
93528c3d4f
|
@ -62,23 +62,29 @@ void HybridGaussianISAM::updateInternal(
|
||||||
for (const sharedClique& orphan : *orphans)
|
for (const sharedClique& orphan : *orphans)
|
||||||
factors += boost::make_shared<BayesTreeOrphanWrapper<Node> >(orphan);
|
factors += boost::make_shared<BayesTreeOrphanWrapper<Node> >(orphan);
|
||||||
|
|
||||||
|
// Get all the discrete keys from the new factors
|
||||||
KeySet allDiscrete;
|
KeySet allDiscrete;
|
||||||
for (auto& factor : factors) {
|
for (auto& factor : newFactors) {
|
||||||
for (auto& k : factor->discreteKeys()) {
|
for (auto& k : factor->discreteKeys()) {
|
||||||
allDiscrete.insert(k.first);
|
allDiscrete.insert(k.first);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Create KeyVector with continuous keys followed by discrete keys.
|
||||||
KeyVector newKeysDiscreteLast;
|
KeyVector newKeysDiscreteLast;
|
||||||
|
// Insert continuous keys first.
|
||||||
for (auto& k : newFactorKeys) {
|
for (auto& k : newFactorKeys) {
|
||||||
if (!allDiscrete.exists(k)) {
|
if (!allDiscrete.exists(k)) {
|
||||||
newKeysDiscreteLast.push_back(k);
|
newKeysDiscreteLast.push_back(k);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// Insert discrete keys at the end
|
||||||
std::copy(allDiscrete.begin(), allDiscrete.end(),
|
std::copy(allDiscrete.begin(), allDiscrete.end(),
|
||||||
std::back_inserter(newKeysDiscreteLast));
|
std::back_inserter(newKeysDiscreteLast));
|
||||||
|
|
||||||
// Get an ordering where the new keys are eliminated last
|
// Get an ordering where the new keys are eliminated last
|
||||||
const VariableIndex index(factors);
|
const VariableIndex index(newFactors);
|
||||||
|
|
||||||
Ordering elimination_ordering;
|
Ordering elimination_ordering;
|
||||||
if (ordering) {
|
if (ordering) {
|
||||||
elimination_ordering = *ordering;
|
elimination_ordering = *ordering;
|
||||||
|
@ -89,10 +95,14 @@ void HybridGaussianISAM::updateInternal(
|
||||||
true);
|
true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GTSAM_PRINT(elimination_ordering);
|
||||||
|
std::cout << "\n\n\n\neliminateMultifrontal" << std::endl;
|
||||||
|
GTSAM_PRINT(factors);
|
||||||
// eliminate all factors (top, added, orphans) into a new Bayes tree
|
// eliminate all factors (top, added, orphans) into a new Bayes tree
|
||||||
HybridBayesTree::shared_ptr bayesTree =
|
HybridBayesTree::shared_ptr bayesTree =
|
||||||
factors.eliminateMultifrontal(elimination_ordering, function, index);
|
factors.eliminateMultifrontal(elimination_ordering, function, index);
|
||||||
|
|
||||||
|
std::cout << "optionally prune" << std::endl;
|
||||||
if (maxNrLeaves) {
|
if (maxNrLeaves) {
|
||||||
bayesTree->prune(*maxNrLeaves);
|
bayesTree->prune(*maxNrLeaves);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue