F-nnn: TBR clip-ordering strategy (SearchControl clipOrder)#239
Merged
ms609 merged 4 commits intocpp-searchfrom Mar 29, 2026
Merged
F-nnn: TBR clip-ordering strategy (SearchControl clipOrder)#239ms609 merged 4 commits intocpp-searchfrom
ms609 merged 4 commits intocpp-searchfrom
Conversation
Add ClipOrder enum, TBRPassRecord struct, and per-pass diagnostic counters to tbr_search() (guarded behind TBRParams::diagnostics=true). Add ts_tbr_diagnostics() Rcpp bridge returning per-pass data frame. Add order_clips() helper implementing RANDOM/INV_WEIGHT/TIPS_FIRST/BUCKET strategies (Phase 2 infrastructure, disabled by default). Add diag_clip_ordering.R to characterise baseline behaviour. Diagnostic results (10 seeds × 4 datasets, random Wagner starts): Tip-clip enrichment in productive passes: 0.43–0.76× Tip clips (~51% of all clips) account for only 22–38% of accepted moves. Medium-small clips (2..sqrt(n)) appear most productive. CONCLUSION (Phase 4): the small/tip-first hypothesis is FALSIFIED. All three proposed variants (INV_WEIGHT, TIPS_FIRST, BUCKET) favour tip clips, which are the LEAST productive clip type. Phase 2–3 skipped. Branch will be closed after coordination notes are updated.
Phase 1 (a159311) added diagnostic instrumentation and the TIPS_FIRST, INV_WEIGHT, BUCKET, ANTI_TIP, LARGE_FIRST ordering variants to ts_tbr.cpp. Phase 2 completes the implementation: Bug fix: clip_order was only propagated to the initial TBR and final TBR polish (~10% of replicate time). The ratchet and all sectorial TBR calls defaulted to RANDOM, making the ordering variants effectively inert for the dominant phase (ratchet ~76%). Fix: add clip_order field to RatchetParams and SectorParams, propagate from SearchControl through ts_driven.cpp into every TBR call site in ts_ratchet.cpp and ts_sector.cpp (6 sites + search_sector signature). Empirical validation (5 seeds, 30s, default config): Agnarsson2004 (62t, default preset): TIPS_FIRST -2%, INV_WEIGHT neutral Zhu2013 (75t, thorough preset): TIPS_FIRST +13%, INV_WEIGHT +9% Dikow2009 (88t, thorough preset): TIPS_FIRST +8%, INV_WEIGHT +3% Theoretical model (Poisson bucket, corrected): TIPS_FIRST saves ~48% per productive TBR pass at 88t; practical throughput gain is ~8-13% because null passes (ordering-invariant, exhaust all clips) dilute savings. Benefit is dataset-size dependent: < ~65t: tip enrichment is low (Agnarsson2004: 0.43); TIPS_FIRST neutral 65-120t (thorough): tip enrichment moderate; TIPS_FIRST +8-13% No preset defaults changed yet — pending GHA 10-seed validation. bench_clip_ordering.R contains the full benchmark driver.
The SearchControl.Rd usage section was generated from an old installed build (missing clipOrder and many parameters added since). The codoc check correctly flagged the mismatch. - Added @param clipOrder documentation in R/SearchControl.R - Regenerated man/SearchControl.Rd with correct \usage and \item{clipOrder}
ms609
added a commit
that referenced
this pull request
Mar 29, 2026
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.
Agent F. Implements configurable TBR clip-ordering strategies with full propagation to ratchet and sectorial search paths.
Summary
Adds
clipOrderparameter toSearchControl()(default 0 = RANDOM). Six strategies available:Root cause of Phase 1 null result
clip_orderwas previously only wired to ~10% of TBR calls (Wagner warmup + final polish). The dominant paths — ratchet (76% of replicate time) and sectorial search (XSS/RSS/CSS) — always used RANDOM. This rendered the ordering variants completely inert empirically.Phase 2 fix
clip_orderfield toRatchetParamsandSectorParamsSearchControlthrough all construction sites ints_driven.cppts_ratchet.cppandts_sector.cppBenchmark results (5 seeds × 30s, default/thorough presets)
Benefit is size/enrichment-dependent: +8–13% throughput at 65–119t (thorough preset); neutral at ≤64t (default preset) because tip enrichment is lower.
No preset defaults changed;
clipOrderremains 0 (RANDOM). Users can opt in withSearchControl(clipOrder = 2L).