Search code examples
anylogicagent

Anylogic: How can I open/close a valve on an agent frame from the main/rootframe?


I am building a DES-ABM hybrid model in AnyLogic. The agents go through the DES blocks on the main frame. From these blocks on the main/root frame, I want to open a valve on the agent frame.

When I use agent.xxx and it finds the proper agent with all elements on the agent frame.

I used

'''agent.valve_trafficsignIN.open(); ''' (in a DES block on main/rootframe)

to open the valve on the agent frame. It does not give me any errors when I run it. Also, when I print the information using traceln, it gives me the correct specs of the valve in question and it states that it is open.

However, when I open the agent frame, the valve is still closed. Also, the changes that should happen in the model when the valve opens do not happen.

What should I change/how do I open the valve on the agent frame from the main/root frame?


Solution

  • I found out that a DES source block generates agents in a DeafaultPopulation, which is why I could not find the correct agent during the simulation run. I changed the source setting to 'add agents to: custom population' and I can now find, and refer to, the right agent.