[Ns-bugs] [Bug 101] random variable intialization
code@nsnam.ece.gatech.edu
code at nsnam.ece.gatech.edu
Tue Jun 7 11:55:29 PDT 2011
https://www.nsnam.org/bugzilla/show_bug.cgi?id=101
--- Comment #9 from Tom Henderson <tomh at tomh.org> 2011-06-07 14:55:28 EDT ---
(In reply to comment #6)
> Here's the approach I propose:
>
> Reserve x number of streams for explicit use. In order to not invalidate
> current simulations, these reserved streams should be well into the generator
> rather than at the beginning (for example, starting at stream y).
Why would choosing x reserved streams to start at stream 0 invalidate current
simulations? It will likely change (not invalidate) simulation output after
this change is made; however, the current system doesn't guarantee that output
is unchanged across ns-3-dev changes.
It seems to be clearer to me to not have these buried somewhere at some offset
y to stream 0. How to pick y so as to be large enough to avoid most (how to
define most?) or all current simulations yet not incur a performance issue
seems tricky.
>
> To reserve these streams, we just need to generate the appropriate seeds for
> them. I have some test code that does this (saves x seeds starting at seed y
> into a static variable, much like nextSeed). Then, when you want to use a
> specific seed, specify the number (between 1-x) and the appropriate seed will
> be set. This will not affect nextSeed, so random variables created after this
> will not be affected.
>
> Here's my question. Can we make setting the stream be a function in
> RandomVariable, or does it need to have a separate constructor, or both? This
> depends upon how these will be used most often.
I would probably lean towards something like a pure virtual method
virtual void RandomVariable::UseReservedStream (uint32_t streamIndex) = 0;
each subclass needs to then deal with this properly when it goes to call 'new
RngStream ()'. By making this pure virtual, we break any out-of-tree
RandomVariables and make them update their model. The SeedManager could
perhaps enforce bounds checking on the streamIndex and whether streams are
requested more than once (calling NS_FATAL_ERROR for exceptions).
We probably also need to extend the constructors too since some of these
variables are instantiated as attributes (see class
RandomWaypointMobilityModel). An alternative is to add an additional attribute
for a ReservedStream that could be used to call "UseReservedStream()", but I am
not sure what the default of such an attribute is if we want it to default to
random stream.
The number of reserved streams could be perhaps set and stored as a GlobalValue
in the same way as RngSeed.
The base class copy constructor needs to do something sane if it is copying a
RandomVariable with a reserved stream.
Then, I think we will need to work through a practical use case (mobility
module) to plumb through the APIs and see if we got the design right.
>
> Then, we'll need to decide the proper values of x and y:
> x - number of reserved streams, we'll need a double[x][6] static array
> y - number of unreserved streams before running into reserved ones, make affect
> performance to generate lots of these, but I haven't tested it yet
--
Configure bugmail: https://www.nsnam.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
More information about the Ns-bugs
mailing list