在 AnyLogic 中导航到代理/代理的默认视图?

Navigate to agent / agent's default view in AnyLogic?

当您在 AnyLogic 中双击一个 Agent 时,它会导航到该 Agent 的内部结构,以便您可以查看其状态、变量等。有没有一种方法可以通过函数调用 以编程方式执行此操作,而无需添加一个ViewArea?我目前的解决方案是添加一个 ViewArea,然后在我需要导航到代理时使用 viewArea.navigateTo(),但这对于多次和多种代理类型来说似乎太过分了。

It used to be that when you double clicked on an Agent in AnyLogic it would navigate to that Agent's internals so you could see its states, variables, etc.

这里是什么意思?您仍然可以双击嵌入式代理直接导航到它们。

My current solution is to add a ViewArea and then use viewArea.navigateTo() whenever I need to navigate to the agent, but that seems excessive to do multiple times and in multiple agent types.

这就是如何以编程方式执行此操作。不要在每个需要它的代理中复制它,而是使用具有 ViewArea 和导航的超类代理,这样您就可以跨代理重用它(例如,代理 ViewAreaAgent 与您的代理 AgentAAgentB 扩展 ViewAreaAgent).

I was hoping to avoid subclassing: it used to cause us all sorts of problems when building hierarchical models incorporating both continuous 2D and GIS environments. Perhaps that's no longer the case in 8.1 (recently upgraded from 7.3.7).

什么样的问题(出于更普遍的兴趣)?我不认为有任何简单的方法可以在不进行子类化的情况下共享视图区域功能。 (更普遍的是,在 Java 中,您可以使用诸如接口和对象组合之类的东西,而不是 继承做同样的事情 --- 参见 Bloch's Effective Java (尤其是第 2 版中的第 16 项) --- 但我不认为这在这里有用,因为视图区域需要在代理中你'重新导航至。)

每个代理都有默认的视图区域对象,其名称是_origin_VA。所以,你可能会调用类似 agent._origin_VA.navigateTo(); 这个区域在图形编辑器中不可见,但你可能会通过代码完成找到它。