Search code examples
anylogic

How to access ResourcePool of higher level agent?


  • I have 7 Agents instances in my Main agent. (Lets call them Production_Line)
  • In each of the agent instances, there are machines. (Lets call them Glass_Former)
  • Each Glass_Former needs to be oiled once every 20 minutes. This requires a "Worker" (Resource).
  • There are 2 Workers in the Factory, who need to do the oiling on all 7 production lines.

How do I create a shared resource_pool for all 7 Production_Lines?

I've tried creating a resource pool in the main agent, but its not accessible from service or seize blocks withing the Production_Line agent.

I've also tried creating a variable inside the Production_Line of object type "ResourcePool" and referencing the main.Workers resource pool, but I can't do anything with it, in terms of using that reference to a resource pool in the seize or service blocks.

I've also tried making the service block visible to the upper agent, but I can't really "access" the resource pool from within the main-agent, so I could use the properties window to assign the resource pool.


Solution

  • I assume by 'non accessible' you mean 'not in the dropdown list'. If you click the equal sign beside the Resource sets: box, it will turn into a standard code box and you can write there anything (even call functions that return the resource set).

    In my experience the syntax can be a bit tricky at first, so I suggest creating a dummy ResourcePool in Production_Line, use it for the desired settings, then click the equal sign and replace the name of your dummy pool with main.resource_pool (you can delete the dummy pool afterwards).

    enter image description here