Fix phantom selections at window boundaries in interleaved solve#273
Open
JoOkuma wants to merge 4 commits into
Open
Fix phantom selections at window boundaries in interleaved solve#273JoOkuma wants to merge 4 commits into
JoOkuma wants to merge 4 commits into
Conversation
Replace the previous heavy-handed unselect/rewrite approach with the
two-pass design discussed in the PR:
- Each batch reads the DB to see whether its neighbours have already
committed; that determines whether each side is *anchored*.
- A non-anchored side keeps the configured overlap on the solver window
and commits one slice past the inner range so the next-solving batch
finds its anchor.
- An anchored side shrinks the solver window to share exactly the
anchored slice with the neighbour, and the commit window stops at the
inner range so the neighbour's previous write is left intact.
To prevent the second-pass batch from spawning or terminating tracks at
the now-interior boundary, ``MIPSolver.add_nodes`` gets two new flags
-- ``free_appear`` and ``free_disappear`` -- that disable the
``is_first_t`` / ``is_last_t`` free-slack behaviour on the side(s)
anchored to a neighbour.
``add_solution`` writes the commit range with full ``parent_id`` except
at the leftmost slice when that slice is also the solver's leftmost --
there the solver has no incoming edge and would write ``NO_PARENT``,
clobbering the previous batch's lineage.
The synthetic test that previously reproduced the boundary overlap
violations and dangling parents now passes cleanly for every combination
of ``window_size`` in {2,3,4,5,10,100}, ``overlap_size`` in {1,2,3},
and timelapse length, under both interleaved (CLI default) and sequential
(``batch_index=...``) execution.
Strengthen ``_validate_tracking_solution`` to fail when any selected
node's ``parent_id`` references a non-selected node.
d855f01 to
b99816e
Compare
Covers each anchoring combination of _compute_layout (first pass, both sides anchored, mixed) and the out-of-range guard of _is_committed_at, so the new helpers have direct unit-test coverage without depending on the full segment->link->solve pipeline.
SQLite stores Boolean as 0/1, so reading the column back via pandas gives an int64 Series. Pandas refuses to use that as a boolean row mask (`df[int_series]` raises KeyError because it tries to interpret the values as column labels), breaking the dangling-parent check on CI. Cast to bool explicitly.
Add the right-anchored-only case alongside the existing left-anchored- only case.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When the CLI solves the ILP in windows (interleaved evens then odds), the boundary slices between batches ended up with phantom
selected=Truerows and brokenparent_idreferences. Result: overlap-constraint violations and dangling parents in the final DB.Refactored
SQLTrackingwith the two-pass design discussed on the PR:To keep the second pass from spawning or terminating tracks at the now-interior seam,
MIPSolver.add_nodesgetsfree_appear/free_disappearflags;SQLTrackingsets them False on the anchored side(s) so the solver pays the regular appearance/disappearance penalty there.add_solutionwrites the commit range with fullparent_idexcept at the leftmost slice when that slice is also the solver's leftmost (the solver has no incoming edge there and would writeNO_PARENT, clobbering the previous batch's lineage).Synthetic test runs cleanly for
window_size ∈ {2,3,4,5,10,100},overlap_size ∈ {1,2,3}, 10-30 frames, under both interleaved and sequential execution._validate_tracking_solutionnow fails on dangling parents as a regression guard.