Reputation: 125
In my Anylogic model I let agents (trucks) enter the process blocks of a terminal. I want to plot this "arrival rate" per each hour of the day (e.g., 100 trucks between 12:00-13:00 arrived at this terminal), for all hours of the day (24). How can I do this the simplest way?
Upvotes: 1
Views: 646
Reputation: 2213
Create a cyclic event that occurs every hour. Also add two datasets to your model: one named cumulativeArrivals, the other arrivals (of course feel free to name the datasets whatever makes sense to you). Finally add a variable of type int
called count with initival value 0.
Then, in the event action field, write the following code:
cumulativeArrivals.add(enter.out.count());
if( count == 0 )
arrivals.add(cumulativeArrivals.getY(count));
else
arrivals.add(cumulativeArrivals.getY(count) - cumulativeArrivals.getY(count-1));
count++;
Finally, add a plot with the following settings:
Upvotes: 2
Reputation: 12605
myDS
that does not update itself. Make sure to untick "use time as horizontal value" (we will use the time but in hour time units)counter
In the event code, write:
myDS.add(time(HOUR), counter); // stores number of arrivals in the past hour, stored at the current model time
counter = 0; // reset for next interval
In the enter
block's "on enter" code, update the counter every time an agent arrives, using counter++;
Now you have a DS that stores how many agents arrived each hour. Plot that in a time plot and you are good to go.
Upvotes: 2