Counts at a specific time step in AnyLogic

933 views Asked by At

I'm trying to run a standard SIR agent-based model where agents transition from 'Susceptible' to 'Infected', and from 'Infected' to 'Recovered'. I'm now interested in calculating the instantaneous incidence, i.e. the number of agents who transition from 'Susceptible' to 'Infected' state at a given time t.

For example: On day 1 (model time), 2 agents transition from 'Susceptible' to 'Infected' On day 2 (model time), 5 agents transition from 'Susceptible' to 'Infected' On day 3 (model time), 7 agents transition from 'Susceptible' to 'Infected' . . .

I am able to get the total count of 'Infected' agents, but I'm interested in knowing this value of each time step. I'm looking to write a function that cumulatively adds up the number of new infections for each time step.

Any ideas on how one might do this in AnyLogic would be very helpful. Thanks.

2

There are 2 answers

0
Benjamin On BEST ANSWER

Here is a screenshot, you need to select "Other" for the key to manually type the dimension "Date()": enter image description here

2
Benjamin On

I suggest you create a collection on Main col_Counter of type where the key is the day and the value is the number of infections. Then create a recurring event in the Agent called e_Counting starting at the model start and recurring every 24 hours. In the action write:

main.col_Counter.add(date(), v_countsToday);

v_countsToday=0;

Also create the v_countsToday as an integer-variable in the agent. Add +1 whenever an infection happens.

There are many other ways but this will work.

cheers