Lecture 2
Lecture 2
Clock
Fixed-time Increment
Variable-time Increment
Introduction(Packages) 1
Flowchart for arrival routine, Arrival
event
queueing model
Schedule the next
arrival event
Yes Is No
the server
busy?
Schedule a
departure event
for this customer
Return
Flowchart for departure routine, Departure
event
queueing model
Yes Is No
the queue
empty?
Schedule a
departure event
for this customer
Return
Distribution of time between arrivals
Time between Cumulative Random digit
Arrivals(min.) Probability Probability Assignment
1 0.10 0.10 01 - 10
2 0.20 0.30 11 - 30
3 0.30 0.60 31 - 60
4 0.25 0.85 61- 85
5 0.10 0.95 86 - 95
6 0.05 1.00 96 - 00
Introduction(Packages) 5
Time-between-arrival Determination
Random Time btwn Random Time btwn
Digit Arrivals Digit Arrivals
Customer (Minutes) Customer (Minutes)
1 _ _ 11 109 1
2 913 8 12 093 1
3 727 6 13 607 5
4 015 1 14 738 6
5 948 8 15 359 3
6 309 3 16 888 8
7 922 8 17 106 1
8 753 7 18 212 2
9 235 2 19 493 4
10 302 3 20 535 5
Introduction(Packages) 6
Service Times Generated
Service Service
Random Random
Customer Time Time
Digit Customer Digit
(Minutes) (Minutes)
1 84 4 11 32 3
2 10 1 12 94 5
3 74 4 13 79 4
4 53 3 14 05 1
5 17 2 15 79 5
6 79 4 16 84 4
7 91 5 17 52 3
8 67 4 18 55 3
9 89 5 19 30 2
10 38 3 20 50 3
Introduction(Packages) 7
Work Sheet
Customer Clock
Event Type
Number Time
Arrival 1 0
. . .
. . .
. . .
Findings from the Simulation
1. Average waiting time for a customer
Introduction(Packages) 9
Findings from the Simulation(cont)
2. Prob. that a customer has to wait in a queue
Introduction(Packages) 10
Findings from the Simulation(cont)
3. Proportion of idle time of the server
Introduction(Packages) 12
The Able-Baker carhop problem
(Interarrival distribution of cars)
Time between Random
Arrivals Cumulative Digit
(Minutes) Probability Probability Assignment
Introduction(Packages) 14
The Able-Baker carhop problem
(Service Distribution of Able)
Service Random
Time Cumulative Digit
(Minutes) Probability Probability Assignment
TEMPORARY
- created/ TRANSACTIONS Flowing
Destroyed -Attributes
Model Dynamically Through
Structure
BLOCKS
- Activated Connected
OPERATIONS NETWORK
by Entering to form
Transactions
Introduction(Packages) 19
GPSS Events
Current-Event Chain:
Transaction with BDT <= C1
Future-Event Chain:
Transaction with BDT > C1
Introduction(Packages) 20
GPSS Events(continued)
Note
Events must be executed chronologically,
so chains are maintained in ascending order
Introduction(Packages) 21
GPSS Execution Trace
The system. Four transactions enter the system at
intervals of 3 time units, starting at time unit 1.
They try to seize facility MACH for 4 time units
and then try to enter storage BUFFE (with
capacity 2) before releasing MACH.
After 9 time units in BUFFE, they leave storage
and terminate. In this model the number of
transactions must be limited because it has been
devised to cause catastrophic congestion.
Introduction(Packages) 22
GPSS Sample instructions
BUFFE STORAGE 2
GENERATE 3,,1,4
QUEUE WAIT
SEIZE MACH
DEPART WAIT
ADVANCE 4
ENTER BUFFE
RELEASE MACH
ADVANCE 9
LEAVE BUFFE
TERMINATE 1
START 4
Introduction(Packages) 23
GPSS (Process-Oriented)
Diagram
no1 no2 no3 no4
0 1 4 7 10 15 20 25 30
no2 no4
Storage
no1 27
BUFFE
no3
5 9 14 18 23
Introduction(Packages) 24
GPSS/H Block Diagram,
Queueing Model
N$LVEQ 1000
Create L
GENERATE Arriving (STOP) Test for the
Custome termination
RVEXPO(1,1.0) TEST
r of the run
Seize
SEIZE the SER Release
SERVER VER the
Server RELEASE
(STOP) Server
Leave
LVEQ DEPART the
SERVERQ
Queue Customers
TERMINATE 1
Depart
Introduction(Packages) 25
GPSS/H - Queueing Model
1 * SIMULATION OF THE M/M/1 QUEUE
2*
3 SIMULATE
4 GENERATE RVEXPO(1,1,0) Create Arriving
Customer
5 QUEUE SERVERQ Enter the Queue
6 SEIZE SERVER Seize the Server
7 LVEQ DEPART SERVERQ Leave the Queue
8 TEST L N$LVEQ,1000,STOP Test for Termination
9 ADVANCE RVEXPO(2,0.5) Delay for service
10 STOP RELEASE SERVER Customers Depart
11 TERMINATE 1
12 *
13 * CONTROL STATEMENT
14 *
15 START 1000 Make 1 simulation run
16 END
Introduction(Packages) 26
GPSS/H standard output report,
Queueing Model
RELATIVE CLOCK: 1014.1565 ABSOLUTE CLOCK:1014.1565
-- AVG-UTIL-DURING--
FACILITY TOTAL AVAIL UNAVL ENTRIES AVG CURRENT
TIME TIME TIME TIME/XACT STATUS
SERVER 0.516 1000 0.523 AVAIL
Introduction(Packages) 27
GPSS/H standard output report,
Queueing Model(Continued)
QUEUE MAXIMUM AVERAGE TOTAL ZERO PERCENT
CONTENTS CONTENTS ENTRIES ENTRIES ZEROS
SERVERQ 8 0.605 1000 454 45.4
Introduction(Packages) 28
SIMSCRIPT II.5 Preamble,
1 PREAMBLE
Queueing Model
2 PROCESSES INCLUDE ARRIVAL.GENERATOR,
3 CUSTOMER, AND REPORT
4 RESOURCES INCLUDE SERVER
5 DEFINE DELAY.IN.QUEUE,
MEAN.INTERARRIVAL.TIME,
6 AND MEAN.SERVICE.TIME AS REAL VARIABLES
7 DEFINE TOT.DELAYS AS AN INTEGER VARIABLE
8 DEFINE MINUTES TO MEAN UNITS
9 TALLY AVG.DELAY.IN.QUEUE AS THE AVERAGE AND
10 NUM.DELAYS AS THE NUMBER OF DELAY.IN.QUEUE
11 ACCUMULATE AVG.NUMBER.IN.QUEUE AS THE
12 AVERAGE OF N.Q.SERVER
13 ACCUMULATE UTIL.SERVER AS THE AVERAGE OF
14 N.X.SERVER
15 END Introduction(Packages) 29
SIMSCRIPT II.5 Main program
Queueing Model
1 MAIN
2
3 READ MEAN.INTERARRIVAL.TIME,
4 MEAN.SERVICE.TIME, AND TOT.DELAYS
5
6 CREATE EVERY SERVER(1)
7 LET U.SERVER(1) = 1
8
9 ACTIVATE AN ARRIVAL.GENERATOR NOW
10
11 START SIMULATION
12
13 END
Introduction(Packages) 30
SIMSCRIPT II.5 Process routine
ARRIVAL.GENERATOR
1 PROCESS ARRIVAL.GENERATOR
2
3 WHILE TIME.V >= 0.0
4 DO
5 WAIT EXPONENTIAL.F(MEAN.INTERARRIVAL.TIME,
6 1) MINUTES
7 ACTIVATE A CUSTOMER NOW
8 LOOP
9
10 END
Introduction(Packages) 31
SIMSCRIPT II.5 Process routine
CUSTOMER
1 PROCESS CUSTOMER
2
3 DEFINE TIME.OF.ARRIVAL AS A REAL VARIABLE
4 LET TIME.OF.ARRIVAL = TIME.V
5 REQUEST 1 SERVER(1)
6 LET DELAY.IN.QUEUE = TIME.V - TIME.OF.ARRIVAL
7 IF NUM.DELAYS = TOT.DELAYS
8 ACTIVATE A REPORT NOW
9 ALWAYS
10 WORK EXPONENTIAL.F (MEAN.SERVICE.TIME, 2)
11 MINUTES
12 RELINQUISH 1 SERVER(1)
13
14 END
Introduction(Packages) 32
SIMSCRIPT II.5 Process routine
1 PROCESS REPORT
REPORT
2
3 PRINT 5 LINES THUS
Introduction(Packages) 33
SIMSCRIPT II.5 Process routine
REPORT(Continued)
19 PRINT 8 LINES WITH AVG.DELAY.IN.QUEUE,
20 AVG.NUMBER.IN.QUEUE(1),
ANDUTIL.SERVER(1)
21 THUS
29 STOP
30
31 END
Introduction(Packages) 34
SIMSCRIPT II.5 Output Report
Queueing Model
SIMULATION OF THE M/M/1 QUEUE
0
0. RNORM (3.2, 0.6)
1 1000
1 1
Introduction(Packages) 36
SLAM II Model of
Single-Server Queue
GEN, BANKS CARSON, NELSON SINGLE SERVER QUEUE EXAMPLE, 1/20/95
LIMITS,1,0,30; MODEL CAN USE 1 FILE, MAX NO. OF SIMULTANEOUS ENTRIES 30
NETWORK; BEGINNING OF MODEL
CREATE, EXPON(4.5) CUSTOMERS ARRIVE AT CHECKOUT
QUEUE(1); CUSTOMERS WAIT FOR SERVICE IN
QUEUE FILE ONE (1)
ACTIVITY(1)/1,RNORM(3.2,.6); CHECKOUT SERVICE TIME IS
N(3.2,0.6)
TERMINATE, 1000; SIMULATE UNTIL 1000 CUSTOMERS
ARE CHECKED OUT
ENDNETWORK; END OF MODEL
END OF SIMULATION
Introduction(Packages) 37
CSIM Sample Code(1)
/* simulate an M/M/1 queue
(an open queue with exponential service times and interarrival
intervals)
*/
#include "lib/csim.h"
Introduction(Packages) 38
CSIM Sample Code(2)
sim() /*1st process - named sim */
{
int i;
set_model_name("M/M/1 Queue");
create("sim"); /*required create statement*/
Introduction(Packages) 39
CSIM Sample Code(3)
cust() /*process customer*/
{
float t1;
create("cust"); /*required create statement*/
Introduction(Packages) 40
CSIM Sample Code(4)
theory() /*print theoretical results*/
{
float rho, nbar, rtime, tput;
printf("\n\n\n\t\t\tM/M/1 Theoretical Results\n");
tput = 1.0/IATM;
rho = tput*SVTM;
nbar = rho/(1.0 - rho);
rtime = SVTM/(1.0 - rho);
printf("\n\n");
printf("\t\tInter-arrival time = %10.3f\n",IATM);
printf("\t\tService time = %10.3f\n",SVTM);
printf("\t\tUtilization = %10.3f\n",rho);
printf("\t\tThroughput rate = %10.3f\n",tput);
printf("\t\tMn nbr at queue = %10.3f\n",nbar);
printf("\t\tMn queue length = %10.3f\n",nbar-rho);
printf("\t\tResponse time = %10.3f\n",rtime);
printf("\t\tTime in queue = %10.3f\n",rtime - SVTM);
}
Introduction(Packages) 41
CSIM Results(1)
Tue Dec 1 09:25:18 1987 CSIM Simulation Report Version 12
+----------------------+---------------means----------------+---counts----+
facility srv disp serv_tm util tput qlen resp cmp pre
Introduction(Packages) 42
CSIM Results(2)
Table 1
QTable 2
Introduction(Packages) 43
CSIM Results(3)
Queue Table Histogram
Introduction(Packages) 44
CSIM Results(4)
M/M/1 Theoretical Results
Introduction(Packages) 45