Search code examples
simulationanylogicagent

Anylogic: Agent movement within another agents diagram and main diagram


I created an agent 1 and an agent 2 both existing in main. On startup I place agent 2 in a node which is located whithin agent 1 (main.agent1.node). But now when I want to move agent 2 to another node existing on main, the agent moves to an entirely different location, which seems to be dependent on the relative position of agent 1. Can someone explain the mechanism at work to me? Is agent 2 living in the continuous space of agent 1? How can I transfer it to main, so that it would move to the right position in relation to the main diagram? Thanks for taking the time.


Solution

  • Yes, spacing is always relative to the agent that "owns" you.

    To transfer agent1 back to main alongside agent2, best use a flowchart "enter" block on main, push agent1 through it and use its "New location" setting to select some node on Main.

    You can also call setEnvironment(main.getEnvironment()) to do it programmatically. More info in the help: https://anylogic.help/anylogic/agentbased/continuous-space.html#agent-animation enter image description here