A Java-based simulation project that demonstrates the implementation and comparison of normal queues versus priority queues in a hospital environment.
This simulation models patient flow through a hospital system using two different queue management approaches:
- Normal Queue: First-come, first-served (FCFS) approach
- Priority Queue: Patients are served based on criticality level (Critical, Urgent, Normal)
The project demonstrates how different queue management strategies can impact patient waiting times and overall system efficiency.
- Queue Data Structure: Implementation of queue operations
- Priority Queue: Enhanced queue with priority-based ordering
- Discrete Event Simulation: Modeling arrival and service times
- Exponential & Normal Distributions: Realistic modeling of arrival and service times
- Linked List Implementation: Used for queue management
The project consists of three main Java files:
- Main.java: Contains the simulation driver code, patient generation, and simulation execution
- NormalQueue.java: Implements the standard first-come, first-served queue
- PriorityQueue.java: Implements the priority-based queue where patients are served based on criticality level
- Properties: Arrival time, service time
- Ordered by: Arrival time only
- Properties: Arrival time, service time, criticality level (1-3)
- Ordered by: Criticality level first, then arrival time
- Criticality levels:
- 1: Critical (highest priority)
- 2: Urgent
- 3: Normal
- Clone this repository
- Compile the Java files:
javac Hospital/*.java - Run the simulation:
java Hospital.Main
You can modify the following parameters in the main method of the Main class:
numPatients: Number of patients to simulatenumServers: Number of hospital service points (doctors/nurses)arrivalMean: Mean time between patient arrivals (exponential distribution)serviceMean: Mean time to serve a patient (normal distribution)serviceStd: Standard deviation of service time (normal distribution)
The simulation outputs arrival time, service time, and departure time for each patient in both queue types. For the priority queue, the criticality level is also displayed.
Example output:
=== Simulation Results ===
Normal Queue:
Arrival Time | Service Time | Departure Time
--------------------------------------------
3.75 | 11.81 | 15.56
13.34 | 13.42 | 28.98
...
Priority Queue:
Arrival Time | Service Time | Departure Time | Criticality
-----------------------------------------------------------
5.23 | 7.14 | 12.38 | Critical
1.58 | 10.03 | 22.41 | Urgent
...
The simulation demonstrates that:
-
In a normal queue:
- Patients are served strictly in order of arrival
- This can lead to critical cases waiting behind less urgent ones
-
In a priority queue:
- Critical patients receive care first, regardless of arrival time
- This can significantly reduce waiting times for urgent cases
- Standard cases may experience longer waits but this is acceptable to prioritize critical care
- Arrival times follow an exponential distribution (typical for random arrival processes)
- Service times follow a normal (Gaussian) distribution with specified mean and standard deviation
- Each queue maintains a linked list of patients
- The simulation tracks available servers and assigns patients as servers become available
- The process calculates departure times based on arrival time, service time, and server availability
Potential extensions to this project could include:
- Collecting and analyzing statistics on waiting times
- Simulating different hospital departments with varying parameters
- Incorporating real-world data to calibrate the simulation
- Mohamed Sayed
- Nada Mostafa
- Ward Salkini
- Anas Mohamed
This project is licensed under the MIT License - see the LICENSE file for details
Email: Mostafahany4705@gmail.com
LinkedIn: www.linkedin.com/in/mostafahany4705