-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/factor removal #2
base: main
Are you sure you want to change the base?
Conversation
tests/testDCSAM.cpp
Outdated
dcsam.update(hfg, initialGuess, initialGuessDiscrete, removals, discreteRemovals); | ||
|
||
EXPECT_EQ(dcsam.getDiscreteFactorGraph().at(17), nullptr); | ||
EXPECT_EQ(dcsam.getNonlinearFactorGraph().at(17), nullptr); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test doesn't validate the new estimate after the factor removal.
Suggestion: Try to solve a (simple) factor graph with an known solution (that we can verify to within tol
). Then, remove one or more factors, verify with EXPECT_EQ
that they've been removed, retrieve the new estimate via dcsam_.calculateEstimate()
and validate that the new estimate is correct (to within tol
).
There are also a couple "edge cases" we might want to check on, e.g. what happens if we have a discrete variable with a single discrete factor attached to it, and then we remove that factor? I'm not actually sure what the behavior would be in this case, but it seems like it would be good to know.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what happens if we have a discrete variable with a single discrete factor attached to it, and then we remove that factor?
The variable will be removed (I believe using the gtsam::VariableIndex
that is computed), and any subsequent attempts to retrieve information about the variable will throw errors.
…moval segfault, further testing needed
Just checking in on this - is there anything outstanding on this PR preventing it from being merged? |
@kurransingh Do you remember where we left this off? The main branch is now synced to GTSAM 4.2a8, so if we wanted to push further on this, just need to make sure we pull in those changes first. This seems like a useful feature, but want to make sure everything is working correctly. |
Hey sorry for the extremely late response on this @keevindoherty. I've pulled in all of the latest changes etc. and everything seems to be working. Good to merge from my perspective. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me overall. I haven't tested anything on my end but happy to trust that this is working based on your own usage internal to the MRG. There were a couple TODOs in comments and I wasn't sure if they were stale, so I marked those for your input, but pending that I'm happy to merge!
Thanks for revisiting this, by the way! I know it's been a while and it kind of fell off my radar.
// NOTE: I am not yet 100% sure this is the right way to handle this update. | ||
isam_.update(newFactors, initialGuess, updateParams); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kurransingh Is this comment still valid?
// make sure continuous removal works as well | ||
gtsam::FactorIndices removals{5}; | ||
|
||
// TODO(Kurran) why does removing continous factor 5 cause isam segfault? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kurransingh Is this comment stale?
size_t mpeClassL1 = dcvals.discrete.at(lc1); | ||
EXPECT_EQ(mpeClassL1, 1); | ||
|
||
std::cout << "now let's remove factors! " << std::endl; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this print needed?
Augmented "update" method to pass through to the isam and DiscreteFactorGraph removal methods. We leave it up to the user to keep track of factor indices.