Is there a way to return a list of the nodes along a network between an agent and it's destination?

北城以北 提交于 2020-01-25 04:40:06

问题


I'd like to return and capture a list of the path elements and nodes that an agent will travel if given a moveTo() command. From this list, I can see if the agent will pass through certain nodes where the agent will behave differently (slow down, pause for 1 minute, etc.). I can then cycle through moveTo() commands for each node and change the parameters based on the node it's going through.

I'd love to give some sample code, but I'm not sure where to begin to get the list. TIA


回答1:


You can use this function to get the shortest route from source to target:

RouteData rd = RouteData findShortestPath(ILocation source, ILocation target, Node[] nodesToAvoid, Path[] pathsToAvoid);

You can access the elements of rd by calling rd.getMovements().get(index).getNetworkElement(). This will return an object which could be an instance of a path, or a node, or a rectangular node etc.

For more details you can look here: AnyLogic Help - TransporterControl



来源:https://stackoverflow.com/questions/59312646/is-there-a-way-to-return-a-list-of-the-nodes-along-a-network-between-an-agent-an

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