Subtractive BnB V2 — flat arrays, fast-path depth-0/1, branch ordering#12
Open
AzaelMew wants to merge 2 commits into
Open
Subtractive BnB V2 — flat arrays, fast-path depth-0/1, branch ordering#12AzaelMew wants to merge 2 commits into
AzaelMew wants to merge 2 commits into
Conversation
Optimisations over V1: - Flat primitive arrays for req/bonus (better cache locality) - Fast-path depth-0 and depth-1 search before general DFS - Branch ordering by weight to find best tie-break first - Special-case n=0 and n=1 to skip visited clearing and recursion - Registered alongside V1
Contributor
Author
|
This is same as #9, just fixed to be submitted corrctly. |
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.
Summary
Subtractive BnB V2 is an evolution of the V1 algorithm with aggressive performance optimisations while keeping the exact same correctness guarantees.
What changed
int[][] req/bonusto contiguousint[]for better cache locality in the hot loops.On typical builds this avoids recursion entirely.
nshort-circuit —n ≤ 1skips visited-bitset clearing and recursion overhead.Benchmarks
V2 is now the fastest algorithm on the OneByOne benchmark and retains the top spot on FullEquip.
Correctness
@CombinationTestcases pass for V2.Registration
V2 is registered as a separate class (
SubtractiveBnBV2Algorithm) alongside V1, per the bounty instructions.AI Disclosure
This algorithm was designed and implemented with assistance from an AI coding assistant (Kimi Code CLI). The core mathematical approach (subtractive branch-and-bound with witness-driven removal) was human-directed; performance optimisations (flat arrays, fast paths, branch ordering) were refined iteratively with AI assistance.