【问题标题】:AnyLogic: How to display distribution of agent variables in a histogramAnyLogic:如何在直方图中显示代理变量的分布
【发布时间】:2019-07-05 21:28:03
【问题描述】:

我正在尝试对“患者”代理群体中的年龄分布进行建模,并将其可视化为直方图。每个病人都有一个变量,“PtAge”,每年增加一个 - 他们也有机会每年死亡并从模型中删除。到目前为止的代码是:

#Event, runs each year
PtAge += 1;
#PtAges is a HistogramData object
main.PtAges.add(PtAge);

if (dead)
{
    main.remove_patients(this);
}

我添加了一个直方图,显示来自 PtAges HistogramData 对象的数据,但问题是一旦将年龄添加到分布中,它就会永久保留在分布中。我怎样才能得到一个反映当前患者年龄分布的直方图?

【问题讨论】:

    标签: anylogic


    【解决方案1】:

    据我所知,您无法访问直方图数据对象元素并单独删除它们,因此您每次都必须重置直方图......所以像这样:

    ptAges.reset();
    for(Patient p : patients){
        ptAges.add(p.ptAge);
    }
    ptAges.update(); //not sure if this is necessary for you
    

    【讨论】:

      猜你喜欢
      • 2021-06-06
      • 2021-03-13
      • 2021-09-05
      • 1970-01-01
      • 2018-02-08
      • 1970-01-01
      • 1970-01-01
      • 2019-07-11
      • 2016-09-02
      相关资源
      最近更新 更多