(Anylogic) How to reference Main from another agent

Viewed 363

How Do I Reference Main From Within An Agent?

I have a resourcepool of 1 of an agent moving items in Main. There the process is modelled with The Process Modelling Library. The Agent does neither Enter not Exit the Process Model, but perists indefinitely.
I now wish to add a statechart to my agent, in which I want to test if the agent arrived at a certain Queue Block in Main. However, I cannot reference Main from my agent's statechart. Neither 'get_Main()' nor 'main' work, as I also don't have the arrow with main on it (I have seen this on reference models).
I'm using Anylogic 8.1

The main arrow I found in reference models

Edit: solution i found: Use a variable and set it to Main, you can reference items in Main over this variable.

1 Answers

Two options:

  1. embedd an agent population on Main and make your ResourcePool add agents to that on creation. This will give you the main link

  2. Use getEngine().getRoot() at any point in your model. As long as your top-level agent is Main (normal case), this will work. You may have to type-cast it as ((Main)getEngine().getRoot())

Related