在 Anylogic 模拟中很难找到代理的当前位置
我为从起点线到目标线的行人运动建立了一个简单的模型,我想使用 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 )
事件的动作是获取该区域的代理数量并设置变量crowd1的值:
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.
您的环境中没有代理,因为您尚未创建任何代理类型...要使您的代码正常工作,您需要注册一定数量的行人在您的环境中(意味着您必须创建代理类型并将其添加到 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)