Search code examples
resourcesanylogic

In AnyLogic, how to create a changing, shared resource?


A fake example that emulates what I am trying to accomplish is the following:

I am emulating a restaurant that has employees. There are three sinks for washing dishes.

The "Number of Employees" required to run the sinks uses this formula: Number of Employees = (Number of Sinks) + 2

This is because there are some efficiencies in the workflow when multiple sinks are being used at the same time.

I have a resource for employees and an agent (population) to represent the 3 sinks. When a new sink starts to get used, I check to see the "Number of Employees" currently "busy". I then calculate how many additional workers would be needed to be seized.

The problem I am running into is when a sink stops being used the "Number of Employees" required may change as well. I now need to release that many employees, in order to accurately reflect the required "Number of Employees". The "release" block; however, releases the entirety of the "seize" block. This may be more than the employees that should be released.

Is there an easier way to manage a changing shared resource? Or if this is a good way, how do you manage the releasing of individual employees not the entire seize block?


Solution

  • What you say is not absolutely correct:

    The "release" block; however, releases the entirety of the "seize" block. This may be more than the employees that should be released.

    If you go to the release block, you will see that you have the option to release a specific number of resources of a given pool. Moreover, that number is dynamic so it can be a function with the number of sinks as an input.

    I think the trick is that you MAY need more than one release blocks that are consecutive, one for employees and one for sinks, depending on your model design.

    enter image description here