Repository navigation
Conversation
zayenz
commented
Oct 4, 2026
Member
Author
There was a problem hiding this comment.
RandomOptionnow stores validated state asRndand returns a copy, avoiding serialization and parsing in the accessor.- Documented selector hook buffer sizes, pointer advancement, capture timing, and restore/split behavior.
- Completed
overrideannotations in the two affected selector classes. This removes the missing-override warnings.
zayenz
force-pushed
the
feature/random
branch
from
November 3, 2026 16:58
d36ab08 to
c1a4ae5
Compare
zayenz
force-pushed
the
feature/random
branch
from
November 3, 2026 17:30
c1a4ae5 to
3c6538d
Compare
zayenz
force-pushed
the
feature/random
branch
from
November 14, 2026 22:48
f27899e to
2949778
Compare
Rnd becomes a value type holding the complete state of a splittable engine, SplitMix by default, or any engine through RndGenerator<Engine>. Its state can be printed and restored exactly, which drivers expose as -state and the test harness uses for -replay. Randomized selectors draw from a copy of their state and split it by the committed alternative, so cloning, recomputation and parallel search make the same decisions, and choices store no random state. Posting keys each selector by brancher id and role. Branchers record whether any selector is random and skip the split otherwise, so deterministic branching pays no extra cost. RBS and PBS split the branchers of every spoke by its episode or asset after Space::spoke() returns, so spokes do not repeat each other, also when nested. A model-owned generator is split with rnd.split(sc), as photo and FlatZinc do for large neighbourhood search. Copies of a random cutoff split its generator instead of reseeding it.
zayenz
force-pushed
the
feature/random
branch
from
November 20, 2026 09:39
2949778 to
d3c357d
Compare
This was referenced Nov 20, 2026
This branch has not been deployed
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.
Randomized branching should make the same decisions regardless of how the search tree is explored. Previously, sharing mutable generator state meant cloning, recomputation, and parallel workers could drift apart, and reproducing a run from a printed state was not reliable.
This PR turns
Rndinto a value type holding the complete state of a splittable generator, and splits that state wherever search branches. Cloning, recomputation, and parallel search then make identical random choices, and any printed state can be restored exactly.Key changes
Rnduses SplitMix by default, switches to xorshift64* when built withGECODE_RANDOM_ENGINE=xorshift64star, and supports custom engines throughRndGenerator<Engine>. The seed constructor is now explicit (INT_VAL_RND(Rnd(42))).Space::spoke()returns, so restarts and portfolio assets get distinct streams even when nested. Models that own a generator directly can split it withrnd.split(sc), asphotoand FlatZinc now do for LNS. Copies of a random cutoff split their generator rather than reseeding it.state()andstate(text)replaceseed(). The script drivers and FlatZinc accept-state, andgecode-test -replayaccepts the state printed for a failing test.Compatibility, overhead, and testing
Both the
RndAPI and the sequences produced for a given seed change in this PR. Before rebasing onto #283, recomputation with random branching measured roughly 12% slower with SplitMix and 6% slower with xorshift64*. Also before the rebase, both engines passedcheck, all CTests, and the Search, Branch, Assign, FlatZinc, and NoGoods suites, and the fault-injection tests passed under ASan and UBSan.This branch is a single commit on top of #283. After the rebase, the following pass:
check: 521Stack
Merge in this order. #242 targets
main, and each later PR builds on the one before it so its diff shows only its own commits. The first four PRs are standalone search and random-number changes; #284 through #274 are the Gecode 7 changes split out of what used to be a single branch.