Download presentation

Presentation is loading. Please wait.

Published byPriscila Robbs Modified over 2 years ago

1
Introduction(Packages)1 Management of the Simulated Clock lFixed-time Increment lVariable-time Increment

2
Flowchart for arrival routine, queueing model Arrival event Set delay = 0 for this customer and gather statistics Is the server busy? Schedule the next arrival event Add 1 to the number of customers delayed Make the server busy Schedule a departure event for this customer Add 1to the number in queue Write error message and stop simulation Store time of arrival of this customer Is the queue Full? Return NoYes No

3
Departure event Subtract 1 from the number in queue Is the queue empty? Compute delay of customer entering service and gather statistics Add 1 to the number of customers delayed Schedule a departure event for this customer Make the server idle Move each customer in queue (if any) up one place Eliminate departure event from consideration Return NoYes Flowchart for departure routine, queueing model

4
Introduction(Packages)4 Distribution of time between arrivals Time between Cumulative Random digit Arrivals(min.) Probability Probability Assignment

5
Introduction(Packages)5 Service Time Distribution Service Time Cumulative Random digit (Minutes) Probability Probability Assignment

6
Introduction(Packages)6 Time-between-arrival Determination Random Time btwn Digit Arrivals Digit Arrivals Customer (Minutes) Customer (Minutes) 1 _ _

7
Introduction(Packages)7 Service Times Generated Customer Random Digit Service Time (Minutes) Customer Random Digit Service Time (Minutes)

8
Event Type Work Sheet Clock Time Customer Number Arrival

9
Introduction(Packages)9 Findings from the Simulation 1. Average waiting time for a customer Total time customers wait in queue(minute) Total number of customers

10
Introduction(Packages)10 Findings from the Simulation (cont) 2. Prob. that a customer has to wait in a queue Number of customers who wait Total number of customers

11
Introduction(Packages)11 Findings from the Simulation (cont) 3. Proportion of idle time of the server Total idle time of server(minute) Total run time of simulation(minute) Thus, the probability of the server being busy is the complement of 0.21, or 0.79

12
Introduction(Packages)12 The Able-Baker carhop problem The purpose of this example is to indicate the simulation procedure when there is more than one channel. Consider a drive-in restaurant where carhops take orders and bring food to the car. Cars arrive in the manner shown in the following table.

13
Introduction(Packages)13 The Able-Baker carhop problem (Interarrival distribution of cars) Time between Random Arrivals Cumulative Digit (Minutes) Probability Probability Assignment

14
Introduction(Packages)14 The Able-Baker carhop problem (continued) There are two car hops -- Able and Baker. Able is better able to do the job, and works somewhat faster than Baker. The distribution of service times of Able and Baker is following.

15
Introduction(Packages)15 The Able-Baker carhop problem (Service Distribution of Able) Service Random Time Cumulative Digit (Minutes) Probability Probability Assignment

16
Introduction(Packages)16 The Able-Baker carhop problem (Service Distribution of Baker) Service Random Time Cumulative Digit (Minutes) Probability Probability Assignment

17
Introduction(Packages)17 The Able-Baker carhop problem (Continued) lOver the 62-minute period Able is busy 90% of the time. 2Baker was busy only 69% of the time. The seniority rule keeps Baker less busy. 3Nine of 26 or about 35% of the arrivals had to wait. The average waiting time for all customers was only about 0.42 minute, or 25 seconds, which is very small.

18
Introduction(Packages)18 The Able-Baker carhop problem (Continued) 4Those 9 who did have to wait only waited an average of 1.22 minutes, which is quite low. 5In summary, this system seems well balanced. One server cannot handle all the dinners, and three servers would probably be too many. Adding an additional server would surely reduce the waiting time to nearly zero. However, the cost of waiting would have to be quite high to justify an additional worker.

19
Introduction(Packages)19 GPSS (Process-Oriented) Diagram

20
Introduction(Packages)20 GPSS Events lCurrent-Event Chain: Transaction with BDT <= C1 lFuture-Event Chain: Transaction with BDT > C1

21
Introduction(Packages)21 GPSS Events(continued) lNote Events must be executed chronologically, so chains are maintained in ascending order Current-Event Chain performs an additional tasks(i.e. maintains by priority)

22
Introduction(Packages)22 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.

23
Introduction(Packages)23 GPSS Sample instructions BUFFESTORAGE2 GENERATE3,,1,4 QUEUEWAIT SEIZEMACH DEPARTWAIT ADVANCE4 ENTERBUFFE RELEASEMACH ADVANCE9 LEAVEBUFFE TERMINATE1 START4

24
Introduction(Packages)24 GPSS (Process-Oriented) Diagram

25
Introduction(Packages)25 GPSS/H Block Diagram, Queueing Model

26
Introduction(Packages)26 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 QUEUESERVERQ Enter the Queue 6 SEIZE SERVER Seize the Server 7 LVEQ DEPARTSERVERQ Leave the Queue 8 TEST LN$LVEQ,1000,STOP Test for Termination 9 ADVANCERVEXPO(2,0.5) Delay for service 10STOP RELEASESERVER Customers Depart 11 TERMINATE 1 12 * 13 * CONTROL STATEMENT 14 * 15 START1000 Make 1 simulation run 16 END

27
Introduction(Packages)27 GPSS/H standard output report, Queueing Model RELATIVE CLOCK: ABSOLUTE CLOCK: BLOCK CURRENTTOTAL LVEQ STOP AVG-UTIL-DURING-- FACILITY TOTAL AVAIL UNAVL ENTRIES AVG CURRENT TIME TIME TIME TIME/XACT STATUS SERVER AVAIL

28
Introduction(Packages)28 GPSS/H standard output report, Queueing Model(Continued) QUEUE MAXIMUM AVERAGE TOTAL ZERO PERCENT CONTENTS CONTENTS ENTRIES ENTRIES ZEROS SERVERQ QUEUE AVERAGE $AVERAGE QTABLE CURRENT TIME/UNIT TIME/UNIT NUMBER CONTENTS SERVERQ RANDOM ANTITHETIC INITIAL CURRENT SAMPLE CHI-SQUARE STREAM VARIATES POS. POS. COUNT UNIFORMITY 1 OFF OFF

29
Introduction(Packages)29 SIMSCRIPT II.5 Preamble, Queueing Model 1PREAMBLE 2PROCESSES INCLUDE ARRIVAL.GENERATOR, 3 CUSTOMER, AND REPORT 4 RESOURCES INCLUDE SERVER 5DEFINE DELAY.IN.QUEUE, MEAN.INTERARRIVAL.TIME, 6 AND MEAN.SERVICE.TIME AS REAL VARIABLES 7DEFINE TOT.DELAYS AS AN INTEGER VARIABLE 8DEFINE MINUTES TO MEAN UNITS 9TALLY AVG.DELAY.IN.QUEUE AS THE AVERAGE AND 10 NUM.DELAYS AS THE NUMBER OF DELAY.IN.QUEUE 11ACCUMULATE AVG.NUMBER.IN.QUEUE AS THE 12 AVERAGE OF N.Q.SERVER 13ACCUMULATE UTIL.SERVER AS THE AVERAGE OF 14 N.X.SERVER 15END

30
Introduction(Packages)30 SIMSCRIPT II.5 Main program Queueing Model 1MAIN 2 3 READ MEAN.INTERARRIVAL.TIME, 4 MEAN.SERVICE.TIME, AND TOT.DELAYS 5 6 CREATE EVERY SERVER(1) 7LET U.SERVER(1) = 1 8 9ACTIVATE AN ARRIVAL.GENERATOR NOW 10 11START SIMULATION 12 13END

31
Introduction(Packages)31 SIMSCRIPT II.5 Process routine ARRIVAL.GENERATOR 1PROCESS ARRIVAL.GENERATOR 2 3 WHILE TIME.V >= DO 5 WAIT EXPONENTIAL.F(MEAN.INTERARRIVAL.TIME, 6 1) MINUTES 7 ACTIVATE A CUSTOMER NOW 8LOOP 9 10 END

32
Introduction(Packages)32 SIMSCRIPT II.5 Process routine CUSTOMER 1PROCESS CUSTOMER 2 3DEFINE TIME.OF.ARRIVAL AS A REAL VARIABLE 4 LET TIME.OF.ARRIVAL = TIME.V 5REQUEST 1 SERVER(1) 6LET DELAY.IN.QUEUE = TIME.V - TIME.OF.ARRIVAL 7 IF NUM.DELAYS = TOT.DELAYS 8 ACTIVATE A REPORT NOW 9ALWAYS 10WORK EXPONENTIAL.F (MEAN.SERVICE.TIME, 2) 11 MINUTES 12RELINQUISH 1 SERVER(1) END

33
Introduction(Packages)33 SIMSCRIPT II.5 Process routine REPORT 1PROCESS REPORT 2 3 PRINT 5 LINES THUS SIMULATION OF THE M/M/1 QUEUE 9 PRINT 8 LINES WITH MEAN.INTERARRIVAL.TIME, 10 SERVICE.TIME, AND TOT.DELAYS THUS MEAN INTERARRIVAL TIME**.** MEAN SERVICE TIME**.** NUMBER OF CUSTOMERS*****

34
Introduction(Packages)34 SIMSCRIPT II.5 Process routine REPORT(Continued) 19PRINT 8 LINES WITH AVG.DELAY.IN.QUEUE, 20 AVG.NUMBER.IN.QUEUE(1), ANDUTIL.SERVER(1) 21 THUS AVERAGE DELAY IN QUEUE***.** AVERAGE NUMBER IN QUEUE***.** SERVER UTILIZATION *.** 29STOP 30 31END

35
Introduction(Packages)35 SIMSCRIPT II.5 Output Report Queueing Model SIMULATION OF THE M/M/1 QUEUE MEAN INTERARRIVAL TIME1.00 MEAN SERVICE TIME.50 NUMBER OF CUSTOMERS1000 AVERAGE DELAY IN QUEUE.43 AVERAGE NUMBER IN QUEUE.43 SERVER UTILIZATION.50

36
Introduction(Packages)36 SLAM II network for single-server queue simulation

37
Introduction(Packages)37 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

38
Introduction(Packages)38 CSIM Sample Code(1) /* simulate an M/M/1 queue (an open queue with exponential service times and interarrival intervals) */ #include "lib/csim.h" #defineSVTM1.0/*mean of service time distribution */ #define IATM2.0/*mean of inter-arrival time distribution */ #define NARS5000/*number of arrivals to be simulated*/ FACILITY f;/*pointer for facility */ EVENT done;/*pointer for counter */ TABLE tbl;/*pointer for table */ QTABLE qtbl;/*pointer for qhistogram */ int cnt;/*number of active tasks*/

39
Introduction(Packages)39 CSIM Sample Code(2) sim()/*1st process - named sim */ { int i; set_model_name("M/M/1 Queue"); create("sim");/*required create statement*/ f = facility("facility");/*declare facility*/ done = event("done");/*declare event*/ tbl = table("resp tms");/*declare table */ qtbl = qhistogram("num in sys", 10);/*declare qhistogram*/ cnt = NARS;/*initialize cnt*/ for(i = 1; i <= NARS; i++) { hold(expntl(IATM));/* hold interarrival*/ cust();/*initiate process cust*/ } wait(done);/*wait until all done*/ report();/*print report*/ theory();/*print theoretical res*/ }

40
Introduction(Packages)40 CSIM Sample Code(3) cust()/*process customer*/ { float t1; create("cust");/*required create statement*/ t1 = clock;/*time of request */ note_entry(qtbl);/*note arrival */ reserve(f);/*reserve facility f*/ hold(expntl(SVTM));/*hold service time*/ release(f);/*release facility f*/ record(clock-t1, tbl);/*record response time*/ note_exit(qtbl);/*note departure */ cnt--;/*decrement cnt*/ if(cnt == 0) set(done);/*if last arrival, signal*/ }

41
Introduction(Packages)41 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); }

42
Introduction(Packages)42 CSIM Results(1) Tue Dec 1 09:25: CSIM Simulation Report Version 12 Model: M/M/1 Queue Time: Interval: CPU Time: (seconds) Facility Usage Statistics means counts----+ facility srv disp serv_tm util tput qlen resp cmp pre facility

43
Introduction(Packages)43 CSIM Results(2) Table 1 Table Name: resp tms mean 1.989min variance 3.813max Number of entries 5000 QTable 2 QTable Name: num in sys Mean queue length 0.991Max queue length 13 Mean time in queue 1.989Number of entries 5000

44
Introduction(Packages)44 CSIM Results(3) Queue Table Histogram Length% of Elapsed TimeCumulativeCountMean Time over

45
Introduction(Packages)45 CSIM Results(4) M/M/1 Theoretical Results Inter-arrival time = Service time = Utilization = Throughput rate = Mn nbr at queue = Mn queue length = Response time = Time in queue = 1.000

Similar presentations

© 2017 SlidePlayer.com Inc.

All rights reserved.

Ads by Google