Reputation: 241
I am experiencing some strange random-seed behaviour in my model.
The following procedure:
to testRNG
clear-all
random-seed 10
type random 100
type ","
create-nodes 10
type random 100
type ","
ask nodes[ create-node2node-links-with other nodes in-radius (1000)]
print random 100
end
Produces output that looks like this:
observer> testRNG
78,78,42
observer> testRNG
78,78,42
observer> testRNG
78,78,40
observer> testRNG
78,78,42
observer> testRNG
78,78,71
observer> testRNG
78,78,52
observer> testRNG
78,78,71
observer> testRNG
78,78,40
observer> testRNG
78,78,97
observer> testRNG
78,78,52
observer> testRNG
78,78,97
observer> testRNG
78,78,52
observer> testRNG
78,78,18
observer> testRNG
78,78,19
observer> testRNG
78,78,27
observer> testRNG
78,78,34
observer> testRNG
78,78,58
observer> testRNG
78,78,52
observer> testRNG
78,78,40
Obviously something is happening when the breeded links are created, but I am really unsure what it is. For completeness note that node2node-links are undirected and declared as:
undirected-link-breed [node2node-links node2node-link]
Puzzlingly, while the third call to random 100 is clearly not reproducible, it also looks like it may not be pseudo-random.
I have investigated this a little further and something strange is clearly happening - here is a another example from my actual runtime code. In this case the links are created after the 5th call to random 100, subsequent calls are not reproducible - however I have to think that the odds of the RNG generating "34, 1, 1" seven times out of nineteen would be very small.
START 66 , 62 , 61 , 21 , 62 , 10 , 67 , 2 END
START 66 , 62 , 61 , 21 , 62 , 34 , 1 , 1 END
START 66 , 62 , 61 , 21 , 62 , 34 , 1 , 60 END
START 66 , 62 , 61 , 21 , 62 , 29 , 32 , 41 END
START 66 , 62 , 61 , 21 , 62 , 16 , 71 , 78 END
START 66 , 62 , 61 , 21 , 62 , 10 , 67 , 2 END
START 66 , 62 , 61 , 21 , 62 , 34 , 1 , 1 END
START 66 , 62 , 61 , 21 , 62 , 34 , 1 , 1 END
START 66 , 62 , 61 , 21 , 62 , 34 , 1 , 1 END
START 66 , 62 , 61 , 21 , 62 , 34 , 1 , 1 END
START 66 , 62 , 61 , 21 , 62 , 29 , 32 , 41 END
START 66 , 62 , 61 , 21 , 62 , 81 , 26 , 63 END
START 66 , 62 , 61 , 21 , 62 , 92 , 11 , 93 END
START 66 , 62 , 61 , 21 , 62 , 88 , 93 , 60 END
START 66 , 62 , 61 , 21 , 62 , 34 , 1 , 1 END
START 66 , 62 , 61 , 21 , 62 , 34 , 1 , 1 END
START 66 , 62 , 61 , 21 , 62 , 34 , 93 , 60 END
START 66 , 62 , 61 , 21 , 62 , 88 , 93 , 60 END
START 66 , 62 , 61 , 21 , 62 , 94 , 11 , 38 END
I have created a blank model with just the node and node2node breeds/link-breeds and this single procedure and the behaviour does not occur - instead all calls to random 100 are reproducible.
I am at pains to include all my model code as it is fairly long and would undoubtedly be information overload - moreover, by calling clear-all I think I can rule out dependancy on some other section of the program.
If anyone has any ideas on what might be happening here, or can highlight something simple I have overlooked, it would be greatly appreciated.
Upvotes: 2
Views: 75
Reputation: 12580
Summary from comments:
This is due to a bug in the NW extension where running nw:weak-component-clusters
in a monitor was sporadically advancing the main random number generator. Monitors and plots are meant to use their own RNG, so any code you run in a monitor or plot should not affect the outcome of other code.
https://github.com/NetLogo/NW-Extension/issues/144
Upvotes: 1