NickA
NickA

Reputation: 443

Simulating first come first serve agent distribution

I currently have agents of type patient seizing an exam room when it becomes available, then, to mimic a first come first serve system where different healthcare practitioners see the patient, I have utilized a SelectOutputIn and 4 SelectOutputOut blocks corresponding to the 4 different practitioners that can see the patient. Each SelectOutputOut block has the same probability corresponding to their resource type. The problem arises when all practitioners are busy, it seems to send patients only to the Physio path and overload it. Is this because it is physically the last block in the order? How can I make the distribution of patients random even if all practitioners are busy?

[enter image description here][1

enter image description here

enter image description here

enter image description here

enter image description here

Upvotes: 0

Views: 42

Answers (1)

Emile Zankoul
Emile Zankoul

Reputation: 2213

It is correct. If all probabilities are zero, AnyLogic seems to pick the last option. To address your issue, we need to add a condition for when all practitioners are busy. So you will have 3 possible outcomes as follows:

Surgeons.idle() + Fellows.idle() + Residents.idle() + Physios.idle() == 0 ? 0.25 : Surgeons.idle() > 0 ? 0.25 : 0

The difference between the first and second 0.25 is that in the first case, all ports will have a 0.25 probability. Whereas in the second case, 3 of 4, or 2 of 4 or even 1 of 4 will have a 0.25 probability depending on how many resources are available. AnyLogic normalizes the probabilities. So if two ports have 0.25 probability, then it's like saying it's a 50/50 chance.

Finally, if the code seems too long, you can replace the first part by a function to have a cleaner/shorter code.

The function body could be:

return Surgeons.idle() + Fellows.idle() + Residents.idle() + Physios.idle();

Assume you named the function function, you can simplify your code in the probability field as follows:

function() == 0 ? 0.25 : Surgeons.idle() > 0 ? 0.25 : 0

Upvotes: 1

Related Questions