问题
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