Search code examples
serviceresourcesdelayanylogic

Anylogic: How to set Service delay time depending on the resourceSet being used


Basically I've got a Service which can work with two alternatives of ResourceSets. Let's say, the Service would optimally work with one Doctor and one Nurse, but it is also possible to work with only one Doctor if a Nurse isn't available.

Now, assuming the Doctor works slower without a Nurse, the Service's delay time must depend upon the resourceSet being employed at the moment (Doctor+Nurse or Doctor). Any idea how can I program this?

You should also have in mind that my model has various Services in parallel working in the same way, it's not just only one Service line.

Thanks!


Solution

  • You're using Services but, to me, using the combination of Seize, Delay and Release gives you more flexibility. What I've done is set the resource choice according to the image bellow: enter image description here

    It is important to have the nurses prior to the doctors in the first set (for some reason anylogic would opt for using only the doctor if otherwise - even with a nurse available).

    Than, I would write this code: enter image description here

    Which means that if the agent was only able to seize one resource it will take longer (15 is just a random value).

    In the delay block, I would set the processing time to agent.processTime

    The topology I'm using is this:

    enter image description here

    Obviously this is a workaround and will not work for every case. You can always change the conditions you verify. I couldn't find a way to check which resource set was picked by the seize operation. If you're in a hurry this will do the trick.

    Hope that helps, Luís