{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

09a.LCS

# 09a.LCS - Maggie Johnson CS103B Handout#9a List...

This preview shows pages 1–3. Sign up to view the full content.

Maggie Johnson Handout #9a CS103B List Applications: Simulations Longest Common Subsequence Key topics: * Queues and Simulation * Introduction & Definitions * Recursive Definition of the Length of an LCS * Dynamic Programming Algorithm for LCS * Finding an LCS Queues and Simulation Consider an emergency room that is planning to expand by adding more treatment rooms and staff. There should be enough rooms and staff to service each patient in a "reasonable" wait time, but not too many rooms and staff for the number of arriving patients. The hospital may want to run a computer simulation of typical patient transactions, using data objects to represent real- world physical objects like doctors, rooms, patients and the clock. Such a simulation sets up what is called a queueing system. A queueing system consists of servers and queues of objects to be served. Waiting is the critical element. The objective of a queueing system is to utilize the servers (doctors and rooms) as fully as possible, while keeping the waiting time within a reasonable limit. These goals usually require a compromise between cost and customer/patient satisfaction. To set up a queueing system simulation, we must know four things: 1. the number of service requests or events 2. the number of servers 3. the distribution of arrival times 4. the expected service time for each request The simulation program uses these parameters to predict the average waiting time. For example, a hospital has three rooms and staff to handle these rooms. The servers are the rooms and staff; the objects to be served are the patients; and the events are the arrivals and departures of patients. We are interested in the average waiting time. So, once we have defined the four values above, we can do a time-driven simulation which means that we will have a counter in the program that simulates a clock. To simulate the passing of a unit of time (perhaps a minute), we increment the clock. We will run the simulation for a predetermined amount of time.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
From a software point of view, the simulation is a big loop that executes a set of rules for each value of the clock, from 1 to MAXTIME (the length of the simulation). Here are the rules that are processed in the body of the loop for each time unit (dt): 1. If a patient arrives, he/she gets in line. 2. If a server is free and if there is anyone waiting, the first patient in line (at the front of the queue) leaves the line and advances to the treatment room. The service time is a random number around a mean of 5 hours. 3. If a patient is in the treatment room, the time remaining for that patient to be serviced is decremented. 4. If there are patients in line, the additional minute that they have remained in the queue is recorded.
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}