英文:
Dynamic agent in pedestrian library is not getting connected using Distance Based Network in Anylogic
问题
我正在尝试创建一个动态模型,在这个模型中,代理(行人)在环境中移动,如果满足基于距离的条件,则必须相连。
我参考了在线资源,但是我只能在代理静止不动时获得连接的代理,而不能在代理移动时获得连接,就像在行人中一样。
如果有任何线索,将不胜感激。
祝好,
Avron
英文:
I am trying to make dynamic model where in the agents(pedestrians) move in an environment and must be connected if the condition is distance based is satisfied.
I took reference from online resources,however I could only get a connected agent when the agents are static and not when agents are moving like in a pedestrian.
Any leads would be appreciated.
Cheers,
Avron
答案1
得分: 0
如果您正在使用条件事件(我不知道如何操作),那我可能不会太信任它...
但也许您可以尝试这种效率较低的技术,根据您拥有的模型类型,可以将其变得更加高效:(这应该在每个行人代理的周期事件中运行)
for(Pedestrian p : main.pedestrians){
if(!p.equals(this)){
if(p.distanceTo(this)<100){//假设100是您想要的距离
connections.connectTo(p);
}else{
connections.disconnectFrom(p);
}
}
}
英文:
If you are using a conditional event (i don't know how) then i wouldn't trust it so much...
But maybe you can use this rather inefficient technique, that can be made more efficient depending on what kind of model you have: (this should run in a cyclic event inside each one of your pedestrian agents)
for(Pedestrian p : main.pedestrians){
if(!p.equals(this)){
if(p.distanceTo(this)<100){//assuming 100 is the distance you want
connections.connectTo(p);
}else{
connections.disconnectFrom(p);
}
}
}
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论