AnyLogic funtion with using SelectOutputOut block and while loop

Viewed 62

Good day! I faced the challenge of writing the function for allocation of the agents into SelectOutputOut blocks. Considering various scenarios of using if...else statements in function I understand that all possibilities must be covered (as suggested here). However, the problem is that I don't want the agent to leave the function before it gets the appropriate SelectOutputOut block. This situation may occur if there are not enough resources in any Service blocks (Network1, Network2 or Network3). In this case, it is necessary to wait for any Service block will have enough resources for servicing the agent. For this purpose, I tried to use the while loop, but it doesn't help. The questions are:

  1. How to write the if-else statements to force the agent waits for enough resources in any Service block
  2. Does the Select function monitor the parameters which are outside it? In other words: Does it know about the states of Service blocks during its execution?

Thank you.

The system structure The properties of the SelectFunction

1 Answers

What you need to do is have your agents wait in the queue and then have a function to remove them from the queue and then send them to the correct service block. The best way to do this is with an enter block where you can send them to.

See example below

enter image description here

You then need to call this function at the On enter code for the queue as well as the On exit code for the service blocks, to ensure you are always sending new agents when there is space.

enter image description here enter image description here

Related