Management of the Simulated Clock Fixed-time Increment



Yüklə 471 b.
tarix11.10.2017
ölçüsü471 b.
#4325


Management of the Simulated Clock

  • Fixed-time Increment

  • Variable-time Increment






Distribution of time between arrivals



Service Time Distribution



Time-between-arrival Determination



Service Times Generated





Findings from the Simulation



Findings from the Simulation(cont)



Findings from the Simulation(cont)



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.



The Able-Baker carhop problem (Interarrival distribution of cars)



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.



The Able-Baker carhop problem (Service Distribution of Able)



The Able-Baker carhop problem (Service Distribution of Baker)



The Able-Baker carhop problem (Continued)

  • Over the 62-minute period Able is busy 90% of the time.

  • Baker was busy only 69% of the time. The seniority rule keeps Baker less busy.

  • Nine 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.



The Able-Baker carhop problem (Continued)

  • Those 9 who did have to wait only waited an average of 1.22 minutes, which is quite low.

  • In 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.



GPSS (Process-Oriented) Diagram



GPSS Events

  • Current-Event Chain: Transaction with BDT <= C1

  • Future-Event Chain: Transaction with BDT > C1



GPSS Events(continued)

  • Note

  • Events must be executed chronologically, so chains are maintained in ascending order

  • Current-Event Chain performs an additional tasks(i.e. maintains by priority)



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.



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



GPSS (Process-Oriented) Diagram



GPSS/H Block Diagram, Queueing Model



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



GPSS/H standard output report, Queueing Model

  • RELATIVE CLOCK: 1014.1565 ABSOLUTE CLOCK:1014.1565

  • BLOCK CURRENT TOTAL

  • 1 1000

  • 2 1000

  • 3 1000

  • LVEQ 1000

  • 5 1000

  • 6 999

  • STOP 1000

  • 8 1000

  • -- AVG-UTIL-DURING--

  • FACILITY TOTAL AVAIL UNAVL ENTRIES AVG CURRENT

  • TIME TIME TIME TIME/XACT STATUS

  • SERVER 0.516 1000 0.523 AVAIL



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

  • QUEUE AVERAGE $AVERAGE QTABLE CURRENT

  • TIME/UNIT TIME/UNIT NUMBER CONTENTS

  • SERVERQ 0.614 1.124 0

  • RANDOM ANTITHETIC INITIAL CURRENT SAMPLE CHI-SQUARE

  • STREAM VARIATES POS. POS. COUNT UNIFORMITY

  • 1 OFF 100000 101001 1001 0.71

  • 2 OFF 200000 200999 999 0.69



SIMSCRIPT II.5 Preamble, Queueing Model

  • 1 PREAMBLE

  • 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



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



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



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



SIMSCRIPT II.5 Process routine REPORT

  • 1 PROCESS 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 *****



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

  • AVERAGE DELAY IN QUEUE ***.**

  • AVERAGE NUMBER IN QUEUE ***.**

  • SERVER UTILIZATION *.**

  • 29 STOP

  • 30

  • 31 END



SIMSCRIPT II.5 Output Report Queueing Model

  • SIMULATION OF THE M/M/1 QUEUE

  • MEAN INTERARRIVAL TIME 1.00

  • MEAN SERVICE TIME .50

  • NUMBER OF CUSTOMERS 1000

  • AVERAGE DELAY IN QUEUE .43

  • AVERAGE NUMBER IN QUEUE .43

  • SERVER UTILIZATION .50



SLAM II network for single-server queue simulation



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



CSIM Sample Code(1)

  • /* simulate an M/M/1 queue

  • (an open queue with exponential service times and interarrival intervals)

  • */

  • #include "lib/csim.h"

  • #define SVTM 1.0 /*mean of service time distribution */

  • #define IATM 2.0 /*mean of inter-arrival time distribution */

  • #define NARS 5000 /*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*/



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*/

  • }



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*/

  • }



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);

  • }



CSIM Results(1)

  • Tue Dec 1 09:25:18 1987 CSIM Simulation Report Version 12

  • Model: M/M/1 Queue

  • Time: 10041.661

  • Interval: 10041.661

  • CPU Time: 32.183 (seconds)

  • Facility Usage Statistics

  • +----------------------+---------------means----------------+---counts----+

  • facility srv disp serv_tm util tput qlen resp cmp pre

  • facility 0.992 0.494 0.5 0.991 1.989 5000 0



CSIM Results(2)

  • Table 1

  • Table Name: resp tms

  • mean 1.989 min 0.000

  • variance 3.813 max 14.273

  • Number of entries 5000

  • QTable 2

  • QTable Name: num in sys

  • Mean queue length 0.991 Max queue length 13

  • Mean time in queue 1.989 Number of entries 5000



CSIM Results(3)

  • Queue Table Histogram

  • Length % of Elapsed Time Cumulative Count Mean Time

  • 0 0.506 0.506 2516 2.020

  • 1 0.242 0.748 3694 0.657

  • 2 0.123 0.871 1845 0.671

  • 3 0.067 0.938 1014 0.659

  • 4 0.035 0.972 510 0.686

  • 5 0.015 0.988 234 0.652

  • 6 0.007 0.995 99 0.700

  • 7 0.002 0.997 40 0.627

  • 8 0.001 0.998 21 0.469

  • 9 0.001 0.999 13 0.823

  • 10 0.000 0.999 6 0.519

  • over 0.001 1.000 8 0.807



CSIM Results(4)

  • M/M/1 Theoretical Results

  • Inter-arrival time = 2.000

  • Service time = 1.000

  • Utilization = 0.500

  • Throughput rate = 0.500

  • Mn nbr at queue = 1.000

  • Mn queue length = 0.500

  • Response time = 2.000

  • Time in queue = 1.000



Yüklə 471 b.

Dostları ilə paylaş:




Verilənlər bazası müəlliflik hüququ ilə müdafiə olunur ©genderi.org 2024
rəhbərliyinə müraciət

    Ana səhifə