我想有一个累积的母猪进入水槽(Deadsowsculledsows和
在过去的52周中。我为每周母猪创建了变量
使用循环事件在这些下沉位置的死亡。我希望为模拟的每个星期计算此累积数字。例如,在第10周 - 我想累积
第1至10周的死亡人数;在第52周 - 我想有一个第1周的累积号码
到52,对于第53周 - 我想在第2周到53周之间有一个累积数量,
等等。
有人建议我使用linkedhashmap,我同意,但是我不知道从哪里开始设置?我想将一周用作价值和每周死亡作为关键。我在哪里插入代码以将值放入LinkedHashMap中?
为了实现这一目标,我觉得我缺少组件。
https://i.sstatic.net/eense.png” alt =“ linkedhashmap”的死亡下沉和收集

I want to have a cumulative number of sows that enter the Sink (deadSowsCulledSows and
sowDeaths) over the last 52 weeks. I have created variables for weekly sow
deaths at these sink locations using cyclic events. I want this cumulative number to be calculated for every week of the simulation. For example, at week 10 – I want to have a cumulative
number of deaths for weeks 1 to 10; at week 52 – I want to have a cumulative number for week 1
to 52, and for week 53 – I want to have a cumulative number between weeks 2 and 53,
and so on.
It has been suggested that I use a LinkedHashMap, and I agree, but I don't know where to begin with setting this up? I want to use week as the value and weekly deaths as the key. Where do I insert the code to have the values put into the LinkedHashMap?
I feel like I am missing components in order to achieve this.


发布评论
评论(1)
听起来您想要过去52周的移动窗口。
这里有一些选择,但是我建议您最简单的选择是使用任何logic数据集对象,因为它已经具有您需要的“保持最大数量的样本”功能。
然后获取数据集的总和并将其保存到LinkedHasmap。
您的每周活动的代码可以如下所示,
在下面,我每周可以增加我创建的另一个变量,以跟踪几周。
It sounds like you want a moving window of the last 52 weeks.
There are a few options here but the easiest one I would suggest for you is to make use of the AnyLogic DataSet object as it already has this "keep up to a maximum number of samples" functionality which is what you need.
Then gets the sum of the data set and save it to the LinkedHasMap.
The code for your weekly event can be as below
Where weekCounter is just another variable that I created that I can increase every week to keep track of the weeks.