AnyLogic吸引器奇怪的行为 [英] AnyLogic Attractor weird behavior

查看:61
本文介绍了AnyLogic吸引器奇怪的行为的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的理解是节点内的吸引子的容量应该为 1,也就是说,在 3D 动画中,每个吸引子应该只有一个代理.当我运行模型时,我看到同一个吸引子上有两个代理形状,而其他吸引子是空的.

My understanding is that attractors within nodes should have a capacity of 1, in the sense that in a 3D animation, there should only be one agent per attractor. When I run the model, I am seeing two agent shapes on the same attractor while other attractors are empty.

这是正常行为吗?有没有办法防止这种情况发生?

Is this normal behavior? Is there a way to prevent this from happening?

请注意,这不会一直发生,但随着模型的运行,有时代理会去空的吸引子,而有时他们会去已经有代理的吸引子.

Note that this is not happening all the time, but as the model is running, sometimes agents go to empty attractors, while other times they go to one that already has an agent.

推荐答案

一个选项是创建一个集合,简单的 ArrayList 就可以做到,所有的吸引子

One option is to create a collection, simple ArrayList will do, of all the attractors

然后在设置吸引器的过程建模块 (PML) 中,您有一个返回吸引器的函数.我在这里提供代理,以便我们可以跟踪哪个代理被发送到哪个吸引子,以便一旦代理离开吸引子位置,我们就可以将吸引子放回可用堆中.

Then in the Process Modelling Block (PML) where you setup the attractor you have a function that returns an Attractor. I supply the agent here so that we can keep track of what agent is sent to which attractor so that we can put the attractor back into the available pile once the agent leaves the attractor location.

这里是 getAttractor 函数

Here is the getAttractor function

它获得一个随机可用的吸引子,然后还将把它带到地图上的代理保存

It gets a random available attractor and then also saves the agent that is taking it to a map

如果你想释放吸引子,你可以在吸引子被释放的任何时候简单地调用它

If you want to free the attractor you can simple call this at any point that the attractor is freed

attractorsAvailable.add(mapAgentPerAttractor.get(agent));
mapAgentPerAttractor.remove(agent);

这是最终结果以及我们正在复制您描述的问题的比较

Here is the final result as well as a comparison where we are replciating the problem you described

这篇关于AnyLogic吸引器奇怪的行为的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆