# Concurrency: A simulation in Java

## Description of the system to be modeled: Emergency service in a hospital

Note: This problem is adapted from a case study in the book by Thomas J. Schriber et al., Introduction to Simulation using GPSS/H, John Wiley & Sons, 1991, pp. 258.

The patients arrive at the emergency of a hospital. When they arrive, they are classified by a nurse in the following categories: (1) CW (can wait), and (2) NEA (needs immediate attention). On average, 15% of the patients will be classified NEA, the other 85% CW. There are three (3) nurses that do this classification.

The CW patients see a doctor and then can go back home.

The NEA patients also see a doctor and 20% of them can then go back home. The other 85 80% have to do a test in the laboratory of the hospital, then see the same doctor again before they can go home.

There are six (6) doctors in the emergency. They are partitioned into two groups of 3 doctors each: Group A looks after NEA patients, and Group B looks after CW partients. The laboratory performs one test after another (in FIFO order).

Here is some information about the duration of the different interventions. It is assumed that the durations have uniform distributions; for each intervention is indicated the average duration and the maximal deviation from the average, for example "10 +- 4" means that the duration has a uniform distribution between 6 and 14 minutes.

• Duration of the classification of one patient: 15 +- 5
• Duration of a doctor rendezvous with a CW patient: 30 +- 15
• Duration of the first doctor rendezvous of a NEA patient: 45 +- 10
• Duration of the second doctor rendezvous of a NEA patient: 15 +- 5
• Duration of a test: 30 +- 10
• The arrival pattern of the patients at the emergency is a Poisson distribution with an average inter-arrival time of 10 minutes.

The purpose of the simulation is to determine the average time that the CW and NEA patients remain in the emergency, and to determine the fraction of time the nurses and doctors are busy (their "utilisation") - the same for the laboratory.

For most of the shared resources used by the patients, you can assume a single waiting queue. However, for the group of doctors looking after the NEA patients, the scheduling is not clearly defined by the above text: Do the patients coming back to the same doctor have priority over new NEA patients ? - Also it is not evident how you could organize your simulation program such that NEA patients coming back will be seen by the same doctor they saw previously. You should explain all this in your report.

Note: For your simulation program, you should use one of the approaches discussed in class.

1. Write a Java program that simulates emergency of a hospital, as described above.
2. Determine the average time the CW and NEA patients remain in the hospital.
3. Determine the fraction of time the nurses, the doctors and the laboratory are busy.
4. Determine the expected error of your results. Explain how you have determined the expected error of your results. (Suggestion: Do several simulation runs and compare the different results obtained - as discussed in class).