Search code examples
resourcessimulationreleaseanylogic

Anylogic: Release specific resource


I've got another small issue with AnyLogic resources.

I want to be able to release a specific resource from a resource pool - not just any resource from the pool. The reason is that I occasionally seize multiple resources from a ResourcePool (one at a time) and then wish to release the resources again one at a time. But I don't want to release "any" resource from the pool, I want to be able to specify which specific resource of the pool to release.

Is this possible or is this one of the limitations of the resources implementation?


Solution

  • One way to do this that worked before for us is to use separate agents to grab resources. So for example:

    1. Suppose there is the main WorkItem agent then
    2. When a resource is needed, a Split block is used to spawn a new agent called ResourceHolder
    3. The new ResourceHolder then grabs the resource using normal Seize
    4. Afterwards ResourceHolder carrying the unit is joined back to the WorkItem using Combine.

    The ResourceHolder has to be stored somewhere in WorkItem and it should be built to be able to tell which resource unit it is carrying (i.e. original resource pool, type of resource, when it was grabbed, etc.). Then when only a specific resource unit needs to be released the model needs to find the right ResourceHolder in the WorkItem and run it through a Release block. It is a little cumbersome but definitely gives a very fine control over release logic.