[Networkit] Static seeds for RNGs in NetworKit

Patrick Bisenius patrick.bisenius at gmail.com
Wed Feb 25 17:53:49 CET 2015


last week I talked to Christian Staudt about static seeds for Aux::Random in NetworKit. Today, I implemented a quick solution which is good enough for me, but probably not good enough in general.

Basically, I declared two static variables uint64_t seed and bool staticSeed in Aux::Random and a function setSeed(uint64_t newSeed) to set the seed. If getSeed() is called, I check for a static seed and return it if provided. Otherwise, everything works how it has before.

https://algohub.iti.kit.edu/parco/NetworKit/NetworKit-fork-Bisenius/changeset/14117ca0bd5125b9b86f4645d7aa81bfa626bbe4 <https://algohub.iti.kit.edu/parco/NetworKit/NetworKit-fork-Bisenius/changeset/14117ca0bd5125b9b86f4645d7aa81bfa626bbe4>

This approach is good enough if there is only need for exactly one static seed which is provided before any random number needs to be generated. Once getURNG() was used once, it is no longer possible to set a seed since the generator is initialized statically (see: https://algohub.iti.kit.edu/parco/NetworKit/NetworKit-fork-Bisenius/files/14117ca0bd5125b9b86f4645d7aa81bfa626bbe4/networkit/cpp/auxiliary/Random.cpp#L48 <https://algohub.iti.kit.edu/parco/NetworKit/NetworKit-fork-Bisenius/files/14117ca0bd5125b9b86f4645d7aa81bfa626bbe4/networkit/cpp/auxiliary/Random.cpp#L48>).

One solution to this problem could be to "invalidate" a generator when setSeed() is called.

Patrick Bisenius

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ira.uni-karlsruhe.de/mailman/private/networkit/attachments/20150225/251b8d82/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 842 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <https://lists.ira.uni-karlsruhe.de/mailman/private/networkit/attachments/20150225/251b8d82/attachment.sig>

More information about the NetworKit mailing list