nikhilgupta10 / GridLAB-D

Other
1 stars 0 forks source link

#764 random numbers orders of magnitude smaller in linux, #2501

Closed nikhilgupta10 closed 7 years ago

nikhilgupta10 commented 7 years ago

I/u2019m taking a look at the failing autotests in my 64 bit Ubuntu vm. I noticed that all the failing autotest involve some type of random function in the object code. I/u2019m getting really weird outputs. For example, I created a test that just contained the following.

//test_core_random_number_stream.glm tests to make sure that the same random numbers are produced when the stream is fixed regardless of OS.

set randomseed=12150

module residential {

implicit_enduses NONE;

};
module tape;
module assert;

clock {

timezone PST+8PDT;
starttime '2012-01-01 0:00:00';
stoptime '2012-01-01 1:01:00';

};

class house{

random rnum;

};

object house {

rnum ype:uniform(0,1); refresh:1min; state:12150\;
object recorder {

property rnum;
file test_core_random_number_stream1.csv;
interval 60;
limit 61;

};

};

Here is the range of numbers from windows 64 and 32
0.010834 /u2013 0.998047

Here is the range of numbers from Ubuntu 64
1e-6 /u2013 3e-5

I noticed that we mask the random numbers with RAND_MAX in random.c. That number is 0x7FFF in windows and 0x7FFFFFFF in GNU C libraries for Linux. Could this account for the drastic difference in random numbers produced?

I tried changing the code to mask with number with 0x7FFF instead of RAND_MAX. I got different numbers but they are still the same orders of magnitude smaller than the ones generated in windows. I got this output while debugging in the #739 ticket_branch as my autotools are too new to successfully build the current state of trunk or 3.0.

,

nikhilgupta10 commented 7 years ago

nikhilgupta10 imported these comments from Sourceforge: The user ciraci does not exist anymore. Therefore assigning this to afisher1. "andyfisher": * attachment _test_core_random_numberstream.glm added ,

"ciraci": * status changed from new to closed

RAND_MAX was indeed the problem.

,