Skip to content

Provisional: extensible random generators and splitting for Gecode 7 (breaking changes) - #241

Draft
zayenz wants to merge 7 commits into
mainfrom
feature/random
Draft

Provisional: extensible random generators and splitting for Gecode 7 (breaking changes)#241
zayenz wants to merge 7 commits into
mainfrom
feature/random

Conversation

@zayenz

@zayenz zayenz commented Sep 10, 2026

Copy link
Copy Markdown
Member

Provisional draft — future breaking-change release only

Add modern, user-extensible random number generators with reproducible stream splitting. Splittable SplitMix replaces the old default; xorshift64* provides a smaller-state alternative. The build selects the default engine, while users can supply their own engines through the generic branching APIs.

This is a provisional Gecode 7 design, intended only for a future release that explicitly permits breaking changes. It is not ready for merge and must not ship in Gecode 6.x or any compatibility-preserving release. The default engine, APIs, and performance tradeoffs remain under review.

Generator and search behavior

  • Provide indexed splitting: each alternative derives a distinct successor state from the recorded parent state. Recomputing that choice and alternative reproduces the state exactly.
  • Support complete-state save/restore independently of seed expansion, including engines with more than 64 bits of state.
  • Accept checked 64-bit seeds and complete state on the command line. Test failures and exceptions report exact iteration-state replay commands.
  • Store each generator directly in its consumer. Rnd contains exactly 16 bytes with SplitMix or 8 with xorshift64*, without allocation. Copying produces independent state.
  • Record only the active randomized brancher's selector states, inline in its choice allocation. Cloning does not split; deterministic branches leave unrelated consumers untouched. Model and custom-brancher transitions remain explicit.
  • Keep Space and base Choice unchanged from main, with no extra storage or archive words for nonrandom choices.

Source and binary compatibility, seeded sequences, bounded-draw consumption, random search trees, and randomized choice archives change. No legacy sequence mode is provided. Version and ABI-number changes remain release preparation.

The custom-engine example, engine contracts, migration guidance, and measurements are in examples/random-engine.cpp, docs/random.md, and plans/random.md.

Measured tradeoffs

Local arm64 macOS Release measurements against main (6b7de57), five measured repetitions after warmup:

  • One-selector random position/value choice: 48 bytes with SplitMix or 40 with xorshift64*, including state. Nonrandom choice: unchanged at 24 bytes.
  • Random archive: 28 or 20 bytes. Nonrandom archive: unchanged at 12 bytes.
  • Controlled random-tree time relative to main: SplitMix 1.02x with cloning and 1.16x with recomputation; xorshift64* 1.63x and 2.88x.
  • Indexed binary split-plus-draw: about 15.7 ns for SplitMix versus 237 ns for xorshift64*.
  • Queens: approximately main's time with SplitMix, 1.06x with xorshift64*. Node counts differ slightly.

These are local measurements, not general performance guarantees. RNG replay along a recorded path does not guarantee parallel scheduling or solution order.

Verification and cleanup

  • All five CTests pass with both configured engines, including fault injection, CLI validation, and actual failure/exception state replay.
  • All four CTests pass in the reduced static/no-thread build.
  • Additional LDSB and Random tests pass with both engines. Earlier integration checks also cover Boolean, integer, set, float, assignment, filtered ties, and FlatZinc restarts.
  • Focused tests cover independent copies, untouched model/later-selector state, archived replay, perturbed destination state, sibling alternatives, recomputation, parallel solution agreement, and randomized LDSB archives.
  • Custom-engine full-state replay and example output agree across both full builds and the reduced static build.
  • Replay CTests now use the existing build fixture, including when selected individually.
  • Remove the empty RNG translation unit from both build systems and avoid constructing a temporary choice in LDSB before constructing its final choice.
  • Changelog and documentation lead with the generator and splitting features; stale implementation-history and status text is removed.

Other platforms' CI has not been verified locally. Passing these checks does not change the provisional draft status.

@zayenz zayenz changed the title Provisional: splittable random streams for Gecode 7 (breaking changes) Provisional: extensible random generators and splitting for Gecode 7 (breaking changes) Sep 10, 2026
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