0
votes

I am dumbfounded why I am not able to simulate a simple queue system correctly.

The system is as follows:

Influx Poisson stream (exponential distribution) with a rate of 1 agent per 2 minutes.

A queue with capacity 2.

Two (2) servers with a service rate of 1 agent per 3 minutes each.

If the system is full (both servers and the two places in the queue are occupied) new agents will not enter the system but are destroyed.

In Anylogic I have modeled the system like so: Model

The source element is specified with interarrival time '2' and the agents are destroyed when they are not able to enter the system (because the queue is full). source EDIT: As pointed out by Felipe it should be "exponential(0.5)" instead of simply "2"; Nevertheless this does not solve the problem. The measurements are still wrong: The queue has now an average length of 0.55 vs. 0.413 (should be), the system has now an average number of agents of 1.92 vs. 1.727 (should be) and the average loss rate is 8.67 % vs. 12.4 % (should be).

The queue is specified with capacity '2' and FIFO mechanism. queue

The delay element is specified with capacity '2' and a delay duration of 'exponential(1.0/3.0)' minutes. delay

The sink is plain vanilla. sink

Now, queue theory tells us that we expect to observe a limit mean number of agents in the system of 1.727. And a limit mean number of agents in the queue of 0.413. And an average loss rate (agents destroyed) of 12.4 %.

But when i simulate the system with Anylogic i get different results. Oddly enough the mean of the agents in the queue is correct with 0.413. But the average loss rate in the anylogic simulations is about 1.7 % and the mean of the agents in the system is something like 1.83.

The loss rate can be easily caculated via 'On Discard' action in the 'source' element: "CountLost++;" ('CountLost' being a variable i have created) Then i can compare the 'CountLost' variable against the complete number of agents created.

Whats my mistake?

Thank you very much for your help! Martin

EDIT2: Felipe asked for the calculation: Calculation

1
I don't know if this will solve all your problems but to have an exponential distribution on the source, you need to write the exponential distribution as exponential(0.5) since you have 0.5 arrivals per time unit (minute)... If you only write 2, the agents will arrive at exactly 2 minutes intervals - Felipe
Dear Felipe, thank you very much for your comment and pointing out one of my mistakes. But unfortunately the measurements are still wrong: The queue has now an average length of 0.55 vs. 0.413 (should be), the system has now an average number of agents of 1.92 vs. 1.727 (should be) and the average loss rate is 8.67 % vs. 12.4 % (should be). Are you able to reproduce this result? It should be fairly easy to rebuild the model on your machine. Again, thank you very much! - Martin H.
how are you calculating the theoretical values? - Felipe
Dear Felipe, thank you for your interest! I have added a screenshot with the calculation to the post (see above). The avg. number of agents in the queue can be calculated via 1.727-1.314=0.413 Edit: The theoretical values are correct. I am 99.999% sure. Also when i simulate it with GPSS World i get the theoretical values. But nevertheless it does no harm to check double check it. - Martin H.
I don't know :P sorry - Felipe

1 Answers

0
votes

Ok, I solved the mystery. Indeed Anylogic seems to have a bug in the source element when using "Agents which can't exit: are destroyed". I have remodeled the system using "Forced pushing" in the source and a selectOutput directly connected to the source. The selectOutput routes the agents into a second (discard)-sink if the queue is full. Like so: NewModel

Now the measurements are correct.

EDIT: I received word from the Anylogic Support: "Actually the Source block that destroys agents if queue is full stores 1 agent inside (if the agent cannot exit). Only the 2nd and subsequent agent is destroyed. In this case the model behaves like there is queue with capacity = 1, then goes the queue with capacity = 2, and finally Delay and Sink. This is old feature of Source block, it occurs due to the pull-protocol. I have posted the task for the developers to implement the option with instant destroy of the agents that cannot exit."