AnyLogic 如何将吸引子选择设置为自由和随机 [英] AnyLogic how to set attractor choice to both free and random
问题描述
有没有办法让吸引子选择既免费又免费?同时随机?
我自己的问题是:
- When the choice is set to Free - agents are using attractors in very predictable order based on attractor creation.
- When the choice is set to Random - more than one agent is using an attractor at the same time, which I don't want.
我找到了但不知道如何正确实施的解决方案在以下线程中:
然后在设置吸引器的过程建模块 (PML) 中,您有一个返回吸引器的函数.我在这里提供代理,以便我们可以跟踪哪个代理被发送到哪个吸引子,以便我们可以在代理离开吸引子位置后将吸引子放回可用堆中.
这里是 getAttractor 函数
它获得一个随机的可用吸引子,然后还将把它带到地图上的代理保存
这是地图的设置mapAgentPerAttractor
如果你想释放吸引子,你可以在吸引子被释放的任何时候简单地调用它
attractorsAvailable.add(mapAgentPerAttractor.get(agent));mapAgentPerAttractor.remove(agent);
这是最终结果以及我们正在复制您描述的问题的比较
可以看到在底部节点中只有 8 个点可用,因为一些代理位于同一个吸引子上...
Is there a way to make attractor choice both free & random at the same time?
The problem I have with either on it's own is:
- When the choice is set to Free - agents are using attractors in very predictable order based on attractor creation.
- When the choice is set to Random - more than one agent is using an attractor at the same time, which I don't want.
Solution I found, but don't know how to implement correctly is in the following thread:
AnyLogic Attractor weird behavior
I tried to create an agent type (instead of a class) 'myAttractor' with a boolean variable inside (occupied or not occupied attractor), but I don't know how to assign that agent type to actual attractors within a node - if that is even possible?
Maybe there are other solutions to customise the attractor choice to achieve complete randomness with only one agent per attractor?
Many thanks in advance, Peter
That is a good question and often a problem on the animation side of things.
One option is to create a collection, simple ArrayList will do, of all the attractors
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.
Here is the getAttractor function
It gets a random available attractor and then also saves the agent that is taking it to a map
Here is the setup for the map mapAgentPerAttractor
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
One can see in the bottom node there are only 8 dots available as some agents are on the same attractor...
这篇关于AnyLogic 如何将吸引子选择设置为自由和随机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!