2

When you double click on an Agent in AnyLogic it navigates to that Agent's internals so you can see its states, variables, etc. Is there a way to do this programmatically with a function call without adding a ViewArea? 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.

Dylan Knowles
  • 2,726
  • 1
  • 26
  • 52

2 Answers2

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

Stuart Rossiter
  • 2,432
  • 1
  • 17
  • 20
  • sorry about that. I've clarified. 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). – Dylan Knowles Jun 16 '17 at 01:21
2

Each agent has default view area object, its name is _origin_VA. So, you may call something like agent._origin_VA.navigateTo(); This area is not visible in graphical editor, but you may find it with code completion.

Gregory Monahov
  • 711
  • 3
  • 7