8/20/2019 Mohd Queueing 1999
1/77
QUEUEING SIMULATION USING EXCEL 2000
A Mini-Study Project presented to the Graduate School of
Business of the University of Stellenbosch in partial
fulfilment of the requirements for the degree of
Masters Degree in Business Administration (MBA)
by
Shivan Mohd
Study Leader : Professor WR Gevers
Degree of Confidentiality : Grade A
Date : October 1999
8/20/2019 Mohd Queueing 1999
2/77
ii
DECLARATION
Hereby I, Shivan Chad Mohd, declare that this study project is my own original work and that all
sources have been accurately reported and acknowledged, and that this document has not been
previously in its entirety or in part been submitted at any university in order to obtain an
academic qualification.
S. C. Mohd 4 October 1999
Stellenbosch University http://scholar.sun.ac.za
8/20/2019 Mohd Queueing 1999
3/77
iii
ACKNOWLEDGMENTS
The author wishes to express sincere appreciation to Prof WR Gevers for his assistance in the
preparation of this manuscript. In addition, I would like to thank SPL for allowing me to make
use to their computer and printing equipment and making time available for me to complete
this mini-study project.
The core of this project is a computer simulation model. Although every effort has been taken to
ensure the proper operation of the model, neither the author of the program, nor the study leader
can and will be held liable for any loss of income due to incorrect information used in the
program. The program must be used as aid in making a business decision and not the deciding
factor. At the time of release, the software had no form of virus attached to it. For a more
definitive solution, the author could be contacted and will give guidelines as to your specific
problem.
Stellenbosch University http://scholar.sun.ac.za
8/20/2019 Mohd Queueing 1999
4/77
iv
ABSTRACT
A mini-study project presented on the use of Microsoft Excel 2000 in the field of simulation.
The mini-study project covers the principles of queuing and it’s outputs. The simulation model
will test various scenario’s of queuing theory. Inputs can be changed to suit the users
requirements. Results may be analysed to determine an optimal queuing environment.
Stellenbosch University http://scholar.sun.ac.za
8/20/2019 Mohd Queueing 1999
5/77
v
OPSOMMING
Hierdie mini-werkstuk illustreer die gebruik van Excel 2000 in die veld van simulasie. Die
beginsels van toustaan modelle word gedek, asook die tipiese resultate. Die simulasiemodel
modelleer en toets verskillende toustaan scenarios. Toevoere kan verander word na gelang van
die gebruiker se keuse. Die resultate kan ontleed word om die optimale toustaan omgewing te
bepaal.
Stellenbosch University http://scholar.sun.ac.za
8/20/2019 Mohd Queueing 1999
6/77
vi
TABLE OF CONTENTS
Declaration ii
Acknowledgments iii
Abstract iv
Opsomming v
List of tables viiiList of figures ix
CHAPTER 1. INTRODUCTION 1
1.1 INTRODUCTION 1
1.2 METHODOLOGY USED 2
1.3 LIMITATIONS AND RESTRICTIONS 2
1.4 MINIMUM REQUIREMENTS 3
1.5 DEVELOPMENT OF THE REPORT 3
CHAPTER 2. QUEUING THEORY: A QUICK OVERVIEW 4
2.1 INTRODUCTION 42.2 THE STRUCTURE OF THE QUEUING SYSTEM 4
2.2.1 The Customers and their source 4
2.2.2 The arrival process 4
2.2.3 The service facility and service process 5
2.2.4 The Queue 5
2.2.5 Degree of Patience 6
2.3 SUMMARY 6
CHAPTER 3. THE LOGIC OF THE MODEL PRESENTED 7
3.1 INTRODUCTION 73.2 INPUTS REQUIRED 7
3.2.1 Unit of time 7
3.2.2 The duration of the simulation 7
3.2.3 The number of servers 7
3.2.4 The maximum number of customers allowed in the queue 8
3.2.5 The arrival rate 8
3.2.6 The service rate 9
3.3 SIMULATION OF RANDOM EVENTS 9
3.3.1 Exponential 9
3.3.2 Constant 9
3.3.3 Normal 103.3.4 Triangular 10
3.3.5 Observed Probabilities 10
3.4 SEQUENCE OF EVENTS 11
3.5 SUMMARY 12
CHAPTER 4. VERIFICATION OF MODEL 13
4.1 INTRODUCTION 13
4.2 ANALYTICAL MODELS 13
4.3 SIMULATION RESULTS 14
4.4 OTHER STEPS TO VALIDATE RESULTS 15
4.5 SUMMARY 17
Stellenbosch University http://scholar.sun.ac.za
8/20/2019 Mohd Queueing 1999
7/77
vii
CHAPTER 5. USER GUIDE 18
5.1 INTRODUCTION 18
5.2 USING THIS GUIDE 18
5.3 CONTROL CENTRE 19
5.4 ACTIONS BUTTONS 21
5.4.1 “Change Inputs” Button 21
5.4.2 “Run Simulation Button” Button 24
5.4.3 “Add to History File” button 26
5.4.4 “Clear History” Button 26
5.5 NAVIGATION BUTTONS 26
5.6 SUMMARY 28
CHAPTER 6. SUMMARY AND RECOMMENDATIONS 29
6.1 SUMMARY 29
6.2 RECOMMENDATIONS 29
LIST OF SOURCES 30
APPENDIX A :LIST OF ROUTINES AND THIER FUNCTIONS 31
APPENDIX B: LIST OF SCREENS 33
APPENDIX C: VISUAL BASIC CODE 43
Stellenbosch University http://scholar.sun.ac.za
8/20/2019 Mohd Queueing 1999
8/77
viii
LIST OF TABLES
Table 2.1: Examples of queues 6
Table 3.1: Sequence of events 11
Table 4.1: Inputs for comparison 14
Table 4.2: Comparison of results 14
Table 4.3: A sample of the details table 15
Table 4.4: Input time versus simulated time 16
Table 4.5: Statistical comparison 16
Stellenbosch University http://scholar.sun.ac.za
8/20/2019 Mohd Queueing 1999
9/77
ix
LIST OF FIGURES
Figure 5.1: Welcome Screen 19
Figure 5.2: Control Centre 20
Figure 5.3: Input Screen 21
Figure 5.4: Inter-arrival Input Box 23
Figure 5.5: Service Inputs 24
Figure 5.6: Probability Table 25
Figure 5.7: History Screen 26
.
Stellenbosch University http://scholar.sun.ac.za
8/20/2019 Mohd Queueing 1999
10/77
1
CHAPTER 1
1. INTRODUCTION
1.1 INTRODUCTION
Queuing is a part of many people’s lives. Managing queues and keeping them as short as
possible is a mammoth task and many people prefer to avoid the exercise of trying to calculate
the most user friendly and cost effective queuing environment. In an attempt to make this task a
bit easier, the model developed, will show the characteristics of queues by simulating the
queuing environment.
The model was designed and created for two main reasons:
To simulate a queuing environment based on various factors of queuing e.g. arrival
distribution, services rate, number of servers etc and presenting the results in format that
would make the analysis of the results easier.
The second reason is to show students:
a) how problems (in this case: queuing), can be solved by using spreadsheets as the analytical
tool and by allowing the student to try various combinations of inputs and comparing results;
b) the logic of queuing simulation.
Students and managers who wish to optimise the operations where people or items needs to be
serviced within an appropriate time could use the model. The Model will report simulated results
of the users inputs, thus allowing for various scenarios. Optimal loading for service points could
be determined. It would also allow for controlling queue length and server idle time. In most
situations, a simulation model is a computer model that imitates a real-life situation. Often,
simulation can provide the decision maker with important information. A simulation model
might help answer questions such as the following:
If a service point is added, how will the average waiting time of the customer decrease?
Stellenbosch University http://scholar.sun.ac.za
8/20/2019 Mohd Queueing 1999
11/77
2
If the service time is reduced, by how much will the average waiting time reduce?
Although analytical models can help in answering the questions above, simulation will give the
user a better feel as to the possible outputs of the data inputted. The program caters for both
theoretical probability distributions and observed probabilities.
1.2 METHODOLOGY USED
The model was created using Excel 2000. The main objectives are, to show how simulation can
be accomplished by using Excel spreadsheets and for the model to be practical in application.
Most of the program logic uses Visual Basic and Excel functions to simulate data and calculate
results. Once the program was complete, the data produced were validated using random checks
and the use of an analytical model to compare the analytical results against simulated results. By
covering the theory of queuing, the user will have a better understanding of the model. The
limitations of the model will be discussed in the next paragraph.
1.3 LIMITATIONS AND RESTRICTIONS
The program has its limitations and should only be used as a guideline. It makes the following
assumptions:
The population is from an infinite source
Customers arrive individually and not in groups
Only single or multi-facility – No mixed facility
First come first served
The model does not take into account the following:
Balking
Reneging
Costs
Stellenbosch University http://scholar.sun.ac.za
8/20/2019 Mohd Queueing 1999
12/77
3
1.4 MINIMUM REQUIREMENTS
For the model to work, the following minimum requirements with respect to hardware and
software must be adhered to:
486 100 MHz processor
At least 26 MBytes of RAM
Excel 97 or higher
Windows 95 or higher
1.5 DEVELOPMENT OF THE REPORT
The report covers the following subject areas:
Queuing theory: a quick overview – A revision of queuing theory and the area the model will
cover, is presented. The queuing theory chapter will help the user in recapping on the theory
of queuing which would help the user understand the logic and results produced.
Logic of the model presented – Understanding how the results were derived is a key factor
when working with the model presented. The sequence of the simulation is covered in this
area.
Verification of the model – The focus of this chapter is to prove that the results are correct.
The user may be more comfortable in using the model once it has been proven that the model
produces the correct results.
User guide – If a user requires clarification as to how the program is to be used, a section
covering the use of the program is included in this document.
Stellenbosch University http://scholar.sun.ac.za
8/20/2019 Mohd Queueing 1999
13/77
4
CHAPTER 2
2. QUEUING THEORY: A QUICK OVERVIEW
2.1 INTRODUCTION
In order to understand the program, an overview to discuss some important points and
terminology would be appropriate and helpful when working through the program. The chapter
covers the minimal requirements needed for the simulation of queues.
2.2 THE STRUCTURE OF THE QUEUING SYSTEM
2.2.1 The customers and their source
Customers are defined as those in need of service. Customers can be people, aeroplanes,
machines or raw materials. The customers are generated from a population (calling population)
or a source. The population source may be from an infinite or a finite source. For example, a
hospital’s population would be residents in the surrounding community and the customers would
be those sick people in the population requiring hospitalisation.
2.2.2 The arrival process
The manner in which customers show up at the service facility is called the arrival process. The
distributions of the inter-arrival time may be exponential, constant etc. The average service time
per server is different from the average inter-arrival time, as the two processes are independent
of each other. When describing a waiting system, the manner in which customers or the waiting
units, are arranged for service, must be defined. Waiting line formulas generally require an
arrival rate, or the number of units per period (such as 10 units per hour). The time between
arrivals is the inter-arrival time (such as an average of one every six minutes) or, the reciprocal
of the arrival rate.
Stellenbosch University http://scholar.sun.ac.za
8/20/2019 Mohd Queueing 1999
14/77
5
A constant arrival distribution is periodic, with exactly the same time between successive
arrivals. In productive systems, about the only arrivals that truly approach a constant inter-
arrival period are those that are subject to machine control. Much more common are variable
(random) arrival distributions. In observing arrivals at a service facility, there are two
viewpoints: The time between successive arrivals can be analysed to see if the times follow
some statistical distribution. Usually, in elementary analytical models it is assumed that the
time between arrivals is exponentially distributed.
2.2.3 The service facility and service process
The service is provided by a service facility (or facilities). The service facility may be a person
(bank teller, a barber, machine (elevator, gasoline pump), or space (airport runway, parking lot,
hospital bed), to mention just a few. A service facility may include one person or several people
operating as a team.
Facilities may be fixed (Loading dock) or movable (service technician). The service time may
also follow various distribution patterns, exponential etc.
In elementary models, the exponential distribution is assumed.
2.2.4 The Queue
Whenever an arriving customer finds that the service facility is busy, a queue or waiting line is
formed. Examples of Systems, Queues formed and the Service provided may be found in Table
2.1.
Stellenbosch University http://scholar.sun.ac.za
8/20/2019 Mohd Queueing 1999
15/77
6
Table 2.1: Examples of queues
System Queue Service
Computer Jobs Process facilities
Bank People Tellers
Telephone Callers Switchboards
Library Books to be shelved Librarian’s Assistants
2.2.5 Degree of patience
A patient client is one who waits as long as necessary until the service facility is ready to serve
him or her. (Even if clients grumble and behave impatiently, the fact that the customers wait is
sufficient to label them as patient clients for purposes of waiting line theory.)
There are two classes of impatient clients. Members of the first class arrive, survey both the
service facility and the length of the line, and then decide to leave. Those in the second class
arrive, view the situation, join the waiting line, and then, after some period of time, depart.
The behaviour of the first type is termed balking, while the second is termed reneging.
The program does not cater for impatient behaviour.
2.3 SUMMARY
The understanding of queuing theory is fundamental, when trying to apply the concepts to
simulate an environment. Understanding waiting lines or queues and learning how to manage it,
is one of the most important areas in operations management. Simulation will aid management
in this understanding. It is basic to creating schedules, job design, inventory models and so on. In
a service economy people wait in line every day, from driving to work to checking out at the
supermarket. Management can reduce the amount of time spent in a queue by applying the
concepts of queuing theory.
Stellenbosch University http://scholar.sun.ac.za
8/20/2019 Mohd Queueing 1999
16/77
7
CHAPTER 3
3. THE LOGIC OF THE MODEL PRESENTED
3.1 INTRODUCTION
Once a good understanding of the queuing theory has been formed, the user will have a better
understanding of the logic of the model presented. The purpose of this chapter is to clarify the
flow of inputs, processes and outputs of the model.
3.2 INPUTS REQUIRED
3.2.1 Unit of time
The unit of time may be Minutes, Hours or Days. Once the user uses either one of these options,
the program will use that unit of time for both the arrival and the service calculations.
3.2.2 The duration of the simulation
The duration of the simulation pertains to the length of time the simulation should run. For
example: 25 will equal 25 Days if the Unit of time is days. The longer it is set the longer the
simulation will take to run. Normally a longer run will give an answer closer to that of the
analytical models. If, for example, the simulation run time is set for 10 min and the arrival rate is
one per minute, the program will return approximately 10 observations.
3.2.3 The number of servers
The number of servers that are used or that will be used is required. The option allows the user
to change from a single server environment to a multi-server environment with all servers
rendering an identical service.
Stellenbosch University http://scholar.sun.ac.za
8/20/2019 Mohd Queueing 1999
17/77
8
3.2.4 The maximum number of customers allowed in the queue
The user can set the number of customers the queue can handle. For example: 20 will mean that
once the queue length reaches 20, customers would be turned away until the number in queue
drops to below 20. The customer who will be turned away will then be recorded under the
“Number of Customers turned away” heading on the report sheet. The parameter is governed by
the size available for queuing. If the area in which people are allowed to queue can only house
10 people then the limit must be set to ten. If unlimited space is available for queuing then the
parameter must be set to 1000.
3.2.5 The arrival rate
The average arrival rate will be in the form of e.g. seven per time of unit. It means that if the
customers arrive at a rate of 7 every hour (time unit) then the inter-arrival time will be 1/7 =
0.143 hours between arrivals, and this is the number placed in the input box. The average inter-
arrival time is automatically converted to an arrival rate, which is reported to the Input Screen.
The inter-arrival time on the Input Screen will not be used if the program is using the observed
probability option. By using the Monte-Carlo methodology, random times will be selected from
the inter-arrival probabilities table. The inter-arrival time is then used in the simulation process.
The distribution pattern of the inter-arrival times may be:
Exponential
Constant
Normal
Triangular
Or Observed probabilities
Stellenbosch University http://scholar.sun.ac.za
8/20/2019 Mohd Queueing 1999
18/77
9
3.2.6 The service rate
The average service rate will be in the form of e.g. six per time of unit. It means that if the
customers arrive at a rate of 6 every hour (time unit) then the average time per service will be 1/6
= 0.166 hours, and this is the number placed in the input box. The average time per service is
automatically converted to a service rate, which is reported to the Input Screen. The average time
per service on the Input Screen will not be used if the program is using the observed probability
option. By using the Monte-Carlo methodology, random times will be selected from the service
time probabilities table. The average time per service is then used in the simulation process
The distribution pattern of the mean service time is independent of that of the inter-arrival
times.
3.3 SIMULATION OF RANDOM EVENTS
When simulating data, random numbers are required. In the model, random numbers are
required for the inter-arrival time and the service time. Excel provides a facility that generates
random numbers. In the Visual basic format, the “Rnd” function is used. When observed values
are used, the Monte Carlo methodology is used to generate random times.
Five different probability distributions may be selected. Duration’s are simulated as shown
below for the various distributions.
a) Exponential
When the exponential option is selected, the program uses the following statement:
Duration = MeanArriveTime * Log(Rnd)
Where “Log” represents the natural logarithm.
b) Constant
When the constant option is selected, the program uses the following statement:
Stellenbosch University http://scholar.sun.ac.za
8/20/2019 Mohd Queueing 1999
19/77
10
Duration = MeanArriveTime
c) Normal
When the normal option is selected, the program uses the following statement:
Duration = NormInv (Random Number, Standard Deviation, MeanArriveTime) (Returns the
inverse of the normal cumulative distribution for the specified mean and standard deviation)
If a negative number is generated, the program will loop until the generated number is positive.
Only positive numbers are used in the simulation.
d) Triangular
When the triangular option is selected, the program uses the following statement:
ValA = (MaximumValue - MinimumValue)
If Randomnum
8/20/2019 Mohd Queueing 1999
20/77
11
For example, an inter-arrival time of six may have a probability of 20%. Of all the other inter-
arrival times the inter-arrival time of six appears 20% of the time within the given environment.
The formulae used within Excel to determine the times based on the probabilities: =
VLOOKUP().
The duration is calculated by generating a random number e.g. 0.54 and using it as a percentage.
The random number is used to compare the number against the probability table generated by
the user. The comparison will result in a corresponding inter-arrival or service time. The
newfound time is used as the duration within the simulation program.
3.4 SEQUENCE OF EVENTS
To start the simulation the user has to click on the Run Simulation button. Once this has been
done, the following sequence of events takes place:
Table 3.1: Sequence of events
Main Routine Description of what it does Sub Routine Description of what it does
RunSimulation Gathers the users input parameters from
the Inputs worksheet. Starts the Initialize Routine
Initialize Re sets the simulation parameters to Zero.
Sets the worksheet parameters to Zero
Calculates the First Arrival based on the users inpute.g. Exponential, Normal etc
RunSimulation Start a loop until the simulation time hasexpired as per the users input.
Starts the Timing Routine
Timing Determine whether the time is an arrival or adeparture event.
Update the Clock to the time of the next event
RunSimulation Start the UnpdateAreas Routine
UpdateAreas Update statistical accumulators and writes results tothe reports worksheet
RunSimulation Check to see if this time is an arrivalevent or a departure event.
If it is an arrival event then run the ArriveRoutine
Starts the Arrive Routine
Arrive Checks the input sheet for which distribution patternto use
Once found, it calculates the random time of the nextevent
Check to see if the number in queue is within themaximum allowed in the queue. If above the amountof customers allowed then the programme recordsthe arrival as a lost customer.
Check if all servers are busy, and if so, put the timeat the end of the queue. If not, then put thecustomers directly into service.
Before it can place a customer in service, it searchesfor the first available server by starting from servernumber one and progressing upwards towards thelast server.
Once in service it now calculates a random servicetime
Write the information to the detailed report sheet.
RunSimulation If the Event was a departure event then
Stellenbosch University http://scholar.sun.ac.za
8/20/2019 Mohd Queueing 1999
21/77
12
run the depart routine.
Depart Update the number of customers who finished
Check if any customers are in queue, if not, thenmake the server available else take the customerinto service
If taken into service, schedule a departure for thecustomer, based on the chosen service distributionpattern.
Move everyone else up in the queue.
RunSimulation Loop until the simulation reaches theend of the time stipulated.
Run the Check Routine
Check Fills any blanks with zeros within the worksheets.
RunSimulation Run the finishoff Routine
Finishoff Format the sheets to make it look presentable
RunSimulation Run the Averages Routine
Averages Based on the previously generated information theaverage times are calculated and presented in formof a summary
RunSimulation Run the Queuelength Routine
Queuelength Calculates the number of customers waiting in lineat a particular point in time.
RunSimulation Run the Buildreport Routine
Buildreport Copies the details sheet
Renames the copy
Adds data from other sheets Format the copy into a presentable format
RunSimulation Run the Report Routine
Report Builds the report sheet
RunSimulation Run the CreateChart Routine
CreateChart Creates a chart based on the percentages reportedin the report sheet
RunSimulation Select the Reports worksheet
Close the Control panel dialog box.
A comprehensive list of all the routines and what functions it performs can be found in
Appendix A. Appendix C shows the actual code used to generate the results.
3.5 SUMMARY
The fundamental aim of the chapter is to show the user how the results are generated on a logical
level and the emphasis was removed from the more technical programming side. Many
computations are made to get a result before the next routine may execute, but once the logic is
set-up correctly, the results will be consistent. Users may find the visual basic code to be lengthy
and complex, however Excel still performs at a reasonably fast pace.
Stellenbosch University http://scholar.sun.ac.za
8/20/2019 Mohd Queueing 1999
22/77
13
CHAPTER 4
4. VERIFICATION OF MODEL
4.1 INTRODUCTION
The purpose of the verification stages is two fold:
To prove that the results are reliable and the model works correctly.
To ensure that the results are consistent and accurate. The word accurate is used loosely as in
simulation, the result will vary every time but should average out closely to the analytical
results.
The methodology used will be:
Show which formulas will be used to test the results.
Build a table of inputs (Table 4.1), which will include both single and multiple servers.
Insert the input data in to the analytical formulas.
Insert the input data into the simulation model.
Compare the average simulated results to the analytical result (Table 4.2). (Outputs)
Compare theoretical inter-arrival times to simulated inter-arrival times (Table 4.4). (Input)
Compare theoretical service times to simulated service times (Table 4.4). (Input)
Compare theoretical statistical data to simulated statistical data (Table 4.5).
4.2 ANALYTICAL MODELS
An analytical model, which was supplied by Professor WR Gevers, was used to test the results
of the simulated model.
The model properties are based on the:
M / M / s model.
Stellenbosch University http://scholar.sun.ac.za
8/20/2019 Mohd Queueing 1999
23/77
14
In the above model M / M denotes that both the inter-arrival times and the service time for each
server is exponentially distributed. “s” denotes the number of servers. Customers are serviced in
a First-Come-First-Serve fashion.
4.3 SIMULATION RESULTS
Five different models based on the exponential distribution were analysed. The input parameters
are shown in Table 4.1. The analytical results together with the results of each of three
simulation runs are reported in Table 4.2.
Table 4.1: Inputs for comparison
Inputs Run1 Run2 Run3 Run4 Run5
Average Inter-arr ival t ime 0.04 2.00 0.40 0.17 0.27
Average Service time per
server
0.03 1.50 2.00 0.60 0.50
Number of servers 1 1 6 3 2
Traff ic intensity 0.75 0.75 0.83 1.18 0.93
Units Days Minutes Minutes Days Hours
Durat ion of run 500 800 800 500 1000
Table 4.2: Comparison of results
Outputs Run1 Run2 Run3 Run4 Run5
Average Time in Queue
Analyt ical 0.090 4.500 1.290 Traffic 2.977
Simulated Run 1 0.095 4.196 1.090 intensity 2.765
Simulated Run 2 0.093 4.375 1.440 To high 2.673
Simulated Run 3 0.089 5.689 1.200 3.000
Units Days Minutes Minutes Days Hours
Average Number in Queue
Analyt ical 2.250 2.250 3.230 Traffic 11.024
Simulated Run 1 2.405 2.080 2.843 intensity 10.230
Simulated Run 2 2.307 2.010 3.521 To high 9.856
Simulated Run 3 2.238 2.860 3.345 11.277
Stellenbosch University http://scholar.sun.ac.za
8/20/2019 Mohd Queueing 1999
24/77
15
The simulated results appear to be similar to the analytical results. When running the program it
was found that the higher the traffic intensity the longer the simulation should run to get a
simulated answer similar to the analytical answer. The comparison above, focus’s on the output
data.
4.4 OTHER STEPS TO VALIDATE RESULTS
Table 4.3: A Sample of the Details Table
Customer
Number
Inter-Arrival
Time
Clock Time Of
Arrival
Clock Time
Service Starts
Server Number To
Perform The
Service
Duration Of
Service
1 1.1881 1.1881 1.1881 Server 1 0.49442 0.3703 1.5584 1.5584 Server 2 0.7515
3 0.2300 1.7884 1.7884 Server 1 0.0587
Table 4.3 represents a sample of the Details Table in the simulation program. Table is used to
show which columns will be used in the following comparison.
Added to the comparison in Section 4.3, the averages of the:
Inter-arrival time
Duration of service,
were found by using the Detailed Results table in the “Detailed results” spreadsheet. By
comparing the Averages in the detailed results table against the actual values used to perform the
simulation, a variation can be found. Even though the random times generated are different to
the original inputs, due to the distributions, the averages are similar to the original values that
were inputted. The comparisons are shown in Table 4.4 for all of the distributions available
within the model. The comparison above focus’s on the inputs of the environment.
Stellenbosch University http://scholar.sun.ac.za
8/20/2019 Mohd Queueing 1999
25/77
16
Table 4.4: Input time versus simulated time
Description Run 1 Run 2 Run 3 Run 4 Run 5
Distribution Exponential Constant Normal Triangular Observed
Traffic Intensity 0.75 0.75 0.83 0.99 0.85
Inter-Arrival timeinserted by user
Average0.0400
Average2.0
Average0.40
Std Deviation0.1
Minimum 1Most Likely 2
Maximum 3
Prob Time0.7 50.1 40.1 30.1 2
Average4.40
Average simulatedinter-arrival time
0.0406 2.0 0.37 1.91 4.23
Variat ion 0.0006 0.000 0.03 0.09 0.17
Service time insertedby the user
Average0.0300
Average1.5
Average2.00
Std Deviation0.5
Minimum 5Most Likely 6
Maximum 7
Prob Time0.1 40.2 60.2 70.5 9
Average 7.5
Average simulatedservice time
0.0290 1.5 2.05 5.96 7.45
Variat ion 0.0010 0.000 0.05 0.04 0.05
The simulated results as shown in Table 4.4 appear to be similar to the analytical results. That
gives confidence that the simulator simulates the times correctly. A further check would be totest the simulated times for statistical significant deviation from the expected values. This has
been done for the observed distribution in Table 4.5.
Table 4.5: Statistical comparison
Description Inter-Arrival Time Service Time
Average Time 4.400 7.500Samp le Size 47 47
Standard Deviat ion 1.020 1.688
Signif icanc e Level 0.05 (95%) 0.05 (95%)
Confid ence Interval
High 4.692 7.983
Low 4.108 7.017
The observed inter-arrival time of 4.23 falls well in to the 95% confidence interval, and so does
the simulated service time of 7.45. This indicates that the observed probability distribution
Stellenbosch University http://scholar.sun.ac.za
8/20/2019 Mohd Queueing 1999
26/77
17
seems to be simulated correctly. An alternative statistical test would have been to do a
goodness-of-fit test on the observed simulated times.
4.5 SUMMARY
It can be seen that there is a small variation between the simulated results and the analytical data.
Both the input data e.g. inter-arrival time, and the output results e.g. number of clients in queue,
are similar when comparing the theoretical data and the simulated results. A conclusion can be
drawn: the simulated results proves to be within a reasonable accuracy when compared to the
analytical results.
Stellenbosch University http://scholar.sun.ac.za
8/20/2019 Mohd Queueing 1999
27/77
18
CHAPTER 5
5. USER GUIDE
5.1 INTRODUCTION
The following section will explain systematically what each button will do when activated.
When loading the Excel simulation file, the user will be prompted to enable the built in macro’s:
The macro’s must be enabled, for the program to work. Once the macro’s have been enabled,
the user will be presented with a Welcome screen (Figure 5.1).
5.2 USING THIS GUIDE
New and experienced users of Microsoft Excel may use this manual. The user will be able to
simulate basic queuing scenario’s. The program is written in a friendly format using a quasi form
of wizard that will try to attempt to catch any incorrect information where possible. The manual
will help the user will be able to use this program by making use of this manual.
Some of the screens are password protected. To unprotect a screen, use the “usb” password. The
password is caps sensitive.
It is compulsory to place information in the input boxes. If the boxes are not completed as
required, with the result of information being omitted, the simulation program will inform the
user to re-enter the required data. The appropriate input box will automatically be displayed.
Stellenbosch University http://scholar.sun.ac.za
8/20/2019 Mohd Queueing 1999
28/77
19
5.3 CONTROL CENTRE
Figure 5.1: Welcome Screen
Press the button to activate the central control menu.
After clicking the Central Control Menu button the following Figure 5.2 appears:
Stellenbosch University http://scholar.sun.ac.za
8/20/2019 Mohd Queueing 1999
29/77
20
Figure 5.2: Control Centre
The control centre screen is divided up into two main sections:
Action buttons: These buttons are used to start a process
Navigation buttons: These buttons are used to navigate from screen to screen.
On the Control Panel a indicator box called “Number of History Space Left” shows the number
of spaces the user has left to record simulated results. For example, if the box displays the
number 3, it means that the user may save three more models out of a total of five saves.
Stellenbosch University http://scholar.sun.ac.za
8/20/2019 Mohd Queueing 1999
30/77
21
5.4 ACTIONS BUTTONS
5.4.1 “Change Inputs” Button
The “Change Inputs” Button is used when the user wants to edit the current data used by
the program to run the simulation. After the change inputs button is pressed, Figure 5.3
appears on the screen.
The information button presents information as to what is required by the input boxes.
Figure 5.3: Input Screen
The input screen requires the following information:
a) The unit of T ime
The unit of time option allows the user to select the time unit he/she would prefer to use when
running the simulation.
The options are:
Minute
Hour
Stellenbosch University http://scholar.sun.ac.za
8/20/2019 Mohd Queueing 1999
31/77
22
Day
b) The number of uni ts that the simulation must run
The number of units that the simulation must run limits the number of observations to generate.
For example, if the units are hours, the arrival rate is 20 per hour, the limit is set to 8 hours as in
a working day then the result will be approximately 160 observations. The higher the limit, the
closer the result will be to the analytical result, however the system takes much longer to
simulate as the time is increased.
c) The number of servers
In the input box, the number of servers must be specified. If, for example two bank tellers are
used to service clients then the number 2 must be inserted in the box.
d) The maximum number of customers all owed in the queue.
The program allows the option of either having an unlimited number of space available for the
customers to queue (setting equals a 1000) or a limited amount of space. It would be used when
the area in which to queue can only hold, for example, 20 customers, the setting would be set to
20. The system now rejects any customer that enters the system if the queue length in longer
than 20.
Once the relevant data has been entered and the continue key clicked, the following screen
appears (Figure 5.4).
Stellenbosch University http://scholar.sun.ac.za
8/20/2019 Mohd Queueing 1999
32/77
23
Figure 5.4: Inter-arrival Input Box
The screen above is the Inter-arrival Input Screen. In the Figure 5.4, the following must be
updated.
e) I nput the inter-arr ival time
If customers arrive at a rate of 12 per hour, then find the reciprocal of 12 to get the inter-arrival
time i.e. 1/12 =0.0833 hours or 5 minutes, is the number entered in the box. The time is used to
simulate the environment specified by the user.
f) Select a distri bution pattern.
Different distribution patterns are selected for the inter-arrival times. The following options are
available:
Exponential
Constant
Normal
Triangular
Observed Probability
The Observed Probability option is important as the program will check this parameter and do
the calculations based on the distribution pattern specified.
Once the relevant data has been entered, click the continue key and the following service inputs
screen will appear (Figure 5.5):
Stellenbosch University http://scholar.sun.ac.za
8/20/2019 Mohd Queueing 1999
33/77
24
Figure 5.5: Service Inputs
In the Service Inputs screen the user will select the following
g) I npu t the average service time per server
If customers are serviced at a rate of 6 per hour, then find the reciprocal of 6 to get the service
time per server i.e. 1/6 = 0.166 hours or 10 minutes, is the number entered in the box. Time is
used to simulate the environment specified by the user.
h) Select a distr ibution pattern.
Different distribution patterns for the average service time per server are the same as the options
for the inter-arrival rate (see point f). Once the appropriate distribution pattern has been
selected, press the "Continue"-button. The input screens for changing or adding data are now
complete. The user will be returned to the last screen he/she was viewing.
5.4.2 “Run Simulation” Button
The "Run Simulation"-button initiates the simulation process. The program will effectively
calculate all relevant information and post it to the different sheets. (See Program Logic).
Stellenbosch University http://scholar.sun.ac.za
8/20/2019 Mohd Queueing 1999
34/77
25
5.4.3 “Update Probability Tables” Button
The “Update Probability Tables”-button takes the user to the probability table screen. Here the
user will enter the observed probabilities for both the arrival time and the service time.
Figure 5.6: Probability Table
Probability: Add the relevant probability in relation to the average Inter-arrival or Service time.
Specific Inter-arrival / Service time: Add the inter-arrival or service time to the corresponding
probability.
Note: the cumulative probability must add to the value one. If not, the program will not run.
The program checks the cumulative probability of both the Arrival and Service times. If either of
the two probabilities of times do not add to one, the program stops and returns to the Probability
Table screen (Figure 5.4), so that the user may make the appropriate amendments. If a value is
entered in the average inter-arrival time box (Paragraph 5.4.1, point e), the program will ignore
the value and replace it with the average of the inter-arrival times, which is shown in the arrival
probability table in Figure 5.6. The average will be shown in Input Screen, however it will not be
used in the simulation program. Only inter-arrival times calculated by generating random
numbers, and finding the corresponding time, in the probability table, will be used.
Stellenbosch University http://scholar.sun.ac.za
8/20/2019 Mohd Queueing 1999
35/77
26
5.4.4 “Add to History File” Button
The "Add to History File"-button allows the program to add / save simulated results in a
spreadsheet. It allows the user to save up to five simulated runs. First, clear the history file by
pressing the “Clear History” button (Paragraph 5.4.4). Then run a simulation. Once the
simulation has run, press the “Add To History File” button and it will save it to the history
screen. Refer to Fig 5.7.
Figure 5.7: History Screen
5.4.5 “Clear History” Button
The “Clear History” button is used to clear all the data on the history screen.
5.4.6 “Restore and Hide” Buttons
The “Restore and Hide” buttons are used to hide or show all the toolbars, status’s bars etc. The
restore/hide feature allows the user to have access to the model, so that changes can be made to
the model.
Stellenbosch University http://scholar.sun.ac.za
8/20/2019 Mohd Queueing 1999
36/77
27
5.5 NAVIGATION BUTTONS
The navigation buttons are used to navigate from screen to screen. Each screen represents a set
of data and it is as follows:
(Please check the Appendix B for a list of all the screens for a more detailed description.)
a) Welcome Screen
The Welcome screen is the introduction screen.
b) The I nput Screen
The Input screen shows all the relevant inputs used for the simulation program except for the
observed probabilities.
c) The Report Screen
The Report screen shows the following information:
User statistics
System orientated statistics
Probability distribution of number in queue.
d) The H istory Screen
The History screen shows a list of up to five saved simulated runs.
e) The Chart Screen
The Chart screen shows the results in form of charts
f) The Probabil i ty Chart Screen
The Probability Chart screen shows one chart that represents the probability distribution of the
number of customers in the queue.
Stellenbosch University http://scholar.sun.ac.za
8/20/2019 Mohd Queueing 1999
37/77
28
g) The Detailed Resul ts Screen
The Detailed Results screen shows information about each customer and each server.
h) The Summar y Screen.
The Summary screen shows a summary of the server idle time and the average customer waiting
time.
5.6 SUMMARY
The user guide covers the navigation of simulation program. An important characteristic, of the
simulation program to remember is, only times, should be inputted when prompted for arrival or
service durations. The other information is self-explanatory. The sequence of usage is irrelevant
i.e. any button may be clicked to see what it does. When trying to run a simulation for the users
environment, the “Change Inputs” button must be clicked followed by the “Run simulation”
button.
Stellenbosch University http://scholar.sun.ac.za
8/20/2019 Mohd Queueing 1999
38/77
29
CHAPTER 6
6. SUMMARY AND RECOMENDATIONS
6.1 SUMMARY
The core of this study project consists of a queuing simulation model that was built in the Excel
environment with visual basic. The model allows a user to run many variations of an
environment that he/she would like to improve. Topics, covered by the document, are from the
input stage to the output stage and how to use the results. Computer simulation is one of the
most versatile of all management science tools, and its popularity is growing constantly. The
simulation model demonstrated how the random function in Excel allows a user to simulate a
wide variety of problems. However, it only represents a small fraction of what simulation can
accomplish. However, the users should come away with an increased understanding of the
concept of simulation.
6.2 RECOMMENDATIONS
To enhance the simulation experience the user could take advantage of a powerful add-in
package, @RISK, that facilitates simulation (not for queuing), particularly statistics gathering
and presentation of results. The add-in, along with the functionality of Excel itself, allows
individuals with virtually no programming skills to perform complex and realistic simulations.
Even this, however, is only the tip of the iceberg in terms of what simulation can accomplish.
There are many special-purpose simulation packages that can simulate complex queuing systems
and a variety of other processes, and these packages are being, using increasingly often in the
business world. The material covered in this document should give the user a start in the use
simulation, however the extent to which simulation is used in the working environment is
extremely large and complex!
Stellenbosch University http://scholar.sun.ac.za
8/20/2019 Mohd Queueing 1999
39/77
30
LIST OF SOURCES
Winston, W.L. & Albright, S.C. 1997. Practical Management Science: Spreadsheet Modelling
and Applications. Belmont, CA: Duxbury
Turban, E. & Meredith, J.R. 1994. Fundamentals of Management Science. 6th ed. BurrRidge,
Ill: Irwin
Microsoft Corporation. 1999. Excel spreadsheet. Version 2000.
Stellenbosch University http://scholar.sun.ac.za
8/20/2019 Mohd Queueing 1999
40/77
31
APPENDIX A: LIST OF ROUTINES AND THEIR FUNCTIONS
Stellenbosch University http://scholar.sun.ac.za
8/20/2019 Mohd Queueing 1999
41/77
32
LIST OF ROUTINES AND THEIR FUNCTIONS
Visual Basic Routine It's function
ServDist_Change The routine prompts the user for either the standard deviation or the min, mostlikely and maximum value depending on what the user chose as the distributionprocess
GetInputs The routing calls up the input boxes for the program
RunSimulation It is the main routine that will run the simulation and call other routines toaccomplish the end result
Finishoff The routine does some formatting for presentation
Averages It creates the averages for the work stations in form of a pivot table in thesummary sheet
Check Checks for blanks and fills it with Zeros
Initialize Resets the sub routine parameters to zero start a new simulation
Timing Finds the most imminent event and record the server that has just finished
Arrive Calculates the Arrival time
Depart Calculates the Departure Time
Report Creates the Report Sheet
UpdateAreas Updates the report sheet
Buildreportsheet Creates the final details report sheet
Queuelength Determines the queue length and inserts it in the appropriate spread sheet
Auto_Close Runs when Excel closes. It restores the Excel sheets
Auto_Open Runs when Excel Opens. It removes toolbars starts sets the environment
GoToReport Takes the user to the Report sheet
CreateChart Creates the probability chart
GoToInputs Takes the user to the Inputs sheet
GeneralInputs Inserts the users inputs into the sheets
ArrivalInputs Inserts the arrival inputs
ServiceInputs Inserts the Service inputs
MaxInQueue_AfterUpdate Calls an information box
GoToCharts Takes user to the chart sheet
GoToHistory Takes user to the History sheet
ClearHistory It clears the history sheet to enable new data to be inputted
AddToHistory It adds data that has been recently run to the history sheet
SetNoOfRuns Sets the number of runs in the history sheet
PrintInputs Prints the Inputs spread sheet
PrintReports Prints the Reports spread sheet
PrintProbtables Prints the Probability table spread sheet
PrintHistory Prints the History spread sheet
PrintGraphs Prints the Graphs spread sheet
ArrDist_Change Shows or hides information which is appropriate or not appropriate at the timeof running the simulation
Stellenbosch University http://scholar.sun.ac.za
8/20/2019 Mohd Queueing 1999
42/77
33
APPENDIX B: LIST OF SCREENS
Stellenbosch University http://scholar.sun.ac.za
8/20/2019 Mohd Queueing 1999
43/77
34
LIST OF SCREENS
B.1 WELCOME SCREEN
Figure B.1: Welcome Screen
a) The Purpose of thi s screen
The Welcome Screen is the default introductory screen, which serves as an introduction screen.
By clicking on the Central Control Menu Button, the user may navigate to any other screen
within the application.
b) How to interpret the information on the screen
The Welcome Screen has no use, other than informing the user of:
The title of the package
The program used
The writer of the program.
Stellenbosch University http://scholar.sun.ac.za
8/20/2019 Mohd Queueing 1999
44/77
35
B.2 INPUTS SCREEN
Figure B.2: Inputs Screen
a) The Purpose of thi s screen
The Inputs Screen shows the inputs that will be used by the program for simulation purposes.
b) How to interpret the information on the screen
The user can use the screen for:
To check that the information used is as per the environment simulated.
Stellenbosch University http://scholar.sun.ac.za
8/20/2019 Mohd Queueing 1999
45/77
36
B.3 REPORTS SCREEN
Figure B.3: Reports Screen
a) The Purpose of thi s screen
The Reports Screen shows some of the outputs generated by the program.
b) How to interpret the information on the screen
Under the sub headings of the screen the following information can be used:
User Statistics
The user statistics information pertains to the individual i.e. the customer (See 2.2.1). It will help
in determining how the queuing environment affects the customer. All these results must be
minimised if possible.
Queue orientated statistics
The queue orientated statistics information pertains to the queue that is formed within the
environment. That the information supplied is concerning the queue and not the entire system.
Stellenbosch University http://scholar.sun.ac.za
8/20/2019 Mohd Queueing 1999
46/77
37
The information supplied by the program must be compared to the desired results of the
management of the queuing environment so that a compromise can be sought.
Probability of distribution number in queue
The “probability of distribution number in queue” information pertains to the queue that is
formed within the environment. The information supplied is concerning the queue and not the
entire system
Stellenbosch University http://scholar.sun.ac.za
8/20/2019 Mohd Queueing 1999
47/77
38
B.4 MULTI-GRAPH SCREEN
Figure B.4: Graphical representation of Results
a) The Purpose of thi s screen
The Graphical representation of Results screen shows some of the outputs generated by the
program in graphical format.
b) How to interpret the information on the screen
The Graphical representation of Results screen is useful for those users who like a quick
overview (“feel”) of the results. In the example above (Figure B.4, top, right graph), the vast
difference between the maximum customers in the queue and the average number in the queue
can be seen. It will help in formulating the size of the area, which should be provided for the
queue.
Stellenbosch University http://scholar.sun.ac.za
8/20/2019 Mohd Queueing 1999
48/77
39
B.5 GRAPHICAL DISTRIBUTION SCREEN
Figure B.5: Graph of Distribution Pattern
a) The Purpose of thi s screen
The Graph of Distribution Pattern screen shows some of the outputs generated by the program in
graphical format.
b) How to interpret the information on the screen
The Graph of Distribution Pattern screen is useful for those users who like a quick overview
(“feel”) of the results. In this example, just over 60% of the people will not have to queue in this
particular environment.
Stellenbosch University http://scholar.sun.ac.za
8/20/2019 Mohd Queueing 1999
49/77
40
B6. DETAILS SCREEN
Figure B.6: Detail Screen
a) The Purpose of thi s screen
The Detail Screen shows some of the detailed outputs generated by the program. Note that the
user will have to scroll to the right to get to the Central Control Panel.
b) How to interpret the information on the screen
The Detail Screen presents the following information about the Queue:
Customer Number
It shows the customer number in the sequence of arrival.
Inter-arrival time
It shows the randomly generated inter-arrival time generated by the program
Clock time of arrival
Stellenbosch University http://scholar.sun.ac.za
8/20/2019 Mohd Queueing 1999
50/77
41
In form of a continuous clock, the time of arrival is calculated, by adding the randomly generated
inter-arrival time to the last arrival time.
Time service starts
In form of a continuous clock, the time of the service start is shown. The time is based on First
come First served i.e. the first available server will take on a new customer. The model checks
for servers that are idle, and of those servers that are idle, it will assign the client to the server
with the lowest number i.e. server two will get preference over server three and four etc.
Server number to perform the service
Shows the server number that serviced the customer.
Duration of service
Show the duration of the service. The service time is randomly generated.
Clock time the service ends
The “clock time the service ends” time is based on the randomly generated duration of service
time i.e. “Time service start” plus “Duration of service” equals “Clock time the service ends”.
Waiting time of customer in minutes
If the customer waits then the time waited is recorded in this field
Queue length
The field shows the queue length at the point where the customer enters the system.
The rest of the information is the same as what is in the blue table expert for the last column in
the green table. The column shows the idle time for each server.
Stellenbosch University http://scholar.sun.ac.za
8/20/2019 Mohd Queueing 1999
51/77
42
B.7 AVERAGES SCREEN
Figure B.7: Averages Screen
a) The Purpose of thi s screen
The Averages screen shows the averages of the simulated data, which was generated by the
program.
b) How to interpret the information on the screen
The user can quickly see when more servers are added, the idle time increase as the number of
servers is increased.
Stellenbosch University http://scholar.sun.ac.za
8/20/2019 Mohd Queueing 1999
52/77
43
APPENDIX C: VISUAL BASIC CODE
Stellenbosch University http://scholar.sun.ac.za
8/20/2019 Mohd Queueing 1999
53/77
44
VISUAL BASIC CODE
Option Explicit
Option Base 1
'Define all the variables that will be used across routines
Dim i As Integer
Dim Nextcell, numberoftoolbars As Single, Nextcust As Integer, serverno As Integer, timingcount As Single
Dim AvgDelay, AvgNumInQ, StdDevArrive, StdDevService, Randomnum, MostLikelyValue, _
MinimumValue, ServiceSeq, MaximumValue, StdCArrive, StdCService, ValA, ValB, ServDist, ArivDist As
Double
Dim MaxInQ As Integer
Dim NextEventType As Integer, NumInQ As Integer, _
NumCusts As Long, NumBusy As Integer, _
numservers As Integer, FinishedServer As Integer, _
MaxInSys As Integer, NumLost As Integer
Dim AreaNumInQ As Single, AreaUtil As Single, MaxDelay As Single, _
TimeArrival(1000) As Single, Time As Single, TimeLastEvent As Single, _
TotDelays As Single, TimeNextEvent() As Single
Dim TimeInQ(0 To 1000) As SingleDim MeanArriveTime As Single, MeanServeTime As Single, _
MaxTime As Single
' Calculate the steady-state probability that no customers are in the
' system - this is needed for the steady-state outputs shown on the
' Report sheet
Function ProbEmpty(arrivetime As Single, servetime As Single, _
numservers As Integer) As Single
Dim Sum As Double, Product As Double, i As Integer, _
Traffic As Single
Traffic = servetime / (numservers * arrivetime)
If numservers = 1 Then
ProbEmpty = 1 - TrafficElse
Product = 1
Sum = 1
For i = 1 To numservers - 1
Product = Product * numservers * Traffic / i
Sum = Sum + Product
Next
Product = Product * Traffic / (1 - Traffic)
Sum = Sum + Product
ProbEmpty = 1 / Sum
End If
Worksheets("reports").Range("probempty").Value = ProbEmpty
End Function
Sub GetInputs()
Dim ArriveRate As Single, arivedist, servdist, arrivedist1 As Single, ServeRate As Single
Dim MaxTime As Single, numservers As Integer
Dim MaxInSys As Integer, timeunit As String
Dim checkforo As Single
Worksheets("Inputs").Range("ArriveTime").Value = 0
Worksheets("Inputs").Range("serveTime").Value = 0
'call msg boxes
DialogSheets("QGeneral Inputs").EditBoxes("NoOfUnits").Text = 0DialogSheets("QGeneral Inputs").EditBoxes("NumService").Text = 0
DialogSheets("QGeneral Inputs").EditBoxes("MaxInQueue").Text = 0
Stellenbosch University http://scholar.sun.ac.za
8/20/2019 Mohd Queueing 1999
54/77
45
DialogSheets("QGeneral Inputs").Show
DialogSheets("QArrival Inputs").EditBoxes("AvgCustArrive").Text = 0
Worksheets("Inputs").Range("ArivDist").Value = 1
DialogSheets("QArrival Inputs").Show
DialogSheets("QService Inputs").EditBoxes("AvgCustService").Text = 0
Worksheets("Inputs").Range("ServDist").Value = 1
DialogSheets("QService Inputs").Show'check if probs = 1
checkforo = Worksheets("Inputs").Cells(4, 6).Value
Do Until checkforo > 1
arivedist = Worksheets("Inputs").Range("ArivDist").Value
If arivedist = 5 Or 4 Then
Worksheets("Inputs").Range("ArriveTime").Value =
Worksheets("Inputs").Range("MostLikArrive").Value
Else
MsgBox "Note: You have selected a Zero Value for the Arrival time. The program cannot run with a zero
value. Please insert a value greater than one!"
DialogSheets("QArrival Inputs").EditBoxes("AvgCustArrive").Text = 0DialogSheets("QArrival Inputs").Show
End If
checkforo = Worksheets("Inputs").Cells(4, 6).Value
Loop
checkforo = Worksheets("Inputs").Cells(3, 6).Value
Do Until checkforo > 1
servdist = Worksheets("Inputs").Range("ServDist").Value
If servdist = 5 Or 4 Then
Worksheets("Inputs").Range("serveTime").Value = 1
ElseMsgBox "Note: You have selected a Zero Value for the Service time. The program cannot run with a zero
value. Please insert a value greater than one!"
DialogSheets("QService Inputs").EditBoxes("AvgCustService").Text = 0
DialogSheets("QService Inputs").Show
End If
checkforo = Worksheets("Inputs").Cells(3, 6).Value
Loop
'warn user of prob 1
arrivedist1 = Worksheets("Inputs").Range("ArivDist").Value
Select Case arrivedist1Case 1, 2, 3, 4
Case 5
MsgBox ("You have selected the 'Observed Probabilities' distribution option for the inter-arrival time,
please Update the Arrival Probability Table before you run the simulation.")
Worksheets("Observed Prob").Select
Worksheets("Observed Prob").Cells(1, 1).Select
Case Else
End Select
arrivedist1 = Worksheets("Inputs").Range("servDist").Value
Select Case arrivedist1
Case 1, 2, 3, 4
Stellenbosch University http://scholar.sun.ac.za
8/20/2019 Mohd Queueing 1999
55/77
46
Case 5
MsgBox ("You have selected the 'Observed Probabilities' distribution option for the service time per server,
please Update the Service Probability Table before you run the simulation.")
Worksheets("Observed Prob").Select
Worksheets("Observed Prob").Cells(1, 1).Select
Case Else
End Select
DialogSheets("Navigation Bar").hide
End Sub
Sub RunSimulation()
Dim arivedist, servdist As Integer
' check if prob = 1 if not abort
arivedist = Worksheets("Inputs").Range("ArivDist").Value
servdist = Worksheets("Inputs").Range("ServDist").Value
If arivedist = 5 Or servdist = 5 Then
Worksheets("Observed Prob").Select
Dim checking As Single
checking = Worksheets("Observed Prob").Cells(14, 2).Value
If checking < 1 Then
If checking = 0 Then
Else
MsgBox "You have selected the 'Observed Probabilities' as your distribution, however the arrival
probability total must add up to one. Please correct any errors."
Worksheets("Observed Prob").Cells(3, 2).SelectDialogSheets("Navigation Bar").hide ' hide bar
Exit Sub
End If
Else
If checking = 1 Then
Else
MsgBox "You have selected the 'Observed Probabilities' as your distribution, however the arrival
probability total must add up to one. Please correct any errors."
Worksheets("Observed Prob").Cells(3, 2).Select
DialogSheets("Navigation Bar").hide ' hide bar
Exit Sub
End If
End If
checking = Worksheets("Observed Prob").Cells(14, 6).Value
If checking < 1 Then
If checking = 0 Then
Else
MsgBox "You have selected the 'Observed Probabilities' as your distribution, however the service
probability total must add up to one. Please correct any errors."
Worksheets("Observed Prob").Cells(3, 6).Select
DialogSheets("Navigation Bar").hide ' hide bar
Exit Sub
End If
Else
If checking = 1 Then
Else
Stellenbosch University http://scholar.sun.ac.za
8/20/2019 Mohd Queueing 1999
56/77
47
MsgBox "You have selected the 'Observed Probabilities' as your distribution, however the service
probability total must add up to one. Please correct any errors."
Worksheets("Observed Prob").Cells(3, 6).Select
DialogSheets("Navigation Bar").hide ' hide bar
Exit Sub
End If
End If
Else
End If
If arivedist = 5 Then
Worksheets("Inputs").Range("ArriveTime").Value = Worksheets("Observed
Prob").Range("Averagearrival").Value
MsgBox "Note: You have chosen the Average Arrival Time as the distribution pattern. The Average of
the times will be displayed (for reporting purposes) on the input screen as 'Average time between arrivals',
however this average will not be used in the simulation."
End If
If servdist = 5 ThenWorksheets("Inputs").Range("ServeTime").Value = Worksheets("Observed
Prob").Range("Averageserve").Value
MsgBox "Note: You have chosen the Average Service Time as the distribution pattern. The Average of
the times will be displayed (for reporting purposes) on the input screen as 'Average time for each service',
however this average will not be used in the simulation."
End If
'get user inputs from Inputs screen
Application.ScreenUpdating = True
With Worksheets("Inputs")
MeanArriveTime = .Range("ArriveTime").ValueMeanServeTime = .Range("ServeTime").Value
numservers = .Range("NumServers").Value
MaxInSys = .Range("MaxInSys").Value
MaxTime = .Range("MaxTime").Value
End With
ReDim TimeNextEvent(numservers + 1)
Nextcell = 1
Initialize
Do
Nextcell = Nextcell + 1
Timing ' Find the time, type of next event, reset clock
UpdateAreas ' Update statistical accumulators
If NextEventType = 1 ThenArrive ' subroutine for an arrival
Else
Depart ' subroutine for a departure (service completion)
End If
' Cut off all future arrivals if store's doors have closed
If Time > MaxTime And TimeNextEvent(1) < 100000 Then
TimeNextEvent(1) = 100000
End If
Loop Until Time > MaxTime And NumBusy = 0
check ' fill blanks with zero's
finishoff ' format table
Averages ' find averages
queuelength ' find queue length
buildreportsheet ' biuld detail table
Stellenbosch University http://scholar.sun.ac.za
8/20/2019 Mohd Queueing 1999
57/77
48
Report ' Put the outputs on the Report sheet
CreateChart ' create chart
Worksheets("Reports").Select ' goto reports sheet
DialogSheets("Navigation Bar").hide ' hide bar
End Sub
Sub finishoff()
Dim count As Single
count = NumCusts + 2
Worksheets("table2").Select
' format table
Range(Cells(3, 1), Cells(count, 6)).Select
Selection.Copy
Range("G3").Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Range(Cells(2, 7), Cells(count, 11)).Select
Application.CutCopyMode = FalseSelection.Sort Key1:=Range("K3"), Order1:=xlAscending, Key2:=Range("I3") _
, Order2:=xlAscending, Header:=xlGuess, OrderCustom:=1, MatchCase:= _
False, Orientation:=xlTopToBottom
Range("L3").Select
ActiveCell.FormulaR1C1 = "0"
Range("L4").Select
ActiveCell.FormulaR1C1 = "=RC[-3]-R[-1]C[-2]"
Range("L4").Select
Selection.AutoFill Destination:=Range(Cells(4, 12), Cells(count, 12)), Type:=xlFillDefault
Worksheets("Table2").Cells(3, 12).Value = Worksheets("Table2").Cells(3, 9).Value
count = 0
Dim nextcustomer As Single
Do Until count = NumCusts
'find blanks and fill
nextcustomer = Worksheets("Table2").Cells(3 + count, 12).Value
If nextcustomer < 0 Then
Worksheets("Table2").Cells(3 + count, 12).Value = 0
Else
End If
count = count + 1
Loop
End Sub
Sub Averages()
'find averages
Worksheets("Summary").Select
ActiveSheet.PivotTables("PivotTable").PivotSelect "", xlDataAndLabel
Selection.ClearContents
Rows("7:16").Select
Selection.Delete Shift:=xlUp
Worksheets("table2").Select
'calculate customer delay
Range(Cells(3 + NumCusts, 6), Cells(3 + NumCusts, 6)).Select
ActiveCell.FormulaR1C1 = "=AVERAGE(R[-" & NumCusts & "]C:R[-1]C)"
Worksheets("Summary").Cells(2, 2).Value = Worksheets("Table2").Cells(3 + NumCusts, 6).Value
Range(Cells(3 + NumCusts, 6), Cells(3 + NumCusts, 6)).ClearContents
Stellenbosch University http://scholar.sun.ac.za
8/20/2019 Mohd Queueing 1999
58/77
49
'calculate server delay
Worksheets("table2").Select
Dim myRange As Single
myRange = 2 + NumCusts
ActiveSheet.PivotTableWizard SourceType:=xlDatabase, SourceData:= _
"Table2!R2C11:R" & myRange & "C12", TableDestination:= _"'[Queuing simulation New.xls]Summary'!R7C1", TableName:="PivotTable"
ActiveSheet.PivotTables("PivotTable").AddFields RowFields:="Server Number"
ActiveSheet.PivotTables("PivotTable").PivotFields("Idle Time of Each Server").Orientation _
= xlDataField
ActiveSheet.PivotTables("PivotTable").ColumnGrand = False
ActiveSheet.PivotTables("PivotTable").PivotFields("sum of Idle Time of Each Server"). _
Function = xlAverage
Cells.Select
Selection.Interior.ColorIndex = 43
Columns("A:A").Select
Selection.Font.Bold = False
Selection.Font.Bold = True
Columns("B:B").SelectSelection.Font.ColorIndex = 6
Selection.Font.Bold = False
Selection.Font.Bold = True
Range("A1").Select
Columns("A:A").EntireColumn.AutoFit
Columns("A:A").Select
Selection.Font.ColorIndex = 2
Worksheets("table2").Select
Range("A1").Select
End Sub
Sub check()
'check for zeros
Dim count As Single, nextcustomer As Single, nextcustomer1 As Double
count = 0
Do Until count = NumCusts
nextcustomer = Worksheets("Table2").Cells(3 + count, 2).Value
nextcustomer1 = Worksheets("Table2").Cells(3 + count, 6).Value
If nextcustomer
8/20/2019 Mohd Queueing 1999
59/77
50
Dim i As Integer
Time = 0
NumBusy = 0
NumInQ = 0
TimeLastEvent = 0
serverno = 0
NumCusts = 0 NumLost = 0
TotDelays = 0
MaxDelay = 0
AreaNumInQ = 0
MaxInQ = 0
AreaUtil = 0
Nextcust = 1
timingcount = 0
Worksheets("Table2").Range("Clearcontents").ClearContents
'rest parameters
Worksheets("Reports").Range("NumLost") = 0
Worksheets("Reports").Range("NumCusts") = 0
Worksheets("Reports").Range("MaxDelay") = 0Worksheets("Reports").Range("AvgDelay") = 0
Worksheets("Reports").Range("AvgNumInQ") = 0
Worksheets("Reports").Range("MaxInQ") = 0
Worksheets("Reports").Range("Util") = 0
arivdist = Worksheets("Inputs").Range("ArivDist").Value
Select Case arivdist ' Evaluate ArivDist
Case 1 ' Case for Poisson and Exponetial
' Schedule an arrival from the exponential distribution
TimeNextEvent(1) = -MeanArriveTime * Log(Rnd)
Case 2 'Case for Constant distribution
TimeNextEvent(1) = MeanArriveTime
Case 3 ' Case for Normal Distribution
StdDevArrive = Worksheets("Inputs").Range("StdDevArrive").Value
MeanArriveTime = Worksheets("Inputs").Range("ArriveTime").Value
Randomnum = Rnd
meanarrivetime2 = MeanArriveTime
MeanArriveTime = Application.WorksheetFunction.NormInv(Randomnum, StdDevArrive,
MeanArriveTime)Do Until MeanArriveTime > 0
Randomnum = Rnd
MeanArriveTime = Application.WorksheetFunction.NormInv(Randomnum, StdDevArrive,
meanarrivetime2)
Loop
MeanArriveTime = MeanArriveTime
TimeNextEvent(1) = MeanArriveTime
Case 4 ' Case Triangular
Randomnum = Rnd
MostLikelyValue = Worksheets("Inputs").Range("MostLikArrive").Value
MinimumValue = Worksheets("Inputs").Range("MinArriveValue").Value
MaximumValue = Worksheets("Inputs").Range("MaxValueArrive").Value
StdCArrive = Worksheets("Inputs").Range("StdCArrive").Value
Stellenbosch University http://scholar.sun.ac.za
8/20/2019 Mohd Queueing 1999
60/77
51
ValA = (MaximumValue - MinimumValue)
If Randomnum
8/20/2019 Mohd Queueing 1999
61/77
52
Case 1 ' Case for Poisson and Exponetial
' Schedule an arrival from the exponential distribution
TimeNextEvent(1) = Time - MeanArriveTime * Log(Rnd)
Case 2 'Case for Constant distribution
TimeNextEvent(1) = Time + MeanArriveTime
Case 3 ' Case for Normal Distribution
StdDevArrive = Worksheets("Inputs").Range("StdDevArrive").Value
MeanArriveTime = Worksheets("Inputs").Range("ArriveTime").Value
Randomnum = Rnd
meanarrivetime2 = MeanArriveTime
MeanArriveTime = Application.WorksheetFunction.NormInv(Randomnum, StdDevArrive,
MeanArriveTime)
Do Until MeanArriveTime > 0
Randomnum = Rnd
MeanArriveTime = Application.WorksheetFunction.NormInv(Randomnum, StdDevArrive,
meanarrivetime2)
LoopMeanArriveTime = MeanArriveTime
TimeNextEvent(1) = Time + MeanArriveTime
Case 4 ' Case Triangular
Randomnum = Rnd
MostLikelyValue = Worksheets("Inputs").Range("MostLikArrive").Value
MinimumValue = Worksheets("Inputs").Range("MinArriveValue").Value
MaximumValue = Worksheets("Inputs").Range("MaxValueArrive").Value
StdCArrive = Worksheets("Inputs").Range("StdCArrive").Value
ValA = (MaximumValue - MinimumValue)
If Randomnum MaxInQ Then
MaxInQ = NumInQ
End If
' Keep track of each customer's arrival time (for later stats)
TimeArrival(NumInQ) = Time
Stellenbosch University http://scholar.sun.ac.za
8/20/2019 Mohd Queueing 1999
62/77
53
' Otherwise, customer can go directly into service
Else
' Make the first idle server busy and schedule a departure
NumBusy = NumBusy + 1
i = 2
SchedDep = TimeNextEvent(i)
' This loop searches for the first idle serverDo
If SchedDep > 99999 Then
ServiceSeq = 1
'Determine the Service Distribution
'schedule an Service based on users input
servdist = Worksheets("Inputs").Range("ServDist").Value
' Stop
Select Case servdist ' Evaluate ServDist
Case 1 ' Case for Poisson and Exponetial
' Schedule an Service from the exponential distribution
If ServiceSeq = 1 ThenTimeNextEvent(i) = Time - MeanServeTime * Log(Rnd)
Else
Stop
TimeNextEvent(FinishedServer) = Time - MeanServeTime * Log(Rnd)
End If
Case 2 'Case for Constant distribution
If ServiceSeq = 1 Then
TimeNextEvent(i) = Time + MeanServeTime
Else
TimeNextEvent(FinishedServer) = Time + MeanServeTime
End If
Case 3 ' Case for Normal Distribution
StdDevService = Worksheets("Inputs").Range("StdDevService").Value
MeanServeTime = Worksheets("Inputs").Range("ServeTime").Value
Randomnum = Rnd
meanservetime2 = MeanServeTime
MeanServeTime = Application.WorksheetFunction.NormInv(Randomnum, StdDevArrive,
MeanServeTime)
Do Until MeanServeTime > 0
Randomnum = Rnd
MeanServeTime = Application.WorksheetFunction.NormInv(Randomnum, StdDevArrive,
meanservetime2)
LoopMeanServeTime = MeanServeTime
If ServiceSeq = 1 Then
TimeNextEvent(i) = Time + MeanServeTime
Else
TimeNextEvent(FinishedServer) = Time + MeanServeTime
End If
Case 4 ' Case Triangular
Randomnum = Rnd
MostLikelyValue = Worksheets("Inputs").Range("MostLikService").Value
MinimumValue = Worksheets("Inputs").Range("MinServiceValue").Value
MaximumValue = Worksheets("Inputs").Range("MaxValueService").Value
StdCService = Worksheets("Inputs").Range("StdCService").Value
ValB = (MaximumValue - MinimumValue)
Stellenbosch University http://scholar.sun.ac.za
8/20/2019 Mohd Queueing 1999
63/77
54
If Randomnum 0 And i > 0 Then
'update table
Worksheets("Table2").Cells(2 + Nextcust, 1).Value = Nextcust
Worksheets("Table2").Cells(2 + Nextcust, 4).Value = TimeNextEvent(i)
Worksheets("Table2").Cells(2 + Nextcust, 3).Value = starttime
Worksheets("Table2").Cells(2 + Nextcust, 5).Value = "server " & serverno
Nextcust = Nextcust + 1
Else
End If
End Sub
Sub Depart()
Dim i As Integer, Delay As Single, starttime As Double, servetemp As Double, numberone As Double,
numbertwo As Double
servetemp = serverno
' Update number of customers who have finished
NumCusts = NumCusts + 1
Stellenbosch University http://scholar.sun.ac.za
8/20/2019 Mohd Queueing 1999
64/77
55
' Check if any customers are waiting in queue - if not, make the
' server who just finished idle by resetting the TimeNextEvent to a
' large number
If NumInQ = 0 Then
NumBusy = NumBusy - 1TimeNextEvent(FinishedServer) = 100000
' Otherwise, take customer from front of queue into service
Else
NumInQ = NumInQ - 1
'Worksheets("Table2").Cells(2 + Nextcust, 13).Value = NumInQ
' Delay is the time this customer has been waiting in line
Delay = Time - TimeArrival(1)
If Delay > MaxDelay Then
MaxDelay = Delay
End IfTotDelays = TotDelays + Delay
AvgDelay = TotDelays / NumCusts
'Worksheets("Reports").Range("AvgDelay").Value = AvgDelay
'Worksheets("Reports").Range("MaxDelay").Value = MaxDelay
' Schedule departure for this customer with the same server who just
' finished
ServiceSeq = 2
i = 2
'Determine the Service Distribution
'schedule an Service based on users inputservdist = Worksheets("Inputs").Range("ServDist").Value
Select Case servdist ' Evaluate ServDist
Case 1 ' Case for Poisson and Exponetial
' Schedule an Service from the exponential distribution
If ServiceSeq = 1 Then
TimeNextEvent(i) = Time - MeanServeTime * Log(Rnd)
Else
TimeNextEvent(FinishedServer) = Time - MeanServeTime * Log(Rnd)
End If
Case 2 'Case for Constant distributionIf ServiceSeq = 1 Then
TimeNextEvent(i) = Time + MeanServeTime
Else
TimeNextEvent(FinishedServer) = Time + MeanServeTime
End If
Case 3 ' Case for Normal Distribution
StdDevService = Worksheets("Inputs").Range("StdDevService").Value
MeanServeTime = Worksheets("Inputs").Range("ServeTime").Value
Randomnum = Rnd
meanarrivetime2 = MeanServeTime
MeanServeTime = Application.WorksheetFunction.NormInv(Randomnum, StdDevService,
MeanServeTime)
Stellenbosch University http://scholar.sun.ac.za
8/20/2019 Mohd Queueing 1999
65/77
56
Do Until MeanServeTime > 0
Randomnum = Rnd
MeanServeTime = Application.WorksheetFunction.NormInv(Randomnum, StdDevService,
meanarrivetime2)
Loop
MeanServeTime = MeanServeTime
If ServiceSeq = 1 ThenTimeNextEvent(i) = Time + MeanServeTime
Else
TimeNextEvent(FinishedServer) = Time + MeanServeTime
End If
Case 4 ' Case Triangular
Randomnum = Rnd
MostLikelyValue = Worksheets("Inputs").Range("MostLikService").Value
MinimumValue = Worksheets("Inputs").Range("MinServiceValue").Value
MaximumValue = Worksheets("Inputs").Range("MaxValueService").Value
StdCService = Worksheets("Inputs").Range("StdCService").Value
ValB = (MaximumValue - MinimumValue)
If Randomnum 0 And i > 0 Then
serverno = FinishedServer - 1
'update tables
Worksheets("Table2").Cells(2 + Nextcust, 6).Value = Delay
Worksheets("Table2").Cells(2 + Nextcust, 1).Value = Nextcust
Worksheets("Table2").Cells(2 + Nextcust, 4).Value = TimeNextEvent(FinishedServer)
Worksheets("Table2").Cells(2 + Nextcust, 3).Value = starttime
Worksheets("Table2").Cells(2 + Nextcust, 5).Value = "server " & serverno
Worksheets("Table2").Cells(2 + Nextcust, 2).Value = starttime - Delay
Stellenbosch University http://scholar.sun.ac.za
8/20/2019 Mohd Queueing 1999
66/77
57
Nextcust = Nextcust + 1
serverno = FinishedServer + 1
Else
End If
' Move everyone else in line up one space
For i = 1 To NumInQTimeArrival(i) = TimeArrival(i + 1)
Next
End If
End Sub
Sub Report()
'ActiveWorkbook.Protect Password:="usb", structure:=False, Windows:=False
Dim i As Integer
Dim AvgDelay As Single, AvgNumInQ As Single, Util As Single
AvgDelay = TotDelays / NumCusts
AvgNumInQ = AreaNumInQ / Time
Util = AreaUtil / Time
Time = 0
For i = 0 To MaxInQ
Time = TimeInQ(i) + Time
Next
For i = 0 To MaxInQ
TimeInQ(i) = TimeInQ(i) / Time
Next
With Worksheets("Reports")
.Activate
.Range("NumCusts").Value = NumCusts.Range("AvgDelay").Value = AvgDelay
.Range("MaxDelay").Value = MaxDelay
.Range("AvgNumInQ").Value = AvgNumInQ
.Range("MaxInQ").Value = MaxInQ
.Range("Util").Value = Util / numservers
.Range("NumLost").Value = NumLost
' TimeInQ records, for value of NumInQ (0 to MaxInQ) the percentage
' of time that many customers were waiting in the queue
.Range("NumInQ").ClearContents
.Range("TimeInQ").ClearContents
.Range("diference").ClearContents
End With
With ActiveWorkbook
.Names("NumInQ").Delete
.Names("TimeInQ").Delete
End With
Worksheets("Reports").Range("NumInQ1").Select
With Selection
For i = 0 To MaxInQ
.Offset(i, 0).Value = i
.Offset(i, 1).Value = TimeInQ(i)
Next
End With
ActiveWorkbook.Names.Add Name:="NumInQ", _
Stellenbosch University http://scholar.sun.ac.za
8/20/2019 Mohd Queueing 1999
67/77
58
RefersToR1C1:=Range(Selection, Selection.End(xlDown))
Selection.Offset(0, 1).Select
ActiveWorkbook.Names.Add Name:="TimeInQ", _
RefersToR1C1:=Range(Selection, Selection.End(xlDown))
With Application
.Calculation = xlAutomatic
.MaxChange = 0.001
.CalculateBeforeSave = False
End With
End Sub
Sub UpdateAreas()
Dim TimeSinceLastEvent As Single
TimeSinceLastEvent = Time - TimeLastEvent
TimeLastEvent = Time
TimeInQ(NumInQ) = TimeInQ(NumInQ) + TimeSinceLastEvent
AreaNumInQ = AreaNumInQ + NumInQ * TimeSinceLastEvent
AvgNumInQ = AreaNumInQ / TimeAreaUtil = AreaUtil + NumBusy * TimeSinceLastEvent
End Sub
Sub buildreportsheet()
'
' buildreportsheet Macro
' Macro recorded 05/10/1999 by Shivan Mohd
'
'
Application.DisplayAlerts = False
Sheets("Reports2").DeleteApplication.DisplayAlerts = True
Sheets("Table2").Select
Sheets("Table2").Copy Before:=Sheets(7)
Sheets("Table2 (2)").Select
Sheets("Table2 (2)").Name = "Reports2"
Columns("D:D").Select
Selection.Insert Shift:=xlToRight
Columns("F:F").Select
Selection.Cut Destination:=Columns("D:D")
Columns("F:F").Select
Selection.Delete Shift:=xlToLeft
Columns("G:G").Select
Selection.Insert Shift:=xlToRightActiveWindow.SmallScroll ToRight:=1
Columns("N:N").Select
Selection.Cut Destination:=Columns("G:G")
Columns("N:N").Select
Selection.Delete Shift:=xlToLeft
ActiveWindow.SmallScroll ToRight:=-7
Columns("B:B").Select
Selection.Insert Shift:=xlToRight
Range("B2").Select
ActiveCell.FormulaR1C1 = "Interarrival Time"
With ActiveCell.Characters(Start:=1, Length:=17).Font
.Name = "Arial"
.FontStyle = "Bold"
.Size = 10
Stellenbosch University http://scholar.sun.ac.za
8/20/2019 Mohd Queueing 1999
68/77
59
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = 2End With
Columns("B:B").Select
Selection.ColumnWidth = 10.71
Selection.NumberFormat = "0.0000"
Range("B3").Select
ActiveCell.FormulaR1C1 = "=RC[1]"
Dim stepdown As Single
stepdown = 0
Do Until stepdown = NumCusts - 1
Worksheets("Reports2").Cells(4 + stepdown, 2).Value = Worksheets("Reports2").Cells(4 + stepdown,
3).Value - Worksheets("Reports2").Cells(4 - 1 + stepdown, 3).Value
stepdown = stepdown + 1
Loop
Columns("F:F").Select
Selection.Insert Shift:=xlToRight
Range("F2").Select
ActiveCell.FormulaR1C1 = "Duration Of Service"
With ActiveCell.Characters(Start:=1, Length:=19).Font
.Name = "Arial"
.FontStyle = "Bold"
.Size = 9
.Strikethrough = False
.Superscript = False.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = 2
End With
stepdown = 0
Do Until stepdown = NumCusts - 1
Worksheets("Reports2").Cells(3 + stepdown, 6).Value = Worksheets("Reports2").Cells(3 + stepdown,
7).Value - Worksheets("Reports2").Cells(3 + stepdown, 4).Value
stepdown = stepdown + 1
LoopSheets("Summary").Select
Range("B3").Select
ActiveCell.FormulaR1C1 = "=AVERAGE(Reports2!RC[4]:R[3333]C[4])"
Range("B2:B6").Select
Selection.NumberFormat = "0.0000"
End Sub
Sub queuelength()
Worksheets("Table2").Select
Dim q, stepup, stepdown As Single
q = 1
Stellenbosch University http://scholar.sun.ac.za
8/20/2019 Mohd Queueing 1999
69/77
60
stepup = 1
stepdown = 0
Worksheets("Table2").Cells(3, 2).Select
Do Until Worksheets("Table2").Cells(3 + stepdown, 1).Value = Nextcust - 1
If Worksheets("Table2").Cells(3 +