Skip to content

perf(solver): restore only the touched ruin permutation positions - #247

Merged
blackopsrepl merged 1 commit into
mainfrom
perf/ruin-touched-positions
Nov 10, 2026
Merged

blackopsrepl merged 1 commit into
mainfrom
perf/ruin-touched-positions

Conversation

@blackopsrepl

Copy link
Copy Markdown
Collaborator

Closes #244. Batches and random draws are identical to the full-reset reference (oracle test over 40 entity counts, 7 ruin ranges, 25 seeds; dropping the restore loop fails it).

generate_ruin_batches reset the whole permutation to the identity before
every batch, an O(entity count) fill per batch although the partial
Fisher-Yates shuffle touches at most twice the ruin count positions. It now
restores, after each batch, only the prefix and the original positions of
the values the batch took: a value that enters the prefix never moves
again, so every other position still holds its own index. Batches and the
random draws they consume are identical; a test checks them against the
full-reset reference over 40 entity counts, 7 ruin ranges and 25 seeds.

Closes #244
@blackopsrepl
blackopsrepl merged commit 84e50f3 into main Nov 10, 2026
7 checks passed
@blackopsrepl
blackopsrepl deleted the perf/ruin-touched-positions branch November 10, 2026 21:55
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.

perf(solver): ruin batches reset the whole permutation for every batch

1 participant