Assignment 5: Simulate a store with queues
Grade: | Only compulsory for grade 5. |
Preparations: |
All net lessons and assignment 4. |
Examination: | Mail the solution no later than December 14, 2020. |
In this assignment you will write a program that simulates a store, with one or more queues/cashiers: Blue squares are symbolizes cashiers, dark read circles customers being processed and light red circles customers in queue. |
You should reuse the queue data structures from Assignment 4.
The aim is to do simulations and make estimates of
- Average waiting time (Time from arriving to queue until leaving the store).
- Maximum waiting time.
Some basic assumptions are
- When a customer has finished collecting items (this is when the customer is created in the simulation), it chooses the shortest queue.
- When a customer has payed it leaves the store, and the cashier expedites the next customer in its queue
Some input parameters of the program are
- The number of queues/cashiers nq.
- The probability of a customer being created for each time step.
- The probability of different number of items a new customer has nitem ∈ [nmin, nmax]. This is individually set for each customer. The number of items equals the number of time steps a customer will be standing at the cashier when it is served.
- The opening time of the store, tmax is the number of time steps that the simulation is run.
Supplied files and tips
-
prand.c, prand.h Poisson distribution,
to be used as a probability distribution for defining the number of
items (nitem) a new customer has.
Example code of usage testPoisson.c.
The usage is basically
sprand(
nm)
and thenprand()
will return an integer nitem ∈ [0, 3nm]. -
You can use the Poisson distribution code as a random number generator also for determining if a new
customer should be created in a time step, or use
drand48()
orlrand48()
. Use theman
command in the terminal to get information on how to use. The usage is basicallysrand48(time(&ttime));
is an initial seed wheretime_t ttime;
anddrand48()
returns a random double in [0, 1].
Some optional extra features that can be added
- Add various ways to input the parameters of the program; command line arguments, read from a file, get information from stdio
- Generate visualizations of interesting statistics in for example Matlab or Python.
- Verify Little’s Law with your program.