有没有办法返回代理与其目的地之间网络沿线的节点列表? [英] Is there a way to return a list of the nodes along a network between an agent and it's destination?

查看:30
本文介绍了有没有办法返回代理与其目的地之间网络沿线的节点列表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果给定 moveTo() 命令,我想返回并捕获代理将行进的路径元素和节点的列表.从这个列表中,我可以看到代理是否会通过某些节点,在这些节点中代理的行为会有所不同(减速、暂停 1 分钟等).然后,我可以为每个节点循环执行 moveTo() 命令,并根据它经过的节点更改参数.

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.

我很想提供一些示例代码,但我不确定从哪里开始获取列表.TIA

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

推荐答案

您可以使用此函数获取从源到目标的最短路径:

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);

您可以通过调用 rd.getMovements().get(index).getNetworkElement() 来访问 rd 的元素.这将返回一个对象,该对象可以是路径、节点或矩形节点等的实例.

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.

有关更多详细信息,您可以查看此处:AnyLogic 帮助 - TransporterControl

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

这篇关于有没有办法返回代理与其目的地之间网络沿线的节点列表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆