首页 > > 详细

讲解R、R设计辅导留学生、辅导R、讲解留学生Applied Mathematics

Applied Mathematics 3911
Due: Monday March 19, 2018 (by 5pm, in the my o ce. Rm 285 MSC )
Assignment 4 Simulation of a Bank Teller
As an example of the concept of discrete event simulation, write a program to simulate
the processing of customers by a teller at a bank. Customers arrive at the bank, wait for
service by the teller if the teller is busy, are served, and then depart the system. Customers arriving
to the system when the teller is busy wait in a single queue in front of the teller. For simplicity,
initially assume that the time of arrival of a customer and the service time by the teller for each
customer are known and are shown below. The objective is to manually simulate the above system
to determine the percent of time the teller is idle and the average time an average customer spends
at the bank.
Customer # Time of Arrival Service Time
(Minutes) (Minutes)
1 3.2 3.8
2 10.9 3.5
3 13.2 4.2
4 14.8 3.1
5 17.7 2.4
6 19.8 4.3
7 21.5 2.7
8 26.3 2.1
9 32.1 2.5
10 36.6 3.4
11 40.0 2.0
12 41.0 5.0
13 41.3 3.0
Hints/Background:
Since the simulation is the dynamic portrayal of the changes in the state of a system over time,
the states of the system must be de ned. For this example, they can be de ned by the status of
the teller (busy or idle) and by the number of customers at the bank. The state of the system
is changed by a customer arriving to the bank, and the completion of service by the teller and
subsequent departure of the customer. In the simulation, one determines the state of the system
over time by processing the events corresponding to the arrival and departure of customers in a
time-ordered sequence. So in this simulation time does not ow in uniform. steps, but changes
according to the next event to occur. The results of your simulation for this example should
corresponded to the values in the table below. It is assumed that initially there are no customers
in the system, the teller is idle, and the rst customer is to arrive at time 3.2. ( So the simulation
really starts at t=0 but until t=3.2 the teller is idle and no customers are waiting. ) The last three
rows are only partially led so I can check your code. This rst 10 rows are complete so you can
check your code.
Customer Arrival Start Departure Time in Time in
Number Time Service Time Queue Bank
(1) (2) Time (3) (4) (5)=(3)-(2) (6)=(4)-(2)
1 3.2 3.2 7.0 0.0 3.8
2 10.9 10.9 14.4 0.0 3.5
3 13.2 14.4 18.6 1.2 5.4
4 14.8 18.6 21.7 3.8 6.9
5 17.7 21.7 24.1 4.0 6.4
6 19.8 24.1 28.4 4.3 8.6
7 21.5 28.4 31.1 6.9 9.6
8 26.3 31.1 33.2 4.8 6.9
9 32.1 33.2 35.7 1.1 3.6
10 36.6 36.6 40.0 0.0 3.4
11 40.0
12 41.0
13 41.3
In the above table, columns (1) and (2) are taken from the rst table. The start of service
time given in column (3) depends on whether the preceding customer has departed the bank. It
is taken as the larger value of the arrival time of the customer and the departure time of the
previous customer. Column (4), the departure time, is the sum of the column (3) value and the
service time for the customer given in the rst table. Values for time in queue and time in bank for
each customer are computed as shown in the above table. Average values per customer for these
variables are 2.61 minutes and 5.81 minutes, respectively. Your code should calculate columns 3-6.
and the averages.
The logic associated with processing the arrival and departure events depends on the state of
the system at the time of the event. In the case of the arrival event, the disposition of the arriving
customer is based on the status of the teller. If the teller is idle, the status of the teller is changed
to busy and the departure event is scheduled for the customer by adding his service time to the
current time. However, if the teller is busy at the time of an arrival, the customer cannot begin
service at the current time and, therefore, he enters the queue (the queue length is increased by
one). For the departure event, the logic associated with processing the event is based on queue
length. If a customer is waiting in the queue, the teller status remains busy, the queue length is
reduced by one, and the departure event for the rst waiting customer is scheduled. However, if
the queue is empty, the status of the teller is set to idle. Before writing any computer code you
should document this logic in a ow chart!
To place the arrival and departure events in their proper chronological order, it is necessary
to maintain a record calendar of future events to be processed. This is done by maintaining the
times of the next arrival event and the next departure event. The next event to be processed is
then selected by comparing these event times. For situations with many events, an ordered list of
events would be maintained which is referred to as an event le or event calendar. There are several
important concepts illustrated by the above example. We observe that at any instant in simulated
time, the model is in a particular state. As events occur, the state of the model may change as
prescribed by the logical-mathematical relationships associated with the events. Thus, the events
de ne the dynamic structure of the model. Given the starting state, the logic for processing each
event, and a method for specifying sample values, our problem is largely one of bookkeeping. An
essential element in our bookkeeping scheme is an event calendar which provides a mechanism for
recording and sequencing future events. Another point is that we can view the state changes from
two perspectives: the process that the customer encounters as he seeks service (the customer’s
view), or the events that caused the state of the teller to change (the teller’s or bank’s view)

联系我们
  • QQ:99515681
  • 邮箱:99515681@qq.com
  • 工作时间:8:00-21:00
  • 微信:codinghelp
热点标签

联系我们 - QQ: 99515681 微信:codinghelp
程序辅导网!