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)

Shivan Mohd

Study Leader

: Professor WR Gevers

Degree of Confidentiality

: Grade A


: October 1999

Stellenbosch University http://scholar.sun.ac.za

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

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

Stellenbosch University http://scholar.ac. Inputs can be changed to suit the users requirements. .sun. The simulation model will test various scenario’s of queuing theory. The mini-study project covers the principles of queuing and it’s outputs. Results may be analysed to determine an optimal queuing environment.za iv ABSTRACT A mini-study project presented on the use of Microsoft Excel 2000 in the field of simulation.

Toevoere kan verander word na gelang van die gebruiker se keuse. Die beginsels van toustaan modelle word gedek.sun.ac. Die simulasiemodel modelleer en toets verskillende toustaan scenarios.za v OPSOMMING Hierdie mini-werkstuk illustreer die gebruik van Excel 2000 in die veld van simulasie. Die resultate kan ontleed word om die optimale toustaan omgewing te bepaal. .Stellenbosch University http://scholar. asook die tipiese resultate.

1 INTRODUCTION 2.2. VERIFICATION OF MODEL 13 4.2 THE STRUCTURE OF THE QUEUING SYSTEM 2.2.4 SEQUENCE OF EVENTS 3.5 DEVELOPMENT OF THE REPORT 1 2 2 3 3 CHAPTER 2.Stellenbosch University http://scholar.3 The service facility and service process 2.1 INTRODUCTION 1.2 INPUTS REQUIRED 3.3 The number of servers 3.1 INTRODUCTION 4.2 Constant 3.2.3.sun.4 Triangular 3. INTRODUCTION 1 1.2.2 METHODOLOGY USED 1.1 The Customers and their source 2.3 Normal 3.2 ANALYTICAL MODELS 4.1 Exponential 3.5 The arrival rate 3.4 The maximum number of customers allowed in the queue 3.3 LIMITATIONS AND RESTRICTIONS The Queue MINIMUM REQUIREMENTS 1.2 The duration of the simulation 3.za vi TABLE OF CONTENTS Declaration Acknowledgments Abstract Opsomming List of tables List of figures ii iii iv v viii ix CHAPTER 1.3.ac.2.2.6 The service rate 3.1 INTRODUCTION 3.2. THE LOGIC OF THE MODEL PRESENTED 7 3.5 SUMMARY 7 7 7 7 7 8 8 9 9 9 9 10 10 10 11 12 CHAPTER 4.3 SUMMARY 4 4 4 4 5 5 6 6 CHAPTER 3.5 Degree of Patience 2.3 SIMULATION RESULTS 4.2.1 Unit of time 3.2 The arrival process 2.4 OTHER STEPS TO VALIDATE RESULTS 4.2.3 SIMULATION OF RANDOM EVENTS 3.2. QUEUING THEORY: A QUICK OVERVIEW 4 2.5 Observed Probabilities 3.5 SUMMARY 13 13 14 15 17 .

ac. USER GUIDE 18 5.1 SUMMARY 6.1 INTRODUCTION 5.2 USING THIS GUIDE 5.3 “Add to History File” button 5.4.4 ACTIONS BUTTONS 5.sun. SUMMARY AND RECOMMENDATIONS 29 6.4 “Clear History” Button 5.za vii CHAPTER 5.1 “Change Inputs” Button 5.5 NAVIGATION BUTTONS 5.6 SUMMARY 18 18 19 21 21 24 26 26 26 28 CHAPTER 6.3 CONTROL CENTRE 5.Stellenbosch University http://scholar.4.2 “Run Simulation Button” Button 5.4.2 RECOMMENDATIONS 29 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 .4.

1: Sequence of events 11 Table 4.za viii LIST OF TABLES Table 2.Stellenbosch University http://scholar.sun.1: Inputs for comparison 14 Table 4.2: Comparison of results 14 Table 4.5: Statistical comparison 16 .1: Examples of queues 6 Table 3.3: A sample of the details table 15 Table 4.ac.4: Input time versus simulated time 16 Table 4.

za ix LIST OF FIGURES Figure 5.2: Control Centre 20 Figure 5.7: History Screen 26 . .4: Inter-arrival Input Box 23 Figure 5.1: Welcome Screen 19 Figure 5.5: Service Inputs 24 Figure 5.6: Probability Table 25 Figure 5.ac.Stellenbosch University http://scholar.sun.3: Input Screen 21 Figure 5.

The model was designed and created for two main reasons:  To simulate a queuing environment based on various factors of queuing e.Stellenbosch University http://scholar. the model developed. Often. Optimal loading for service points could be determined.g.za 1 CHAPTER 1 1.sun. how will the average waiting time of the customer decrease? . b) the logic of queuing simulation. 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.  The second reason is to show students: a) how problems (in this case: queuing). 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. A simulation model might help answer questions such as the following:  If a service point is added. can be solved by using spreadsheets as the analytical tool and by allowing the student to try various combinations of inputs and comparing results. number of servers etc and presenting the results in format that would make the analysis of the results easier. thus allowing for various scenarios. In an attempt to make this task a bit easier. In most situations.ac. simulation can provide the decision maker with important information.1 INTRODUCTION Queuing is a part of many people’s lives. The Model will report simulated results of the users inputs. will show the characteristics of queues by simulating the queuing environment. arrival distribution. It would also allow for controlling queue length and server idle time. services rate. INTRODUCTION 1. a simulation model is a computer model that imitates a real-life situation.

1. 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 . 1. 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.sun. by how much will the average waiting time reduce? Although analytical models can help in answering the questions above.3 LIMITATIONS AND RESTRICTIONS The program has its limitations and should only be used as a guideline.za 2  If the service time is reduced. Most of the program logic uses Visual Basic and Excel functions to simulate data and calculate results. By covering the theory of queuing. the user will have a better understanding of the model.ac. The limitations of the model will be discussed in the next paragraph. The program caters for both theoretical probability distributions and observed probabilities. The main objectives are.2 METHODOLOGY USED The model was created using Excel 2000. to show how simulation can be accomplished by using Excel spreadsheets and for the model to be practical in application. simulation will give the user a better feel as to the possible outputs of the data inputted.Stellenbosch University http://scholar.

ac. The user may be more comfortable in using the model once it has been proven that the model produces the correct results.  Verification of the model – The focus of this chapter is to prove that the results are correct.za 3 1.sun. a section covering the use of the program is included in this document.4 MINIMUM REQUIREMENTS For the model to work.  Logic of the model presented – Understanding how the results were derived is a key factor when working with the model 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. The sequence of the simulation is covered in this area. 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. is presented.  User guide – If a user requires clarification as to how the program is to be used.Stellenbosch University http://scholar. .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.

the manner in which customers or the waiting units. or the number of units per period (such as 10 units per hour).1 INTRODUCTION In order to understand the program.2. the reciprocal of the arrival rate. are arranged for service. The distributions of the inter-arrival time may be exponential. QUEUING THEORY: A QUICK OVERVIEW 2. Customers can be people. an overview to discuss some important points and terminology would be appropriate and helpful when working through the program. must be defined.za 4 CHAPTER 2 2.Stellenbosch University http://scholar. The chapter covers the minimal requirements needed for the simulation of queues.sun. a hospital’s population would be residents in the surrounding community and the customers would be those sick people in the population requiring hospitalisation. The customers are generated from a population (calling population) or a source. The population source may be from an infinite or a finite source. Waiting line formulas generally require an arrival rate. 2. The time between arrivals is the inter-arrival time (such as an average of one every six minutes) or. machines or raw materials. aeroplanes. For example. constant etc. The average service time per server is different from the average inter-arrival time.2 THE STRUCTURE OF THE QUEUING SYSTEM 2. .ac.2. 2. When describing a waiting system.1 The customers and their source Customers are defined as those in need of service.2 The arrival process The manner in which customers show up at the service facility is called the arrival process. as the two processes are independent of each other.

machine (elevator. A service facility may include one person or several people operating as a team.ac.sun. Usually.2.za 5 A constant arrival distribution is periodic.1. the exponential distribution is assumed. In elementary models. Queues formed and the Service provided may be found in Table 2. Much more common are variable (random) arrival distributions.4 The Queue Whenever an arriving customer finds that the service facility is busy. In observing arrivals at a service facility. Examples of Systems. . with exactly the same time between successive arrivals. The service time may also follow various distribution patterns.Stellenbosch University http://scholar. to mention just a few. parking lot. in elementary analytical models it is assumed that the time between arrivals is exponentially distributed. a queue or waiting line is formed. In productive systems. exponential etc. The service facility may be a person (bank teller. Facilities may be fixed (Loading dock) or movable (service technician).3 The service facility and service process The service is provided by a service facility (or facilities). 2.2. or space (airport runway. gasoline pump). about the only arrivals that truly approach a constant interarrival period are those that are subject to machine control. there are two viewpoints: The time between successive arrivals can be analysed to see if the times follow some statistical distribution. 2. hospital bed). a barber.

The program does not cater for impatient behaviour. and then. job design. depart. In a service economy people wait in line every day. Understanding waiting lines or queues and learning how to manage it. while the second is termed reneging. . inventory models and so on. Those in the second class arrive. Management can reduce the amount of time spent in a queue by applying the concepts of queuing theory. is one of the most important areas in operations management. The behaviour of the first type is termed balking. Simulation will aid management in this understanding. survey both the service facility and the length of the line.za 6 Table 2. view the situation. It is basic to creating schedules.1: Examples of queues System Computer Bank Telephone Library Queue Jobs People Callers Books to be shelved Service Process facilities Tellers Switchboards 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. the fact that the customers wait is sufficient to label them as patient clients for purposes of waiting line theory. and then decide to leave.2. when trying to apply the concepts to simulate an environment. (Even if clients grumble and behave impatiently. join the waiting line. Members of the first class arrive.ac. from driving to work to checking out at the supermarket.) There are two classes of impatient clients.sun.Stellenbosch University http://scholar.3 SUMMARY The understanding of queuing theory is fundamental. after some period of time.

The longer it is set the longer the simulation will take to run. The option allows the user to change from a single server environment to a multi-server environment with all servers rendering an identical service. processes and outputs of the model.2. for example. 3. If. 3. Normally a longer run will give an answer closer to that of the analytical models. Once the user uses either one of these options. Hours or Days. the program will return approximately 10 observations. 3.sun. the user will have a better understanding of the logic of the model presented.1 Unit of time The unit of time may be Minutes. For example: 25 will equal 25 Days if the Unit of time is days. the program will use that unit of time for both the arrival and the service calculations. THE LOGIC OF THE MODEL PRESENTED 3.2 The duration of the simulation The duration of the simulation pertains to the length of time the simulation should run. The purpose of this chapter is to clarify the flow of inputs.ac. the simulation run time is set for 10 min and the arrival rate is one per minute.2.2.za 7 CHAPTER 3 3.2 INPUTS REQUIRED 3. .3 The number of servers The number of servers that are used or that will be used is required.1 INTRODUCTION Once a good understanding of the queuing theory has been formed.Stellenbosch University http://scholar.

The average interarrival time is automatically converted to an arrival rate. 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. which is reported to the Input Screen. and this is the number placed in the input box. customers would be turned away until the number in queue drops to below 20. seven per time of unit. 3.4 The maximum number of customers allowed in the queue The user can set the number of customers the queue can handle. The parameter is governed by the size available for queuing. For example: 20 will mean that once the queue length reaches 20.5 The arrival rate The average arrival rate will be in the form of e.ac. random times will be selected from the inter-arrival probabilities table.2.g. The inter-arrival time on the Input Screen will not be used if the program is using the observed probability option.143 hours between arrivals. The inter-arrival time is then used in the simulation process.za 8 3. The customer who will be turned away will then be recorded under the “Number of Customers turned away” heading on the report sheet.2.Stellenbosch University http://scholar.sun. If the area in which people are allowed to queue can only house 10 people then the limit must be set to ten. By using the Monte-Carlo methodology. The distribution pattern of the inter-arrival times may be:  Exponential  Constant  Normal  Triangular  Or Observed probabilities . If unlimited space is available for queuing then the parameter must be set to 1000.

the “Rnd” function is used. The average time per service is automatically converted to a service rate.za 9 3. Duration’s are simulated as shown below for the various distributions. Excel provides a facility that generates random numbers. The average time per service on the Input Screen will not be used if the program is using the observed probability option. the Monte Carlo methodology is used to generate random times.g. and this is the number placed in the input box. By using the Monte-Carlo methodology.6 The service rate The average service rate will be in the form of e. When observed values are used. 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.2. the program uses the following statement: Duration = MeanArriveTime * Log(Rnd) Where “Log” represents the natural logarithm.sun. which is reported to the Input Screen. b) Constant When the constant option is selected. 3. random numbers are required. random numbers are required for the inter-arrival time and the service time.ac. 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. Five different probability distributions may be selected. the program uses the following statement: . In the Visual basic format.166 hours.3 SIMULATION OF RANDOM EVENTS When simulating data.Stellenbosch University http://scholar. In the model. a) Exponential When the exponential option is selected. random times will be selected from the service time probabilities table.

Only positive numbers are used in the simulation. hence the name. the program will loop until the generated number is positive.Sqr ((1 . the program uses the following statement: Duration = NormInv (Random Number.sun. .za 10 Duration = MeanArriveTime c) Normal When the normal option is selected. the program uses the following statement: ValA = (MaximumValue .ac. The probabilities table is a set of specific inter-arrival times and its corresponding probability. Monte Carlo simulation involves feeding a large number of random inputs (in this case. The random inputs are analogous to rolls of dice or spins of a roulette wheel at a casino.MinimumValue) If Randomnum <= StdCArrive (Standardised “C”) Then MeanArriveTime = ValA * Sqr (Randomnum * StdCArrive) Else MeanArriveTime = ValA * (1 .Stellenbosch University http://scholar. d) Triangular When the triangular option is selected. MeanArriveTime) (Returns the inverse of the normal cumulative distribution for the specified mean and standard deviation) If a negative number is generated. The option of observed probabilities uses the Monte Carlo Methodology using inputs (inter-arrival and service times) from the user and extracting information from the probabilities table to complete the simulation. inter-arrival and service times) into a model while recording the range of outputs. Standard Deviation.StdCArrive) * (1 -Randomnum))) End If Duration = Minimum Value + MeanArriveTime e) Observed Probabilities Developed during the Manhattan (Atomic Bomb) Project in the 1940’s.

Check if all servers are busy. Once in service it now calculates a random service time Write the information to the detailed report sheet. The random number is used to compare the number against the probability table generated by the user. Normal etc Timing  UpdateAreas    Determine whether the time is an arrival or a departure event. then put the customers directly into service. put the time at the end of the queue.g. If above the amount of customers allowed then the programme records the arrival as a lost customer.g. The duration is calculated by generating a random number e.Stellenbosch University http://scholar. Exponential.4 SEQUENCE OF EVENTS To start the simulation the user has to click on the Run Simulation button.za 11 For example. Of all the other interarrival times the inter-arrival time of six appears 20% of the time within the given environment. The comparison will result in a corresponding inter-arrival or service time. If not.1: Sequence of events Main Routine RunSimulation RunSimulation Description of what it does  Gathers the users input parameters from the Inputs worksheet.sun.54 and using it as a percentage. Update the Clock to the time of the next event Arrive        RunSimulation  If the Event was a departure event then Update statistical accumulators and writes results to the reports worksheet Checks the input sheet for which distribution pattern to use Once found. . 3. it calculates the random time of the next event Check to see if the number in queue is within the maximum allowed in the queue. Starts the Timing Routine Start the UnpdateAreas Routine Check to see if this time is an arrival event or a departure event. it searches for the first available server by starting from server number one and progressing upwards towards the last server.ac. Once this has been done. The newfound time is used as the duration within the simulation program. The formulae used within Excel to determine the times based on the probabilities: = VLOOKUP(). the following sequence of events takes place: Table 3. Sets the worksheet parameters to Zero Calculates the First Arrival based on the users input e. Before it can place a customer in service. 0.  Starts the Initialize Routine   RunSimulation RunSimulation     Start a loop until the simulation time has expired as per the users input. If it is an arrival event then run the Arrive Routine Starts the Arrive Routine Sub Routine  Description of what it does Initialize    Re sets the simulation parameters to Zero. and if so. an inter-arrival time of six may have a probability of 20%.

then make the server available else take the customer into service If taken into service. but once the logic is set-up correctly. Users may find the visual basic code to be lengthy and complex. Buildreport     Copies the details sheet Renames the copy Adds data from other sheets Format the copy into a presentable format Report  Builds the report sheet CreateChart  Creates a chart based on the percentages reported in the report sheet Finishoff Format the sheets to make it look presentable Based on the previously generated information the average times are calculated and presented in form of a summary 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. . based on the chosen service distribution pattern. however Excel still performs at a reasonably fast pace. Run the Check Routine Run the finishoff Routine Run the Averages Routine Run the Queuelength Routine Run the Buildreport Routine RunSimulation  Run the Report Routine RunSimulation  Run the CreateChart Routine RunSimulation   Select the Reports worksheet Close the Control panel dialog box. schedule a departure for the customer.ac. the results will be consistent. Averages      Queuelength  Calculates the number of customers waiting in line at a particular point in time.za 12 run the depart routine. if not. 3. Depart     RunSimulation   RunSimulation RunSimulation RunSimulation RunSimulation      Loop until the simulation reaches the end of the time stipulated.sun. Check Update the number of customers who finished Check if any customers are in queue.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.Stellenbosch University http://scholar. Many computations are made to get a result before the next routine may execute. Fills any blanks with zeros within the worksheets. Move everyone else up in the queue.

the result will vary every time but should average out closely to the analytical results. which was supplied by Professor WR Gevers. .  Insert the input data in to the analytical formulas. (Input)  Compare theoretical statistical data to simulated statistical data (Table 4. The methodology used will be:  Show which formulas will be used to test the results.  To ensure that the results are consistent and accurate.1). which will include both single and multiple servers.1 INTRODUCTION The purpose of the verification stages is two fold:  To prove that the results are reliable and the model works correctly. The word accurate is used loosely as in simulation.2).  Build a table of inputs (Table 4.  Insert the input data into the simulation model.  Compare the average simulated results to the analytical result (Table 4. 4.za 13 CHAPTER 4 4. VERIFICATION OF MODEL 4.4).4).Stellenbosch University http://scholar.5).sun.ac. (Outputs)  Compare theoretical inter-arrival times to simulated inter-arrival times (Table 4.2 ANALYTICAL MODELS An analytical model. The model properties are based on the: M / M / s model. (Input)  Compare theoretical service times to simulated service times (Table 4. was used to test the results of the simulated model.

17 0.860 3.090 4.50 1 1 6 3 2 0.27 Table 4.3 SIMULATION RESULTS Five different models based on the exponential distribution were analysed.sun.2: Comparison of results Outputs Run1 Run2 Run3 Run4 Run5 Average Time in Queue Analytical 0.200 Units Days Minutes Minutes Days Hours Analytical 2.2.093 4.83 Minutes 800 1.50 2.00 0.250 3.673 Simulated Run 3 0.405 2.93 Hours 1000 Average Service time per server Number of servers Traffic intensity Units Duration of run Run2 Run3 Run5 0.1.250 2.689 1.ac.375 1. “s” denotes the number of servers.277 .230 Traffic 11. The input parameters are shown in Table 4.75 Days 500 0.095 4.521 To high 9.1: Inputs for comparison Inputs Average Inter-arrival time Run1 0.za 14 In the above model M / M denotes that both the inter-arrival times and the service time for each server is exponentially distributed.18 Days 500 0.00 0.977 Simulated Run 1 0. Table 4.345 3.440 To high 2. 4.843 intensity 10.Stellenbosch University http://scholar.290 Traffic 2.04 2.60 0.40 Run4 0.765 Simulated Run 2 0.024 Simulated Run 1 2.75 Minutes 800 0.307 2.010 3.000 Average Number in Queue 11.080 2.500 1.090 intensity 2.230 Simulated Run 2 2. The analytical results together with the results of each of three simulation runs are reported in Table 4. Customers are serviced in a First-Come-First-Serve fashion.856 Simulated Run 3 2.238 2.089 5.03 1.196 1.

sun.5584 1. due to the distributions.5584 Server 2 1.2300 1.1881 0.za 15 The simulated results appear to be similar to the analytical results. focus’s on the output data. The comparisons are shown in Table 4.7884 1.7884 Server 1 0.3.7515 0. . The comparison above focus’s on the inputs of the environment. By comparing the Averages in the detailed results table against the actual values used to perform the simulation. 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. a variation can be found. Table is used to show which columns will be used in the following comparison.1881 Server 1 1.1881 1. were found by using the Detailed Results table in the “Detailed results” spreadsheet.0587 Table 4. the averages of the:  Inter-arrival time  Duration of service.4944 0.3703 0.4 for all of the distributions available within the model. Even though the random times generated are different to the original inputs. Added to the comparison in Section 4. 4.3 represents a sample of the Details Table in the simulation program.4 OTHER STEPS TO VALIDATE RESULTS Table 4.3: A Sample of the Details Table Customer Number Inter-Arrival Clock Time Of Time Arrival Clock Time Server Number To Perform The Service Starts Duration Of Service Service 1 2 3 1. the averages are similar to the original values that were inputted.ac.Stellenbosch University http://scholar.

Table 4.1 Triangular 0.017 The observed inter-arrival time of 4. This indicates that the observed probability distribution .5 7.75 Average 0.5.1 4 0.0290 1.4: Input time versus simulated time Description Distribution Traffic Intensity Inter-Arrival time inserted by user Average simulated inter-arrival time Variation Service time inserted by the user Average simulated service time Variation Run 1 Run 2 Exponential 0.020 0.96 Average 7.03 Average 2.00 Std Deviation 0.0 Run 3 Run 4 Run 5 Normal 0. and so does the simulated service time of 7. This has been done for the observed distribution in Table 4.5 0.05 (95%) 7.000 0.40 4.05 Prob 0.0 0.692 4.688 0.500 47 1.05 (95%) 4.91 0.45 0.4 appear to be similar to the analytical results.sun.400 47 1.85 Prob Time 0.05 5. That gives confidence that the simulator simulates the times correctly.45.0010 0.1 2 Average 4.2 0.09 Minimum 5 Most Likely 6 Maximum 7 0.ac.23 falls well in to the 95% confidence interval.04 0.5 0.83 Average 0.17 Time 4 6 7 9 The simulated results as shown in Table 4.5: Statistical comparison Description Average Time Sample Size Standard Deviation Significance Level Confidence Interval High Low Inter-Arrival Time Service Time 4.0300 0.0406 2.5 2.7 5 0.05 0.108 7.75 Average 2.983 7.1 0.Stellenbosch University http://scholar.0400 Constant 0.000 Average 1.37 1.0006 Average 0. A further check would be to test the simulated times for statistical significant deviation from the expected values.40 Std Deviation 0.99 Minimum 1 Most Likely 2 Maximum 3 Observed 0.1 3 0.23 0.2 0.5 0.za 16 Table 4.

4. and the output results e. number of clients in queue. An alternative statistical test would have been to do a goodness-of-fit test on the observed simulated times.sun. . Both the input data e. are similar when comparing the theoretical data and the simulated results.ac.Stellenbosch University http://scholar.5 SUMMARY It can be seen that there is a small variation between the simulated results and the analytical data.g. A conclusion can be drawn: the simulated results proves to be within a reasonable accuracy when compared to the analytical results. inter-arrival time.g.za 17 seems to be simulated correctly.

The appropriate input box will automatically be displayed.2 USING THIS GUIDE New and experienced users of Microsoft Excel may use this manual.za 18 CHAPTER 5 5. use the “usb” password. the user will be prompted to enable the built in macro’s: The macro’s must be enabled.Stellenbosch University http://scholar. The password is caps sensitive. USER GUIDE 5. Some of the screens are password protected. the user will be presented with a Welcome screen (Figure 5. When loading the Excel simulation file. 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.1). the simulation program will inform the user to re-enter the required data.1 INTRODUCTION The following section will explain systematically what each button will do when activated. Once the macro’s have been enabled. The manual will help the user will be able to use this program by making use of this manual. It is compulsory to place information in the input boxes. for the program to work. .ac. 5.sun. To unprotect a screen. The user will be able to simulate basic queuing scenario’s. If the boxes are not completed as required. with the result of information being omitted.

za 19 5. After clicking the Central Control Menu button the following Figure 5.3 CONTROL CENTRE Figure 5.ac.Stellenbosch University http://scholar.2 appears: .1: Welcome Screen Press the button to activate the central control menu.sun.

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. it means that the user may save three more models out of a total of five saves. if the box displays the number 3. . For example.za 20 Figure 5.Stellenbosch University http://scholar.sun.ac. 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.

The options are:  Minute  Hour . Figure 5.4 ACTIONS BUTTONS 5. After the change inputs button is pressed.4.3 appears on the screen.sun. The information button presents information as to what is required by the input boxes.Stellenbosch University http://scholar.za 21 5.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. Figure 5.ac.3: Input Screen The input screen requires the following information: a) The unit of Time The unit of time option allows the user to select the time unit he/she would prefer to use when running the simulation.

If. 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.Stellenbosch University http://scholar. the following screen appears (Figure 5. 20 customers. for example. for example two bank tellers are used to service clients then the number 2 must be inserted in the box. however the system takes much longer to simulate as the time is increased.ac. the setting would be set to 20. if the units are hours. d) The maximum number of customers allowed in the queue. The higher the limit.za 22  Day b) The number of units that the simulation must run The number of units that the simulation must run limits the number of observations to generate. . c) The number of servers In the input box.sun. For example. the arrival rate is 20 per hour. the closer the result will be to the analytical result. the number of servers must be specified. Once the relevant data has been entered and the continue key clicked. the limit is set to 8 hours as in a working day then the result will be approximately 160 observations.4). The system now rejects any customer that enters the system if the queue length in longer than 20. It would be used when the area in which to queue can only hold.

ac. f) Select a distribution pattern.5): .0833 hours or 5 minutes. Different distribution patterns are selected for the inter-arrival times.za 23 Figure 5. e) Input the inter-arrival time If customers arrive at a rate of 12 per hour. 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. the following must be updated. In the Figure 5.Stellenbosch University http://scholar.4: Inter-arrival Input Box The screen above is the Inter-arrival Input Screen. then find the reciprocal of 12 to get the inter-arrival time i. is the number entered in the box.e. The time is used to simulate the environment specified by the user.4. 1/12 =0. click the continue key and the following service inputs screen will appear (Figure 5.sun. Once the relevant data has been entered.

ac.Stellenbosch University http://scholar. 1/6 = 0. is the number entered in the box. then find the reciprocal of 6 to get the service time per server i. press the "Continue"-button.166 hours or 10 minutes. Time is used to simulate the environment specified by the user.2 “Run Simulation” Button The "Run Simulation"-button initiates the simulation process. Once the appropriate distribution pattern has been selected.5: Service Inputs In the Service Inputs screen the user will select the following g) Input the average service time per server If customers are serviced at a rate of 6 per hour. (See Program Logic).4.e. The user will be returned to the last screen he/she was viewing. . Different distribution patterns for the average service time per server are the same as the options for the inter-arrival rate (see point f). 5. The program will effectively calculate all relevant information and post it to the different sheets.sun. h) Select a distribution pattern. The input screens for changing or adding data are now complete.za 24 Figure 5.

Specific Inter-arrival / Service time: Add the inter-arrival or service time to the corresponding probability. will be used.4).sun.1. Note: the cumulative probability must add to the value one. If a value is entered in the average inter-arrival time box (Paragraph 5. If not.4.4. The average will be shown in Input Screen. which is shown in the arrival probability table in Figure 5. Only inter-arrival times calculated by generating random numbers.6. . in the probability table. so that the user may make the appropriate amendments. the program stops and returns to the Probability Table screen (Figure 5. the program will not run.Stellenbosch University http://scholar. however it will not be used in the simulation program. Figure 5.ac.6: Probability Table Probability: Add the relevant probability in relation to the average Inter-arrival or Service time.3 “Update Probability Tables” Button The “Update Probability Tables”-button takes the user to the probability table screen. The program checks the cumulative probability of both the Arrival and Service times.za 25 5. and finding the corresponding time. If either of the two probabilities of times do not add to one. Here the user will enter the observed probabilities for both the arrival time and the service time. the program will ignore the value and replace it with the average of the inter-arrival times. point e).

6 “Restore and Hide” Buttons The “Restore and Hide” buttons are used to hide or show all the toolbars. so that changes can be made to the model.5 “Clear History” Button The “Clear History” button is used to clear all the data on the history screen.Stellenbosch University http://scholar. Refer to Fig 5. status’s bars etc.za 26 5. Once the simulation has run.4).7.4. Then run a simulation. press the “Add To History File” button and it will save it to the history screen. The restore/hide feature allows the user to have access to the model.4.sun. Figure 5.4.4. clear the history file by pressing the “Clear History” button (Paragraph 5. .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.ac.7: History Screen 5. 5. First.

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.sun. d) The History Screen The History screen shows a list of up to five saved simulated runs. b) The Input Screen The Input screen shows all the relevant inputs used for the simulation program except for the observed probabilities.ac. e) The Chart Screen The Chart screen shows the results in form of charts f) The Probability 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.) a) Welcome Screen The Welcome screen is the introduction screen. c) The Report Screen The Report screen shows the following information:  User statistics  System orientated statistics  Probability distribution of number in queue. .za 27 5.5 NAVIGATION BUTTONS The navigation buttons are used to navigate from screen to screen.

An important characteristic. .Stellenbosch University http://scholar. The Summary screen shows a summary of the server idle time and the average customer waiting time.6 SUMMARY The user guide covers the navigation of simulation program. the “Change Inputs” button must be clicked followed by the “Run simulation” button.sun.e. The other information is self-explanatory. should be inputted when prompted for arrival or service durations. any button may be clicked to see what it does. only times. When trying to run a simulation for the users environment. h) The Summary Screen. 5.za 28 g) The Detailed Results Screen The Detailed Results screen shows information about each customer and each server. of the simulation program to remember is. The sequence of usage is irrelevant i.ac.

The material covered in this document should give the user a start in the use simulation.2 RECOMMENDATIONS To enhance the simulation experience the user could take advantage of a powerful add-in package. however the extent to which simulation is used in the working environment is extremely large and complex! . However. SUMMARY AND RECOMENDATIONS 6.ac. The model allows a user to run many variations of an environment that he/she would like to improve. The add-in. however. is only the tip of the iceberg in terms of what simulation can accomplish.sun. Even this. particularly statistics gathering and presentation of results. Computer simulation is one of the most versatile of all management science tools. However. @RISK. 6. The simulation model demonstrated how the random function in Excel allows a user to simulate a wide variety of problems. and its popularity is growing constantly.za 29 CHAPTER 6 6. that facilitates simulation (not for queuing). it only represents a small fraction of what simulation can accomplish. Topics. There are many special-purpose simulation packages that can simulate complex queuing systems and a variety of other processes. the users should come away with an increased understanding of the concept of simulation. using increasingly often in the business world. covered by the document.1 SUMMARY The core of this study project consists of a queuing simulation model that was built in the Excel environment with visual basic.Stellenbosch University http://scholar. along with the functionality of Excel itself. and these packages are being. allows individuals with virtually no programming skills to perform complex and realistic simulations. are from the input stage to the output stage and how to use the results.

C.sun. Ill: Irwin Microsoft Corporation. & Albright.za 30 LIST OF SOURCES Winston.ac. Belmont. J. CA: Duxbury Turban. 1999. W. Practical Management Science: Spreadsheet Modelling and Applications. . S. 1994.L. Fundamentals of Management Science. 6th ed. Version 2000. 1997. & Meredith. E.Stellenbosch University http://scholar. BurrRidge. Excel spreadsheet.R.

za 31 APPENDIX A: LIST OF ROUTINES AND THEIR FUNCTIONS .Stellenbosch University http://scholar.ac.sun.

Stellenbosch University http://scholar.sun.ac.za



Visual Basic Routine


It's function
The routine prompts the user for either the standard deviation or the min, most
likely and maximum value depending on what the user chose as the distribution

The routing calls up the input boxes for the program
It is the main routine that will run the simulation and call other routines to
accomplish the end result
The routine does some formatting for presentation
It creates the averages for the work stations in form of a pivot table in the
summary sheet
Checks for blanks and fills it with Zeros
Resets the sub routine parameters to zero start a new simulation
Finds the most imminent event and record the server that has just finished
Calculates the Arrival time
Calculates the Departure Time
Creates the Report Sheet
Updates the report sheet
Creates the final details report sheet
Determines the queue length and inserts it in the appropriate spread sheet
Runs when Excel closes. It restores the Excel sheets
Runs when Excel Opens. It removes toolbars starts sets the environment
Takes the user to the Report sheet
Creates the probability chart
Takes the user to the Inputs sheet
Inserts the users inputs into the sheets
Inserts the arrival inputs
Inserts the Service inputs
MaxInQueue_AfterUpdate Calls an information box
Takes user to the chart sheet
Takes user to the History sheet
It clears the history sheet to enable new data to be inputted
It adds data that has been recently run to the history sheet
Sets the number of runs in the history sheet
Prints the Inputs spread sheet
Prints the Reports spread sheet
Prints the Probability table spread sheet
Prints the History spread sheet
Prints the Graphs spread sheet
Shows or hides information which is appropriate or not appropriate at the time
of running the simulation

Stellenbosch University http://scholar.sun.ac.za



Stellenbosch University http://scholar.sun.ac.za



Figure B.1: Welcome Screen
a) The Purpose of this 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. .2: Inputs Screen a) The Purpose of this screen The Inputs Screen shows the inputs that will be used by the program for simulation purposes.sun. 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.2 INPUTS SCREEN Figure B.za 35 B.ac.

e. .Stellenbosch University http://scholar.1).za 36 B.sun.2. That the information supplied is concerning the queue and not the entire system.  Queue orientated statistics The queue orientated statistics information pertains to the queue that is formed within the environment.3: Reports Screen a) The Purpose of this screen The Reports Screen shows some of the outputs generated by the program. It will help in determining how the queuing environment affects the customer.3 REPORTS SCREEN Figure B. 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.ac. All these results must be minimised if possible. the customer (See 2.

The information supplied is concerning the queue and not the entire system .ac.za 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.Stellenbosch University http://scholar.sun.

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.za 38 B. In the example above (Figure B.Stellenbosch University http://scholar. the vast difference between the maximum customers in the queue and the average number in the queue can be seen.4: Graphical representation of Results a) The Purpose of this screen The Graphical representation of Results screen shows some of the outputs generated by the program in graphical format.sun. right graph). which should be provided for the queue.ac. top.4. It will help in formulating the size of the area.4 MULTI-GRAPH SCREEN Figure B. .

ac. 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.5 GRAPHICAL DISTRI BUTION SCREEN Figure B.sun. just over 60% of the people will not have to queue in this particular environment.za 39 B.Stellenbosch University http://scholar. In this example. .5: Graph of Distribution Pattern a) The Purpose of this screen The Graph of Distribution Pattern screen shows some of the outputs generated by the program in graphical format.

DETAILS SCREEN Figure B.sun.  Inter-arrival time It shows the randomly generated inter-arrival time generated by the program  Clock time of arrival . 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.za 40 B6.6: Detail Screen a) The Purpose of this 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.Stellenbosch University http://scholar.ac.

The time is based on First come First served i.  Time service starts In form of a continuous clock. The model checks for servers that are idle. The column shows the idle time for each server.  Server number to perform the service Shows the server number that serviced the customer. server two will get preference over server three and four etc. The rest of the information is the same as what is in the blue table expert for the last column in the green table.e. it will assign the client to the server with the lowest number i.  Duration of service Show the duration of the service.sun.Stellenbosch University http://scholar. the time of the service start is shown.  Clock time the service ends The “clock time the service ends” time is based on the randomly generated duration of service time i. by adding the randomly generated inter-arrival time to the last arrival time. and of those servers that are idle.za 41 In form of a continuous clock. .ac.e. The service time is randomly generated. the time of arrival is calculated.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 first available server will take on a new customer.

7: Averages Screen a) The Purpose of this screen The Averages screen shows the averages of the simulated data. b) How to interpret the information on the screen The user can quickly see when more servers are added. which was generated by the program. the idle time increase as the number of servers is increased. .7 AVERAGES SCREEN Figure B.ac.Stellenbosch University http://scholar.sun.za 42 B.

za 43 APPENDIX C: VISUAL BASIC CODE .sun.Stellenbosch University http://scholar.ac.

_ MaxInSys As Integer.EditBoxes("NumService").Range("serveTime"). ServDist.this is needed for the steady-state outputs shown on the ' Report sheet Function ProbEmpty(arrivetime As Single. AreaUtil As Single. NumBusy As Integer. numservers As Integer Dim MaxInSys As Integer. timeunit As String Dim checkforo As Single Worksheets("Inputs"). servdist. StdDevService. _ TimeArrival(1000) As Single. Randomnum.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").Traffic Else Product = 1 Sum = 1 For i = 1 To numservers . ServiceSeq. numberoftoolbars As Single. Product As Double. StdCArrive. AvgNumInQ. MaxDelay As Single. _ Traffic As Single Traffic = servetime / (numservers * arrivetime) If numservers = 1 Then ProbEmpty = 1 .Text = 0 DialogSheets("QGeneral Inputs"). _ numservers As Integer) As Single Dim Sum As Double.za 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. ValA. _ MinimumValue. NumLost As Integer Dim AreaNumInQ As Single. Time As Single. TimeNextEvent() As Single Dim TimeInQ(0 To 1000) As Single Dim MeanArriveTime As Single.Text = 0 DialogSheets("QGeneral Inputs").Text = 0 . serverno As Integer. _ numservers As Integer.Range("ArriveTime"). MostLikelyValue.Stellenbosch University http://scholar. StdDevArrive.Range("probempty"). _ MaxTime As Single ' Calculate the steady-state probability that no customers are in the ' system .EditBoxes("NoOfUnits"). ArivDist As Double Dim MaxInQ As Integer Dim NextEventType As Integer. arrivedist1 As Single. Nextcust As Integer.sun. arivedist. i As Integer. StdCService. _ TotDelays As Single.Value = ProbEmpty End Function Sub GetInputs() Dim ArriveRate As Single. FinishedServer As Integer. _ NumCusts As Long. NumInQ As Integer. ValB. TimeLastEvent As Single. servetime As Single. MeanServeTime As Single.Value = 0 'call msg boxes DialogSheets("QGeneral Inputs"). ServeRate As Single Dim MaxTime As Single.EditBoxes("MaxInQueue"). timingcount As Single Dim AvgDelay. MaximumValue.ac.Value = 0 Worksheets("Inputs").

please Update the Arrival Probability Table before you run the simulation.Cells(4. 4 .Text = 0 DialogSheets("QArrival Inputs"). 3.") Worksheets("Observed Prob").ac.Range("ArivDist").Select Worksheets("Observed Prob").Value If arivedist = 5 Or 4 Then Worksheets("Inputs").EditBoxes("AvgCustService"). 6).Range("ArivDist").Value Select Case arrivedist1 Case 1.Text = 0 Worksheets("Inputs").Range("servDist"). Please insert a value greater than one!" DialogSheets("QService Inputs").Value Else MsgBox "Note: You have selected a Zero Value for the Arrival time.Show DialogSheets("QService Inputs").Range("ArriveTime").EditBoxes("AvgCustService"). The program cannot run with a zero value. 1).Range("MostLikArrive").Cells(3.Cells(4. 2. 6).Select Case Else End Select arrivedist1 = Worksheets("Inputs").EditBoxes("AvgCustArrive").Show End If checkforo = Worksheets("Inputs"). 6).Text = 0 Worksheets("Inputs").EditBoxes("AvgCustArrive").Show End If checkforo = Worksheets("Inputs").Value Loop 'warn user of prob <> 1 arrivedist1 = Worksheets("Inputs"). 2. Please insert a value greater than one!" DialogSheets("QArrival Inputs").Cells(3.Range("ArivDist").Show 'check if probs = 1 checkforo = Worksheets("Inputs").Stellenbosch University http://scholar.Text = 0 DialogSheets("QService Inputs").Value = Worksheets("Inputs").sun. 4 Case 5 MsgBox ("You have selected the 'Observed Probabilities' distribution option for the inter-arrival time.Value Do Until checkforo > 1 servdist = Worksheets("Inputs").Range("ServDist").Value = 1 DialogSheets("QArrival Inputs").Value = 1 DialogSheets("QService Inputs").Range("serveTime"). 6).za 45 DialogSheets("QGeneral Inputs").Value Select Case arrivedist1 Case 1. 3.Range("ServDist").Show DialogSheets("QArrival Inputs").Value Loop checkforo = Worksheets("Inputs").Value = 1 Else MsgBox "Note: You have selected a Zero Value for the Service time. The program cannot run with a zero value.Cells(1.Value Do Until checkforo > 1 arivedist = Worksheets("Inputs").Value If servdist = 5 Or 4 Then Worksheets("Inputs").

Stellenbosch University http://scholar.Select Dim checking As Single checking = Worksheets("Observed Prob").Select Case Else End Select DialogSheets("Navigation Bar").za 46 Case 5 MsgBox ("You have selected the 'Observed Probabilities' distribution option for the service time per server.") Worksheets("Observed Prob").hide ' hide bar Exit Sub End If Else If checking = 1 Then Else . servdist As Integer ' check if prob = 1 if not abort arivedist = Worksheets("Inputs"). 1).Cells(3.Cells(14." Worksheets("Observed Prob"). 6).Range("ServDist"). please Update the Service Probability Table before you run the simulation. 6)." Worksheets("Observed Prob").Value If checking < 1 Then If checking = 0 Then Else MsgBox "You have selected the 'Observed Probabilities' as your distribution.sun. Please correct any errors.Select DialogSheets("Navigation Bar").Select DialogSheets("Navigation Bar"). however the arrival probability total must add up to one. 2). 2). however the arrival probability total must add up to one.Value servdist = Worksheets("Inputs").Select Worksheets("Observed Prob")." Worksheets("Observed Prob").Value If arivedist = 5 Or servdist = 5 Then Worksheets("Observed Prob").Select DialogSheets("Navigation Bar"). Please correct any errors. however the service probability total must add up to one.Cells(3.hide End Sub Sub RunSimulation() Dim arivedist.ac.hide ' hide bar Exit Sub End If Else If checking = 1 Then Else MsgBox "You have selected the 'Observed Probabilities' as your distribution.Range("ArivDist").Cells(1.Cells(14. Please correct any errors.hide ' hide bar Exit Sub End If End If checking = Worksheets("Observed Prob").Value If checking < 1 Then If checking = 0 Then Else MsgBox "You have selected the 'Observed Probabilities' as your distribution.Cells(3. 2).

" End If 'get user inputs from Inputs screen Application.Range("ArriveTime")." End If If servdist = 5 Then Worksheets("Inputs").Range("MaxInSys").Select DialogSheets("Navigation Bar").Value = Worksheets("Observed Prob"). type of next event.Range("Averageserve"). however this average will not be used in the simulation.Value = Worksheets("Observed Prob").Value End With ReDim TimeNextEvent(numservers + 1) Nextcell = 1 Initialize Do Nextcell = Nextcell + 1 Timing ' Find the time. The Average of the times will be displayed (for reporting purposes) on the input screen as 'Average time for each service'.Value MsgBox "Note: You have chosen the Average Service Time as the distribution pattern. however this average will not be used in the simulation.Value MsgBox "Note: You have chosen the Average Arrival Time as the distribution pattern. 6).Range("ServeTime").Range("NumServers").za 47 MsgBox "You have selected the 'Observed Probabilities' as your distribution. The Average of the times will be displayed (for reporting purposes) on the input screen as 'Average time between arrivals'." Worksheets("Observed Prob").Range("ArriveTime").Stellenbosch University http://scholar.ac.hide ' hide bar Exit Sub End If End If Else End If If arivedist = 5 Then Worksheets("Inputs").Value MaxTime = .ScreenUpdating = True With Worksheets("Inputs") MeanArriveTime = .Value MaxInSys = .Value MeanServeTime = . reset clock UpdateAreas ' Update statistical accumulators If NextEventType = 1 Then Arrive ' 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 .Range("Averagearrival").sun.Value numservers = . Please correct any errors.Range("ServeTime"). however the service probability total must add up to one.Range("MaxTime").Cells(3.

12).Cells(3 + NumCusts.Value = 0 Else End If count = count + 1 Loop End Sub Sub Averages() 'find averages Worksheets("Summary"). 6)).ClearContents Rows("7:16").Value Range(Cells(3 + NumCusts. 6).Select ActiveCell. 2). 7). Key2:=Range("I3") _ . Order2:=xlAscending.Select ' goto reports sheet DialogSheets("Navigation Bar"). 12).za 48 Report ' Put the outputs on the Report sheet CreateChart ' create chart Worksheets("Reports").Select ' format table Range(Cells(3.Value If nextcustomer < 0 Then Worksheets("Table2").Cells(3 + count.Select 'calculate customer delay Range(Cells(3 + NumCusts.Select ActiveCell.ClearContents . 12).FormulaR1C1 = "0" Range("L4"). 9).Select Selection. Transpose:=False Range(Cells(2.Sort Key1:=Range("K3").hide ' hide bar End Sub Sub finishoff() Dim count As Single count = NumCusts + 2 Worksheets("table2"). xlDataAndLabel Selection. SkipBlanks:= _ False. 12)).Select Selection.Select ActiveCell. 6)). MatchCase:= _ False.Select ActiveSheet.Cells(3 + count.sun.PivotTables("PivotTable"). 12).PasteSpecial Paste:=xlValues.Value = Worksheets("Table2"). Operation:=xlNone.Cells(2.Cells(3. 6). Type:=xlFillDefault Worksheets("Table2"). 6). OrderCustom:=1.CutCopyMode = False Selection.Cells(3.Stellenbosch University http://scholar.FormulaR1C1 = "=RC[-3]-R[-1]C[-2]" Range("L4"). Header:=xlGuess.ac. 1). Cells(3 + NumCusts.Copy Range("G3").Delete Shift:=xlUp Worksheets("table2"). 11)).PivotSelect "". Orientation:=xlTopToBottom Range("L3"). Cells(count.AutoFill Destination:=Range(Cells(4.Select Selection. Cells(count. Cells(3 + NumCusts. Cells(count. Order1:=xlAscending.Value = Worksheets("Table2").Value count = 0 Dim nextcustomer As Single Do Until count = NumCusts 'find blanks and fill nextcustomer = Worksheets("Table2").Select Selection.Select Application.FormulaR1C1 = "=AVERAGE(R[-" & NumCusts & "]C:R[-1]C)" Worksheets("Summary"). 6)).

ColorIndex = 2 Worksheets("table2").Value nextcustomer1 = Worksheets("Table2").Font.ac.Cells(3 + count. 2). SourceData:= _ "Table2!R2C11:R" & myRange & "C12". TableName:="PivotTable" ActiveSheet.Value Else End If If nextcustomer1 <= 0 Then Worksheets("Table2"). nextcustomer As Single.PivotTables("PivotTable").Select Selection.Value = Worksheets("Table2"). _ Function = xlAverage Cells. 6).Cells(3 + count.Select Dim myRange As Single myRange = 2 + NumCusts ActiveSheet.Font.ColumnGrand = False ActiveSheet.Font.Bold = False Selection.Font.Value If nextcustomer <= 0 Then Worksheets("Table2").PivotTables("PivotTable").ColorIndex = 43 Columns("A:A").AddFields RowFields:="Server Number" ActiveSheet.Select End Sub Sub check() 'check for zeros Dim count As Single.Cells(3 + count.PivotFields("sum of Idle Time of Each Server"). 2).Cells(3 + count.AutoFit Columns("A:A"). nextcustomer1 As Double count = 0 Do Until count = NumCusts nextcustomer = Worksheets("Table2"). 3).EntireColumn.Font.Cells(3 + count.sun.Bold = True Range("A1").Select Selection.Select Columns("A:A").Bold = True Columns("B:B").Interior.Select Range("A1").PivotFields("Idle Time of Each Server").Bold = False Selection.ColorIndex = 6 Selection. TableDestination:= _ "'[Queuing simulation New.Stellenbosch University http://scholar.Select Selection.xls]Summary'!R7C1".PivotTables("PivotTable").PivotTables("PivotTable").za 49 'calculate server delay Worksheets("table2").Font.Orientation _ = xlDataField ActiveSheet.Select Selection.Value = 0 Else End If count = count + 1 Loop End Sub Sub Initialize() . 6).PivotTableWizard SourceType:=xlDatabase.

Value Randomnum = Rnd meanarrivetime2 = MeanArriveTime MeanArriveTime = Application.Range("NumLost") = 0 Worksheets("Reports").Range("MostLikArrive").Range("StdDevArrive").Range("Clearcontents").Range("StdCArrive"). StdDevArrive.Range("MaxInQ") = 0 Worksheets("Reports").ac.Value .NormInv(Randomnum.NormInv(Randomnum.Range("MaxDelay") = 0 Worksheets("Reports").Range("AvgNumInQ") = 0 Worksheets("Reports").sun.Range("NumCusts") = 0 Worksheets("Reports").Range("ArriveTime").Range("Util") = 0 arivdist = Worksheets("Inputs"). StdDevArrive. MeanArriveTime) Do Until MeanArriveTime > 0 Randomnum = Rnd MeanArriveTime = Application. meanarrivetime2) Loop MeanArriveTime = MeanArriveTime TimeNextEvent(1) = MeanArriveTime Case 4 ' Case Triangular Randomnum = Rnd MostLikelyValue = Worksheets("Inputs").za 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("AvgDelay") = 0 Worksheets("Reports").Value MaximumValue = Worksheets("Inputs").Value StdCArrive = Worksheets("Inputs").Range("ArivDist").Range("MaxValueArrive").ClearContents 'rest parameters Worksheets("Reports").WorksheetFunction.Value MinimumValue = Worksheets("Inputs").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").Stellenbosch University http://scholar.Range("MinArriveValue").Value MeanArriveTime = Worksheets("Inputs").WorksheetFunction.

Value = TimeNextEvent(1) ' Don't schedule a departure because there are no customers being served For i = 1 To numservers TimeNextEvent(i + 1) = 100000 Next End Sub Sub Timing() Dim i As Integer.za 51 ValA = (MaximumValue .Randomnum))) End If MeanArriveTime = MinimumValue + MeanArriveTime TimeNextEvent(1) = MeanArriveTime Case 5 'Calls the MeanArriveTime from a cell within the observed probibiltie work sheet. The cell uses the ‘VLOOKUP commamd to detemne the time.Stellenbosch University http://scholar.Range("ArivDist").sun.Sqr((1 . i As Integer.StdCArrive) * (1 .ac. starttime As Double arivdist = Worksheets("Inputs").Range("MeanArriveT").MinimumValue) If Randomnum <= StdCArrive Then MeanArriveTime = ValA * Sqr(Randomnum * StdCArrive) Else MeanArriveTime = ValA * (1 .Cells(3 + Nextcust. 2). also record the index (2 to NumServers + 1) ' of the server who finished NextEventType = 2 FinishedServer = i End If End If Next ' Update the clock to the time of the next event Time = MinTimeNextEvent End Sub Sub Arrive() Dim SchedDep As Single. MinTimeNextEvent As Single MinTimeNextEvent = 99999 ' Find type and time of next event (most imminent event) For i = 1 To numservers + 1 If TimeNextEvent(i) < MinTimeNextEvent Then MinTimeNextEvent = TimeNextEvent(i) If i = 1 Then NextEventType = 1 Else ' For a departure event.Value Select Case arivdist ' Evaluate ArivDist . meanarrivetime2. MeanArriveTime = Worksheets("Observed Prob").Value TimeNextEvent(1) = MeanArriveTime Case Else MsgBox ("Please Select one of the options presented") End Select Worksheets("Table2").

Value MaximumValue = Worksheets("Inputs").Range("MostLikArrive").Value MeanArriveTime = Worksheets("Inputs").WorksheetFunction.sun.Value ValA = (MaximumValue .Stellenbosch University http://scholar.Value MinimumValue = Worksheets("Inputs").Range("ArriveTime").NormInv(Randomnum.Range("MeanArriveT"). MeanArriveTime) Do Until MeanArriveTime > 0 Randomnum = Rnd MeanArriveTime = Application.Sqr((1 .StdCArrive) * (1 .NormInv(Randomnum.Value = TimeNextEvent(1) starttime = Time If NumInQ = MaxInSys Then NumLost = NumLost + 1 Exit Sub End If If NumBusy = numservers Then NumInQ = NumInQ + 1 If NumInQ > MaxInQ Then MaxInQ = NumInQ End If ' Keep track of each customer's arrival time (for later stats) TimeArrival(NumInQ) = Time .Range("StdCArrive"). 2).ac.Range("StdDevArrive"). StdDevArrive. StdDevArrive.Value Randomnum = Rnd meanarrivetime2 = MeanArriveTime MeanArriveTime = Application.Cells(3 + Nextcust.WorksheetFunction.za 52 Case 1 ' Case for Poisson and Exponetial ' Schedule an arrival from the exponential distribution TimeNextEvent(1) = Time .Value StdCArrive = Worksheets("Inputs").MinimumValue) If Randomnum <= StdCArrive Then MeanArriveTime = ValA * Sqr(Randomnum * StdCArrive) Else MeanArriveTime = ValA * (1 . meanarrivetime2) Loop MeanArriveTime = MeanArriveTime TimeNextEvent(1) = Time + MeanArriveTime Case 4 ' Case Triangular Randomnum = Rnd MostLikelyValue = Worksheets("Inputs").Range("MinArriveValue").Range("MaxValueArrive").Value TimeNextEvent(1) = Time + MeanArriveTime Case Else MsgBox ("Please Select one of the options presented") End Select Worksheets("Table2").MeanArriveTime * Log(Rnd) Case 2 'Case for Constant distribution TimeNextEvent(1) = Time + MeanArriveTime Case 3 ' Case for Normal Distribution StdDevArrive = Worksheets("Inputs").Randomnum))) End If MeanArriveTime = MinimumValue + MeanArriveTime TimeNextEvent(1) = Time + MeanArriveTime Case 5 MeanArriveTime = Worksheets("Observed Prob").

Range("MinServiceValue").Value StdCService = Worksheets("Inputs"). StdDevArrive.MeanServeTime * Log(Rnd) Else Stop TimeNextEvent(FinishedServer) = Time .WorksheetFunction.MinimumValue) .Range("ServeTime").Value ' Stop 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 .za 53 ' Otherwise.NormInv(Randomnum.Range("MaxValueService"). meanservetime2) Loop MeanServeTime = 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").Value MaximumValue = Worksheets("Inputs").NormInv(Randomnum.WorksheetFunction.Range("StdCService").Value MinimumValue = Worksheets("Inputs").Range("StdDevService").sun. MeanServeTime) Do Until MeanServeTime > 0 Randomnum = Rnd MeanServeTime = Application.Value Randomnum = Rnd meanservetime2 = MeanServeTime MeanServeTime = Application.Range("MostLikService"). 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 server Do If SchedDep > 99999 Then ServiceSeq = 1 'Determine the Service Distribution 'schedule an Service based on users input servdist = Worksheets("Inputs").Stellenbosch University http://scholar.Value ValB = (MaximumValue .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"). StdDevArrive.ac.Value MeanServeTime = Worksheets("Inputs").Range("ServDist").

Value = Nextcust Worksheets("Table2").Randomnum))) End If MeanServeTime = MinimumValue + MeanServeTime If ServiceSeq = 1 Then TimeNextEvent(i) = Time + MeanServeTime Else TimeNextEvent(FinishedServer) = Time + MeanServeTime End If Case 5 MeanServeTime = Worksheets("Observed Prob"). 3).Cells(2 + Nextcust. starttime As Double.Value = TimeNextEvent(i) Worksheets("Table2").1 End If If serverno > 0 And i > 0 Then 'update table Worksheets("Table2").ac.Stellenbosch University http://scholar. servetemp As Double. 4).za 54 If Randomnum <= StdCService Then MeanServeTime = ValB * Sqr(Randomnum * StdCService) Else MeanServeTime = ValB * (1 .sun. 1). 5).Cells(2 + Nextcust.Sqr((1 .Value If ServiceSeq = 1 Then TimeNextEvent(i) = Time + MeanServeTime Else Stop TimeNextEvent(FinishedServer) = Time + MeanServeTime End If Case Else MsgBox ("Please Select one of the options presented") End Select Exit Do Else i=i+1 SchedDep = TimeNextEvent(i) End If Loop End If If i = 0 Then Else serverno = i .Range("MeanServiceT"). Delay As Single.Cells(2 + Nextcust.Value = starttime Worksheets("Table2").StdCService) * (1 .Value = "server " & serverno Nextcust = Nextcust + 1 Else End If End Sub Sub Depart() Dim i As Integer.Cells(2 + Nextcust. numbertwo As Double servetemp = serverno ' Update number of customers who have finished NumCusts = NumCusts + 1 . numberone As Double.

Range("MaxDelay").NormInv(Randomnum.Stellenbosch University http://scholar.Range("ServDist"). make the ' server who just finished idle by resetting the TimeNextEvent to a ' large number If NumInQ = 0 Then NumBusy = NumBusy .Value = NumInQ ' Delay is the time this customer has been waiting in line Delay = Time .WorksheetFunction.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) .Value = AvgDelay 'Worksheets("Reports").MeanServeTime * Log(Rnd) Else TimeNextEvent(FinishedServer) = Time .Cells(2 + Nextcust. take customer from front of queue into service Else NumInQ = NumInQ .1 TimeNextEvent(FinishedServer) = 100000 ' Otherwise.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 input servdist = Worksheets("Inputs"). StdDevService.Range("AvgDelay"). 13).Value Randomnum = Rnd meanarrivetime2 = MeanServeTime MeanServeTime = Application.if not.sun.ac.1 'Worksheets("Table2").TimeArrival(1) If Delay > MaxDelay Then MaxDelay = Delay End If TotDelays = TotDelays + Delay AvgDelay = TotDelays / NumCusts 'Worksheets("Reports").Range("ServeTime").Value MeanServeTime = Worksheets("Inputs").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").za 55 ' Check if any customers are waiting in queue .Range("StdDevService").

2).Sqr((1 .Value MinimumValue = Worksheets("Inputs").Value = starttime Worksheets("Table2").Delay . 6).Range("MinServiceValue").Value ValB = (MaximumValue .Cells(2 + Nextcust.Value If ServiceSeq = 1 Then TimeNextEvent(i) = Time + MeanServeTime Else TimeNextEvent(FinishedServer) = Time + MeanServeTime End If Case Else MsgBox ("Please Select one of the options presented") End Select i = serverno + 1 starttime = Time If serverno > 0 And i > 0 Then serverno = FinishedServer .Cells(2 + Nextcust. 3). 1). 4). meanarrivetime2) Loop MeanServeTime = 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").Range("StdCService").Randomnum))) End If MeanServeTime = MinimumValue + MeanServeTime If ServiceSeq = 1 Then TimeNextEvent(i) = Time + MeanServeTime Else TimeNextEvent(FinishedServer) = Time + MeanServeTime End If Case 5 MeanServeTime = Worksheets("Observed Prob").Cells(2 + Nextcust.Value StdCService = Worksheets("Inputs").Stellenbosch University http://scholar.MinimumValue) If Randomnum <= StdCService Then MeanServeTime = ValB * Sqr(Randomnum * StdCService) Else MeanServeTime = ValB * (1 .Value = Delay Worksheets("Table2").za 56 Do Until MeanServeTime > 0 Randomnum = Rnd MeanServeTime = Application.Range("MaxValueService").sun.Cells(2 + Nextcust.Cells(2 + Nextcust.WorksheetFunction.Value = "server " & serverno Worksheets("Table2"). StdDevService.Value MaximumValue = Worksheets("Inputs").Value = TimeNextEvent(FinishedServer) Worksheets("Table2").Range("MeanServiceT").NormInv(Randomnum.Cells(2 + Nextcust.Value = starttime . 5).Value = Nextcust Worksheets("Table2").1 'update tables Worksheets("Table2").StdCService) * (1 .ac.

Range("MaxDelay"). 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") . for value of NumInQ (0 to MaxInQ) the percentage ' of time that many customers were waiting in the queue .Value = NumCusts . 0).Value = MaxInQ .Range("NumInQ1").Value = Util / numservers .ClearContents .Value = AvgNumInQ .Delete .ClearContents End With With ActiveWorkbook .Names("NumInQ"). Windows:=False Dim i As Integer Dim AvgDelay As Single.Range("AvgNumInQ").Range("Util").Value = NumLost ' TimeInQ records.Value = i .Range("NumInQ").Add Name:="NumInQ".ac.Range("AvgDelay").Names.sun. 1).Value = TimeInQ(i) Next End With ActiveWorkbook.Range("NumCusts").Delete End With Worksheets("Reports").za 57 Nextcust = Nextcust + 1 serverno = FinishedServer + 1 Else End If ' Move everyone else in line up one space For i = 1 To NumInQ TimeArrival(i) = TimeArrival(i + 1) Next End If End Sub Sub Report() 'ActiveWorkbook.Range("TimeInQ").Activate .Value = AvgDelay . _ .Range("MaxInQ").ClearContents .Offset(i.Protect Password:="usb".Stellenbosch University http://scholar.Range("diference").Range("NumLost").Select With Selection For i = 0 To MaxInQ . structure:=False.Offset(i.Names("TimeInQ").Value = MaxDelay .

Insert Shift:=xlToRight ActiveWindow.End(xlDown)) With Application .FontStyle = "Bold" .Stellenbosch University http://scholar.Cut Destination:=Columns("G:G") Columns("N:N").FormulaR1C1 = "Interarrival Time" With ActiveCell.Select Selection.Select Selection.SmallScroll ToRight:=1 Columns("N:N").End(xlDown)) Selection.Copy Before:=Sheets(7) Sheets("Table2 (2)").Select Sheets("Table2").Select ActiveCell.Add Name:="TimeInQ".TimeLastEvent TimeLastEvent = Time TimeInQ(NumInQ) = TimeInQ(NumInQ) + TimeSinceLastEvent AreaNumInQ = AreaNumInQ + NumInQ * TimeSinceLastEvent AvgNumInQ = AreaNumInQ / Time AreaUtil = AreaUtil + NumBusy * TimeSinceLastEvent End Sub Sub buildreportsheet() ' ' buildreportsheet Macro ' Macro recorded 05/10/1999 by Shivan Mohd ' ' Application. Selection.MaxChange = 0.CalculateBeforeSave = False End With End Sub Sub UpdateAreas() Dim TimeSinceLastEvent As Single TimeSinceLastEvent = Time . _ RefersToR1C1:=Range(Selection.sun.Names.Delete Shift:=xlToLeft Columns("G:G").Font .Select Selection. Selection.Offset(0.Select Selection.Delete Shift:=xlToLeft ActiveWindow.Insert Shift:=xlToRight Range("B2").Name = "Arial" .DisplayAlerts = True Sheets("Table2").Select Sheets("Table2 (2)").DisplayAlerts = False Sheets("Reports2").Select Selection. Length:=17).Calculation = xlAutomatic .Select ActiveWorkbook.Size = 10 .Cut Destination:=Columns("D:D") Columns("F:F").ac. 1).SmallScroll ToRight:=-7 Columns("B:B").Delete Application.001 .za 58 RefersToR1C1:=Range(Selection.Name = "Reports2" Columns("D:D").Select Selection.Characters(Start:=1.Select Selection.Insert Shift:=xlToRight Columns("F:F").

4).Select Selection.ColorIndex = 2 End With stepdown = 0 Do Until stepdown = NumCusts . stepup.Select ActiveCell. 6).FontStyle = "Bold" .1 + stepdown.Select Range("B3").OutlineFont = False .Shadow = False .Cells(4 + stepdown. 3).Value = Worksheets("Reports2").Value .Select Selection.Strikethrough = False .Value .Characters(Start:=1.Underline = xlUnderlineStyleNone .ColorIndex = 2 End With Columns("B:B").FormulaR1C1 = "=RC[1]" Dim stepdown As Single stepdown = 0 Do Until stepdown = NumCusts .sun. 3).Superscript = False .1 Worksheets("Reports2").Select Selection.FormulaR1C1 = "Duration Of Service" With ActiveCell. 2).ColumnWidth = 10.za 59 .Subscript = False .Cells(3 + stepdown. stepdown As Single q=1 .ac.Font .0000" Range("B3").Cells(3 + stepdown.Cells(4 .Worksheets("Reports2").0000" End Sub Sub queuelength() Worksheets("Table2").Value stepdown = stepdown + 1 Loop Sheets("Summary").Cells(3 + stepdown.Underline = xlUnderlineStyleNone .Subscript = False .Insert Shift:=xlToRight Range("F2").FormulaR1C1 = "=AVERAGE(Reports2!RC[4]:R[3333]C[4])" Range("B2:B6").Select ActiveCell.NumberFormat = "0.Superscript = False .Shadow = False .Stellenbosch University http://scholar.Strikethrough = False .1 Worksheets("Reports2").Worksheets("Reports2").Value stepdown = stepdown + 1 Loop Columns("F:F").Value = Worksheets("Reports2").Name = "Arial" .Cells(4 + stepdown.Select ActiveCell.OutlineFont = False . Length:=19).71 Selection. 7).NumberFormat = "0.Size = 9 .Select Dim q.

Cells(3.Cells(3 + stepdown.Cells(3 + stepdown.DisplayVerticalScrollBar = True . 2).Cells(3 + stepdown.Stellenbosch University http://scholar.1 If Worksheets("Table2").Value = Worksheets("Table2").Value > Worksheets("Table2"). 1).DisplayHeadings = True .Value = q Else stepup = 1 If Worksheets("Table2"). 2). 2).DisplayWorkbookTabs = True End With Application.Value = q q=1 End If End If stepdown = stepdown + 1 Loop End Sub Sub restorescreen() Dim x As Single Toolbars(1). 13).za 60 stepup = 1 stepdown = 0 Worksheets("Table2").Visible = True With Application . 13).Visible = True Toolbars(2).Value > Worksheets("Table2").Cells(3 + stepdown.Value q=q+1 stepup = stepup + 1 Loop Worksheets("Table2").Value = Nextcust .DisplayFormulaBar = True .Cells(3 + stepdown.stepup.DisplayHorizontalScrollBar = True .Cells(3 + stepdown.sun.Value = q Else stepup = 1 Do Until Worksheets("Table2").DisplayFullScreen = False End Sub .Value Then q=0 Worksheets("Table2").Cells(3 + stepdown.Value Then q=1 Worksheets("Table2").Cells(3 + stepdown . 2).Select Do Until Worksheets("Table2").Cells(3 + stepdown stepup. 3).DisplayStatusBar = True End With With ActiveWindow . 3).Cells(3 + stepdown. 3). 13).ac.

Activate Range("A1").Activate Application.DisplayStatusBar = True End With With ActiveWindow .DisplayStatusBar = False End With With ActiveWindow .DisplayHorizontalScrollBar = True .DisplayFormulaBar = False .DisplayHeadings = False .DisplayHeadings = False End With Dim x As Single Worksheets("Welcome").DisplayHorizontalScrollBar = True .") Dim x As Single Toolbars(1).DisplayHeadings = True End With Application.Visible = True Toolbars(2).DisplayFullScreen = True With Application . Enjoy your day.DisplayVerticalScrollBar = True .DisplayFormulaBar = False .DisplayHorizontalScrollBar = True .sun.DisplayFullScreen = True With Application .Visible = True With Application .ac.za 61 Sub Auto_Close() MsgBox ("Thank You for using the Simulation Package.Select numberoftoolbars = Application.DisplayWorkbookTabs = True .Stellenbosch University http://scholar.DisplayStatusBar = False End With With ActiveWindow .DisplayFullScreen = False End Sub Sub Auto_Open() Worksheets("Welcome").Visible = False Next End Sub Sub hidescreenset() Application.DisplayHeadings = False .DisplayFormulaBar = True .DisplayHeadings = True .count For x = 1 To numberoftoolbars Toolbars(x).DisplayWorkbookTabs = False .Toolbars.DisplayVerticalScrollBar = True .DisplayVerticalScrollBar = True .

Range( _ "NumInQ.ClearFormats .GapWidth = 0 With .ChartTitle.ac.OnAction = "GoToNavigateBar" .Font.Name = "QChart" End With ' Add a button to the chart sheet (to return to the Report) ActiveChart.Select numberoftoolbars = Application.Size = 12 End With With .AxisTitle.count For x = 1 To numberoftoolbars Toolbars(x).Size = 16 .Buttons. SeriesLabels:=0.Activate End Sub Sub GeneralInputs() . CategoryLabels:=1.5625.Axes(xlCategory) .75). (Actually.Add ActiveChart.ChartGroups(1).Toolbars.sun.Characters(Start:=1.Text = "Control Central" .DisplayWorkbookTabs = False End With Dim x As Single Worksheets("Welcome").ChartWizard Source:=Sheets("Reports"). Gallery:=xlColumn.TickLabels.Select With Selection .Size = 14 End With ActiveChart.Activate Range("A1"). format:=1.Font. _ Title:="Distribution of Number in Queue".Stellenbosch University http://scholar.Font. CategoryTitle:= _ "Number in Queue".Size = 14 . 200.TickLabels.Add(376.Select End Sub Sub CreateChart() ' Create a chart of TimeInQ versus NumInQ.Font.AxisTitle.Size = 14 . 43.Characters.Font. delete the old ' chart and create a new one) Application. Length:=18).Size = 12 End With .DisplayAlerts = False Sheets("QChart").Visible = False Next End Sub Sub GoToReport() Worksheets("Reports").za 62 . 81. HasLegend:=2.Delete Application.PlotArea.Font.Deselect End Sub Sub GoToInputs() Worksheets("Inputs").ScreenUpdating = False Application.TickLabels.TimeInQ"). PlotBy:= _ xlColumns.DisplayAlerts = True Charts.25. ValueTitle:="Percentage of Time" With ActiveChart .Axes(xlValue) .NumberFormat = "0%" .

Range("ArivDist").Range("MaxValueArrive").Range("NumServers").EntireRow.Range("ArriveTime").Text) Worksheets("Inputs").Protect DrawingObjects:=True.Select Selection. mynum2.Text) End Sub Sub cont() End Sub Sub ServiceInputs() . Contents:=True.InputBox("Enter a the Minimum Value in " & tunit & "s for the average time between arrivals") mynum2 = Application.Value = (DialogSheets("QGeneral Inputs").Value = 1000 End If End Sub Sub ArrivalInputs() Dim arrivedist1.Text) If Worksheets("Inputs"). Scenarios:=True Worksheets("Observed Prob"). 1).Range("MaxInSys"). Scenarios:=True Case 4 mynum = Application. Scenarios:=True Case 3 mynum = Application.EntireRow.EntireRow.Text) Worksheets("Inputs").Unprotect Rows("12:16").EditBoxes("MaxInQueue").Range("MostLikArrive").EditBoxes("AvgCustArrive").Value = mynum Rows("12:12"). Contents:=True.Range("MaxInSys").Hidden = True arrivedist1 = Worksheets("Inputs").Range("MaxTime").Value tunit = Worksheets("Inputs").Value = (DialogSheets("QGeneral Inputs").Range("MaxInSys").Protect DrawingObjects:=True.Hidden = False ActiveSheet.Value = mynum Worksheets("Inputs").Protect DrawingObjects:=True.InputBox("Enter a the Maximum Value in " & tunit & "s for the average time between arrivals") Worksheets("Inputs").Range("TimeUnit").ac.Value > 1000 Then Worksheets("Inputs").Select Case Else End Select Worksheets("Inputs").Stellenbosch University http://scholar. mynum.Value Select Case arrivedist1 Case 1. Contents:=True.InputBox("Enter the Standard Deviation in " & tunit & "s for the average time between arrivals") Worksheets("Inputs"). mynum3 As Single Worksheets("Inputs"). Scenarios:=True Case 5 ActiveSheet.Protect DrawingObjects:=True.Value = (DialogSheets("QArrival Inputs").Value = mynum3 Rows("13:16").InputBox("Enter a the Most Likely Value in " & tunit & "s for the average time between arrivals") mynum3 = Application.EditBoxes("NoOfUnits").Hidden = False ActiveSheet.sun.Select Selection. tunit.Cells(1.Select Worksheets("Observed Prob").Select ActiveSheet.Range("MinArriveValue").Select Selection.Value = mynum2 Worksheets("Inputs").za 63 ' get general inputs Worksheets("Inputs").Range("StdDevArrive"). Contents:=True.Value = (DialogSheets("QGeneral Inputs"). 2 ActiveSheet.EditBoxes("NumService").

Range("MaxValueService").InputBox("Enter the Standard Deviation in " & tunit & "s for the average time per server") Worksheets("Inputs").Protect DrawingObjects:=True.Hidden = False ActiveSheet.Select Case Else End Select Worksheets("Inputs").Range("MostLikService").ac. no arrivals will be allowed.EntireRow.Select ActiveSheet.Value = (DialogSheets("QService Inputs").Activate End Sub Sub GoToHistory() Worksheets("QHistory").Range("StdDevService").Unprotect Rows("22:26").Stellenbosch University http://scholar.Range("servdist"). Contents:=True.Hidden = False ActiveSheet.Range("TimeUnit").Value Select Case servdist1 Case 1.") End Sub Sub GoToCharts() Worksheets("Graphic Reports").Text) End Sub Sub MaxInQueue_AfterUpdate() MsgBox ("1) Enter the time unit you would like to use eg Day to work with days etc. 3) Enter the number of servers available 4) Enter the number of customers allowed in the queue.Cells(1. mynum As Single.Value = mynum Worksheets("Inputs").EditBoxes("AvgCustService").InputBox("Enter a the Most Likely Value in " & tunit & "s for the average time per server") mynum3 = Application.sun.Protect DrawingObjects:=True. 2 will equal two days Note: At the end of this time. Contents:=True. but customers already in the system will be served.Range("MinServiceValue"). Scenarios:=True Case 3 mynum = Application.Value = mynum3 Rows("23:26").InputBox("Enter a the Maximum Value in " & tunit & "s for the average time per server") Worksheets("Inputs"). 1).Protect DrawingObjects:=True. Scenarios:=True Case 4 mynum = Application.Select Selection. mynum3 As Single servdist1 = Worksheets("Inputs"). tunit As String.Protect DrawingObjects:=True.Hidden = True Dim servdist1 As Single.EntireRow. Scenarios:=True Worksheets("Observed Prob"). mynum2 As Single. 2) Enter the number of time units the simulation will last eg.InputBox("Enter a the Minimum Value in " & tunit & "s for the average time per server") mynum2 = Application.Value = mynum Rows("22:22").EntireRow.Activate End Sub . Contents:=True.Select Selection. Contents:=True. 2 ActiveSheet.Value = mynum2 Worksheets("Inputs"). Scenarios:=True Case 5 ActiveSheet.Select Worksheets("Observed Prob").Range("ServeTime").Value tunit = Worksheets("Inputs").za 64 Worksheets("Inputs").Select Selection.

Value = 0 DialogSheets("Navigation Bar").Show End Sub Sub GotoWelcome() Worksheets("Welcome").Value = 3 Case Is = 3 Worksheets("QHistory").Value = Worksheets("Reports").Value = 4 Case Is = 4 Worksheets("QHistory").Value Worksheets("QHistory").Range("CurrentData").Value = Worksheets("Reports").Activate End Sub Sub GoToProb() Sheets("QChart").Activate End Sub Sub GoToSummaryT() Sheets("Summary").Activate End Sub Sub GoToProbTable() Sheets("Observed Prob").Value = 1 Worksheets("QHistory").Range("RunNo").Activate End Sub Sub GoToAnalyticalModel() Sheets("Analytical Model").Value = Worksheets("Reports").Stellenbosch University http://scholar.Range("CurrentData").Activate End Sub Sub ClearHistory() Worksheets("QHistory").Range("Run3").Value = Worksheets("Reports").Range("Run5").RunNo Case Else DialogSheets("Navigation Bar").Text = 5 .Value = 6 .Range("RunNo").EditBoxes("NoOfRunsLeft").Range("HistoryData").Value Worksheets("QHistory").ac.Range("RunNo").Range("CurrentData").Range("RunNo").Value = 5 Case Is = 5 Worksheets("QHistory").Value = Worksheets("Reports").Range("RunNo").Range("RunNo").Range("Run1").Value Worksheets("QHistory").Range("Run4").Range("CurrentData").Range("CurrentData").Text = 5 End Sub Sub AddToHistory() Dim RunNo As Single RunNo = Worksheets("QHistory").Value = 2 Case Is = 2 Worksheets("QHistory").EditBoxes("NoOfRunsLeft").za 65 Sub GoToNavigateBar() DialogSheets("Navigation Bar").Activate End Sub Sub GoToDetail() Sheets("Reports2").Value Worksheets("QHistory").Value Worksheets("QHistory").Text = 0 End Select Select Case RunNo Case Is = 1 Worksheets("QHistory").Value Select Case RunNo Case 1 To 5 DialogSheets("Navigation Bar").EditBoxes("NoOfRunsLeft").Range("RunNo").sun.Range("Run2").

Close Savechanges:=True Else ' User chose No. Title.Stellenbosch University http://scholar.xls").Show End Sub Sub PrintInputs() ' ' PrintSelection Macro ' Macro recorded 04/03/99 by Shivan Mohd ' ' .Text = 0 End Select End Sub Sub ExitSimulation() ' ' ExitSimulation Macro ' Macro recorded 03/03/99 by Shivan Mohd ' Dim Msg. 'Help = "DEMO.za 66 Case Else MsgBox ("You are only allowed 5 History Files to find an Average. Ctxt. Help. ' Display message.Range("RunNo"). Response. Thank You") End Select End Sub Sub SetNoOfRuns() Dim RunNo As Single RunNo = Worksheets("QHistory"). Title = "Exit Simulation" ' Define title. Style. Help. Ctxt) If Response = vbYes Then ' User chose Yes. MyString = "No" ' Perform some action. MyString Msg = "The Workbook will now Close and Save all changes!Do you want to continue ?" ' Define message. Workbooks("Queuing Simulation." ' Perform some action. Title.Value Select Case RunNo Case 2 To 5 Case Else DialogSheets("Navigation Bar").EditBoxes("NoOfRunsLeft"). Response = MsgBox(Msg.ac. MyString = "Thank You for using this Package.HLP" ' Define Help file. Style = vbYesNo + vbCritical + vbDefaultButton2 ' Define buttons. Style. End If End Sub Sub About() ' ' About Macro ' Macro recorded 11-11-98 by Shivan Mohd ' DialogSheets("About").sun. Ctxt = 1000 ' Define topic ' context.

Goto Reference:="ProbTables" Selection.Range("A1").Stellenbosch University http://scholar. Collate:=True Worksheets("Graphic reports").Range("A1").Range("A1"). Collate:=True Worksheets("QHistory").sun.Goto Reference:="Inputs" Selection.Select End Sub Sub PrintHistory() ' ' PrintSelection Macro ' Macro recorded 04/03/99 by Shivan Mohd ' Application.Range("A1").PrintOut Copies:=1. Preview:=True.PrintOut Copies:=1. Collate:=True Worksheets("Inputs").Select End Sub Sub PrintGraphs() ' ' PrintSelection Macro ' Macro recorded 04/03/99 by Shivan Mohd ' ' Application.PrintOut Copies:=1.Range("A1").Select End Sub Sub Printreports() ' ' PrintSelection Macro ' Macro recorded 04/03/99 by Shivan Mohd ' ' Application.za 67 Application. Collate:=True Worksheets("Reports").ac. Preview:=True. Preview:=True.Goto Reference:="Reports" Selection.Goto Reference:="History" Selection. Preview:=True. Preview:=True.Select End Sub Sub PrintProbTables() ' ' PrintSelection Macro ' Macro recorded 04/03/99 by Shivan Mohd ' ' Application.Select End Sub Sub Resettables() ' ' Resettables Macro .Goto Reference:="Graphs" Selection.PrintOut Copies:=1. Collate:=True Worksheets("Observed Prob").PrintOut Copies:=1.

Stellenbosch University http://scholar.EntireRow.ac.F3:G13").Select ActiveCell.Select ActiveCell.FormulaR1C1 = "0" Range("F3").Select Selection.Select Selection.FormulaR1C1 = "0" Range("G3").Select End Sub Sub hide() ' ' hide Macro ' Macro recorded 01/07/99 by Shivan Mohd ' Rows("12:12").Select Selection.Select ActiveCell.Select ActiveCell.Select Range("F3").EntireRow.FormulaR1C1 = "0" Range("C3").Activate Selection. Type:=xlFillDefault Range("F3:G13").FormulaR1C1 = "0" Range("B3:C3").sun.AutoFill Destination:=Range("B3:C13").za 68 ' Macro recorded 20/10/1999 by Shivan Mohd Range("B3:C13.ClearContents Range("B3"). Type:=xlFillDefault Range("B3:C13").Hidden = True Rows("12:12").Hidden = False End Sub .AutoFill Destination:=Range("F3:G13").Select Range("F3:G3").Select Selection.