Java Reference
In-Depth Information
The key to avoiding this problem is to advance the clock to the next event
time at each stage, called an event-driven simulation, which is conceptually
easy to do. At any point, the next event that can occur is either the arrival of
the next customer in the input stream or the departure of one of the customers
from a teller's station. All the times at which the events will happen are avail-
able, so we just need to find the event that happens soonest and process that
event (setting the current time to the time that the event occurs).
If the event is a departure, processing includes gathering statistics for the
departing customer and checking the line (queue) to determine whether
another customer is waiting. If so, we add that customer, process whatever
statistics are required, compute the time when the customer will leave, and
add that departure to the set of events waiting to happen.
If the event is an arrival, we check for an available teller. If there is none,
we place the arrival in the line (queue). Otherwise, we give the customer a
teller, compute the customer's departure time, and add the departure to the set
of events waiting to happen.
An event-driven
simulation
advances the cur-
rent time to the
next event.
The waiting line for customers can be implemented as a queue. Because
we need to find the next soonest event, the set of events should be organized
in a priority queue. The next event is thus an arrival or departure (whichever is
sooner); both are easily available. An event-driven simulation is appropriate if
the number of ticks between events is expected to be large.
The event set (i.e.,
events waiting to
happen) is orga-
nized as a priority
queue.
13.2.2 example: a call bank simulation
The main algorithmic item in a simulation is the organization of the events in
a priority queue. To focus on this requirement, we write a simple simulation.
The system we simulate is a call bank at a large company.
A call bank consists of a large number of operators who handle phone
calls. An operator is reached by dialing one telephone number. If any of
the operators are available, the user is connected to one of them. If all the
operators are already taking a phone call, the phone will give a busy signal.
This can be viewed as the mechanism that is used by an automated customer
service facility. Our simulation models the service provided by the pool of
operators. The variables are
The call bank
removes the wait-
ing line from the
simulation. Thus
there is only one
data structure.
The number of operators in the bank
n
The probability distribution that governs dial-in attempts
n
The probability distribution that governs connect time
n
The length of time the simulation is to be run
n
The call bank simulation is a simplified version of the bank teller simula-
tion because there is no waiting line. Each dial-in is an arrival, and the total
 
Search WWH ::




Custom Search