Skip to content

fix: share crossing-reduction trial budget across groups - #22

Merged
bwin merged 2 commits into
devfrom
fix/swap-budget
Nov 3, 2026
Merged

bwin merged 2 commits into
devfrom
fix/swap-budget

Conversation

@bwin

@bwin bwin commented Nov 3, 2026 •

Copy link
Copy Markdown
Owner

Summary

Fixes CONFIRMED-FINDINGS.md item 7: the fixed crossing-reduction budget was consumed in group order, so early groups used it all before later groups were reached.

  • src/layout.ts: swaps is renamed to swapTrials and documented as pair trials, not accepted swaps. Each pass now visits pair index 0 of every eligible group, then pair index 1, etc., so one large early group cannot consume every later group's trials. The total 64-trial budget is unchanged.
  • The convergence-trial budget gets the same round-robin candidate ordering across eligible groups.
  • tests/core.test.ts: regression with a 66-pair early group; a later group still reverses a worse initial port order and shortens its route score. Verified to fail against the old loop.
  • CHANGELOG.md: one scoped [Unreleased] / Fixed entry.

Stress comparison

Crossings Obstacle collisions Scene hash
Before 1758 0 c4c086c4…557a99
After 1758 0 c4c086c4…557a99

All five benchmark fixtures also produce identical diagnostics and scene hashes.

Verification

  • npm run format — passed
  • npm run typecheck — passed
  • npm run lint — passed
  • npm test — 153 tests passed
  • npm run build — passed
  • npm run stress — 1758 crossings, 0 collisions, hash c4c086c4…557a99
  • Reviewer instrumented the stress fixture: 150 eligible groups / 450 pairs; old code gave all 64 trials to the first groups, the PR spreads them across the first 64 groups. The new regression fails on dev and passes on the PR.

Notes

The total 64-trial budget still cannot visit every group on a 150-group stress graph; groups after the cutoff receive no trial. Pass 0 can also still consume the total budget before pass 1. Enlarging or splitting the fixed total budget was out of scope; the changelog describes only the fair spreading of the existing budget.

@bwin
bwin merged commit 06f2a49 into dev Nov 3, 2026
2 checks passed
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.

1 participant