Professional Documents
Culture Documents
Simulation Modeling in Arena For BU385
Simulation Modeling in Arena For BU385
Justin Clarke
Simulation Modeling & Analysis with Arena : A Business Students Primer Justin Clarke Copyright 2005
This work is licensed under a Creative Commons License
Attribution-NonCommercial-ShareAlike 2.5
You are free: to copy, distribute, display, and perform the work to make derivative works Under the following conditions: Attribution. You must attribute the work in the manner specified by the author or licensor.
Noncommercial. You may not use this work for commercial purposes. Share Alike. If you alter, transform, or build upon this work, you may distribute the resulting work only under a licence identical to this one. For any reuse or distribution, you must make clear to others the licence terms of this work. Any of these conditions can be waived if you get permission from the copyright holder. Your fair dealings and other rights are in no way affected by the above. The full license can be viewed here: http://creativecommons.org/licenses/by-nc-sa/2.5/legalcode
School of Business & Economics, Wilfrid Laurier University 75 University Avenue West Waterloo, ON, N2L 3C5
Feedback Information
The author and the reviewers of this book have created and tested the examples and models in this book with care and precision. It is our goal to create a primer of the highest quality and value, and your feedback as a reader will be a natural continuation of this process. If you have any comments on how we can improve the quality of this book, or otherwise alter it to better suit your needs, you can contact the author and/or the editor. We greatly appreciate your assistance. Author -- Justin Clarke: justin@webartpromotions.com Editor -- Umar Ruhi: uruhi@wlu.ca
Trademark Acknowledgements
All terms mentioned in this book that are known to be trademarks or service marks have been appropriately capitalized. The author and reviewers cannot attest to the accuracy of this information. Use of a term in this book should not be regarded as affecting the validity of any trademark or service mark. Microsoft, Microsoft Excel, and Microsoft Word are registered trademarks of Microsoft Corporation. Arena is a registered trademark of Rockwell Software Inc. Mr. Lube is a registered trademark of Mr. Lube
Page 76
Table of Contents
1.0 2.0 3.0 4.0 5.0 5.1 5.2 6.0 6.1 6.2 7.0 7.1 7.2 Warnings .................................................................................................... Prerequisites ............................................................................................... Special Functions ......................................................................................... Counters..................................................................................................... Balking ....................................................................................................... Balking if more than X in entire system ........................................................ Balking if more than X in queue .................................................................. Separated Waiting Lines................................................................................ 2 Separated Waiting Lines.......................................................................... N Separated Waiting Lines ......................................................................... Additional Resources .................................................................................... Previous Arena Workbooks ......................................................................... Arena Manuals.......................................................................................... 78 78 78 80 83 83 85 88 88 89 93 93 93
Page 77
1.0 Warnings
Do NOT save your Arena models on floppy disks. Floppy disks are a very fragile media and are bound to become damaged no matter how carefully you take care of them. Save your work frequently onto a more stable source such as a hard drive, network drive, or a USB key. It should be noted that USB keys arent without their own problems but they are much more reliable than floppy disks. Do NOT save documents directly on the hard drives of public computers as those files are often deleted every time you reboot the computer. If the computer crashes and reboots, you will lose any files on the hard drive. Do NOT save Arena models deep within the folder structure of your computer. There is a limitation in Crystal Reports (the reporting mechanism of Arena) that cannot handle exceptionally long file paths. In newer operating systems (Windows 2000 or Windows XP) if you save your Arena models under My Documents or the Desktop you may have problems. This is because the actual path to these folders is already quite long. For example, the path to the My Documents folder in Windows XP is C:\documents and settings\user name\My Documents. If you were to save your model within a few folders under My Documents, it is likely you would run into this problem. A safe location to save these models is to create a folder called Arena directly on the C:\ drive and then create a folder for each model inside this folder. Arena will not display reports if you run your simulation from a non-writeable media (such as a CD or a write-protected floppy/USB key), as it cannot write the reports. Also, Arena will not display reports if you run the simulation from inside a compressed folder (zip) for the same reason. Save your model to the hard drive or a writeable media before running the simulation.
2.0 Prerequisites
This module assumes you have working knowledge of building models in Arena, running simulations, and analyzing results. If you havent used Arena in awhile (or have never used it at all) it is highly recommended that you work through some of the resources identified in the Additional Resources section.
Page 78
Simulation Applications in Queuing Theory NR ( Resource ID ) Number of busy resource units. Each time an entity seizes or preempts capacity units of a resource, the NR variable changes accordingly. NR is not userassignable; it is an integer value.
Page 79
4.0 Counters
Counters can be used in Arena to measure and report a specific statistic. For example, you may wish to count the number of entities that pass through the TRUE and FALSE paths of a condition. Examine the following model:
The situation shown above is a movie theatre where, after buying tickets, customers have a 50% chance of continuing to also buy concessions. This is modeled using a condition module with a 50% 2-way by chance. When you run the report on a model like this, you are able to obtain numbers on the number of entities who left the Buy Tickets process, and the number of entities who left the Buy Concessions process, but to determine those who did not enter the Buy Concessions process would require subtracting the difference between those two numbers. While this is a fairly trivial task, it would be preferable if those counts could be ready in the report after you run it. That is where counters come in. In this example, we will add two counters (or record modules) after the TRUE and FALSE points of the decision module. These counters will increment every time an entity passes through them, and these statistics will be displayed at the end of the report.
Page 80
Simulation Applications in Queuing Theory The following is an updated flow chart with the two record modules:
You must simply add the record modules in the appropriate part of the flow chart (where you want the increment to happen) and name them accordingly. Num Buy Concessions Properties:
Page 81
As you can see, you now have an accurate picture of the number of entities which bought and skipped the concessions process. Counters can be used in many other similar circumstances.
Page 82
5.0 Balking
Balking is an event whereby an entity decides against entering a queue because of its size. An example of this would be a person deciding against using an ATM machine because there are 3 people in line. Simulating balking is likely handled in the following two ways: 1. An entity will not enter the system if there are more than X entities in the entire system OR 2. An entity will not enter a specific queue if there are more than X entities waiting in the queue
Note: We are assuming at this point that you are familiar with creating entities, resources, and processes, setting their arrival/service times, and setting up the simulation run time. In order to simulate balking, we must do the following: 1. Create a condition called Balk? before any of the processes (i.e. just after the create module) that, when TRUE, will continue with the process, and when FALSE, will dispose the entity without entering any of the processes. a. TRUE links to the Register with Nurse module b. FALSE links with the next module 2. Add a Balked Patients dispose module that links to the FALSE path of the condition 3. Add a counter (record module) to count the number of patients served (placed just before the Patients Served dispose module) 4. Add a counter (record module) to count the number of patients that balked (placed just before the Balked Patients dispose module)
Page 83
Simulation Applications in Queuing Theory The following is a flow chart of the updated system:
Adding the record modules is done in order to create a statistic that can be analyzed in the report to determine how many balked and how many were served. These two numbers should add up to the NumberOut variable in the report. As this was covered earlier, we will not go into detail on setting these modules up. Furthermore, creating the dispose module is fairly simple as well, so it wont be covered. The Balk? Condition: The following is the properties of the balk condition:
Under Type, choose 2-way by Condition. This means that a condition expression will be provided that will determine the path the entity will take. This is opposed to 2-way by Chance where the path of the entity is based solely on a percentage (i.e. TRUE = 90% of the time) Under IF, choose Expression (as we are building an expression) Under Value, type EntitiesWIP(Patient) <= 5. You may notice EntitiesWIP from an earlier section. It is a function that will count the number of entities in the entire process. You must provide the name of the entity between the parentheses ( and ) (in this case the entity has been named Patient, the default entity name is Entity 1 if you have not changed it). When this condition is evaluated (i.e. whenever an entity is created), it will count the number of entities in the system, and if the count is less than or equal to five, it will
Page 84
Simulation Applications in Queuing Theory evaluate the condition to TRUE and continue the entity on the normal path. If FALSE (i.e. more than five entities in the system), the entity will balk and be disposed early.
In order to simulate balking, we must do the following: 1. Create a condition called Balk? before any of the processes (i.e. just after the create module) that, when TRUE, will continue with the process, and when FALSE, will dispose the entity without entering any of the processes. a. TRUE links to the Use ATM module b. FALSE links with the next module 2. Add a Balked People dispose module that links to the FALSE path of the condition 3. Add a counter (record module) to count the number of patients served (placed just before the People Served dispose module) 4. Add a counter (record module) to count the number of patients that balked (placed just before the Balked People dispose module)
Page 85
Simulation Applications in Queuing Theory The following is a flow chart of the updated system:
As mentioned in the previous example, adding the record modules is done in order to create a statistic that can be analyzed in the report to determine how many balked and how many were served. These two numbers should add up to the NumberOut variable in the report. The Balk? Condition: The following is the properties of the balk condition:
Under Type, choose 2-way by Condition as in the previous example. Under IF, choose Expression (as we are building an expression) Under Value, type NQ(Use ATM.Queue) + NR(ATM) <= 3. You may notice NQ and NR from an earlier section. NQ is a function that will count the number of entities in a queue. You must provide the name of the queue between the parentheses ( and ) (in this case the process module has been named Use ATM you must add .Queue after the name of the process module). NR is a function that will count the number of utilized resources (i.e. the number of people being served in the process, usually one or zero). You must provide the name of the resource that is used by the process between the parentheses ( and ) (in this case the resource was named ATM). Note: This not only counts the number of people waiting in line but also includes the person actually being served. Therefore, if the question/problem/situation dictates that an entity will balk if there are more than three people waiting (excluding any being served), then you would exclude the + NR(ATM) portion of the expression. Page 86
When this condition is evaluated (i.e. before the entity enters the process), it will count the number being served and waiting, and if the count is less than or equal to three, it will evaluate the condition to TRUE and continue the entity on the normal path. If FALSE, the entity will balk and be disposed early.
Page 87
Everything here is fairly standard there are two process modules (and each process module has a unique resource: Teller #1 and Teller #2). The only tricky part to this model is the condition underlying the Which Line? condition module. We must program a condition such that entities will evaluate the line length of both modules and choose lower of the two. Since a condition module always has a TRUE and a FALSE connection, we must write the condition such that when TRUE, the entity will continue along to Teller #1, and whenever FALSE, will travel to Teller #2. Which Line? Condition Module Properties: Name: Which Line? Type: 2-way by Condition If: Expression NQ(Teller 1.Queue) + NR(Teller Resource 1) <= NQ(Teller 2.Queue) + NR(Teller Resource 2) Value: Page 88
As shown previously and NQ counts the number of entities in a queue, NR counts the number of a resource being utilized (in this case the value will be 0 if no one is being served, 1 if someone is being served). This formula will check to see if the total number in the Teller #1 line is <= the total number in the Teller #2 line. After running a report, you can see the number of people served by Teller #1 and Teller #2 (shown below). Its important to realize that if the service times are the same for both processes, the first process will most likely serve more entities than the second process because people will enter it first if there is a tie. Report:
Page 89
Now, we must add the conditions to the decision module. Instead of choosing 2-way by Condition, we must choose N-Way by Condition and add 2 conditions. The first condition will, when TRUE, send the entity to Teller #1, the second condition, when true, will send the entity to Teller #3. A third condition isnt needed because if the first two conditions arent met, then the FALSE path will be connected to Teller #3. This example can be expanded to accommodate as many tellers as possible. The important point to note is that you need to define N - 1 conditions where N is the number of separate paths. Adding Conditions to N-Way Condition Module: To add a condition to an N-Way Condition Module, double click the module, and choose NWay by Condition under type.
Next, click ADD and type the expression in the box shown below:
Page 90
After typing your condition, you will click OK twice to go back to the model and you must then connect that condition to the next appropriate module. Condition #1: - Is the line for Teller #1 shorter than the line for Teller #2? AND - Is the line for Teller #1 shorter than the line for Teller #3? - Arena Expression: (one line)
( NQ(Teller 1.Queue) + NR(Teller Resource 1) <= NQ(Teller 2.Queue) + NR(Teller Resource 2) ) && ( NQ(Teller 1.Queue) + NR(Teller Resource 1) <= NQ(Teller 3.Queue) + NR(Teller Resource 3) )
The first part of this expression (before the && symbol, which means AND) takes the number in queue of Teller #1 plus the number being serviced by Teller #1 and compares it with the same for Teller #2. The second part of this expression compares the same values against Teller #3. After adding this condition to the decision module, link that condition to the Teller #1 path:
Condition #2: - Is the line for Teller #2 shorter than the line for Teller #3?
Page 91
Page 92
Page 93