Hi,
I must be missing something basic as my use of random_vertex returns always
the same vertex each time I run the code (which is listed below).
Help would be much appreciated. I'm using MSVC 7.1 and boost 1.32 on windows
XP.
TIA,
Rui
#include <iostream>
#include
Rui Carvalho wrote:
Hi,
I must be missing something basic as my use of random_vertex returns always the same vertex each time I run the code (which is listed below).
Sure, because the random number generator is initialized with the same seed on each invocation. You can seed it with current time or something like that. Note however, that you'll need to output the seed and have an option to specify it manually, if you want to be able to debug anything. If you're using random_vertex for some testing, I'd recommend not using seed and just running the tests several times. The sequence of vertices will be always the the same, but still sufficiently "random". - Volodya
Vladimir Prus wrote:
Sure, because the random number generator is initialized with the same seed on each invocation. You can seed it with current time or something like that.
Thanks for this. Is there anything on the docs/examples on how to initialize the random number generator? I mean, boost/random/mersenne_twister.hpp seems to be an adaptation of the original Mersenne Twister by Matsumoto and Nishimura -is it the same as the original? Thanks, Rui
Rui Carvalho wrote:
Vladimir Prus wrote:
Sure, because the random number generator is initialized with the same seed on each invocation. You can seed it with current time or something like that.
Thanks for this. Is there anything on the docs/examples on how to initialize the random number generator?
http://boost.org/libs/random/random-generators.html#mersenne_twister
mentions this method:
void seed(DataType value);
I think passing the result of time:
#include
I mean, boost/random/mersenne_twister.hpp seems to be an adaptation of the original Mersenne Twister by Matsumoto and Nishimura -is it the same as the original?
I don't know, sorry. - Volodya
On Dec 8, 2004, at 7:26 AM, Rui Carvalho wrote:
Hi,
I must be missing something basic as my use of random_vertex returns always the same vertex each time I run the code (which is listed below).
Help would be much appreciated. I'm using MSVC 7.1 and boost 1.32 on windows XP.
The generators in the Random library are deterministic, so they should always return the results. Seed the generator with something more "random" (like the result of time(0)) to get some randomness. Doug
participants (3)
-
Doug Gregor
-
Rui Carvalho
-
Vladimir Prus