UC-Davis-molecular-computing / ppsim

Python package for simulating population protocols
MIT License
9 stars 5 forks source link

add controllable random number seed for reproducible results #16

Open dave-doty opened 3 years ago

dave-doty commented 3 years ago

This can be tricky. When I did this in dsd, it wasn't sufficient to use the same RNG everywhere. I discovered through much trial and error that I was getting different results on different runs because Python does not guarantee iteration order of set's, i.e., if you make the same set by putting in items in the same order twice, and iterate over them, you might iterate in a different order each time. That's why dsd uses the ordered-set package and only uses OrderedSet when it could affect the run results.

Luckily, Python dict's do guarantee iteration order.

EricESeverson commented 3 years ago

There is a seed option, so in theory it should be reproducible. I haven't tested this thoroughly, so the TODO here is to add some unit tests of reproducibility.