2

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?

Jaco-Ben Vosloo
  • 3,770
  • 2
  • 16
  • 33
CrustyNoodle
  • 379
  • 1
  • 14

3 Answers3

2

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

Felipe
  • 8,311
  • 2
  • 15
  • 31
  • Thanks Felipe, I'm not sure this will work for me as I have multiple resources seized all from the same ResourcePool. So I'd really like to be able to control which of the resources from the same ResourcePool to release. – CrustyNoodle Sep 21 '21 at 07:40
  • that's exactly what I proposed as a solution here... but depending on your situation you will need to define which one of the 3 options i provided work best.... Stop a moment, and think carefully about this... you will see that it works perfectly fine... you will need to add some code that's all – Felipe Sep 21 '21 at 07:46
  • Sorry, I'm just not seeing it. The issue I'm wrestling to understand is with the Release block which only provides you with the ability to release resources from a given ResourcePool rather than a specific resource from a pool. – CrustyNoodle Sep 21 '21 at 07:54
  • it depends.. what do you want to do with the agent that seized the resource... you want it to continue without the resource while the resource is not released (solution 3 from my answer), you want it to continue with the resource to find a different moment to release in the flow (solution 1) or you want it to wait before release (solution 2) – Felipe Sep 21 '21 at 09:17
  • if you want something like solution 1, then Jaco's answer is also an option – Felipe Sep 21 '21 at 09:41
2

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.

Artem P.
  • 816
  • 1
  • 6
  • 8
  • Hey Artem, I think this will work for my use case. I'll have a go at implementing it and get back to you. – CrustyNoodle Sep 21 '21 at 11:42
  • Thanks Artem, I have implemented this approach and it is working very successfully for me. In my use case multiple resources are seized using the same Seize block so the only solution that works for me is to have a "ResourceManager" agent seize the resource and then attach itself to my flowchart agent (actually the ResourceManager is just added to a collection in the flowchart agent). – CrustyNoodle Sep 27 '21 at 04:47
1

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.

Jaco-Ben Vosloo
  • 3,770
  • 2
  • 16
  • 33
  • Thanks Jaco, a bit cumbersome but it could work. I suspect that under the covers when you say you want to release a resource that was seized in a particular seize block A/L actually just looks at the ResourcePool that the seize block seized from rather than the actual resource that was seized. I will experiment with this option though. – CrustyNoodle Sep 21 '21 at 07:43
  • Cumbersome indeed. We have built our own resource manager in the past but it requires a lot of testing to make sure you manage the seize and release of resources and agents correctly, but in the end, it is super flexible and you can literally make it do exactly what you want. You might also want to check this answer as to how you can save the resources that get seized https://stackoverflow.com/questions/68631813/resource-specifications-and-tracking-of-agent/68632841#68632841 – Jaco-Ben Vosloo Sep 21 '21 at 09:13
  • 1
    "I suspect that under the covers when you say you want to release a resource that was seized in a particular seize block A/L actually just looks at the ResourcePool that the seize block seized from rather than the actual resource that was seized." It doesn't: it does do what it says (releases the exact set of resources seized in that Seize block, which could have come from any number of pools and any number of resources within each pool). – Stuart Rossiter Sep 23 '21 at 09:51