在Anylogic仿真中很难找到代理的当前位置 [英] difficult to find the current location of agents in Anylogic simulation
问题描述
我为行人从起始线到目标线的移动建立了一个简单的模型,我想使用XY坐标(在X = 150到X = 350,Y相同)中找到某个区域中移动代理的数量。
i built a simple model for pedestrian movement from start line towards target line, I want to find the number of moving agents in some area using the XY-coordinates (from X=150 to X=350, Y is the same )
该事件的操作是获取该区域中的业务代表计数,并为变量人群1设置值:
The action for the event is to get the count of agents in that area and set the value for the variable crowd1:
crowd1=count(agents(), p-> p.getX()>150 && p.getX()<350)
问题在于,即使绅士在模拟中移动,该值始终为0。
the problem is that it's always 0 , even though the gents are moving in the simulation.
推荐答案
您的环境中没有代理,因为因为您尚未创建任何座席类型...为了使代码正常工作,您需要在环境中注册大量的行人(这意味着您必须创建座席类型并将其作为populatin添加到main中),并且那么您必须将在pedSource中创建的代理添加到自定义总体中。
There are no agents in your environment because you haven't created any agent type... For your code to work you need to have a population of pedestrians registered in your environment (meaning that you have to create the agent type and add it to main as a populatin), and then you have to add to a custom population the agents created in pedSource...
否则,您可以使用以下代码:
Otherwise, you can use this code:
count(pedGoTo.getPeds(),p->p.getX()>150 && p.getX()<350)
这篇关于在Anylogic仿真中很难找到代理的当前位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!