[Ns-developers] Random Variables API changes

Raj Bhattacharjea raj.b at gatech.edu
Tue Jan 20 08:40:56 PST 2009


On Mon, Jan 19, 2009 at 1:34 AM, Tom Henderson <tomh at tomh.org> wrote:
> Similarly, in all of the example files, I think we should be careful to
> update our suggested usage pattern; e.g.:
>
> -  RandomVariable::UseGlobalSeed (1, 1, 2, 3, 5, 8);
> +  uint32_t seed[6] = {1, 1, 2, 3, 5, 8};
> +  SeedManager::SetSeed(seed);
>
> is going to reinforce the less-preferred behavior of changing seeds each
> time to try to get independent runs.  Better would be something like:
>
> -  RandomVariable::UseGlobalSeed (1, 1, 2, 3, 5, 8);
> +  // Change either the run number below or the RngXXX attribute to obtain
> an independent replication
> +  SeedManager::SetRun (1);
>

I'll admit that this suggested usage pattern was a quick idea I came
up with to make the tree compilable.  There are some other of these
quick ideas that need to be looked at.  The biggest of these is a
change like the following:

- UniformVariable::GetSingleValue (0, N)
+ UniformVariable().GetValue (0, N)

I had to do this in one place to make things compile, but seems a bit
wasteful to construct and destruct a RV in this way each time.  The
alternative I would suggest is for each class which formerly used the
static GetSingleValue APIs to now maintain a private RV member from
which they can draw random variables.  The affected file is
olsr-agent-impl.cc, so I would suggest Gustavo provides a patch if he
doesn't like the anonymous temp variable approach I hacked in.

-- 
Raj Bhattacharjea
Georgia Institute of Technology
School of Electrical and Computer Engineering
Ph.D. Candidate
Systems Analyst
404.894.2955


More information about the Ns-developers mailing list