2

I am trying to implement 2 metrics for queues (or Service blocks) in my model; average waiting time and average number waiting. For the average waiting time; I can time stamp every agent in the 'On Enter' action and then calculate the delta in the 'On seize unit', something like time()-agent.entryTime;. This value can added to the Data Set and its average value can then be obtained. Any suggestions on how to implement the average number waiting metric. I would like to use these metrics to identify bottlenecks in my process. Thanks in advance.

M Rawat
  • 27
  • 1
  • 7

2 Answers2

1

I usually do one of these:

  1. The easy: myQueue.statsSize.mean()
  2. Create a Statistics block and turn on the "Log to database" option (located just at the bottom of the Statistics block). The value could be myQueue.size()
  3. Estimate the queue average time by simulation and the average number waiting L by the Little’s law: L = lambda * W. Where lambda is the agent’s arrival rate and W is the average time that a agent spends in the queue.

The Little's law works for both the average number waiting in the queue and the average number in the system (in queue plus in service).

  • implemented your suggestion 1 and it works. I also tried ```myQueue.size()``` suggested by you and Benjamin. That approach would be sensitive to the recurrence time of the event. I could potentially collect a lot of 0 values, thereby affecting my mean. Unless I am missing something conceptually. – M Rawat Jan 18 '20 at 16:41
  • Exactly. I prefer the option no 1, also. For additional note, you can put the `myQueue.statsSize.mean()` in an Output block (Analysis Palette) with "Calculate" option check to "On simulation end". – Afonso Medina Jan 18 '20 at 20:27
  • I have a followup question if you don't mind helping me out. How do I access this statistic for an embedded queue in a service block or that's not possible? – M Rawat Jan 22 '20 at 19:02
  • 1
    Since the service block has an embedded queue block, you can collect statistics on that queue as follows ```myService.sieze.queue.statsSize.mean()```. This wasn't obvious, AL help and code complete doesn't mention any of this. Some documentation in the future from AL would be very helpful. – M Rawat Jan 23 '20 at 16:10
  • If you are studying queues with AnyLogic, give a try to the book: "The Art of Process-Centric Modeling with AnyLogic", from Arash Mahdavi. The book is free [at AnyLogic site](https://www.anylogic.com/resources/books/the-art-of-process-centric-modeling-with-anylogic/) and Mahdavi spend most of the book discussing modelling queueing models with AnyLogic. It´s an excellent material. – Afonso Medina Jan 25 '20 at 21:43
0

Create an event that cyclically counts the number of agents in the queue, something like myQueue.size() .

Add that value to another DataSet (or Statistics object, even better) and you can get your Mean :-)

Benjamin
  • 10,603
  • 3
  • 16
  • 28
  • Thanks for the suggestion. I also stumbled upon ```myQueue.statsSize.mean()``` that could potentially work as well. If using a Statistics object, I can't identify the queue block that contributed that value, since it only accepts numbers. It appears I might have to create a database (or a text file) and insert values. – M Rawat Jan 17 '20 at 20:27
  • correct, if that is important. Or have several stats objects for each queue. Or a LinkedHashMap... – Benjamin Jan 18 '20 at 17:37