Skip to content

Fix IncrementalFixedLagSmoother with factor removal#2474

Open
Ellon wants to merge 6 commits intoborglab:developfrom
Ellon:fix_incremental_fixed_lag_smoother_with_removal
Open

Fix IncrementalFixedLagSmoother with factor removal#2474
Ellon wants to merge 6 commits intoborglab:developfrom
Ellon:fix_incremental_fixed_lag_smoother_with_removal

Conversation

@Ellon
Copy link
Contributor

@Ellon Ellon commented Mar 20, 2026

Hi,

I was working with the IncrementalFixedLagSmoother in a setup where the smoother is updated frequently with new values, but only a subset of these values are kept in the long term. The values are removed by removing all the factors connecting them to the rest of the graph, using the argument factorsToRemove of the smoother's update(...) method.

While at it I found two bugs related to factor removals and unused values. In this PR I added a test that reproduces my setup and exposes the bugs, and two other commits fixing each one of them.

I hope it is good enough for a merge, otherwise let me know what can be improved.

Cheers,

EDIT: force-pushed changes to simplify the test file.

@Ellon Ellon force-pushed the fix_incremental_fixed_lag_smoother_with_removal branch from 2c74c5a to 688a246 Compare March 20, 2026 15:24
@ProfFan ProfFan requested review from ProfFan and dellaert March 20, 2026 17:01
@ProfFan
Copy link
Collaborator

ProfFan commented Mar 20, 2026

@Ellon can you first open two issues on the bug you discovered and link this PR?

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes incorrect behavior in IncrementalFixedLagSmoother/ISAM2 when factors are removed such that some keys become unused, and adds a regression test that exercises frequent updates with periodic factor removal.

Changes:

  • Add a new regression test covering repeated updates with factorsToRemove, including unused-key removal scenarios.
  • Update IncrementalFixedLagSmoother to erase timestamps for keys reported as unusedKeys after an ISAM2::update().
  • Fix ISAM2::recalculateBatch() to exclude unusedKeys from constrained ordering groups.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
gtsam/nonlinear/tests/testIncrementalFixedLagSmoother.cpp Adds a new test scenario that removes factors to intentionally create unused keys.
gtsam/nonlinear/IncrementalFixedLagSmoother.cpp Removes timestamps for keys that become unused after an update.
gtsam/nonlinear/ISAM2.cpp Filters ordering constraints during batch recalculation to exclude unused keys.

@Ellon
Copy link
Contributor Author

Ellon commented Mar 23, 2026

@ProfFan Done: #2478 and #2479

@Ellon
Copy link
Contributor Author

Ellon commented Mar 24, 2026

I'm updating the test to expose the problem mentioned by copilot. I'll update the branch in a few minutes.

@Ellon Ellon force-pushed the fix_incremental_fixed_lag_smoother_with_removal branch from 357a2c3 to 6592581 Compare March 24, 2026 11:56
@Ellon
Copy link
Contributor Author

Ellon commented Mar 24, 2026

Done. Now the test expose the bug found by copilot.

@ProfFan Do I need to open another issue? IMO I think all these issues are in fact one single issue related to proper handling of factor removals in the smoother.

@Ellon Ellon force-pushed the fix_incremental_fixed_lag_smoother_with_removal branch from 6592581 to 488c5ec Compare March 24, 2026 13:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants