swarm-support
[Top][All Lists]
Advanced

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

Re: [Swarm-Support] Re: Simulation timing


From: Steve Railsback
Subject: Re: [Swarm-Support] Re: Simulation timing
Date: Thu, 08 May 2003 12:58:11 -0700

Kanagaraj Krishna wrote:
> 
> Hi,
>    I have questions regarding the simulation timing in SWARM.
> 
> -how does getCurrentTime() method in Swarms Global enviroment works? Does it 
> follow the system timing (hours,minutes,second) of the PC or does it have its 
> own way of quantifying time?

getCurrentTime just tells you the number of times the swarm's schedule
has been cycled through. So, yes, it is like the number of cycles
completed, no relation to clock time.
 

> -this question is just out of curiosity. If it doesn't follow the system 
> timing, is it possible to set simulations to run on real time.

If what you mean is whether you can relate a swarm schedule's time to
your computer clock's current time... yes you could, by writing system
calls to get the current time from your operating system, then using
dynamic scheduling to tell model actions to take place at that current
time. Your operating system uses a time value that is in "time_t"
format, the integer number of seconds since 1/1/1970. So if the current
time happened to be 935424000 (as it approximately is) you could
schedule an action to be executed at 935424000. The schedule will
execute that action as soon as there are no other actions scheduled at a
smaller time value. Of course you would want to convert the time_t value
back into something humans can read.

However, what you may mean is how can you do models where every cycle
through the schedule represents a day or an hour, etc. We do this a lot,
and eventually wrote a class to interact between Swarm and the system's
built-in date-time functions. This was necessary because the system
functions are quirky, handle daylight savings time in the worst possible
way, and vary among systems in undocumented ways. 

Go to http://math.humboldt.edu/~simsys/software.html and get the
documentation for TimeManager. The code is in Obj-C but if you want to
use Java Swarm, you are far better off translating our code to Java than
starting from scratch. You just include a TimeManager update in your
model schedule, and it keeps track of the simulation date & time. The
documentation will at least tell you a little more about how the time_t
stuff works.

I am also right now finishing up some related code that reads and
manages time series input data. So if you model is currently simulating
Hour 13 on January 23, 2007, our TimeSeriesDataManager will get you the
right input data for that date and hour.

Steve R.
 
-- 
Lang Railsback & Assoc.
250 California Ave.
Arcata CA  USA 95521
707-822-0453; fax 822-1868


reply via email to

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