swarm-support
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

wierd random number behavior


From: Paul Box
Subject: wierd random number behavior
Date: Mon, 19 Apr 1999 00:39:47 -0600 (MDT)

Hello Group

I have been working with a fire model that uses CA-like behavior in a
landscape.  The model worked fine when used on my linux box at work (a
pentium 200 with 64M RAM); however, I have put the code on my pet
laptop and recompiled it for a presentation, and started getting
bizarre behavior with the model.  After some fiddling around, I
discovered the culprit to be coming from uniformDblRand.

Here is where the offending lines occurred:

A cell is given a number of messages from neighboring cells, which are 
requests to burn.  Each fuel component inside the cell compares the
urgency of the burn requests with its own conditions, and decides
whether to start burning or not.

The code, in Fuel.m, is as such:

- makeDecisionAtUrgency: (float) urgency {

  double randNum;
  double threshold;

  threshold = urgency * load * exp(-moisture / 4);
  randNum = [uniformDblRand getDoubleWithMin: 0.0 withMax: 1.0];

  if (randNum < threshold)
    [self setBurning: 1];
  else
    [self setBurning: 0];
  
  printf ("\t\t fuel compared %f and %f \n", randNum, threshold);

    return self;
}

The printf statement was added as a way to check why things were going 
wrong when this ran on my laptop.  At this part of the simulation, the 
printf statement gave the following output:

                 fuel compared 0.353868 and -27255296557.392986 
                 fuel compared 0.313851 and 9945314261.998653 
                 fuel compared 0.007383 and 18195143603.152775 
                 fuel compared 0.236007 and -12823928380.525589 
                 fuel compared 0.304299 and 4679383970.345970 
                 fuel compared 0.628275 and 8561022917.100419 
                 fuel compared NaN and -28163390113.579769 
                 fuel compared NaN and 10276672821.115992 
                 fuel compared NaN and 18801370456.165474 
                 fuel compared NaN and -8273947266.455919 
                 fuel compared NaN and 3019119809.569216 
                 fuel compared NaN and 5523537722.697916 

The NaN's continue on for about 30 more lines.  This pattern continues 
every step, with the first six calls showing reasonable numbers and
the rest a bunch of NaNs.

Any ideas as to what's happening?  

I'm a great fan of Indian food, and love NaNs with curry, but not in
my random number streams.


-- 
//////////////////////////////////////////////////
// Dr. Paul Box
// Dept of Geography and Earth Resources
// UMC 5240
// Utah State University      http://www.nr.usu.edu/~sanduku
// Logan, UT  84321           Phone: 435-797-2546
//////////////////////////////////////////////////

*  If Elvis was so great, why was he buried in the back yard like a
*  hamster?

                  ==================================
   Swarm-Support is for discussion of the technical details of the day
   to day usage of Swarm.  For list administration needs (esp.
   [un]subscribing), please send a message to <address@hidden>
   with "help" in the body of the message.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]