We could have every ls:ask (ls:of, etc) sets the child's seed with a nextInt off the parent's RNG (or some function of it anyway). This way:
Setting parent's random seed implicitly sets the children's (there's a downside to this too).
Parallelism still works, since the children are still using different RNGs.
There's no correlation between the states of the children's RNGs, as there would be if they were all given the same seed.
Calling ls:ask (etc) multiple times without intervening RNG calls in the parent won't cause the child to repeat the same sequence multiple times (as would happen if we simply synchronized the child's RNG with the parent's). We need to be careful here, though, as we could repeat sub-sequences if, for instance, x and y end up the same in something like:
child.seed(parent.nextInt)
child.nextInt
x = child.nextInt
child.seed(parent.nextInt)
y = child.nextInt
I think this is prevented by how Mersenne Twister works, but we should test for it. The NetLogo test for this would be something like:
not member? ([ random-float 1 ] ls:of 0) ([ list random-float 1 random-float 1 ] ls:of 0)
The downsides to this are that:
Setting the random seed of a child won't stick between ls:ask calls.
ls:ask (etc) advances the random seed (I really don't think this is a problem).
New proposal: We set child model seed at model creation. Then add a ls:random-seed primitive which sets the parent's seed and every child's seed using nextInt.
We could have every
ls:ask
(ls:of
, etc) sets the child's seed with anextInt
off the parent's RNG (or some function of it anyway). This way:ls:ask
(etc) multiple times without intervening RNG calls in the parent won't cause the child to repeat the same sequence multiple times (as would happen if we simply synchronized the child's RNG with the parent's). We need to be careful here, though, as we could repeat sub-sequences if, for instance,x
andy
end up the same in something like:I think this is prevented by how Mersenne Twister works, but we should test for it. The NetLogo test for this would be something like:
The downsides to this are that:
ls:ask
calls.ls:ask
(etc) advances the random seed (I really don't think this is a problem).@arthurhjorth what do you think?