This Python project simulates the arrival and service of customers in a single-server queue system for a small grocery store. The simulation includes the generation of random interarrival times, the calculation of arrival times, service time generation, and the computation of various performance measures.
The random interarrival times are generated using the interArrivalTime function, ensuring the first customer's arrival time is initialized to 0.
Arrival times are calculated by accumulating the interarrival times.
Random service times are generated based on the given service times and their probabilities using the serviceTime function.
The times when service begins and ends are calculated, considering the maximum of arrival time and the previous service end time.
The waiting time in the queue is computed using the queueTime function.
Each customer's time in the system is calculated using the timeInSystem function.
The idle time of the server is determined by comparing arrival times and the previous service end time.
The total time customers spend in the system is calculated using the totalTimeInSystem function.
The results are visualized in a table using Plotly, showing various parameters for each customer.
Key performance measures are calculated, including average waiting time, probability of waiting, probability of idle server, average service time, average time between arrivals, average waiting time of those who wait, and average time a customer spends in the system.
A histogram is plotted to visualize the frequency distribution of individual customer waiting times.
# Code for plotting the histogram
plt.style.use("bmh")
fig, ax = plt.subplots()
ax.hist(queue_time, bins = 15, linewidth = 1.0, align='mid', edgecolor = "white")
x = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
default_x_ticks = range(len(x))
plt.xticks(default_x_ticks, x)
plt.ylim(0, 70)
plt.xlabel("( Queue waiting Times )")
plt.ylabel("( Frequency )")
plt.title("(Frequency of individual customer waiting time)")
plt.show()