difficult to find the current location of agents in Anylogic simulation

£可爱£侵袭症+ 提交于 2019-12-11 17:35:09

问题


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 )

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)

the problem is that it's always 0 , even though the gents are moving in the simulation.


回答1:


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)


来源:https://stackoverflow.com/questions/51688718/difficult-to-find-the-current-location-of-agents-in-anylogic-simulation

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!