Anylogic: Release specific resource

Viewed 218

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?

3 Answers

I can think of many ways to do this depending on the situation... first one is to use a selectOutput before the release in order to release or not. The selectOutput will check if it's the right resource to release

select output

the other option, if you want to release everything with the same release block but in a given order, you can put a wait block before the release block and wait for the right moment to release the resource

wait

another one, is to use wrap up actions, and put a wait block in the wrap up, to wait for the other resources to arrive there before releasing so they are released in order

post-wait

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.

The only way to release specific resources, with the standard seize blocks, is to specify that you want to release resources that were seized at a specific seize block

enter image description here

This then implies that you need as many seize and release blocks as you want control over the release process. i.e. if you seize 5 of a resource type and want to release them 1 by 1 over the course of the flow chart you will need 5 seize and 5 release blocks.

Related