I am working on a system dynamics model, whose units are days, in AnyLogic. The model tracks daily demand of water for 10,950 days (30 years). One of the model’s outputs is a timeplot that keeps track of this demand, but I don’t want it to plot the daily demand. Instead, I want the timeplot to show demand in years (i.e. the sum of 365 days across the 30 years). I am having a bit of trouble finding a way to do this and would appreciate any help. Thank you!
Asked
Active
Viewed 102 times
0
-
how are you tracking the daily demand? – Felipe Jul 09 '21 at 06:18
-
I have 6 different kinds of demands, each is calculated in a dynamic variable by multiplying a parameter (that has Gallons Per Capita per Day) with population (which is a stock). All of these demands are added together to create the TOTAL daily city demand – Vianey Rueda Jul 10 '21 at 06:16
1 Answers
0
I assume your problem is twofold.
- How to get the time plot to display 30 years of data
- How to sum the annual demand for 30 years
Here is a simple example that I believe answers your question.
In this simple model, there is a daily event that simulates the daily demand, and adds it to a variable called annualDemand
There is another event that runs yearly and tasks the annualDemand
and saves it to a data set, and rests the annual demand accumulator to 0.
In your time plot, you simply display the dataset which will at the end of the model only contain 30 entries, one for each year.
By following the same principles
- Save annual demand
- yearly event to add annual demand to data set and reset the annual demand
- time plot to plot the dataset
You should be able to get what you need.

Jaco-Ben Vosloo
- 3,770
- 2
- 16
- 33
-
Thank you for this! Could you speak more to the code that’s in the daily event (annualDemand += uniform discr (10))? I’m not sure I understand this. My daily demand is calculated by the product of dynamic variables and parameters. – Vianey Rueda Jul 10 '21 at 01:31
-
`annualDemand += uniform discr (10))` is the same as `annualDemand = annualDemand + uniform discr (10))` so it just increases the annual demand by some random number between 0 and 10. Since I do not have the details about your exact implementation I just created some sample code. I you find the answer useful remember to accept it – Jaco-Ben Vosloo Jul 11 '21 at 06:28
-
I haven’t been able to get the events to work. The way I calculate emend is as follows: I have 6 different kinds of demands, each is calculated in a dynamic variable by multiplying a parameter (that has Gallons Per Capita per Day) with population (which is a stock). All of these demands are added together to create the TOTAL daily city demand. These daily demands I need to add up for each year. – Vianey Rueda Jul 11 '21 at 19:04
-
You need to record the total daily demand where you calculate it and then store it to the variable. It is hard to provide more meaningful advice without a better understanding of your model. Can you either add more details to your question or perhaps post a new one. Since it is a System Dynmics model you might be able to simple record the change in the variable from one time period to the next – Jaco-Ben Vosloo Jul 12 '21 at 05:00