This Python script simulates a simple queueing system using event-driven simulation. The system comprises customers arriving at a service facility and being served by a given number of servers. The code uses the heapq library to manage events, such as customer arrivals and departures, and PrettyTable for displaying the simulation results.
The code simulates the behavior of customers arriving and departing from the service facility. It keeps track of events, such as arrivals and departures, and calculates key metrics like the busy time of the service facility.
The simulation follows these steps:
- Initialize variables and data structures.
- Create an event queue using heapq.
- Push arrival events onto the event queue.
- Process events in chronological order.
- Update the state of the system accordingly (e.g., when a customer arrives, they are either served immediately or added to a waiting queue).
- Record events and future events as the simulation progresses.
- Display the simulation results in a table format using PrettyTable.
- Clone or download the repository to your local machine.
git clone https://github.com/mayankpujara/Event-Scheduling-Algorithm.git
- Install the required libraries if you haven't already.
pip install prettytable
- Modify the arrivals, service_time, and num_servers variables to match your specific queueing system parameters. You can provide your own list of arrival times, service times, and the number of servers.
- Run the script by executing it with Python
python scheduling_algorithm.py
The provided example uses the following input parameters:
- Arrival times: [8, 6, 1, 8, 2,]
- Service times: [4, 1, 4, 3, 2, 4]
- Number of servers: 1
After running the simulation, the code will output the results in a tabular format, showing events and future events.
Mayank Pujara