0

Good morning, in a System Dynamics model created on AnyLogic, I would like to compute the cumulative sum of a flow of the previous 7 days. My purpose is to calculate the reproduction ratio of a disease starting from the infectious population at time t over the cumulative sum of the infectious in a fixed time interval. The formula is the following:

Formula

where:

  • I(t) = infectious population at time t --> I(t) is a flow in the model that changes a stock
  • I(t-s) = infectious population at time t-s
  • w(s) = gamma distribution
  • s represents the time interval of the previous 7 days

I have all the data but I am not able to calculate the sum of I(t-s).

Thanks.

1 Answers1

0

You have to do this manually. Create a variable mySum of type double. Then, add a cyclic event that regularly adds to it from the stock (something like myVar += myStock).

You may need to use an additional variable that stores the temporary stock value from the last time you added, so you only add what was "new" since the last cycle.

In short: use a cyclic event to "approximate" your integral.

Benjamin
  • 10,603
  • 3
  • 16
  • 28
  • Thank you for the answer. You are right, I need an additional variable to store the temporary stock value because the variable mySum continues to increase. But how can I create this additional variable for stocking? – VERONICA ARIOLI Jun 17 '21 at 15:23
  • Drag in a variable and ... use it? :) – Benjamin Jun 18 '21 at 04:57