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

时间:2017-06-15 03:27:49

标签: anylogic

当您在AnyLogic中双击代理时,它会导航到该代理的内部,这样您就可以看到它的状态,变量等。有没有办法通过函数调用以编程方式执行此操作而无需添加 ViewArea?我当前的解决方案是添加ViewArea,然后在我需要导航到代理时使用viewArea.navigateTo(),但这似乎过多,多次执行并且在多个代理类型中。

2 个答案:

答案 0 :(得分:2)

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.

What do you mean here? You still can double-click on embedded agents to navigate straight to them.

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.

That is how to do it programmatically. Rather than duplicate it in each Agent you need it in, use a superclass Agent which has the ViewArea and navigation in so you can reuse it across Agents (e.g., Agent ViewAreaAgent with your agents AgentA and AgentB extending 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).

What kind of problems (out of more general interest)? I don't think there's any easy way of sharing view area functionality without subclassing. (More generally in Java you can use things like interfaces and object composition instead of inheritance to do the same thing --- see Bloch's Effective Java (especially Item 16 in the 2nd edition) --- but I don't think that can usefully work here because of view areas needing to be in the Agent you're navigating to.)

答案 1 :(得分:1)

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