Skip to content

ncarusso/Simulation

Repository files navigation

Queuing Theory Simulation

queueTheorySimulation is a bash script that implements the solution of the queuing theory example proposed in pages 3 and 4 of the book "Systems Simulation: The Art and Science" by Robert Shannon (1975)

Proposed example

Consider a single-channel queueing (waiting line) system such as a checkout stand at a small gift shop. Assume that the time between arrivals of the customers is uniformly distributed from 1 through 10 minutes (for simplicity we round off all times to the nearest whole minute). Let us assume further that the amount of time required to service each customer is uniformly distributed from 1 through 6 minutes. We are interested in the average time a customer spends in the system (both waiting and being serviced) and the percentage of time that the check-out clerk is not occupied with work.

In brief, we are looking for:

    i Average time a customer spends in the system
    ii. % of time that the check-out clerk is not occupied with work.
Customer Time Since Last Arrival (min) Service Time (min) Arrival Clock Time Service Begins Service Ends Customer Wait (min) Clerk idle (min)
1 - 1 0:00 0:00 0:01 1 0
2 2 3 0:03 0:03 0:07 4 2
3 7 4 0:10 0:10 0:14 4 3
4 3 2 0:13 0:14 0:16 3 0
5 9 1 0:22 0:22 0:23 1 6
6 10 5 0:32 0:32 0:37 5 9
7 6 4 0:38 0:38 0:42 4 1
8 8 6 0:46 0:46 0:52 6 4
9 8 1 0:54 0:54 0:55 1 2
10 8 3 1:02 1:02 1:05 3 7
11 7 5 1:09 1:09 1:14 5 4
12 3 5 1:12 1:14 1:19 7 0
13 8 3 1:20 1:20 1:23 3 1
14 4 6 1:24 1:24 1:30 6 1
15 4 1 1:28 1:30 1:31 3 0
16 7 1 1:35 1:35 1:36 1 4
17 1 6 1:36 1:36 1:42 6 0
18 6 1 1:42 1:42 1:43 1 0
19 7 2 1:49 1:49 1:51 2 6
20 6 2 1:55 1:55 1:57 2 4

Solution

I have only used the commands available in the BASH command interpreter in a linux debian system. Nevertheless, I have found a limitation while trying to obtain non-integer values in a division operation. For this reason, I have installed bash calculator.

apt-get install bc

I have tested the script in ubuntu and derivatives (such as mint) and I have noticed that bc is already installed on them.

Run

To run the script you must grant execution permissions to the user by doing

chmod +x queueTheorySimulation.sh

and then

./queueTheorySimulation.sh

Finally, you need to enter the amount of customers to be used in the simulation, for instance, n. Two arrays with n random integers each will be generated. The first one is time between arrivals of the customers [1..10] and the second represents the time required to service each customer [1..6].

True Random Numbers (Update!)

I have created a menu that presents two different options to generate the random numbers.

  1. PseudoRandom numbers generated by the linux PRNG (present in the first version of this script)
  2. Random numbers I get these numbers from the project http://www.random.org/. RANDOM.ORG offers true random numbers to anyone on the Internet. The randomness comes from atmospheric noise.

The details of the implementation of the HTTP interface (in my case, it's just a HTTP GET)

http://www.random.org/analysis/
To learn the analysis performed to RANDOM.ORG service to demonstrate that the generated numbers are truly random. http://www.random.org/analysis/

About

Queuing theory simulation

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages