maxitg / SetReplace

C++/Wolfram Language package for exploring set and graph rewriting systems
MIT License
219 stars 46 forks source link

Using multiple rules ignores RandomSeeding in WolframModel #642

Closed maxitg closed 3 years ago

maxitg commented 3 years ago

The problem

RandomSeeding is ignored in some cases in WolframModel.

For example:

In[] := Counts @ Table[
  BlockRandom[
    WolframModel[<|"PatternRules" -> {{{1, 2}} -> {}, {{2, 3}} -> {}}|>,
                 {{1, 2}, {2, 3}},
                 <|"MaxEvents" -> 1|>,
                 "EventOrderingFunction" -> "Random"]["FinalState"],
    RandomSeeding -> 123],
  100]
Out[] = <|{{2, 3}} -> 95, {{1, 2}} -> 5|>

produces different results every time it's run. However, doing the same with a single rule (which is equivalent in this case), produces consistent results as expected:

In[] := Counts @ Table[
    BlockRandom[
      WolframModel[<|"PatternRules" -> {{{a_, b_}} :> {}}|>,
                   {{1, 2}, {2, 3}},
                   <|"MaxEvents" -> 1|>,
                   "EventOrderingFunction" -> "Random"]["FinalState"],
      RandomSeeding -> 123],
    100]
Out[] = <|{{1, 2}} -> 100|>

Expected behavior

Since the seed is specified, the result should always be the same.

Version

In[] := SystemInformation["Small"]
image
In[] := $SetReplaceGitSHA

c07dba14af76d7be0c71c60d9c96c1a7f41cae58

daneelsan commented 3 years ago

Could you share what hypergraphConsensusRule looks like? 😛

maxitg commented 3 years ago

@daneelsan, oops, sorry, updated now to include the rule.

maxitg commented 3 years ago

It looks like this weed only appears if using multiple rules. I updated it with a minimal example.