Upload
others
View
2
Download
0
Embed Size (px)
Citation preview
Défense
nationale
National
Defence
Defence R&D CanadaCentre for Operational Research and Analysis
Director General Military Personnel ResearchAnd Analysis
Chief Military Personnel
DRDC CORA TM 2007-47December 2007
Human Resource Model DevelopmentUsing ArenaA Beginning Tutorial
Stan IsbrandtPersonnel Operational Research Team
Human Resource Model Development Using ArenaA Beginning Tutorial
Stan IsbrandtPersonnel Operational Research Team
Defence R&D Canada – CORATechnical Memorandum
DRDC CORA TM 2007-47
December 2007
Principal Author
Stan Isbrandt
Approved by
Sanela DursunActing Section Head, Personnel and Social Science Operational Research Teams
Approved for release by
Susan TruscottDirector General Military Personnel Research and Analysis
The information contained herein has been derived and determined through best practice and adher-ence to the highest levels of ethical, scientific and engineering investigative principles. The reportedresults, their interpretation, and any opinions expressed therein, remain those of the authors and donot represent, or otherwise reflect, any official opinion or position of DND or the Government ofCanada.
c© Her Majesty the Queen in Right of Canada as represented by the Minister of National Defence,2007
c© Sa Majesté la Reine (en droit du Canada), telle que représentée par le ministre de la Défensenationale, 2007
Abstract
The Canadian Department of National Defence uses computer simulations to project characteristicsof military occupations or occupational groupings. The Canadian simulation capability generatedsignificant interest in the Workforce Modelling and Analysis Working Group of The TechnicalCooperation Program. As part of a process of presenting this Canadian capability, a real-timemodel-building tutorial session was given at the working group, illustrating how one might createa basic Human Resources model. At the request of the working group, this report details andformalizes the tutorial session. It documents the tutorial for both reference purposes, as well as forfurther dissemination of the tutorial content.
Résumé
Le département de la défense nationale du Canada exploite les techniques de simulation par ordina-teur dans la projection de caractéristiques propre à la population d’un ou d’un ensemble de groupesprofessionnels militaire. L’approche canadienne a suscité beaucoup d’intérêt au sein du groupede travail sur la modélisation et l’analyse des effectifs de “The Technical Cooperation Program”.Cette approche canadienne a été présentée sous forme de tutoriel lors de la dernière rencontre dugroupe de travail illustrant les étapes dans l’élaboration d’un modèle de base pour la projection desressources humaines. À la demande du groupe de travail, ce rapport se veut un guide et une docu-mentation de ce tutoriel. Ce document peut servir à la fois comme document de référence et facilitela dissémination du contenu de ce tutoriel.
DRDC CORA TM 2007-47 i
This page intentionally left blank.
ii DRDC CORA TM 2007-47
Table of contents
Abstract . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . i
Résumé . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . i
Table of contents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . iii
List of tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . iv
List of figures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . iv
1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
2 Tutorial . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
2.1 Model Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
2.2 A Simple Start . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
2.3 Simple Attrition and Promotion . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
2.4 Synchronization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
2.5 Submodels and Another Rank . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
2.6 Signals and Basic Output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
2.7 Importing Text Results into Access . . . . . . . . . . . . . . . . . . . . . . . . . 21
2.8 Refining the Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
2.9 Automated Generation of an Output Chart . . . . . . . . . . . . . . . . . . . . . 33
2.10 Modelling Considerations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
3 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
List of Abbreviations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
DRDC CORA TM 2007-47 iii
List of tables
Table 1: Arena VBA Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
Table 2: MasterFunction Skeleton Code . . . . . . . . . . . . . . . . . . . . . . . . . . 24
Table 3: Access Delete Unneeded Tables Visual Basic for Applications (VBA) Code . . 25
Table 4: Access Import Tables VBA Code . . . . . . . . . . . . . . . . . . . . . . . . . 26
Table 5: MasterFunction Full Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
Table 6: Access Query Export VBA Code . . . . . . . . . . . . . . . . . . . . . . . . . 34
Table 7: Access Query Export VBA Code . . . . . . . . . . . . . . . . . . . . . . . . . 35
Table 8: Excel Convert.xls Auto-Run VBA Code . . . . . . . . . . . . . . . . . . . . . 36
Table 9: Final Arena VBA Code to Automate the Output Chart “ChartFromQuery.xls” . 37
List of figures
Figure 1: Create Block Values - For Member Creation . . . . . . . . . . . . . . . . . . . 4
Figure 2: Assign Block Values - For Member Attributes . . . . . . . . . . . . . . . . . . 5
Figure 3: A Simple First Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
Figure 4: Simple Attrition Sampling . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
Figure 5: Push Promote to Rank 2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
Figure 6: Assign New Rank Attribute Value . . . . . . . . . . . . . . . . . . . . . . . . 7
Figure 7: Assign Values to Age a Member . . . . . . . . . . . . . . . . . . . . . . . . . 8
Figure 8: Sample Model 2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
Figure 9: Hold for Signal 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
Figure 10: Create 2 Dialog Values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
Figure 11: Delay 1 Dialog Values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
Figure 12: Signal 1 Dialog Values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
iv DRDC CORA TM 2007-47
Figure 13: Model with Timing Signal . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
Figure 14: Step Arrow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
Figure 15: Submodels for Each Rank . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
Figure 16: Junior Rank Submodel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
Figure 17: Intermediate Rank Submodel . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
Figure 18: Senior Rank Submodel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
Figure 19: Enhanced Timing Signals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
Figure 20: Intermediate Submodel Including the ReadWrite block . . . . . . . . . . . . . 20
Figure 21: Office Security Level for Automated VBA . . . . . . . . . . . . . . . . . . . . 21
Figure 22: Import Fields Specification . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
Figure 23: Dialog for Push Promotion . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
Figure 24: Senior Strength Increment . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
Figure 25: Senior Strength Decrease . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
Figure 26: Additional Create Block . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
Figure 27: Simple Input Connection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
Figure 28: Simple Excel Input File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
Figure 29: Additional ReadWrite Block . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
Figure 30: Access Query Definition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
Figure 31: Example Automated Chart . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
DRDC CORA TM 2007-47 v
This page intentionally left blank.
vi DRDC CORA TM 2007-47
1 Introduction
The Canadian Department of National Defence (DND) uses simulation to project personnel demo-graphics subject to static or dynamic policies and occupational parameters. This is typically doneto investigate the impacts of either current or proposed policies over a future period of 20 years ormore. Various examples of such modelling have been documented in [1], [2], [3], and [4].
As part of The Technical Cooperation Program (TTCP) Workforce Modelling and Analysis WorkingGroup, held in May 2007 [5], a real-time model-building tutorial session was presented. A simpleHuman Resource (HR) model, using concepts similar to one of the Canadian military occupationmodels, was built from scratch into a structure that illustrated modelling concepts that were foundto be generally useful in more complex models. The audience requested that the tutorial session beformalized and be made available to the TTCP member nations. This report fulfills that request bypresenting a quite detailed documentation of that tutorial.
Tutorial model files corresponding to the model at various stages, as well as supporting files, areincluded in a compact disc (CD) that is used to distribute an electronic version of this report. Whenthe files are copied to a computer, they may be written as “read-only” files. It may then be necessaryto remove the “read-only” attribute in order to work with and/or execute the various files.
Assumptions:
• Requires Rockwell Arena software installed on a Personal Computer (PC). This tutorial wasconstructed with Arena Version 11.0.
• This tutorial assumes that the reader knows how to place various blocks provided on the“Basic Process” Panel to the model-building area in Arena, how to connect them, as well ashow to set values or assignments within them.
• The model being built will deal with only one type of entity, and it will be used to representindividuals with different characteristics, or “attributes”.
• The model as constructed in the tutorial, and provided as sample model files on an accompa-nying CD, uses Microsoft Access and Microsoft Excel for data manipulation and reportingpurposes. (The tutorial presented here used Microsoft Office 2003 versions of Access andExcel.) These must both be available on a computer in order to run the models as describedin the later portions of the tutorial.
• Before undertaking the tutorial presented here, it is very useful to become familiar with atleast the basic concepts of Arena documented in [6] and [7].
In this tutorial, we build a simple Human Resources model, endeavouring to illustrate several con-cepts which can be similarly used within much more complex models. The tutorial also illustratesa possible means of incorporating external input and output files, so as to make use of MicrosoftOffice features to complement the capabilities inherent in Arena. This includes, for instance, a basicexample of automatic creation of an Excel chart from model simulation results.
DRDC CORA TM 2007-47 1
2 Tutorial
This tutorial presents only one approach out of many possibilities for using Arena to create a HRmodel. The concepts illustrated here are drawn from the Arena Career Modelling Environment(ACME) [1], and can be a useful starting point for getting some background information beforedelving into ACME. Nevertheless, the tutorial can also stand on its own as a potential starting pointfor other variations on HR modelling.
The Arena model-building software provides a rich variety and numerous components, of whichonly a small proportion are actually used here. Part of the model-building challenge is to identifythe most useful components out of the many provided for the model that is being built.
Other very different styles of HR models exist, and may be quite useful within their respectiveapplication areas. One such model is the Production Management Tool (PMT) which was developedin Personnel Operational Research Team (PORT) for detailed modelling of “pipeline” training flowsfor particular occupational areas (documentation for PMT will be available in the near future).
2 DRDC CORA TM 2007-47
2.1 Model Overview
The model construction process described here gradually develops a model with three ranks orlevels, from 3 (lowest) to 1 (highest). The completed model uses both “push” promotion and “pull”promotion mechanisms1. Individuals are represented as corresponding entities within the model,each one with its own specific attributes.
The model simulates the overall changes to personnel within an occupation on a yearly basis -attrition, training (which is not illustrated here but is included in ACME), promotions and recruiting,and aging. A population of individuals is generated, and put through these various processes toreflect what the projected end state would be after one year. This end state then becomes thenext starting population, and the process is repeated in a cyclical fashion to effectively project thepopulation of the occupation through a time period of multiple years.
Since the model effectively tries to capture the aggregate occupational progression processes thattake place over the period of a year, some corresponding assumptions are made. For example,since individuals could enter the occupation any time during the year, when they are “generated” orintroduced into the model, they are given 0.5 Years of Service (YOS) and 0.5 Time In Rank (TIR),as an approximation to the “real” case where they would have values which varied between 0 and1. Similarly, since in this model we are assuming that promotions could take place any time duringthe year, individuals on entering a new rank are given 0.5 TIR. (A more accurate representationwould be to use a random distribution providing values from 0 up to 1 to assign a YOS value uponcreation.)
The tutorial progressively shows how one might construct such a model in stages, as well as showinghow to draw input from an Excel file into the simulation, how to save run results in a text file, andthen how to process these results in Access and create an output chart in Excel.
1A “push” promotion here means that ALL eligible members are promoted to the next rank when achieving relevantpromotion criteria. With a “pull” promotion, there is a maximum number of eligible members who are promoted tothe next rank, determined by the size of a shortfall existing in the next rank, so only SOME eligible members may bepromoted.
DRDC CORA TM 2007-47 3
2.2 A Simple Start
Place a Create Block. Double click on its image and set the values as shown in Figure 1. This blockwill, every simulated year for 200 years, introduce 15 new entities, which here represent individualmembers of some group. The created members have no attribute values set yet as they proceedout of the Create block. The first group of 15 members will be created at time 0.1 days, and eachsubsequent group will be created at subsequent intervals of 365.25 days. The 15 member entitiesof each group are conceptually created at the same “time”, but Arena actually creates them one ata time, and moves each one along subsequent connections and blocks until it reaches a point whereit must spend some time (such as a Hold block). Then, Arena creates another member entity, andagain moves it along until it reaches a point where it must be delayed for at least a bit of time. Theprocess continues until all 15 member entities have been created and moved as far as they can gobefore being delayed. Then, Arena examines its internal event queue to determine which event intime takes place next, and with which member entity. If this event conceptually involves more thanone entity, then it still processes one at a time even though the event conceptually happens to allmember entities simultaneously. The simulation continues in a similar manner until some sort ofending process or logic takes effect.
Figure 1: Create Block Values - For Member Creation
Place an Assign Block, and connect to the Create Block. Set its values as shown in Figure 2.When you add values using the “Add” button, another Dialog box appears for assignments. It hasa “Type” drop-down list (here we’ll use “attribute”) and a “Name” drop-down list (here we’ll typein the attribute name corresponding to the attributes defined below), and “New Value” box where anumber or an expression is entered to define the value that will be assigned.
This assign block has several assignments. When an assignment is defined for an attribute whichhas not yet appeared in the model, then a place-holder for that attribute becomes available for allmember entities. So, in the Figure the attributes YOS, Rank, TimeInRank, and Age are beingdefined for the first time, and all of those attributes become available for each current and futuremember entity. With the exception of Age, the attributes are set to the same values for each memberentity. Here, Age will receive a value that is the YOS value (previously set to 0) plus a numberrandomly drawn from a uniform distribution between 20 and 30. So, the Age is effectively somerandom value between 20 and 30.
4 DRDC CORA TM 2007-47
When you’re adding specific assignments within an Assign Block, you can right-click within the“New Value” box to bring up an Expression Builder dialogue. It includes prompts for a number ofbuilt-in Arena functions, distributions, and such, which can be used within your assignment.
Figure 2: Assign Block Values - For Member Attributes
Place a Dispose Block, and connect to the Assign Block. Your model should now look similar toFigure 3. On the CD accompanying the electronic version distribution of this report, there is anArena model file called “SampleModel1.doe” which corresponds to Figure 3.
Create 1 Assign 1 Dispose 1
0 0
Figure 3: A Simple First Model
It’s possible to do a fundamental check of your model before running it, verifying basic things suchas making sure there is no dangling component that should have a connection. This can be doneby choosing from the top tool bar menu “Run” followed by selecting “Check Model”. If the basicslook all right, then Arena informs you that it has no errors or warnings. Otherwise, it will display awindow indicating the first issue (of perhaps several) that it identified.
Assuming there are no problems, this model can now be run, by clicking on the triangle “Go” key onthe Arena toolbar. However, it doesn’t yet do anything very exciting. Basically, it ends up creating4000 members who all look very similar (although with different Age values), and disposing ofthem immediately. However, some summary results are generated.
DRDC CORA TM 2007-47 5
2.3 Simple Attrition and Promotion
Move the Dispose Block far enough to the right of the Assign Block to allow other blocks to beplaced in between. Delete the connection between the Assign and the Dispose Blocks. Place aDecide Block, and a connection from the Assign Block to the Decide Block. Double click on theDecide Block’s image and set the values as shown in Figure 4. When a member enters this decideblock, a random number is generated and compared to the “Percent True” value. If the number isbetween 0 and 0.15, the test is considered to be “True” and the member will continue through theDecide Block Connector Anchor labelled “True”. Connect this “True” anchor to the Dispose Block.This logic now corresponds to a 15% attrition or leaving rate each time a member enters the block.The remaining 85% of the time the member will proceed through the other connector anchor, to ablock which will now be created.
Figure 4: Simple Attrition Sampling
Place another Decide Block below the first one, and connect the “False” anchor of the first DecideBlock to the input anchor of the new Decide Block. Double click on the new Decide Block’s imageand set the values as shown in Figure 5. (In order to get the proper fill-in boxes shown, the entriesmay have to be filled in from left-to-right, and top-to-bottom). Amongst other things, the block willbe renamed from its default name to “Decide Promote To 2”, so it can be distinguished from otherblocks. The effect of this block will be (after some more structure is added) that when an individualmember has a value for attribute TimeInRank greater than or equal to 2 years, the member will bepromoted to Rank level 2. This can be referred to as a “push” promotion, since each member willbe pushed to the next rank level as soon as they meet this criterion.
Place an Assign block above the “Dispose1” block, and put a connection from the “true” connectionpoint of the “Decide Promote To 2” block to the new Assign block. Double click on this new Assignblock to rename it to “Assign Rank 2” and set the Rank attribute on promotion as shown in Figure6. Also, place a connection going from this Assign block to the Dispose block. (The Rank 2 andRank 1 logic will be filled out later.)
Place another Assign block below the “Decide Promote To 2” block, and connect that Decideblock’s “False” connection point to the input connection point of the new Assign block. Doubleclick on the Assign block, rename it to “Assign Aging” and set the other dialog values as shown
6 DRDC CORA TM 2007-47
Figure 5: Push Promote to Rank 2
Figure 6: Assign New Rank Attribute Value
DRDC CORA TM 2007-47 7
in Figure 7. Connect the outgoing connection point of this Assign block to the ingoing connectionpoint of the topmost Decide block (which probably still has the default name “Decide 1”). So,this Assign block effectively “ages” an individual and sends them on again, to repeat the cycle ofsampling attrition, then (if they don’t leave) promotion, then (if they’re not promoted) aging, andso on. (Note that if the default connection between blocks creates a “messy” configuration, you caninstead create a connection with “waypoints” which define the connection in subsequent segmentsthrough the final segment which connects with a destination block.)
One subtlety of model design is where to place the “aging” process. Here, we’ve put it chronologi-cally after the promotion process, so only people who are not promoted are “aged” at this rank. If wehad placed it before the promotion process, then some people would be “aged” and then promotedimmediately afterward. So, it may be necessary to carefully consider model chronology, and verifythat the model actions will correspond to what is desired for modelling simulation purposes. So, inorder to maintain some model consistency for this model, individuals who are promoted should be“aged” upon entering their new rank. We’ll hold this thought for now, and introduce further in thetutorial this “aging” process for those promoted to rank 2.
Figure 7: Assign Values to Age a Member
Your model should now look similar to Figure 8. On the CD accompanying the electronic versiondistribution of this report, there is an Arena model file called “SampleModel2.doe” which corre-sponds to Figure 8.
Again, this model can now be run, by clicking on the triangle “Go” key. However, it doesn’tdo anything very practical yet. It generates a member, ages them around a loop, eventually pushpromotes them, and disposes of them, before repeating the process one at a time for all the othermembers who are created. In the next section, we introduce some synchronization to effectivelygroup one year’s worth of activity at a time, which will eventually allow some practical projectionand reporting to be done.
8 DRDC CORA TM 2007-47
Create 1 Assign 1 Dispose 1T ru e
F a l s e
Decide 1
T ru e
F a l s e
Decide Promote To 2
Assign Rank 2
A ssign Aging
0 0
0
0
0
0
Figure 8: Sample Model 2
DRDC CORA TM 2007-47 9
2.4 Synchronization
Structure will now be added to the model to shape the simulation flows into events that correspondto a yearly cycle. This is done by inserting a “hold” queue into the flow, and coordinating the queuewith a signal which is generated once a year.
Referring to the model as represented in Figure 8, remove the connection between the “Assign1” and “Decide 1” blocks. If the “Advanced Process” Template Panel is not showing in Arena,then display it by successively choosing from the menu bar “File”, “Template Panel”, “Attach...”,and then choosing the file “AdvancedProcess.tpo”. From the “Advanced Process” panel, choose a“Hold” block and place it where the removed connection used to be. (If necessary, move some ofthe other components either left or right.)
Edit the Hold block Dialog as shown in Figure 9 including re-naming the block to “Hold for Signal1”. The effect of these values is that whenever a “Signal” of value 1 is triggered, then this blockwill release all entities currently held in its queue.
Figure 9: Hold for Signal 1
Again, place a connection from the “Assign 1” block to the “Hold for Signal 1” block. Also, placea connection from the “Hold for Signal 1” block to the “Decide 1” block.
In order to properly include the hold queue, first delete the connection going out from the “AssignAging” block, and create a new connection going from the “Assign Aging” block to the “Hold forSignal ‘” block.
Now it’s time to create a construct that will trigger “Signal 1” at appropriate times.
Below all the other blocks in the model and towards the left, place a new create block, setting theDialog to the values as shown in Figure 10. This will create one entity per year, with the firstentity created at time 0.05 days, and each subsequent creation exactly one year later. The reasonfor having the creation offset by 0.05 days (rather than exactly at time 0), is (i) to synchronize theentity creation with the processing of the “Create 1” block, (ii) to also ensure that for each yearlycycle this create block is enacted just prior to the “Create 1” block, and (iii) to allow the use (lateron) of time 0 with another create block which reads in an initialization value.
10 DRDC CORA TM 2007-47
Figure 10: Create 2 Dialog Values
Connect this create block to a new “Delay” block (found in the “advanced process” panel) placed toits right, with Dialog values as shown in Figure 11. This delay block will hold an entity for “1 day”before sending it on to generate a signal. By doing this, the entities in the flows in the main portionof the model will have a chance to settle down in a queue before the queue receives a signal (fromthe next block which we’ll create) in order to release the entities to continue flowing.
Figure 11: Delay 1 Dialog Values
Connect this delay block to a new “Signal” block placed to its right, with Dialog values as shownin Figure 12.
Finally, connect the “Signal 1” block to a new “Dispose” block placed to its right.
The current version of the model should look something like Figure 13. On the CD accompanyingthe electronic version distribution of this report, an Arena model file called “SampleModel3.doe”corresponds to Figure 13.
You can get an idea of how the model is shaping up by running it with the “step” button, shownin Figure 14, which can be found in the Arena Standard Toolbar. You can, from the main menu,choose “Run”, “Run Control”, and then toggle “Highlight Active Module” to “on” to trace entitymovement. By repeatedly hitting the arrow, you can see how entities are created, how they flow and
DRDC CORA TM 2007-47 11
Figure 12: Signal 1 Dialog Values
Create 1 A ssign 1 Dispose 1T ru e
F a l s e
Decide 1
T ru e
F a l s e
Decide Promote To 2
Assign Rank 2
A ssign A ging
Hold for Signal 1
Create 2 Delay 1 Signal 1 Dispose 2
0 0
0
0
0
0
0 0
Figure 13: Model with Timing Signal
12 DRDC CORA TM 2007-47
are held in the model, how the signal eventually kicks in to release the queue, and how some areeventually promoted or leave and are disposed of.
Figure 14: Step Arrow
Alternatively, you can observe the model by clicking the triangle “go” button. Use the slider bar (orpress the “<” or “>” keys) to adjust the animation speed.
2.5 Submodels and Another Rank
Now, the logic comprising the entry rank level will be grouped into a submodel. This submodelis then copied to be used, and adapted as appropriate, for the expansion of model logic for theintermediate level rank (corresponding to attribute Rank = 2), and the representation of a seniorlevel rank (attribute Rank = 1).
In the model corresponding to Figure 13 select the blocks
• Assign 1
• Hold for Signal 1
• Decide 1
• Decide Promote to 2, and
• Assign Aging
and also select the connectors that have both ends connecting to one of these blocks.
Keeping these objects “selected” choose from the Arena Menu “Object”, then “Submodel”, andthen “Aggregate”. This creates a submodel enclosing the objects which have been aggregated.Right-click on the submodel, choose “Properties”, and re-name the submodel from “Submodel1 ‘”to “Junior”. Appropriate connection points and new edge connectors are created for the submodelto make the result functionally equivalent to the previous state of the model.
Again, select the “Junior” submodel, right-click and choose “Copy”. Then, right-click in an openarea of the model window, away from any of the components, and choose “Paste”. Place the newsubmodel above the original one, call up its properties, and rename it to “Intermediate”. Finally,
DRDC CORA TM 2007-47 13
right-click again in an open area of the model window away from any of the components, and pasteanother copy of the submodel above the other two, and rename it to “Senior”. The model now hasthree rank levels, but needs to be edited and some of the components need to be properly connected.
(As an aside, you can open a view of the objects enclosed in a submodel by double-clicking on thesubmodel. You can return from the interior view of a submodel by right-clicking in an open areaof the model window and choosing “Close Submodel”. Submodels can also be contained withinsubmodels, leading to a higher degree of hierarchical modularity in a model.)
First, the outer connections of the submodels will be adjusted before editing the internal compo-nents, beginning with the Junior rank level submodel. Select the connector going from the Juniorsubmodel to the “Assign Rank 2” block, and delete it. Place a connector going from the same placeon the Junior submodel (the bottom connection point on the right-hand side) to the single connectionanchor on the left-hand side of the “Intermediate” submodel.
If you view inside the “Intermediate” submodel, you can see that the upper connection on theright exiting the submodel leads out of the Decide block that samples attrition, and so should leadfrom the submodel to a Dispose block. The lower connection on the right exiting the submodelrepresents those who satisfy promotion criteria, and so should lead from the submodel to the nexthigher rank. Change to the larger model view outside the “Intermediate” submodel, and consistentwith the above observations, connect the upper connection point on the right of the submodel to the“Dispose 1” block, and connect the lower connection anchor on the right of the submodel to thesingle connection anchor on the left-hand side of the “Senior” rank level submodel.
Since the ‘Senior” submodel is the highest rank, there is no need for a “promotion” flow out ofthe submodel, but only an “attrition” flow to the dispose block. So, we’ll connect the top rightconnection point of the submodel to the dispose block. Right-click on the “Senior” submodel, andchange the value for “Number of Exit Points” to 1. We’ll edit the inside of this submodel later.
The “Assign Rank 2” submodel in the top level model view is redundant, and we’ll delete it.
Now, we’ll edit the internal components of the “Intermediate” submodel. View again inside thesubmodel. If you double-click on the “Hold for Signal 1” block to see it’s Dialog properties, andthen click the OK button to close the Dialog, you get an error. What happens here is that anyblock that has been given a specific name (i.e. doesn’t still have Arena’s original default name)isn’t renamed when you copy it. So, to avoid this error and maintain uniqueness, we’ll change theproperty “Wait for Value” to 2, rename this block to “Hold for Signal 2”, and we’ll introduce ablock to generate a signal 2 later on in this section of the tutorial.
If you double-click on the “Assign Aging” block, it turns out that it also must be renamed, althoughit’s internal properties are still OK, so here we rename it to “Assign Aging Rank 2”.
Again, the block “Decide Promote To 2” should be renamed, and it is renamed to “Decide PromoteTo 1”. We’ll leave the push promotion criteria for now, but come back to it later where we’ll defineit as “pull” promotion logic.
The assign block at the left of the submodel needs some edits. In this block the assignment of Rank
14 DRDC CORA TM 2007-47
should be changed from a value of 3 to a value of 2, to correspond to the new Rank value, andthe assignment of 0 to the attribute YOS should be changed. Also, the Age assignment within theblock should be changed. Both YOS and Age should be incremented by one year. This ensures thatpeople who have been promoted to Rank 2 don’t miss out on their yearly aging.
Closing the “Intermediate” submodel and viewing inside the “Senior” submodel, the “Hold forSignal 1” block should also be renamed. We’ll change the property “Wait for Value” to 3, renamethis block to “Hold for Signal 3”, and we’ll introduce a block to generate a signal 3 later on in thissection of the tutorial.
Since the “Senior” submodel represents the top rank, the promotion block (“Decide Promote to 2”)makes no sense here, so we’ll delete it. This means we’ll now have to connect the “Decide 5” blockfalse connection point to the aging block, which we correspondingly rename to “Assign Aging Rank1”.
The assign block at the left of the “Senior” submodel again needs some edits. In this block theassignment of Rank should be changed from a value of 3 to a value of 1, to correspond to thenew Rank value, and the assignment of 0 to the attribute YOS should be changed. Also, the Ageassignment within the block should be changed. Again, both YOS and Age should be incrementedby one year.
The current version of the overall model should look something like Figure 15. On the CD ac-companying the electronic version distribution of this report, an Arena model file called “Sample-Model4.doe” corresponds to Figure 15.
The internal representation of the Junior submodel should look similar to Figure 16, the internal rep-resentation of the Intermediate submodel should look similar to Figure 17, and the Senior submodelshould look somewhat like Figure 18.
DRDC CORA TM 2007-47 15
Create 1 Dispose 1
Create 2 Delay 1 Signal 1 Dispose 2
Junior
Intermediate
Senior
0 0
0 0
Figure 15: Submodels for Each Rank
Assign 1 Decide 1
Decide Promote To 2
Assign Aging
Hold for Signal 1Tru e
Fa ls e
Tru e
Fa ls e
0
0
0
0
Figure 16: Junior Rank Submodel
16 DRDC CORA TM 2007-47
Assign 4 Decide 3
Decide Promote To 1
Rank 2Assign Aging
Hold for Signal 2Tru e
Fa ls e
Tru e
Fa l s e
0
0
0
0
Figure 17: Intermediate Rank Submodel
Assign 6 Decide 5
Rank 1Assign Aging
Hold for Signal 3True
Fa ls e
0
0
Figure 18: Senior Rank Submodel
DRDC CORA TM 2007-47 17
2.6 Signals and Basic Output
Referring to Figure 15, delete the connection between the “Create2” and “Delay 1” blocks, insertan Assign block between them, and place connections from the “Create 2” block to the Assignblock, and from the Assign block to the “Delay 1” block. This Assign block is used to update aRun Year number to identify each simulated year for output purposes. Double click on the Assignblock, rename it to “AssignRunYear”, and add an assignment with Type “Variable”, Variable Name“RunYear”, and New Value “RunYear + 1”. Variables in Arena have a default value of 0, unlessexplicitly set beforehand. We’ll want the RunYear to start with value -1, so that the Assign blockwe just edited will set it to 0 after it is first invoked. Since the RunYear variable was defined inthe Assign block, it is now accessible in the Basic Process panel, in the “Variable” module (it has across-hatched pattern). Double click on the Variable module, and in the row for the newly createdRunYear variable, double-click on the button in the column under the “Initial Values” heading, andput in the value -1.
Again referring to Figure 15, simultaneously select the “Delay 1”, “Signal 1” and “Dispose 2”blocks as well as the connectors between them (this can be done by “rubber-banding” with themouse a box that encompasses all these components). Place the mouse cursor on one of the selectedcomponents and drag it well to the right. (The other selected components will follow along happily.)Delete the connection going into the “Delay 1” block, to allow the insertion of other components.
Similarly, select again only the “Delay 1” and “Signal 1” blocks with the connector in betweenthem, right-click on one of the components and select “Copy”. Then paste this configuration twiceto form a line between the Assign block and the “Delay 1” block. Place connectors from left toright between contiguous components.
From left to right along this line, there are now three Signal blocks. Going from left to right, adjustthe “Signal Value” of the first Signal block to 3, and the “Signal Value” of the second Signal blockto 2. This will cause the signals to be sent to receiving hold queues within the Senior submodelfirst, the Intermediate submodel second, and the Junior submodel last (because these are the valuesexpected in the respective submodels).
Now we’ll incorporate some basic output. Expand the “Junior” submodel, and place a “ReadWrite”block from the Advanced Process panel to the left of the Hold block (adjust spacing of other com-ponents as needed). Delete the connection between the “Assign Aging” and the Hold block, andconnect the outgoing connectors of BOTH assign blocks to the ingoing connector of the ReadWriteblock. Connect the outgoing connection point of the ReadWrite block to the incoming connectionpoint of the Hold block.
Double-click on the ReadWrite block and adjust the properties. Change the “Type” to “Write toFile”. Change the “Arena File Name” to “YearlyPop” and leave the “Overriding File Format”blank. Add “Assignments” as follows (in each case choose the “Type” first before specifying thecorresponding value):
• “Type” “Other” with “Other” value “NREP”
• “Type” “Variable” with “Variable Name” value “RunYear”
18 DRDC CORA TM 2007-47
• “Type” “Attribute” with “Attribute Name” value “Age”
• “Type” “Attribute” with “Attribute Name” value “Rank”
• “Type” “Attribute” with “Attribute Name” value “TimeInRank”
• “Type” “Attribute” with “Attribute Name” value “YOS”
“NREP” is an internal Arena variable which returns the current replication value as an integer num-ber. The number of replications an Arena model will carry out can be specified by choosing, fromthe top toolbar, “Run”, “Setup..”, then selecting the “Replication parameters” tab, and then settinga value in the “Number of Replications” field. In the tutorial models, a value of 20 replications isused.
In the Advanced Process panel, double-click on the “File” module. There will already be an entryfor the YearlyPop file. Under the “Operating System File Name” insert the entry “YearlyPop.txt”.By doing these actions, “YearlyPop” is the internal Arena reference to a file which the ReadWriteblock will write to, and the file “YearlyPop.txt” is the actual file name which will hold this data onthe local hard drive. Leave the other options for the file as the default values. The file will then becreated if it doesn’t already exist, and will be replaced if it does already exist.
Copy the ReadWrite block, and similarly insert it before the Hold block in the Intermediate andSenior submodels. Since the file specifics and block properties have already been set, they will nothave to be re-done.
The current version of the overall model should look something like Figure 19. On the CD ac-companying the electronic version distribution of this report, an Arena model file called “Sample-Model5.doe” corresponds to Figure 19. The simulation can be run, and will generate one recordper individual per simulated year, in the text file “YearlyPop.txt”, in the same directory location asthe model *.doe file, although we could have specified another folder when the file properties wereset. In the next section, we’ll import the text file into Microsoft Access. Then, we’ll go back tosome more model modifications. Later on still, we’ll return to Access, generate an Access queryand show how it can be used for the basis of a graph in Excel.
Make sure the model is run before working through the next section of the tutorial. The purpose ofthis is to ensure that the “YearlyPop.txt” file exists for setting up the process of importing data intoAccess.
The configuration of the ReadWrite block is shown for the Intermediate submodel in Figure 20. Theconfiguration should be similar for both the Junior and Senior submodels.
DRDC CORA TM 2007-47 19
Create 1 Dispose 1
Create 2 Delay 1 S ignal 1 Dispose 2
Junior
Intermediate
Senior
As sign 8 Delay 2 S ignal 2Delay 3 S ignal 3
0 0
0 0
Figure 19: Enhanced Timing Signals
Assign 4 Decide 3
Decide Promote To 1
Rank 2Assign Aging
2Hold for Signal
T ru e
F a l s e
T ru e
F a l s e
ReadWrite 20
0
0
0
Figure 20: Intermediate Submodel Including the ReadWrite block
20 DRDC CORA TM 2007-47
2.7 Importing Text Results into Access
In order to have the tutorial model automatically enact macros or Visual Basic for Applications(VBA) code in Access, it is necessary to set the Microsoft Office security level to “Low”, as picturedin Figure 21. This dialog box can be displayed in Access by choosing the successive menu items:
• Tools
• Macro
• Security
Figure 21: Office Security Level for Automated VBA
If you are saving a large volume of data as a simulation proceeds, it may be desirable to recordthe data to a text file, rather than continually invoke recording to Access time and time again. IfAccess is invoked in this way, the Microsoft protocols for connecting between Arena and Accessare repeatedly enacted, resulting in a potential very significant slowdown in execution time of asimulation run. On one large Arena run, this caused a slowdown of about an order of magnitudecompared to recording data in text files.
For large volumes of output it is more time efficient to store output in text files and once the simu-lation is completed to import the data into Access all at once. This can be done by using MicrosoftOffice VBA, both within Arena and within Access.
The use of VBA with Arena amounts to a manual in itself [8]. Here, one example of tying intoAccess using VBA is shown. Other VBA methods or code could certainly be developed to dosimilar processing.
DRDC CORA TM 2007-47 21
First, we’ll place some VBA code in Arena, which will call up VBA code in Access.
With the Arena model open, choose the “Tools” menu item, then “Macro”, and then “Visual BasicEditor”. This opens a separate window for VBA code and editing.
In this window, you can call up skeleton code for various Arena events. One of the subtleties ofVBA in Arena is that some events occur at the Arena application level, and some events occur afterArena has passed off execution to its internal Siman simulation processor (Arena is actually a GUIapplication that encompasses a lower-level simulation engine called Siman). Here, we will be usingan event corresponding to a Siman event.
Double-click the “This Document” entry on the left-hand side for your model project. Click on the“(General)” drop down list and choose “Model Logic”.
Click on the right-hand side drop-down list and choose “RunEndReplication”. This event is runduring the simulation run, after each replication finishes. The code we will be using checks to see ifthe last replication has executed, and if so starts up some VBA code (which we haven’t specified yet)in Access which is designated by the name ‘MasterModule”. (The default code which remains forthe “Sub ModelLogic_DocumentOpen()” can be deleted if desired since it isn’t used in the tutorial.)
The code to be used for “RunEndReplication” is shown in Table 1. This code is included in theArena model file called “SampleModel6.doe” on the CD made to accompany this paper. In thesample model, the code option “Option Explicit” has also been included. This will enforce that allvariables in the VBA code must be explicitly declared. The code could also, if needed, be cut andpasted from the *.pdf version of this paper.
Now, we’ll tie this code into Access. First, in the same folder as your Arena model create a newAccess database file named “tutorial.mdb”. In order to create an import specification which willbe used to import the data in YearlyPop.txt, we’ll manually start the import process, and create thespecification, and then save it. It will then be accessible for use in VBA code within Access.
Open the empty “tutorial.mdb” database, and from the menu choose “File”, then “Get ExternalData”, and then “Import..”. Using the browser supplied, choose to Import the “YearlyPop.txt” filewhich has some model output. An import wizard is then displayed. Choose the “Delimited ” option,then click on the “Next” button. On the next screen, choose “Space” as the delimiter, and again hitthe “Next” button. At this point, click on the “Advanced” button. On the screen that comes up, fillin the field specifications for the data which will be imported, according to the information whichwas specified in the model ReadWrite blocks, as shown in Figure 22.
Then, click on the “Save As ...” button and save the specification as “YearlyPop Import Specifica-tion”. Now that the specification we want has been saved, the wizard screen can be cancelled.
Now, we’ll create in Access the VBA code that will actually import the data into an Access table.From the Access menu, choose “Tools”, then “Macro”, and then “Visual Basic Editor” to bringforward the VBA editing window.
Right-click on the “tutorial” entry on the left, choose “Insert”, and then choose “Module”. In thecode window create a function by putting in the lines (the second line may be generated automati-
22 DRDC CORA TM 2007-47
Private Sub ModelLogic_RunEndReplication()Dim mDim sSet m = ThisDocument.Model
Set s = m.SIMANRem The m.QuiteMode is used to turn off all messages (i.e. Summary Report)m.QuietMode = TrueRem Check to see if you have finished the last replication, if so end the model run.If s.RunMaximumReplications = s.RunCurrentReplication Then
m.End
Dim objAccessDim objExcelDim pathPrefix As StringDim pathAndFile As String
Rem Create Access Application Object in the current directorypathPrefix = CurDirpathAndFile = CurDir + "\tutorial.mdb"
Set objAccess = GetObject(pathAndFile)
Rem MsgBox "The path is: " + CurDirobjAccess.DoCmd.OpenModule "MasterModule", "MasterFunction"objAccess.Run "MasterFunction"
Set objAccess = Nothing
MsgBox "Processing of Macros Complete!"
End If
End Sub
Table 1: Arena VBA Code
DRDC CORA TM 2007-47 23
Figure 22: Import Fields Specification
cally) shown in Table 2.
Function MasterFunction()
End Function
Table 2: MasterFunction Skeleton Code
This will create an empty function which we’ll fill in later. Save the code (by clicking on the disketteicon in the VBA editor toolbar, and specify the module name as “MasterModule”. Exit the VBAeditor and Access. Although this skeleton code won’t do much, the model and then the VBA codeshould execute, finishing with a dialog box indicating that the processing of macros is complete.Clicking “OK” will allow Arena to finish up. It seems that sometimes Arena may have a timingissue where the invoking of macros leaves Microsoft Windows in a state where the “focus” is on thewrong window. In these cases, a dialog will come up, where you respond by clicking the “Switchto..” button, and Arena will then continue until the processing of macros is complete.
We’ll now proceed with filling out more of the Access VBA code to import the YearlyPop.txt fileinfo into an Access table, called “YearlyPopFile”.
First, we’ll include code to delete any existing table, if there is one. The code for this is shown inTable 3. This code as shown will only delete one file, but the “Case” statement can be expanded todelete other chosen Access Tables as well. Open the tutorial.mdb database, open the VBA editor,
24 DRDC CORA TM 2007-47
under “Modules” insert a new module, insert the code from Table 3, and save the code using theModule name “DeleteTables”. The code can be used as a guide, along with Access help files, forspecifying other text tables to be deleted as well. A couple of code lines have been commented outfor “production” purposes, but can be un-commented for debugging purposes if more tables are tobe deleted.
Rem ————————————————————Rem DeleteUnneededTables()Rem Delete Selected TablesRem ————————————————————
Function DeleteUnneededTables()On Error GoTo DeleteUnneededTables_Err
Dim obj As AccessObject, dbs As ObjectSet dbs = Application.CurrentDataRem Search for AccessObject objects in AllTables collectionFor Each obj In dbs.AllTables
Select Case obj.NameCase "YearlyPopFile"
Rem MsgBox "Deleting Table: " + obj.NameDoCmd.DeleteObject acTable, obj.Name
Case ElseRem MsgBox "Do not delete Table: " + obj.Name
End SelectNext obj
DeleteUnneededTables_Exit:Exit Function
DeleteUnneededTables_Err:MsgBox Error$Resume DeleteUnneededTables_Exit
End Function
Table 3: Access Delete Unneeded Tables VBA Code
Next, we’ll include code to import the “YearlyPop.txt” into an Access table called “YearlyPopFile”.Sample code to do this is shown in Table 4. The code can be used as a guide, along with Accesshelp files, for specifying other text files to be imported into Access tables as well. The code can besaved in Access with the name “ImportTables”.
DRDC CORA TM 2007-47 25
Rem ————————————————————Rem ImportTextFilesRemRem ————————————————————Function ImportTextFiles()On Error GoTo ImportTextFiles_Err
Dim FolderPath, fs
FolderPath = CurrentProject.Path
DoCmd.TransferText acImportDelim, "YearlyPop Import Specification", "YearlyPopFile", _FolderPath & "\YearlyPop.txt", True, ""
ImportTextFiles_Exit:Exit Function
ImportTextFiles_Err:MsgBox Error$Resume ImportTextFiles_Exit
End Function
Table 4: Access Import Tables VBA Code
26 DRDC CORA TM 2007-47
Now the “DeleteTables” and “ImportTables” functions can be incorporated into the “Master Func-tion” of the “Master Module” (see Table 5). A copy of the database as it would be found at this point(including the VBA code) of the tutorial is on the accompanying CD as file “tutorial_temp1.mdb”.
Function MasterFunction()
On Error GoTo MasterFunction_Err
Rem Run VBA Module FunctionsRun ("DeleteUnneededTables")Run ("ImportTextFiles")
MasterFunction_Exit:Exit Function
MasterFunction_Err:MsgBox Error$Resume MasterFunction_Exit
End Function
Table 5: MasterFunction Full Code
The Arena model if it is run now, will (after the final replication) check that any existing Access“YearlyPopFile” table is deleted, and then it will import the “YearlyPop.txt” file results into Accessas a table named “YearlyPopFile”. We’ll process this file later on, by making an Access query,exporting results to Excel, and then defining an output chart to display in Excel.
On the CD accompanying the electronic version distribution of this report, an Arena model filecalled “SampleModel6.doe” corresponds to the model as it would be at the end of this section, andthe Access tutorial file has been included as “SampleModel6_tutorial.mdb” (it has to be re-namedto “tutorial.mdb” if you actually want to test it out in conjunction with the corresponding Arenamodel).
DRDC CORA TM 2007-47 27
2.8 Refining the Model
So far, the model has two “push” promotion mechanisms, one from Rank 3 to Rank 2, and one fromRank 2 to 1. Here, we’ll change one promotion mechanism to a “pull” promotion when going fromRank 2 to 1. When doing this, we’ll also use one parameter that is input from an Excel file - thiswill provide a very simple example of data-driven input, namely input that can easily be changed fordifferent model runs without having to change the Arena model file itself. It will also be necessaryto provide a means and a place where the value is read into Arena from the Excel file.
To begin with, expand the “Intermediate” submodel. Double click on the “Decide Promote To 1”decide block, and change the dialog values as shown in Figure 23. Here, the decide block will notonly test whether an individual has at least 2 years TimeInRank, but will also test that the numberof members at the Senior Rank 1 is less than the desired strength level. If these conditions are met,then the individual is promoted to Rank 1.
Figure 23: Dialog for Push Promotion
In the “Basic process” panel, double-click on the “Variables” module. To be consistent withthe changes just made to the decide block, add the variables “SeniorStrength” and “DesiredSe-niorStrength”. “SeniorStrength” will start with a default value of 0, and we’ll add code to the modelto maintain a current value as a simulation proceeds. “DesiredSeniorStrength” will be read in froman Excel file, and we’ll also have to make changes to the model to make this happen.
First, we’ll add code to the model to maintain the proper value for “SeniorStrength”. Expand the“Senior”’ submodel. In the Assign block at the entry to the submodel code, add another assignmentwhich increments the “SeniorStrength” variable, as shown in Figure 24. This will increase therecorded strength value each time someone is promoted to, and enters, Rank 1.
Add an assign block before the exit of the submodel. Connect the “true” connection point of thedecide block to the new assign block’s entry connection point, and connect the leaving connectionpoint of the assign block to the submodel exit point. The existing connection from the decide
28 DRDC CORA TM 2007-47
Figure 24: Senior Strength Increment
block to the submodel exit point must be deleted. In this assign block, add another assignmentwhich decrements the “SeniorStrength” variable, as shown in Figure 25. This will correspondinglydecrease the recorded strength value each time someone leaves Rank 1.
Figure 25: Senior Strength Decrease
Some structure still has to be introduced to tie in the “DesiredSeniorStrength” variable to an externalExcel file. Close any expanded submodel to return to the high-level Arena model view. Placean additional “Create” block, connected to a new “ReadWrite” block, and finally connected toa new “Dispose” block in the Arena model. The create block will fire only once, and then thereadWrite block will read in the “DesiredSeniorStrength”, using some Arena constructs to hookinto an Excel file. Such a create block could be used to set or read in various initial values for thestarting state of the simulation. In more complex models, it could also be used to read in a starting
DRDC CORA TM 2007-47 29
population (derived from an HR database), so the simulation runs start with a real representation ofthe population within the corresponding occupational group.
Double-click on the new create block and set it’s dialog values as shown in Figure 26.
Figure 26: Additional Create Block
We have to define an Excel file within Arena. Here, the Excel file “DesiredStrength.xls” is eitherdefined in, or copied from sample files to, the same folder as the Arena modle file. Under the“Advanced Process” panel, in the “File” module, create a new entry. Double-click on the left-hand side of it’s row entry, and complete the dialog values as shown in 27, including an entry of“DesiredStrength” in the child dialog for the “Recordset” value. (Note that the “SampleInput” filename is an Arena internal identifier, and not the actual file name on your hard drive.)
A screenshot of the corresponding Excel file is shown in Figure 28, with the Excel Range “Desired-Strength” value of 10 defined in Row 1 Column A. (Although we’re reading in only one value, largerranges can be used as input from Excel to Arena.) Again, this file is expected to be located in thesame file folder or sub-folder as the Arena *.doe model file which refers to it. On the accompanyingCD there is an Excel file called “DesiredStrength.xls” which is used for this simple illustration ofdata-driven input.
Then, double-click on the new readWrite block and set it’s dialog values as shown in Figure 29.
On the CD accompanying the electronic version distribution of this report, an Arena model filecalled “SampleModel7.doe” corresponds to the model as it could be run at the end of this section.No changes were made to the Access “*.mdb” file since the previous section.
30 DRDC CORA TM 2007-47
Figure 27: Simple Input Connection
Figure 28: Simple Excel Input File
DRDC CORA TM 2007-47 31
Figure 29: Additional ReadWrite Block
32 DRDC CORA TM 2007-47
2.9 Automated Generation of an Output Chart
Here, we do not actually make any changes to the Arena model itself. Rather, we’ll build on theinformation it generates, which is imported into Access, by creating queries which organize theoutput in a summary for highlighting a particular aspect of the model results. At the end of a modelrun, these queries can be exported to Excel. This exported information can be used in a pre-definedchart in an Excel file, which is automatically updated when you open the file.
In production runs of larger models, this paradigm can be extended to automate the production ofnumerous charts either in different Excel files, or on tabs within one Excel file. What’s nice is to beable to start an Arena run, go and tend to other business, and come back to results which are alreadyorganized and available in graphical form. Having a built-in automation feature also provides someconsistency to the formats for different analyses.
First, an Access query is created is in Figure 30, where a Crosstab Query is defined using the tableYearlyPopFile with:
• Field ’Rank’ as a ’Group By’ ’Row Heading’
• Field ’Replication’ as a ’Group By’ ’Row Heading’
• Field ’RunYear’ as a ’Group By’ ’Column Heading’, and
• Field ’Rank’ as a ’Count’ ’Value’
Save the query with the name “RankCountByReplicationByRunYear”.
Figure 30: Access Query Definition
DRDC CORA TM 2007-47 33
Next, VBA code is created in a module to export the results of the query to an Excel file called’RankCountByReplicationByRunYear.xls’ in a sub-folder called ’Query_Output’. Save the moduleas “ExportExcelQueries”. The code to do this is shown in Table 6. In practice, this code would beextended with similar ’DoCmd.OutputTo’ statements for each query being exported.
Rem ————————————————————Rem ExportQueriesRemRem ————————————————————Function ExportQueries()On Error GoTo ExportQueries_Err
Dim FolderPath
FolderPath = CurrentProject.Path & "\Query_Output\"
Set fs = CreateObject("Scripting.FileSystemObject")fs.DeleteFile FolderPath & "*.*", TrueSet fs = Nothing
DoCmd.OutputTo acQuery, "RankCountByReplicationByRunYear", "MicrosoftExcelBiff8(*.xls)", _FolderPath & "RankCountByReplicationByRunYear.xls", False, "", 0
ExportQueries_Exit:Exit Function
ExportQueries_Err:MsgBox Error$Resume ExportQueries_Exit
End Function
Table 6: Access Query Export VBA Code
Then, the MasterFunction VBA Code needs to be adjusted to call the new code, as shown in Table7.
Although the Access query export creates an Excel file, it was found that the Microsoft Officeversion had some difficulties using the file in an automated fashion. The work-around here was tocreate and use an auto-open Excel file called ’Convert.xls’ which uses VBA code to open and thensave the Excel file which was exported. The exported query file can then be transparently referenced
34 DRDC CORA TM 2007-47
Function MasterFunction()On Error GoTo MasterFunction_ErrRem Run VBA Module FunctionsRun ("DeleteUnneededTables")Run ("ImportTextFiles")Run ("ExportQueries")
MasterFunction_Exit:Exit Function
MasterFunction_Err:MsgBox Error$Resume MasterFunction_Exit
End Function
Table 7: Access Query Export VBA Code
by another Excel file which contains a pre-defined chart. This is somewhat awkward, but it works.
The VBA code used in ’Convert.xls’ is presented in Table 8. In this code, only one file is opened andclosed. In practice, the macro should be extended in a similar fashion for each *.xls file resultingfrom Access queries, that would be subsequently referred to.
Note that in order to edit Auto-Run code in Excel, you hold down the <Shift> button when openingthe file. You can then open and edit the VBA code.
Table 9 shows the final Arena model VBA code, including the invocation of the ’Convert.xls’ file.When the model is run, the embedded VBA in both Arena and Access will generate the appropriatesimulation query results, and “convert” it to a usable form.
Then, opening the ’ChartFromQuery.xls’ spreadsheet (which reads data from the query results) andupdating the spreadsheet will automatically generate the chart that is defined in the spreadsheet.(Within the ’ChartFromQuery.xls’ spreadsheet, the ’IF’ function is used to ensure that blank entriesresulting from the Access query are interpreted as ’0’ entries for the purposes of chart creation.) Anexample final output chart is shown in Figure 31.
On the CD accompanying the electronic version distribution of this report, an Arena model filecalled “SampleModel8.doe” corresponds to the model as it could be run at the end of this section,along with supporting Access and Excel files as described in the tutorial.
DRDC CORA TM 2007-47 35
Sub Auto_open()
Application.DisplayAlerts = False
Dim CurrentPath As StringDim WorkingPath As String
CurrentPath = ActiveWorkbook.PathWorkingPath = CurrentPath + "\Query_Output\"
Workbooks.Open Filename:= _WorkingPath + "RankCountByReplicationByRunYear.xls"
ActiveWorkbook.SaveAs Filename:= _WorkingPath + "RankCountByReplicationByRunYear.xls", _FileFormat:=xlNormal, Password:="", WriteResPassword:="", _ReadOnlyRecommended:=False, CreateBackup:=False
ActiveWorkbook.Close
Application.Quit
End Sub
Table 8: Excel Convert.xls Auto-Run VBA Code
Average Number of Members, by Rank, by Run Year
0
10
20
30
40
50
60
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
Run Year
Ave
rage
Cou
nt
Rank 1Rank 2Rank 3
Figure 31: Example Automated Chart
36 DRDC CORA TM 2007-47
Private Sub ModelLogic_RunEndReplication()
Dim mDim s
Set m = ThisDocument.ModelSet s = m.SIMAN
Rem The m.QuiteMode is used to turn off all messages (i.e. Summary Report)m.QuietMode = TrueRem Check to see if you have finished the last replication, if so end the model run.
If s.RunMaximumReplications = s.RunCurrentReplication Thenm.End
Dim objAccessDim objExcelDim pathPrefix As StringDim pathAndFile As String
Rem Create Access Application Object in the current directorypathPrefix = CurDirpathAndFile = CurDir + "\tutorial.mdb"Set objAccess = GetObject(pathAndFile)objAccess.DoCmd.OpenModule "MasterModule", "MasterFunction"objAccess.Run "MasterFunction"Set objAccess = Nothing
Rem Automatic Conversion of Excel File(s)Rem This was needed on the development system to ensure compatabilityRem of theExcel files with the current Excel program.pathAndFile = CurDir + "\Convert.xls"Set objExcel = GetObject(pathAndFile)
Set objExcel = Nothing
MsgBox "Processing of Macros Complete!"
End IfEnd Sub
Table 9: Final Arena VBA Code to Automate the Output Chart “ChartFromQuery.xls”
DRDC CORA TM 2007-47 37
2.10 Modelling Considerations
The tutorial has emphasized the conceptual level of HR modelling in the development of a smallexample model. There are some additional considerations which may be relevant to a full-scaleproduction model.
Here, we used Microsoft Access for data manipulation in a process to generate automated simulationresults. The version of Access used here has a 2 Gigabyte file size limit, including temporary spaceneeded when executing queries. When running large models, this file size limitation may have tobe taken into account. For instance, if a large amount of model text input is imported into Accessas numbers, it may be necessary to customize the Access import specification to use smaller sizedfields (Integer, or Byte, for example) rather than letting the import use a field type which uses morespace (such as Single or Double).
When using an existing model to start a new analysis, or modify it for a new model, you may wantto delete unwanted tables and compact the Access database. This ensures that any “holdover” datawithin Access (even for items which have been “deleted”) is eliminated from the database, and mayreduce the size of the Access database considerably.
The ACME model which is a base for the concepts in this tutorial has training modules for bothmandatory and specialization training. It is quite possible to extend a model such as the tutorialmodel to include training capabilities as well. However, the tutorial model in its simplicity includessome artificialities which should be critically examined before expanding it to a more realistic ap-plication.
The tutorial shows only a simple example of data input from an Excel file. However, this styleof input can be extended to provide much more extensive input to provide “data-driven” models,where different scenarios do not require model changes, but rather only data input file changes. Inthe case of ACME, there are input data files for a number of scenario-specific items including: astarting population derived from military HR databases, attrition profiles, course training specifics,and occupation characteristics such as Preferred Manning Level (PML).
Arena has some debugging facilities that are not well described in the basic documentation *.pdffiles provided with the software installation. Descriptions of the debugging facilities can be foundin the Arena Help by searching on “debug” and choosing the topic “Debug Bar”. It is possible toset breakpoints and watches, and to step through a model in increments. One of the features whendebugging is that there is an “Active Entity Window” which shows the attribute values, includinguser-defined attributes such as age or YOS, of any current entity. With this feature it may be possibleto follow an entity through various stages to check that any logic or assignments involving theentity’s attributes are handled correctly in the model. The debugging chronology follows the Arenamodel event chronology when stepping through the model. This means that subsequent steps mayinvolve different entities, if the latter simulation event involves a different entity.
When running the example simulation model from the tutorial, when the VBA code is enacted atthe end of a simulation run a “Switch To ...” message box may appear. The author’s speculation isthat the VBA code switching between applications has landed on a displayed Window which does
38 DRDC CORA TM 2007-47
not have “focus”. Clicking “OK” on the box should keep the program happy and continue the VBAprocessing until completion.
DRDC CORA TM 2007-47 39
3 Conclusion
This tutorial documentation was requested by members of the TTCP Workforce Modelling andAnalysis Working Group. Along with supporting files and an additional example model on anaccompanying CD, it is being distributed to the member nations of the group. It also fulfills aninternal requirement for documentation of basic modelling techniques which are used within somePORT models.
This paper has presented a simple HR model which illustrates some of the basic concepts inherentin a larger, more complex model, namely ACME. The philosophy in PORT for using ACME [1]has been to try and maintain ACME as a very capable “generic” base model, and to create code tocustomize it for specific analyses. So far, this has seemed to work very well. This results from thefact that many of the basic characteristics of Canadian Forces (CF) occupations are very similar.Nevertheless, many of the occupations still have some particular aspects which are a bit different,and some of the analyses explore proposed changes to occupation characteristics. So, this philos-ophy of a base model designed to be customized in different particular “flavours” has allowed thecreation of new models as necessary in a timely manner.
40 DRDC CORA TM 2007-47
References
[1] Isbrandt, S. and Zegers, A. (2006), The Arena Career Modelling Environment IndividualTraining and Education (ACME IT & E) Projection Tool, (CORA Technical Report TR2006-03) Centre for Operational Research and Analysis, Ottawa, Canada.
[2] Isbrandt, S. and Zegers, A. (2006), Artillery Non-Commissioned Member Occupational GroupModelling Projections, (CORA Technical Memorandum TM 2006-34) Centre for OperationalResearch and Analysis, Ottawa, Canada.
[3] Woodill, Gerald (2005), Forecasting Training Requirements for the Field Artillery, (TechnicalMemorandum TM 2005-11) Centre for Operational Research and Analysis, Ottawa, Canada.
[4] Maj Adrian Erkelens, Fariya Syed, Stan Isbrandt (2007), Development of a Prototype Modelfor Civilian Occupational Group Projections, CD Proceedings of the 2007 Summer SimulationMulticonference, The Society for Modeling and Simulation International.
[5] WorkForce Modelling And Analysis Working Group, Minutes of the Fourth Annual MeetingHeld Under The Auspices of HUM-TP3, (Technical Report DOC-HUM-9 (2007)) TheTechnical Cooperation Program.
[6] Rockwell Software Inc. (2006), Arena Basic User’s Guide, Arena pro v11.0 ed, Milwaukee,Wisconsin USA: Rockwell Automation.
[7] Rockwell Software Inc. (2006), Arena User’s Guide, Arena pro v11.0 ed, Milwaukee,Wisconsin USA: Rockwell Automation.
[8] Systems Modelling Corporation (2000), VBA with Arena Training Course, Sewickley, PA,USA: Systems Modelling Corporation.
DRDC CORA TM 2007-47 41
This page intentionally left blank.
42 DRDC CORA TM 2007-47
List of Abbreviations
ACME Arena Career Modelling Environment
CD compact disc
CF Canadian Forces
DND Department of National Defence
HR Human Resource
PML Preferred Manning Level
PC Personal Computer
PORT Personnel Operational Research Team
PMT Production Management Tool
TTCP The Technical Cooperation Program
TIR Time In Rank
VBA Visual Basic for Applications
YOS Years of Service
DRDC CORA TM 2007-47 43
This page intentionally left blank.
44 DRDC CORA TM 2007-47
DOCUMENT CONTROL DATA(Security classification of title, body of abstract and indexing annotation must be entered when document is classified)
1. ORIGINATOR (The name and address of the organization preparing thedocument. Organizations for whom the document was prepared, e.g. Centresponsoring a contractor’s report, or tasking agency, are entered in section 8.)
Defence R&D Canada – CORANDHQ, 101 Colonel By Drive, Ottawa ON K1A 0K2
2. SECURITY CLASSIFICATION (Overallsecurity classification of the documentincluding special warning terms if applicable.)
UNCLASSIFIED
3. TITLE (The complete document title as indicated on the title page. Its classification should be indicated by the appropriateabbreviation (S, C or U) in parentheses after the title.)
Human Resource Model Development Using Arena
4. AUTHORS (Last name, followed by initials – ranks, titles, etc. not to be used.)
Isbrandt, S.
5. DATE OF PUBLICATION (Month and year of publication ofdocument.)
December 2007
6a. NO. OF PAGES (Totalcontaining information.Include Annexes,Appendices, etc.)
54
6b. NO. OF REFS (Totalcited in document.)
8
7. DESCRIPTIVE NOTES (The category of the document, e.g. technical report, technical note or memorandum. If appropriate, enterthe type of report, e.g. interim, progress, summary, annual or final. Give the inclusive dates when a specific reporting period iscovered.)
Technical Memorandum
8. SPONSORING ACTIVITY (The name of the department project office or laboratory sponsoring the research and development –include address.)
Defence R&D Canada – CORANDHQ, 101 Colonel By Drive, Ottawa ON K1A 0K2
9a. PROJECT NO. (The applicable research and developmentproject number under which the document was written.Please specify whether project or grant.)
N/A
9b. GRANT OR CONTRACT NO. (If appropriate, the applicablenumber under which the document was written.)
10a. ORIGINATOR’S DOCUMENT NUMBER (The officialdocument number by which the document is identified by theoriginating activity. This number must be unique to thisdocument.)
DRDC CORA TM 2007-47
10b. OTHER DOCUMENT NO(s). (Any other numbers which maybe assigned this document either by the originator or by thesponsor.)
11. DOCUMENT AVAILABILITY (Any limitations on further dissemination of the document, other than those imposed by securityclassification.)( X ) Unlimited distribution( ) Defence departments and defence contractors; further distribution only as approved( ) Defence departments and Canadian defence contractors; further distribution only as approved( ) Government departments and agencies; further distribution only as approved( ) Defence departments; further distribution only as approved( ) Other (please specify):
12. DOCUMENT ANNOUNCEMENT (Any limitation to the bibliographic announcement of this document. This will normally correspondto the Document Availability (11). However, where further distribution (beyond the audience specified in (11)) is possible, a widerannouncement audience may be selected.)
(NON-CONTROLLED GOODS)DMC A
13. ABSTRACT (A brief and factual summary of the document. It may also appear elsewhere in the body of the document itself. It is highlydesirable that the abstract of classified documents be unclassified. Each paragraph of the abstract shall begin with an indication of thesecurity classification of the information in the paragraph (unless the document itself is unclassified) represented as (S), (C), (R), or (U).It is not necessary to include here abstracts in both official languages unless the text is bilingual.)
The Canadian Department of National Defence uses computer simulations to project charac-teristics of military occupations or occupational groupings. The Canadian simulation capabilitygenerated significant interest in the Workforce Modelling and Analysis Working Group of TheTechnical Cooperation Program. As part of a process of presenting this Canadian capability,a real-time model-building tutorial session was given at the working group, illustrating how onemight create a basic Human Resources model. At the request of the working group, this reportdetails and formalizes the tutorial session. It documents the tutorial for both reference purposes,as well as for further dissemination of the tutorial content.
14. KEYWORDS, DESCRIPTORS or IDENTIFIERS (Technically meaningful terms or short phrases that characterize a document and couldbe helpful in cataloguing the document. They should be selected so that no security classification is required. Identifiers, such asequipment model designation, trade name, military project code name, geographic location may also be included. If possible keywordsshould be selected from a published thesaurus. e.g. Thesaurus of Engineering and Scientific Terms (TEST) and that thesaurus identified.If it is not possible to select indexing terms which are Unclassified, the classification of each should be indicated as with the title.)
ACME, Analysis, Arena, Canadian Forces, Career Progression, Human Resources, Military,Modelling, Occupation, Operational Research, Personnel, Projection, Rank, Simulation, Tuto-rial
DRDC CORA
www.drdc-rddc.gc.ca