Skip to content

Fix odd-N mating and add an opt-in two-shuffle pool - #10

Merged
jkbennitt merged 1 commit into
mainfrom
cursor/mating-odd-n-two-shuffle-0b37
Sep 30, 2026
Merged

jkbennitt merged 1 commit into
mainfrom
cursor/mating-odd-n-two-shuffle-0b37

Conversation

@jkbennitt

Copy link
Copy Markdown
Member

Summary

Odd populations skipped parents[N-1] in SBX because the pair cursor wrapped to 0 before that index was read. Das–Dennis sizes such as M=2, p=12 (N=13) and M=3, p=12 (N=91) hit this every generation. The leftover parent is now paired with parent 0, then the cursor restarts. Even N still walks (0,1), (2,3), … and wraps to (0,1) with no extra random draw, so the published ZDT1 (52) and DTLZ2 (92) pair sequences stay the same.

Two opt-in modes follow the existing TournamentMode style. Defaults are unchanged.

  • MatingPoolMode.TwoShuffledPasses: two shuffled passes of consecutive tournaments (Seada & Deb Algorithm 1 and pymoo 0.6.2 TournamentSelection with pressure 2). When N parents are drawn from N members, each index is a contestant twice. The default pool remains N independent tournaments with replacement, which is the published ZDT1 Wilcoxon protocol.
  • TournamentMode.Algorithm2: a same-niche perpendicular-distance tie keeps the second parent. PymooCompatible still coin-flips. RankNicheDistance is unchanged. Either comparator works with either pool.

No package version bump. No new IGD or Wilcoxon numbers.

Checklist

  • dotnet test Unsga3.slnx -c Release passes locally
  • CHANGELOG.md updated under Unreleased (if user-visible)
  • Public API changes documented (XML docs / README)
  • If survival / normalization / metrics changed: noted oracle impact (or re-ran multi-seed)

Survival, normalization, duplicate keys, p_c, and the published tables are untouched. Even-N mating order is locked by tests, so the published ZDT1 / DTLZ2 protocols are not remeasured.

Test plan

  • dotnet test Unsga3.slnx -c Release — 87 passed, 0 failed.
  • Odd N: AdvanceMatingPair and a recording crossover prove parents[N-1] is an SBX parent for N=13 (and the cursor for N=3 and N=91).
  • Even N: consecutive pairs for 4, 52, and 92, including the wrap back to (0,1). A recording crossover checks the N=4 cycle does not use the odd wrap.
  • Two-shuffle: for N in {4, 13, 52, 91} and 40 seeds, every index is a contestant twice and every contest is two distinct members. SelectParents follows that contest order.
  • Default pool: independent Next / NextExcept draws still match the previous sequence on a ranked population.
  • Algorithm2 keeps the second parent on a same-niche distance tie, still prefers the shorter distance, and still coin-flips an equal constraint violation. PymooCompatible coin-flip tests are unchanged.
  • One-generation ZDT1 run with Das–Dennis (2, 2) (N=3), TwoShuffledPasses, and Algorithm2 returns a full population.

What stayed unchanged

  • Default tournament RankNicheDistance
  • Default mating pool (independent tournaments with replacement)
  • PymooCompatible distance-tie coin flip
  • p_c = 1.0
  • Duplicate G12 keys
  • Collapsed nadir = ideal + 1
  • PrepareForSelection re-normalization
  • Published IGD / Wilcoxon tables
Open in Web Open in Cursor 

Odd populations now pair the leftover parent with parent 0 so parents[N-1] enters crossover. Even-N consecutive pairs are unchanged.

MatingPoolMode.TwoShuffledPasses and TournamentMode.Algorithm2 are opt-in. RankNicheDistance, the independent pool, and the PymooCompatible coin flip stay the defaults.

Co-authored-by: Jason <jkbennitt@users.noreply.github.com>
@jkbennitt
jkbennitt merged commit d64abb3 into main Sep 30, 2026
2 checks passed
jkbennitt pushed a commit that referenced this pull request Sep 30, 2026
Resolve CHANGELOG Unreleased conflict after #10 (odd-N mating / two-shuffle)
landed on main: keep both constraint/two-layer notes and mating-pool notes.
@jkbennitt jkbennitt mentioned this pull request Sep 30, 2026
5 tasks done
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.

2 participants