如何绘制 enter block 中代理的每小时到达率?

How to plot arrival rate per hour of agents in enter block?

在我的 Anylogic 模型中,我让代理(卡车)进入终端的流程块。我想绘制一天中每小时的“到达率”(例如,12:00-13:00 之间有 100 辆卡车到达该航站楼),一天中的所有时间 (24)。我怎样才能以最简单的方式做到这一点?

  1. 创建一个不会自行更新的数据集myDS。确保取消选中“使用时间作为水平值”(我们将使用时间,但以小时为单位)
  2. 创建一个整型变量counter
  3. 创建一个每小时循环触发的事件。

在事件代码中,写:

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

enter 块的“进入时”代码中,每次代理到达时更新计数器,使用 counter++;

现在您有一个 DS,它存储每小时到达的代理数。在时间图中绘制它,你很高兴。

创建一个每小时发生的循环事件。还要向模型中添加两​​个数据集:一个名为 cumulativeArrivals,另一个名为 arrivals (当然,您可以随意命名数据集,只要您觉得合适)。最后添加一个类型为 int 的变量,名为 count,初始值为 0.

然后,在事件操作字段中,写入以下代码:

cumulativeArrivals.add(enter.out.count());

if( count == 0 )
   arrivals.add(cumulativeArrivals.getY(count));
else
   arrivals.add(cumulativeArrivals.getY(count) - cumulativeArrivals.getY(count-1));

count++;

最后,添加具有以下设置的绘图: