Homework 1: Discrete-Event Simulation
Hints,
Partial solution,
Suggested format of Log File,
Directions for mailing homework to Lab Instructor,
Write in C a program to do the discrete-event simulation of a
system representing a pediatrician's office.
We assume that there is a pediatrician and a nurse and that we have
three kinds of patients:
- Patients that see first the nurse then the pediatrician
- Patients that only see the nurse
- Patients that only see the pediatrician
Thus the situation is as described in the following
queueing network:
SWITCH1 ----+ +--+ SWITCH2
INPUT ---->x----->||||------>| |---->x---------------------->x-----> OUTPUT
| ----+ +--+ | ^
| QUEUE1 SERVER1 | |
v (nurse) v ----+ +--+ |
x------------------------->x---->||||---->| |---->x
----+ +--+
QUEUE2 SERVER2
(pediatrician)
where SERVER1 is the nurse and SERVER2 is the pediatrician. QUEUE1 and QUEUE2
are, respectively, waiting rooms for the nurse and for the pediatrician.
- The pediatrician's office is open from INITTIME to FINTIME.
- Jobs arrive to the INPUT randomly,
say, with interarrival time uniformly distributed in the time interval
AMIN..AMAX.
- At SWITCH1 the patients may go to the nurse with probability
R1 (of course, with probability 1-R1 they go to the pediatrician).
- At SWITCH2 the patients that are done with the nurse will
go to the OUTPUT with probability R2 (of course, they will go to the
pediatrician with probability 1-R2).
- When patients get to a server (nurse or pediatrician), if the server
is free the patients move directly to the server; otherwise they wait in
the queue of that server until their turn to move to the server arrives.
- Jobs are serviced at a server for a random amount of time, uniformly
distributed, say, in the interval S1MIN..S1MAX and S2MIN..S2MAX respectively
at the nurse and the pediatrician.
- At FINTIME the simulation terminates, that is, we do not consider further the patients that
are being serviced or that are waiting in the queues.
The user is asked at run time for:
- a seed for the random number generator
- the values of INITTIME, FINTIME,
AMIN, AMAX, R1, R2, S1MIN, S1MAX, S2MIN, S2MAX
- the name of a log file where will be logged each significant event
[the significant events are the arrival of a new
patient into the system, the start of a job at a server (nurse or pediatrician),
and the completion of a job at a server] [Here is
the suggested format for the log file.]
Determine:
- The average and the maximum size of each Queue.
- The Utilization of each Server [= time-the-server-is-busy / total-time;
where total-time = time of termination of the simulation - start time
of simulation].
- The Average and Maximum Response Time at each Server [or Turn-Around
Time = Time a job completes service at the Server - Time that job arrived
at that server and queue].
- For each kind of user, compute the Average and Maximum Response
Time for the whole system
Run the program a number of times with different values for the parameters and
random seed. Examine in correspondence the utilizations and queue sizes. If for
a given choice of parameters by changing the random seed we obtain utilization and size values
that are stable [i.e. do not change much, say, change at most 10%], then we have a good
simulation.
This homework is assigned on January 19 and it is due February 10 by 5pm.
Be sure to receive a message back from the TA confirming that he has received
the homework.
ingargiola@cis.temple.edu