Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Factors Inhibiting Reproducability Of Simulation Results

Reply
Thread Tools

Factors Inhibiting Reproducability Of Simulation Results

 
 
Chris Gordon-Smith
Guest
Posts: n/a
 
      09-10-2011
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
 
Reply With Quote
 
 
 
 
Jorgen Grahn
Guest
Posts: n/a
 
      09-11-2011
On Sat, 2011-09-10, Chris Gordon-Smith wrote:
> 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

--
// Jorgen Grahn <grahn@ Oo o. . .
\X/ snipabacken.se> O o .
 
Reply With Quote
 
 
 
 
Miles Bader
Guest
Posts: n/a
 
      09-12-2011
Jorgen Grahn <(E-Mail Removed)> writes:
>> 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.


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

--
`There are more things in heaven and earth, Horatio,
Than are dreamt of in your philosophy.'
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Top Ten SEO Factors zak Java 1 02-19-2007 07:12 PM
Displaying factors using Recursion smshinde@gmail.com Java 2 07-29-2006 07:46 AM
inhibiting comment reflow Roedy Green Java 11 07-29-2005 03:35 AM
Power Factors,,,Hmmmmm Nick Beard Digital Photography 10 01-11-2005 01:17 AM
inhibiting NG access? Sligo Computer Support 3 02-10-2004 06:27 AM



Advertisments