Fix to allow eliminating variable that doesn't exist using FactorGraph eliminate(One)
parent
8ca71f833d
commit
f142758ec8
|
|
@ -177,6 +177,9 @@ namespace gtsam {
|
|||
*std::max_element(factor->begin(), factor->end()));
|
||||
}
|
||||
|
||||
sharedConditional conditional;
|
||||
sharedFactor remainingFactor;
|
||||
if(involvedFactors.size() > 0) {
|
||||
// Now permute the variables to be eliminated to the front of the ordering
|
||||
Permutation toFront = Permutation::PullToFront(variables, highestInvolvedVariable+1);
|
||||
Permutation toFrontInverse = *toFront.inverse();
|
||||
|
|
@ -186,12 +189,18 @@ namespace gtsam {
|
|||
|
||||
// Eliminate into conditional and remaining factor
|
||||
EliminationResult eliminated = eliminateFcn(involvedFactors, variables.size());
|
||||
sharedConditional conditional = eliminated.first;
|
||||
sharedFactor remainingFactor = eliminated.second;
|
||||
conditional = eliminated.first;
|
||||
remainingFactor = eliminated.second;
|
||||
|
||||
// Undo the permutation
|
||||
conditional->permuteWithInverse(toFront);
|
||||
remainingFactor->permuteWithInverse(toFront);
|
||||
} else {
|
||||
// Eliminate 0 variables
|
||||
EliminationResult eliminated = eliminateFcn(involvedFactors, 0);
|
||||
conditional = eliminated.first;
|
||||
remainingFactor = eliminated.second;
|
||||
}
|
||||
|
||||
// Build the remaining graph, without the removed factors
|
||||
FactorGraph<FACTOR> remainingGraph;
|
||||
|
|
|
|||
Loading…
Reference in New Issue