Idea of time in Agents.jl modelling

Hello everyone,

It may be very naive to ask but Im not sure I understand idea of time in Agents.jl modelling. In Agents modelling we usually use steps right? like for how many steps it should run. But lets say I want to reflect some specific time so for example lets say I wanna run simulation for 12 hours period for my model. How one should integrate steps with time or if they are same thing ? So in this case will be simulating for 12 steps and then you frame it what you call it hours or day.

Thank you

Its all about the self-consistency of the properties and units of your model. If you are simulating the movement of cars, the cars will have velocities with specific units (for instance km/h) and your time-step will mean something relative to those velocities.

4 Likes

This is a modelling decision that’s completely detached from the modelling framework you’re using. It’s of theoretical nature and the utmost priority is to keep your model consistent. Basically what @lmiq said.

2 Likes

okay. So, let’s say if I have a system where ball moves based on some dynamics which are govern by set of differential equations. Then in this case end output solution of set of differential eqaution will inform each ball step. Something like this? Indirectly, time isn’t important in case of agents.jl but for differential part.

the reason I want to clear this up is for my model I want to have a condition that agents come from normal state to some active state and do something for some time period and then go in normal state again.

  1. You need to determine whether the phenomena you are modeling is best described using discrete or continuous time. It also depends on your research question.

  2. If you decided on discrete time, then you need to determine which time step / time delta is the best to answer your research question.

  3. You can emulate multiple timeframes even with discerete time steps, i.e using if abmtime(model) % cycle_time == 0

  4. Special case: If you want to model Time Travel, then you need to add time dimension into your space. i.e. (x, y, t) for 2D, and (x, y, z, t) for 3D (doesn’t matter ContinuousSpace or GridSpace).

  5. Useful mental models

One mental model is a a regular OS like Windows or Linux vs special “tickless” Realtime OS (RTOS). In the former the scheduler switches between tasks every so and so milliseconds (called “tick”), which creates an illusion that all processes run concurrently, but in practice most of the time the system is idling between processes, and can miss important hardware or realtime events. In the latter, the RTOS “tickless” scheduler allocates time slices for each task, and have higher priority for important realtime or HW events, so they don’t need to wait for CPU.

Another mental model is Gradient Descent: if your step is too large - you may miss the maximum, if it’s too small - the search will take a long time.


1 Hour Here Is 7 Years on Earth - INTERSTELLAR scene

Time in Agent-based models

2 Likes

Thank you :slight_smile: for such a nice video and description. I guess abmtime() can do the trick. I will try it.

Hello,

I was wondering is there a way to take a copy of timestep by using abmtime()?

To make my question clear:

if I wanna do something like x = abmtime(model) (lets say its 1 ) which extract timepoint now i want to use this in a condition where I have a current running time. So, while x +8 > abmtime(model) do something end Now issue is x gets updated too as its equal to abmtime(model) and its not static. i want to capture timepoint as static values or constants and then use them. Is this possible ?

There is nothing special about timestep values, They’re simply non-negative sequential integers.
Value 0 - is the initial state, then it gets incremented with each step.

You can see them in the model/agent dataframes outputs of the run.

You can save the timestamp values in the model or agent attributes if this makes sense.
For example if your timestemp = 1 day, then you can even convert it to a calendar dates, and check for the day of week, business days, or holidays.

Also if your model/environment has timeseries properties, one need to be careful not to use datapoints from the future, i.e. variable[t+10].

Thank you :slight_smile: this part I understood :sweat_smile: Issue Im facing right now is to use this timestep to schedule something for future. Example agent color red now and after timestep 5 be green. Is this possible ?

Of course it’s possible, but it sounds like you’re simply interested in animated demo / visualization, instead of an underlying phenomena. Unless 5 timesteps has some real meaning in your model.

Let’s say it’s a time of transition between states for that agent type, then I would make it a model parameter. If it’s different for different agents, then it would be a property of an agent, and randomly draw from a distribution.

But in any case it should be relative to the current timestep, not an absolute timestep number.

Actually I have a medium size model where this part is curcial though its not as simple as that red and green in cas eof my model but from there I would had got idea that how can I transfer same idea in my model.

I have one agent which I differentiate based on some agent parameter and they interact with each other when comes in contact. Now I want them to not interact after some time ( In ABM terms - steps). I have tried writing some conditions but everytime issue is I was unable to get a initial timestep of interaction as it was getting updated to with actual model tiem step which makes condition not useful and thats why I asked if there is a way to extract timestep in a way that it can be used as a point of reference and compared to future time step and further apply a condition.

Thank you everyone for your inputs. This works for me exactly how I wanted without going into abmtime() . :slight_smile: May be this will be helpful for someone else coming to this question.

function agent_step! (agent, model)

    if agent.status == :red      #where status is an agent property

        agent.step += 1    #where step is an agent property

        if agent.step == 40    # irrespective of at what time agent got red exactly 
                                # after 40 steps after that it will get blue.

            agent.status = :blue
            agent.step = 0

        end
    end

    move_agent!(agent, model, model.dt)  


end