Professional Documents
Culture Documents
=
=
w L d Q = = and
: delay in queue of ith customer
i i i
S D W + = : waiting time in system of ith customer
) (t Q : number of customers in queue at time t
) (t L : number of customers in system at time t [Q(t) plus number of customers being served at time t]
1 w.p. lim
1
n
W
w
n
i
i
n
=
=
: steady-state average delay
: steady-state average waiting time
1 w.p.
) (
lim
0
T
dt t Q
Q
T
T
}
=
1 w.p.
) (
lim
0
T
dt t L
L
T
T
}
=
: steady-state time-average number in queue
: steady-state time-average number in system
) (S E d w + =
30
e1, e2, , e13 : 13 successive events
n=6 : delays in queue
Interarrival times:
A1=0.4, A2=1.2, A3=0.5, A4=1.7, A5=0.2,
A6=1.6, A7=0.2, A8=1.4, A9=1.9,
Service times:
S1=2.0, S2=0.7, S3=0.2, S4=1.1, S5=3.7, S6=0.6,
31
Measures of Performance for the example
i
D
) (
1
n
D
n d
n
i
i
=
=
: delay in queue of ith customer
: the expected proportion of the time that Q(t) is equal to i
) (t Q : number of customers in queue at time t
) (
Q(t)
) (
) (
T(n)
0 0
n T
dt
n T
iT
n q
i
i
}
= =
=
=
0
) (
i
i
ip n q
=
=
0
) (
i
i
p i n q
i
p
The expected average delay in queue
The expected average number of customers in queue
32
t
Q(t)
0
1 2 3 4 5 6 7 8 9
e1=0.4 e2=1.6
e3=2.1
e4=2.4 e5=3.1
e6=3.3
e7=3.8
e8=4.0
e9=4.9
e10=5.6
e11=5.8
e12=7.2
e13=8.6=T(6)
FIGURE 1.5
Q(t), arrival times, and departure times for a realization of a single-server queueing system.
Arrivals
Departures
1
2
3
33
Measures of Performance for the example
=
t
t
t B
at time idle is server the if 0
at time busy is server the if 1
) (
) (
) (
) (
) (
0
n T
dt t B
n u
n T
}
=
The expected utilization of the server
34
t
B(t)
0
1 2 3 4 5 6 7 8 9
e1=0.4 e2=1.6
e3=2.1
e4=2.4 e5=3.1
e6=3.3
e7=3.8
e8=4.0
e9=4.9
e10=5.6
e11=5.8
e12=7.2
e13=8.6=T(6)
FIGURE 1.6
B(t), arrival times, and departure times for a realization of a single-server queueing system.
Arrivals
Departures
1
35
Intuitive Explanation
36
0 0 0
0
0 0 0 0
Computer Representation
System state
Statistical counters
Sever
status
Total
delay
Area
under Q(t)
Area
under B(t)
Clock
Event list
Initialization
time = 0
System
(a)
Number
in
queue
Times
of
arrival
Time
of last
event
0.4
A
D
Number
delayed
37
1 0 0.4
0.4
1 0 0 0
Computer Representation
System state
Statistical counters
Sever
status
Total
delay
Area
under Q(t)
Area
under B(t)
Clock
Event list
Arrival
time = 0.4
System
(b)
Number
in
queue
Times
of
arrival
Time
of last
event
1.6 A
D
0.4
2.4
Number
delayed
38
1 1 1.6
1.6
1 0 0 1.2
Computer Representation
System state
Statistical counters
Sever
status
Total
delay
Area
under Q(t)
Area
under B(t)
Clock
Event list
Arrival
time = 1.6
System
(c)
Number
in
queue
Times
of
arrival
Time
of last
event
2.1 A
D
0.4
2.4
1.6
1.6
Number
delayed
39
1 2 2.1
2.1
1 0 0.5 1.7
Computer Representation
System state
Statistical counters
Sever
status
Total
delay
Area
under Q(t)
Area
under B(t)
Clock
Event list
Arrival
time = 2.1
System
(d)
Number
in
queue
Times
of
arrival
Time
of last
event
3.8 A
D
0.4
2.4
1.6
1.6
2.1
2.1
Number
delayed
40
1 1 2.4
2.4
2 0.8 1.1 2.0
Computer Representation
System state
Statistical counters
Sever
status
Total
delay
Area
under Q(t)
Area
under B(t)
Clock
Event list
Departure
time = 2.4
System
(e)
Number
in
queue
Times
of
arrival
Time
of last
event
3.8 A
D
1.6
3.1
2.1
2.1
Number
delayed
41
1 0 3.1
3.1
3 1.8 1.8 2.7
Computer Representation
System state
Statistical counters
Sever
status
Total
delay
Area
under Q(t)
Area
under B(t)
Clock
Event list
Departure
time = 3.1
System
(f)
Number
in
queue
Times
of
arrival
Time
of last
event
3.8 A
D
2.1
3.3
Number
delayed
42
0 0 3.3
3.3
3 1.8 1.8 2.9
Computer Representation
System state
Statistical counters
Sever
status
Total
delay
Area
under Q(t)
Area
under B(t)
Clock
Event list
Departure
time = 3.3
System
(g)
Number
in
queue
Times
of
arrival
Time
of last
event
3.8 A
D
Number
delayed
43
1 0 3.8
3.8
4 1.8 1.8 2.9
Computer Representation
System state
Statistical counters
Sever
status
Total
delay
Area
under Q(t)
Area
under B(t)
Clock
Event list
Arrival
time = 3.8
System
(h)
Number
in
queue
Times
of
arrival
Time
of last
event
4.0 A
D
3.8
4.9
Number
delayed
44
1 1 4.0
4.0
4 1.8 1.8 3.1
Computer Representation
System state
Statistical counters
Sever
status
Total
delay
Area
under Q(t)
Area
under B(t)
Clock
Event list
Departure
time = 4.0
System
(i)
Number
in
queue
Times
of
arrival
Time
of last
event
5.6 A
D
3.8
4.9
4.0
4.0
Number
delayed
45
1 0 4.9
4.9
5 2.7 2.7 4.0
Computer Representation
System state
Statistical counters
Sever
status
Total
delay
Area
under Q(t)
Area
under B(t)
Clock
Event list
Departure
time = 4.9
System
(j)
Number
in
queue
Times
of
arrival
Time
of last
event
5.6 A
D 8.6
4.0
Number
delayed
46
1 1 5.6
5.6
5 2.7 2.7 4.7
Computer Representation
System state
Statistical counters
Sever
status
Total
delay
Area
under Q(t)
Area
under B(t)
Clock
Event list
Arrival
time = 5.6
System
(k)
Number
in
queue
Times
of
arrival
Time
of last
event
5.8 A
D
4.0
8.6
5.6
5.6
Number
delayed
47
1 2 5.8
5.8
5 2.7 2.9 4.9
Computer Representation
System state
Statistical counters
Sever
status
Total
delay
Area
under Q(t)
Area
under B(t)
Clock
Event list
Arrival
time = 5.8
System
(l)
Number
in
queue
Times
of
arrival
Time
of last
event
7.2 A
D
4.0
8.6
5.6
5.6
5.8
5.8
Number
delayed
48
1 3 7.2
7.2
5 2.7 5.7 6.3
Computer Representation
System state
Statistical counters
Sever
status
Total
delay
Area
under Q(t)
Area
under B(t)
Clock
Event list
Arrival
time = 7.2
System
(m)
Number
in
queue
Times
of
arrival
Time
of last
event
9.1 A
D
4.0
8.6
5.6
5.6
5.8
5.8
7.2
7.2
Number
delayed
49
1 2 8.6
8.6
6 5.7 9.9 7.7
Computer Representation
System state
Statistical counters
Sever
status
Total
delay
Area
under Q(t)
Area
under B(t)
Clock
Event list
Departure
time = 8.6
System
(n)
Number
in
queue
Times
of
arrival
Time
of last
event
9.1 A
D
5.6
9.2
5.8
5.8
7.2
7.2
Number
delayed
50
Comments
Interaction between the simulation clock and
the event list
Process updates of the state variables and
statistical counters
Contingencies
A departing customer could leave behind an empty
queue
Termination conditions
Time ties
51
1.4.3 Program Organization and Logic
Why general-purpose language
Model being simulated: M/M/1 queue
n=1000
Interarrival and service times
Interarrival: exponential distribution (mean=1 min)
Service: exponential distribution (mean=0.5 min)
|
|
x
e x f
=
1
) (
52
Arrival
Event
Schedule the next
arrival event
Is
the server
busy?
Set delay=0
for this customer
and gather statistics
Add 1 to the
number in queue
Add 1 to the
number of
customers delayed
Make the
server busy
Schedule a
departure event
for this customer
Is
the queue
full?
Write error
message and stop
simulation
Store time of
arrival of this
customer
Return
Yes
Yes
No
No
FIGURE 1.8
Flowchart for arrival routine, queueing model
53
Departure
Event
Is
the queue
empty?
Subtract 1 from
the number
in queue
Compute delay of
customer entering service
and gather statistics
Add 1 to the
number of customers
delayed
Schedule a
departure event
for this customer
Return
Yes No
FIGURE 1.9
Flowchart for arrival routine, queueing model
Move each customer
in queue (if any) up
one place
Make the server idle
Eliminate departure
event from
consideration
54
C Program for Queueing Model
(Fig 1.19 Fig. 1.27)
External definitions
Main functions
Function initialize
Function timing
Function arrive
Function departure
Function report
Function update_avg_stats
Function expon
55
Simulation Output and Discussion
(Fig. 1.28 Output report, queueing model)
Single-server queueing system
Mean interarrival time 1.000 mins
Mean service time 0.500 mins
Number of customers 1000
Average delay in queue 0.430 mins
Average number in queue 0.418
Server utilization 0.460
Time simulation ended 1027.915 mins
56
Alternative Stopping Rules
(Fig. 1.33 Fig. 1.37)
Stop: fixed run time 480 mins
External definitions
Main functions
Function initialize
Function report
Output report
57
Determining the Events and Variables
Event-graph
Arrival Departure
FIGURE 1.38
Event graph, queueing model
58
Determining the Events and Variables
Event-graph
Arrival
Enter
service
FIGURE 1.39
Event graph, queueing model with separate enter-service event
Departure
59
Determining the Events and Variables
Event-graph
FIGURE 1.40
Event graph, queueing model with fixed run length
Arrival Departure
End
simulation
60
STEPS IN A SOUND SIMULATION STUDY
1. Formulate the problem and plan the study
a. Problem of interest is stated by manager.
b. One or more kickoff meeting for the study are conducted,
with the project manager, the simulation analysts, and
subject-matter experts (SMEs) in attendance. The
following issues are discussed:
Overall objectives of the study
Specific questions to be answered by the study
Performance measures that will be used to evaluate the effeciency
of different system configurations
Scope of the model
System configurations to be modeled
Software to be used
Time frame for the study and the required resources
61
STEPS
2. Collect data and define a model.
a. Collect information on the system layout and operating procedures.
No single person or document is sufficient.
Some people may have inaccurate information---make sure that ture SMEs are identified.
Operating procedures may not be formalized.
b. Collect data (if possible) to specify model parameters and input probability distributions
c. Delineate the above information and data in an assumptions document, which is the
conceptual model
d. Collect data (if possible) on the performance of the existing systsem (for validation purpose
in Step 6)
e. The level of model detail should depend on the following:
Project objectives
Performance measures
Data availability
Credibility concerns
Computer constraints
Opinions of SMEs
Time and money constraints
f. There need not be a one-to-one correspondence between each element of the model and
the corresponding element of the system.
g. Interact with the manager (and other key project personnel) on a regular basis
62
STEPS
3. Is the conceptual model valid?
a. Perform a structured walk-through of the conceptual model using the
assumptions document before an audience of managers, analysts, and
SMEs
Helps ensure that the models assumptions are correct and complete
Promotes ownership of the model
Take place before programming begins to avoid significant
reprogramming later
4. Construct a computer program and verify.
a. Program the model in a programming language or in simulation
software. Benefits of using a programming language are that one is
often known, they have a low purchase cost, and they may result in a
smaller model execution time. The use of simulation software, on the
other hand, reduces programming time and results in a lower project
cost.
b. Verify (debug) the simulation computer program.
63
STEPS
5. Make pilot runs.
a. Make pilot runs for validation purposes in Step 6.
6. Is the programed model valid?
a. If ther is an existing system, then compare model and system (from
Step 2) performance measures for existing system
b. Regardless of whether there is an existing system, the simulation
analysts and SMEs should review the model results for correctness.
c. Use sensitivity analyses to determine what model factors have a
significant impact on performance measures and, thus, have to be
modeled carefully.
7. Design experiments.
a. Specify the following for each system configuration of interest:
Length of each run
Length of the warmup period, if one is appropriate
Number of independent simulation runs using different random numbers--
-facilitates construction of confidence intervals
64
STEPS
8. Make production runs.
a. Production runs are made for use in Step 9.
9. Analyze output data.
a. Two major objectives in analyzing output data are:
Determining the absolute performance of certain system configurations
Comparing alternative system configurations in a relative sense
10. Document, present, and use results.
a. Document assumptions (see Step 2), computer program, and studys
results for use in the current and future projects.
b. Present studys results.
Use animation to communicate model to managers and other people who
are not familiar with all of the model details.
Discuss model building and validation process to promote credibility.
c. Results are used in decision-making process if they are both valid and
credible.
65
Formulate problem
and plan the study
Collect data and
define a model
Conceptual
model valid?
Construct a computer
program and verify
Make pilot runs
Programmed
Model valid?
Design experiments
Make production runs
Analyze output data
Document, present,
and use results
No
Yes
No
Yes
FIGURE 1.68
Steps in a simulation study.
66
ADVANTAGES OF SIMULATION
Most complex, real-world systems with stochastic elements cannot be
accurately described by a mathematical model that can be evaluated
analytically. Thus, a simulation is often the only type of investigation
possible.
Simulation allows one to estimate the performance of an existing system
under some projected set of operating conditions.
Alternative proposed system designs (or alternative operating policies for a
single system) can be compared via simulation to see which best meets a
specified requirement.
In a simulation we can maintain much better control over experimental
conditions than would generally be possible when experimenting with the
system itself.
Simulation allows us to study a system with a long time frame---e.g., an
economic system---in compressed time, or alternatively to study the
detailed workings of a system in expanded time.
67
DISADVANTAGES OF SIMULATION
Each run of a stochastic simulation model produces only
estimates of a models true characteristics for a particular set
of input parameters. If a valid analytic model is available or
can be easily de developed, it will generally be preferable to a
simulation model.
Simulation models are often expensive and time-consuming to
develop.
If a model is not a valid representation of a system under
study, the simulation results, no matter how impressive they
appear, will provide little useful information about the actual
system.
In some studies both simulation and analytic models might
be useful. In particular, simulation can be used to check the
validity of assumptions needed in an analytic mode. On the
other hand, an analytic model can suggest reasonable
alternatives to investigate in a simulation study.
68
Pitfalls to the successful completion of
a simulation study
Failure to have a well-defined set of objectives at the beginning of
the simulation study
Inappropriate level of model detail
Failure to communicate with management throughout the course of
the simulation study
Misunderstanding of simulation by management
Treating a simulation study as if it were primarily an exercise in
computer programming
Failure to have people with a knowledge of simulation methodology
and statistics on the modeling team
Failure to collect good system data
Inappropriate simulation software
Obliviously using simulation software products whose complex
marco statement may not be well documented and may not
implement the desired modeling logic
69
Pitfalls to the successful completion of a
simulation study
Belief that easy-to-use simulation packages, which require little or
no programming, require a significantly lower level of technical
competence
Misuse of animation
Failure to account correctly for sources of randomness in the actual
system
Using arbitrary distributions (e.g., normal, uniform, or trianglar) as
input to the simualation
Analyzing the output data from one simulation run (replication) using
formulas that assume independence
Making a single replication of a particular system design and treating
the output statistics as the true answers
Comparing alternative system design on the basis of one replication
for each design
Using the wrong performance measures
70
Notes
In some studies both simulation and
analytic models might be useful. In
particular, simulation can be used to
check the validity of assumptions needed
in an analytic model. On the other hand,
an analytic model can suggest reasonable
alternatives to investigate in a simulation
study.
71
Tarea 1: Simulation of a Single server queueing system
Modify the code for the single-server queue in Chapter 1 to
compute and write in addition the following measures of
performance:
1. The time-average number in the system
2. The average total time in the system
3. The maximum queue length
4. The maximum delay in quque
5. The maximum time in the system
6. The proportion of customers having a delay in queue in excess of 1 minute
Entegar: report on the simulation including simulation model description, design of
the experiments, results of above measures after the simulation, conclusion on
the simulation, and program code.
Fecha limite: 18 de Febrero de 2005