Boost logo

Boost Users :

Subject: [Boost-users] Cost of constructing models of RandomDistribution
From: Robert Patterson (riap2_at_[hidden])
Date: 2010-02-19 08:03:19


I have a fairly large simulation code, that I need to get into a state
in which I can multi-thread it. One of my problems is a global random
number generator state.

I am thinking that I should replace this global object with a collection
of generator engines, one for each thread, which would be passed down by
non-const reference from the top level of each thread to the places
where random numbers are needed. In this case it seems best to pass
around engines that model PseudoRandomNumberGenerator. In each place
that I want a random number (I rarely need more than 1 or 2 at once or
with the same parameters) I would then have to construct and use a
RandomDistribution, such as uniform_int, exponential_distribution (or
poisson, but that is a question for another day).

This approach relies on these models of RandomDistribution being fairly
cheap to construct. I cannot see any reason why this should not be the
case, but equally I cannot see any promise in the docs that they will be
cheap to construct.

Am I proposing to use the library in a sensible way?

Thanks

Robert Patterson


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net