Homework 6
A Hospital Simulation

(20 points)

As for the previous assignments, you can work in a team of two

Concepts

Problem

Seattle General Hospital has just been bought out by an HMO, and it's budget-crunch time.  You have been hired to model the flow of patients in their emergency room and answer some key questions: "How long do patients wait to be treated?"  "What is the average treatment time?"  "What is an optimal number of treatment rooms that balances cost against patient service?"  

Specification

You are going to design an event-driven simulation that models the treatment of patients in a hospital emergency room.  The number of examination rooms in use will be entered by the user.  When a patient arrives, if there is an open treatment room, they go right in.  If there is no treatment room available, patients wait for an open room.  Patients are treated in order according to their urgency rating; patients with the same urgency rating are treated in order of arrival.  Once treatment begins, the examination room is occupied until treatment is finished, even if a more urgent patient arrives in the mean time.

All the relevant data about a patient (when they arrive, the urgency of their condition, and how long treatment will take) is generated by methods in PatientVisitGenerator.java. (You will also need PatientVisit.java that you can modify).

Events:

This program will be an event-driven simulation and includes two different kinds of events:

The simulation is to run for 10 simulated hours.  After 10 hours, no new arrival events should be generated.  Let the patients that are still being treated and any that are waiting after the 10 hour mark finish normally.

Implementation:

 

Simulation:

Write a class (e.g. Simulation) with a main method to run the simulation. Let the user input the number of rooms and select the type of simulation (random and preset for testing). Output the results (see below) in a nice readable format. Run the simulation by filling the arrival queue with new patients as given by the PatientVisitGenerator class. Dequeue patients from the arrival queue and route them to the examination queue. The simulation is over when the duration of the simulation (= 10 hours) has passed and the examination queue is empty. Tabulate your results as the simulation runs and report your results at the end of the simulation.

Results:

As the simulation runs, collect data to answer these questions.  Display the answers to the user in an easily readable form:

  1. How many examination rooms are in the system?
  2. For how long did the simulation run (in hours)?  Note: this will be longer than 10 hours since some patients might still be being treated.
  3. How many patients were treated in all?
  4. What was the average wait for treatment (in minutes).  Note that sometimes the wait time is zero (if the patient is moved into an examination room without being placed in the patient queue).  In addition to the average overall wait, provide two other values: 
  5. What was the average duration of treatment (in minutes)?
  6. How many patients were treated in each examination room?
  7. What percentage of time was each examination room busy?

Suggestions

As always, you will have success if you code and test in pieces.  Get your individual classes working first.  Then put them together in the simulation.

When testing, you may want to start with simple numbers instead of the random numbers.  A static method named getNextProgrammedArrival is provided that you may find helpful.  Remember that the objective of testing is to prove that the program is working correctly.  This is easier to do with simple data.

You could run the simulation for a shorter period of time during testing so that you don't have to examine a huge amount of data.  Though not a requirement, you might think about adding a 2nd input field to enter the number of hours to run the simulation.  This might aid in testing.

Documentation, Style & Testing

  1. Make sure you have documented your public interfaces well.  Remember, you are building these classes from scratch.  No one has any idea of what they do except you.  You need to communicate these ideas to the reader.
  2. Use appropriate style that we've discussed in class.  This includes (but not limited to) named constants, private methods, and throwing exceptions when appropriate.
  3. Develop unit tests for the PriorityQueue class.  Be sure to include code that checks to make sure all your links are correct (going forward and backward), like printing out the PriorityQueue in forward and reverse order.  
  4. Carefully test your code and include information about the testing you performed in your report.  

Written Report (typed and turned in as a pdf file)

You must turn in a short report that discusses your program, describes the class design, and discusses issues you encountered while working on it.   Your report should cover the following:
  1. Planning: How did you plan and organize your program?  What does it do?  Include user instructions if appropriate.
  2. Implementation: How is your program organized?  What are the major classes?  How do the objects interactRemember, I didn't give you a design to start with so I know nothing about your code.  Explain this well.
  3. Testing: How did you test your code?  What sort of bugs did you encounter?  Are there any unresolved problems in the code?  Be sure to list any ways in which the program falls short of the specification.
  4. Evaluate this project.  What did you learn from it?  Was it worth the effort?  This could include things you learned about specifications and interfaces, design issues, Java language issues, debugging, etc.
  5. Finally, as a result of the testing you have performed, what do you think is the optimal number of examination rooms?  Make sure to back up your recommendation by referring to your results, including average waiting times.

 

Individual evaluation report (should be typed and turned in class)

Evaluate this project:



Good Luck!!