Factors Inhibiting Reproducability Of Simulation Results

C

Chris Gordon-Smith

I just managed to get my artificial chemistry simulation producing the
same results when I run it twice with the same parameters. Perhaps some
members of the group will be interested in the two factors that led to
differing results:

1) My graphics library (GTKMM2) calling rand() at random times between
the calls made by my code
2) My code storing pointers in an std::set, and then iterating over the
set. The ordering is dependent on the memory locations of the dynamically
allocated objects to which the pointers point.

Chris Gordon-Smith
www.simsoup.info
 
J

Jorgen Grahn

I just managed to get my artificial chemistry simulation producing the
same results when I run it twice with the same parameters. Perhaps some
members of the group will be interested in the two factors that led to
differing results:

1) My graphics library (GTKMM2) calling rand() at random times between
the calls made by my code

Aargh! But in a sense that's just another example of the brokenness
of rand(). You usually want a PRNG where you keep the state manually.
I assume the TR1 random number stuff can do that.

/Jorgen
 
M

Miles Bader

Jorgen Grahn said:
Aargh! But in a sense that's just another example of the brokenness
of rand(). You usually want a PRNG where you keep the state manually.
I assume the TR1 random number stuff can do that.

The random state in both TR1 and C++11 is a part of the generator
object, so ... yeah. [Of course it would be super duper surprising if
this wasn't true!]

-Miles
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top